blob: 1752801b52486615ab77afbbcb059b46a8838e81 [file] [log] [blame]
2230111590135d72025-06-03 17:11:40 +08001package com.example.myproject.mapper;
2import com.example.myproject.entity.User;
3
4import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5import org.apache.ibatis.annotations.Mapper;
6import org.apache.ibatis.annotations.Select;
7import org.apache.ibatis.annotations.Update;
8import org.springframework.data.repository.query.Param;
9
10import java.util.List;
11
12@Mapper
13public interface UserMapper extends BaseMapper<User> {
14
15
16 User selectByUsername(@Param("username") String username);
17
18 User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
19
20 User selectByEmail(@Param("email") String email);
21
22
23 // 根据用户名包含查找用户
24 List<User> selectByUsernameContaining(@Param("name") String name);
25
26 @Update("UPDATE user SET downloaded = downloaded + #{size} WHERE id = #{userId}")
27 void increaseDownloaded(@Param("userId") Long userId, @Param("size") double size);
28
29 boolean hasRole(@Param("userId") Long userId, @Param("role") String role);
30
YelinCui196bd692025-06-05 22:18:17 +080031 @Select("SELECT * FROM user WHERE user_id = #{userId}")
32 User selectByUserId(@Param("userId") Long userId);
33
34
2230111590135d72025-06-03 17:11:40 +080035}