22301115 | 90135d7 | 2025-06-03 17:11:40 +0800 | [diff] [blame] | 1 | package com.example.myproject.mapper; |
| 2 | import com.example.myproject.entity.User; |
| 3 | |
| 4 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | import org.apache.ibatis.annotations.Select; |
| 7 | import org.apache.ibatis.annotations.Update; |
| 8 | import org.springframework.data.repository.query.Param; |
| 9 | |
| 10 | import java.util.List; |
| 11 | |
| 12 | @Mapper |
| 13 | public 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 | } |