blob: 4a10a38cf239f94fa6d1e17a3848bc7dcf25f4b6 [file] [log] [blame]
2230111590135d72025-06-03 17:11:40 +08001package com.example.myproject.mapper;
YelinCui09ee07c2025-06-07 05:09:55 +08002import com.example.myproject.entity.TorrentEntity;
2230111590135d72025-06-03 17:11:40 +08003import com.example.myproject.entity.User;
4
5import com.baomidou.mybatisplus.core.mapper.BaseMapper;
6import org.apache.ibatis.annotations.Mapper;
7import org.apache.ibatis.annotations.Select;
8import org.apache.ibatis.annotations.Update;
9import org.springframework.data.repository.query.Param;
10
11import java.util.List;
12
13@Mapper
14public interface UserMapper extends BaseMapper<User> {
15
16
17 User selectByUsername(@Param("username") String username);
18
19 User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
20
21 User selectByEmail(@Param("email") String email);
22
23
24 // 根据用户名包含查找用户
25 List<User> selectByUsernameContaining(@Param("name") String name);
26
27 @Update("UPDATE user SET downloaded = downloaded + #{size} WHERE id = #{userId}")
28 void increaseDownloaded(@Param("userId") Long userId, @Param("size") double size);
29
30 boolean hasRole(@Param("userId") Long userId, @Param("role") String role);
31
YelinCui196bd692025-06-05 22:18:17 +080032 @Select("SELECT * FROM user WHERE user_id = #{userId}")
33 User selectByUserId(@Param("userId") Long userId);
YelinCui09ee07c2025-06-07 05:09:55 +080034 @Update("UPDATE user SET upload_count = upload_count + #{bonusUploaded}, download_count = download_count + #{bonusDownloaded} WHERE user_id = #{userId}")
35 int updateUserUploadDownload(@Param("userId") Long userId,
36 @Param("bonusUploaded") double bonusUploaded,
37 @Param("bonusDownloaded") double bonusDownloaded);
38
39
40
41
YelinCui196bd692025-06-05 22:18:17 +080042
43
2230111590135d72025-06-03 17:11:40 +080044}