blob: 3a29b64dc0cfc718578f9f136000e7292af48f24 [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
31}