wuchimedes | a1bf278 | 2025-03-27 15:08:54 +0800 | [diff] [blame] | 1 | package com.example.g8backend.mapper; |
| 2 | |
| 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | import com.example.g8backend.entity.User; |
| 5 | import org.apache.ibatis.annotations.Mapper; |
| 6 | import org.apache.ibatis.annotations.Param; |
夜雨声烦 | 35c9da9 | 2025-05-20 00:12:48 +0800 | [diff] [blame] | 7 | import org.apache.ibatis.annotations.Select; |
| 8 | import org.apache.ibatis.annotations.Update; |
wuchimedes | a1bf278 | 2025-03-27 15:08:54 +0800 | [diff] [blame] | 9 | |
| 10 | @Mapper |
| 11 | public interface UserMapper extends BaseMapper<User> { |
wuchimedes | 079c163 | 2025-04-02 22:01:20 +0800 | [diff] [blame] | 12 | User getUserByName(@Param("userName") String userName); |
| 13 | User getUserByEmail(@Param("email") String email); |
wuchimedes | a0649c6 | 2025-04-05 15:53:39 +0800 | [diff] [blame] | 14 | User getUserByPasskey(@Param("passkey") String passkey); |
夜雨声烦 | 35c9da9 | 2025-05-20 00:12:48 +0800 | [diff] [blame] | 15 | |
| 16 | @Select("SELECT * FROM users WHERE user_name = #{name}") |
| 17 | User selectByUserName(@Param("name") String name); |
| 18 | |
| 19 | @Update("UPDATE users SET user_level = #{userLevel} WHERE user_id = #{userId}") |
| 20 | int updateUserLevel(@Param("userId") Long userId, @Param("userLevel") String userLevel); |
wuchimedes | a4c6c2b | 2025-06-07 22:42:11 +0800 | [diff] [blame^] | 21 | |
| 22 | @Select("SELECT COUNT(*) FROM user_follows WHERE followed_id = #{userId}") |
| 23 | int countFollowings(Long userId); |
| 24 | |
| 25 | @Select("SELECT COUNT(*) FROM user_follows WHERE follower_id = #{userId}") |
| 26 | int countFollowers(Long userId); |
| 27 | |
| 28 | @Select("SELECT COUNT(*) FROM user_follows " + |
| 29 | "WHERE follower_id = #{currentUserId} AND followed_id = #{targetUserId}") |
| 30 | int existsFollowRelationship( |
| 31 | @Param("currentUserId") Long currentUserId, |
| 32 | @Param("targetUserId") Long targetUserId |
| 33 | ); |
wuchimedes | a1bf278 | 2025-03-27 15:08:54 +0800 | [diff] [blame] | 34 | } |