blob: f913b0ffde41c1c48a8e1a4a83b7febf00862417 [file] [log] [blame]
package com.example.g8backend.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.g8backend.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
@Mapper
public interface UserMapper extends BaseMapper<User> {
User getUserByName(@Param("userName") String userName);
User getUserByEmail(@Param("email") String email);
User getUserByPasskey(@Param("passkey") String passkey);
@Select("SELECT * FROM users WHERE user_name = #{name}")
User selectByUserName(@Param("name") String name);
@Update("UPDATE users SET user_level = #{userLevel} WHERE user_id = #{userId}")
int updateUserLevel(@Param("userId") Long userId, @Param("userLevel") String userLevel);
@Select("SELECT COUNT(*) FROM user_follows WHERE followed_id = #{userId}")
int countFollowings(Long userId);
@Select("SELECT COUNT(*) FROM user_follows WHERE follower_id = #{userId}")
int countFollowers(Long userId);
@Select("SELECT COUNT(*) FROM user_follows " +
"WHERE follower_id = #{currentUserId} AND followed_id = #{targetUserId}")
int existsFollowRelationship(
@Param("currentUserId") Long currentUserId,
@Param("targetUserId") Long targetUserId
);
}