blob: f913b0ffde41c1c48a8e1a4a83b7febf00862417 [file] [log] [blame]
wuchimedesa1bf2782025-03-27 15:08:54 +08001package com.example.g8backend.mapper;
2
3import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4import com.example.g8backend.entity.User;
5import org.apache.ibatis.annotations.Mapper;
6import org.apache.ibatis.annotations.Param;
夜雨声烦35c9da92025-05-20 00:12:48 +08007import org.apache.ibatis.annotations.Select;
8import org.apache.ibatis.annotations.Update;
wuchimedesa1bf2782025-03-27 15:08:54 +08009
10@Mapper
11public interface UserMapper extends BaseMapper<User> {
wuchimedes079c1632025-04-02 22:01:20 +080012 User getUserByName(@Param("userName") String userName);
13 User getUserByEmail(@Param("email") String email);
wuchimedesa0649c62025-04-05 15:53:39 +080014 User getUserByPasskey(@Param("passkey") String passkey);
夜雨声烦35c9da92025-05-20 00:12:48 +080015
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);
wuchimedesa4c6c2b2025-06-07 22:42:11 +080021
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 );
wuchimedesa1bf2782025-03-27 15:08:54 +080034}