刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 1 | package com.pt5.pthouduan.mapper; |
| 2 | |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 3 | import com.pt5.pthouduan.entity.PeerInfo; |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 4 | import com.pt5.pthouduan.entity.User; |
| 5 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 6 | import org.apache.ibatis.annotations.*; |
| 7 | import org.springframework.stereotype.Repository; |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 8 | |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 9 | import java.util.List; |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 10 | |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 11 | /** |
| 12 | * <p> |
| 13 | * Mapper 接口 |
| 14 | * </p> |
| 15 | * |
| 16 | * @author ljx |
| 17 | * @since 2025-04-14 |
| 18 | */ |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 19 | @Repository |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 20 | public interface UserMapper extends BaseMapper<User> { |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 21 | @Insert("INSERT INTO user(username, password, email, passkey) VALUES(#{username}, #{password}, #{email}, #{passkey})") |
| 22 | int insert(User user); |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 23 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 24 | @Select("SELECT * FROM User WHERE username = #{username}") |
| 25 | User selectByUsername(String username); |
| 26 | |
| 27 | @Select("SELECT * FROM User WHERE email = #{email}") |
| 28 | User selectByEmail(String email); |
| 29 | |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 30 | @Select("SELECT credit FROM User WHERE username = #{username}") |
| 31 | int getcreditByUsername(String username); |
| 32 | |
| 33 | @Update("UPDATE user SET credit = credit - #{price} WHERE username = #{username}") |
| 34 | int deductCreditByUsername(@Param("username") String username, @Param("price") int price); |
| 35 | |
| 36 | @Update("UPDATE user SET upload = upload + #{upload} WHERE username = #{username}") |
| 37 | int increaseUploadByUsername(@Param("username") String username, @Param("upload") Integer upload); |
| 38 | |
Sure233 | 8188c5d | 2025-05-28 11:43:06 +0800 | [diff] [blame] | 39 | @Update("UPDATE user SET password = #{password} WHERE username = #{username}") |
| 40 | int updatePassword(@Param("username") String username, @Param("password") String password); |
| 41 | |
| 42 | @Update("UPDATE user SET sex = #{sex} WHERE username = #{username}") |
| 43 | int updatesex(@Param("username") String username, @Param("sex") String sex); |
| 44 | |
| 45 | @Update("UPDATE user SET image = #{image} WHERE username = #{username}") |
| 46 | int updateimage(@Param("username") String username, @Param("image") String image); |
| 47 | |
| 48 | @Update("UPDATE user SET gradeId = #{gradeId} WHERE username = #{username}") |
| 49 | int updateGrade(@Param("username") String username, @Param("gradeId") Integer gradeId); |
刘嘉昕 | 88d3f7d | 2025-06-04 11:54:09 +0800 | [diff] [blame] | 50 | |
| 51 | @Update("UPDATE user SET decoration = CONCAT(IFNULL(decoration, ''), ' ', #{newDecoration}) WHERE username = #{username}") |
| 52 | int appendUserDecoration(@Param("username") String username, @Param("newDecoration") String newDecoration); |
| 53 | |
| 54 | boolean existsByPasskey(String passkey); |
| 55 | void incrementUserTraffic( @Param("info_hash") String infoHash,@Param("passkey") String passkey, @Param("user_upload") long uploaded, @Param("user_download") long downloaded); |
| 56 | |
| 57 | String getUsernameByPasskey(String passkey); |
| 58 | |
| 59 | List<PeerInfo> findSeedersByInfoHash(@Param("infoHash") String infoHash); |
刘嘉昕 | f28ea23 | 2025-04-15 16:55:43 +0800 | [diff] [blame] | 60 | } |