blob: 4a10a38cf239f94fa6d1e17a3848bc7dcf25f4b6 [file] [log] [blame]
package com.example.myproject.mapper;
import com.example.myproject.entity.TorrentEntity;
import com.example.myproject.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.data.repository.query.Param;
import java.util.List;
@Mapper
public interface UserMapper extends BaseMapper<User> {
User selectByUsername(@Param("username") String username);
User selectByUsernameAndPassword(@Param("username") String username, @Param("password") String password);
User selectByEmail(@Param("email") String email);
// 根据用户名包含查找用户
List<User> selectByUsernameContaining(@Param("name") String name);
@Update("UPDATE user SET downloaded = downloaded + #{size} WHERE id = #{userId}")
void increaseDownloaded(@Param("userId") Long userId, @Param("size") double size);
boolean hasRole(@Param("userId") Long userId, @Param("role") String role);
@Select("SELECT * FROM user WHERE user_id = #{userId}")
User selectByUserId(@Param("userId") Long userId);
@Update("UPDATE user SET upload_count = upload_count + #{bonusUploaded}, download_count = download_count + #{bonusDownloaded} WHERE user_id = #{userId}")
int updateUserUploadDownload(@Param("userId") Long userId,
@Param("bonusUploaded") double bonusUploaded,
@Param("bonusDownloaded") double bonusDownloaded);
}