hongjli
2025-04-15 1acf9a48021d0af1d81fdf3ed8fcf8dffd020f6b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package com.weiwojc.mapper;
 
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.weiwojc.model.entity.User;
import org.apache.ibatis.annotations.*;
 
@Mapper
public interface UserMapper extends BaseMapper<User> {
    
    @Select("SELECT * FROM user WHERE username = #{username} AND is_deleted = 0")
    User findByUsername(String username);
 
    @Select("SELECT * FROM user WHERE user_id = #{userId} AND is_deleted = 0")
    User findById(Long userId);
 
    @Update("UPDATE user SET last_login = #{lastLogin} WHERE user_id = #{userId}")
    int updateLastLogin(@Param("userId") Long userId, @Param("lastLogin") java.time.LocalDateTime lastLogin);
 
    @Update("UPDATE user SET login_attempts = #{attempts}, locked_until = #{lockedUntil} WHERE user_id = #{userId}")
    int updateLoginAttempts(@Param("userId") Long userId, 
                          @Param("attempts") Integer attempts, 
                          @Param("lockedUntil") java.time.LocalDateTime lockedUntil);
 
    @Update("UPDATE user SET login_attempts = 0, locked_until = null WHERE username = #{username}")
    int resetLoginAttempts(String username);