113 lines
3.8 KiB
Java
113 lines
3.8 KiB
Java
package com.xkrs.straw.dao;
|
|
|
|
import com.xkrs.straw.model.entity.SysUserEntity;
|
|
import org.springframework.data.jpa.repository.JpaRepository;
|
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
|
import org.springframework.data.jpa.repository.Modifying;
|
|
import org.springframework.data.jpa.repository.Query;
|
|
import org.springframework.data.repository.query.Param;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
@Component
|
|
public interface SysUserDao extends JpaRepository<SysUserEntity, Long>, JpaSpecificationExecutor<SysUserEntity> {
|
|
|
|
@Modifying(clearAutomatically = true)
|
|
@Query(value = "UPDATE sys_user SET vip_level = ?2 WHERE id = ?1", nativeQuery = true)
|
|
void updateVipLevel(Long id, Integer vipLevel);
|
|
|
|
@Modifying(clearAutomatically = true)
|
|
@Query(value = "UPDATE sys_user SET receive_sms = ?2 WHERE id = ?1", nativeQuery = true)
|
|
void updateReceiveSms(Long id, Integer receiveSms);
|
|
|
|
@Modifying(clearAutomatically = true)
|
|
@Query(value = "UPDATE sys_user SET remark = ?2 WHERE id = ?1", nativeQuery = true)
|
|
void updateRemark(Long id, String remark);
|
|
|
|
/**
|
|
* 检查系统用户名是否存在
|
|
*/
|
|
@Query(value = "SELECT COUNT(*) FROM sys_user WHERE user_name = :userName", nativeQuery = true)
|
|
int checkUserName(@Param("userName") String userName);
|
|
|
|
/**
|
|
* 查找用户实体根据用户名
|
|
*/
|
|
@Query(value = "SELECT * FROM sys_user WHERE user_name = :userName", nativeQuery = true)
|
|
SysUserEntity selectByUserName(@Param("userName") String userName);
|
|
|
|
/**
|
|
* 根据用户名查询用户信息
|
|
*/
|
|
SysUserEntity findByUserName(String userName);
|
|
|
|
/**
|
|
* 软删除系统用户根据id
|
|
*/
|
|
@Modifying
|
|
@Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true)
|
|
void softDeleteGeneralUserById(@Param("id") Long id);
|
|
|
|
/**
|
|
* 删除系统用户(危险操作!)
|
|
*/
|
|
@Modifying
|
|
@Query(value = "DELETE FROM sys_user WHERE user_name = :userName ;", nativeQuery = true)
|
|
int deleteSysUser(@Param("userName") String userName);
|
|
|
|
/**
|
|
* 启用
|
|
*/
|
|
@Query(value = "update sys_user set active_flag = 0 where id = ?", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateEnable(Long userId);
|
|
|
|
/**
|
|
* 禁用
|
|
*/
|
|
@Query(value = "update sys_user set active_flag = 1 where id = ?", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateDisable(Long userId);
|
|
|
|
/**
|
|
* 用户修改密码
|
|
*/
|
|
@Query(value = "update sys_user set password = ?2 where id = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updatePassword(Long userId, String newPassword);
|
|
|
|
/**
|
|
* 根据id查询用户的信息
|
|
*/
|
|
@Query(value = "select * from sys_user where id = ?", nativeQuery = true)
|
|
SysUserEntity selectByUserId(Long userId);
|
|
|
|
/**
|
|
* 根据id修改账户的到期时间
|
|
*/
|
|
@Query(value = "update sys_user set over_time = ?2 where id = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateOverTime(Long userId, String overTime);
|
|
|
|
/**
|
|
* 将账户的期限修改为永久有效
|
|
*/
|
|
@Query(value = "update sys_user set over_time = '永久' and day_num = 1 where id = ?", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateDayNum(Long userId);
|
|
|
|
/**
|
|
* 记录用户登录次数
|
|
*/
|
|
@Query(value = "update sys_user set login_num = ?2 where id = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateLoginNum(Long userId, Integer loginNum);
|
|
|
|
/**
|
|
* 修改登陆时间
|
|
*/
|
|
@Query(value = "update sys_user set login_last_time = ?2 where id = ?1", nativeQuery = true)
|
|
@Modifying(clearAutomatically = true)
|
|
void updateLoginLastTime(Long userId, String loginLastTime);
|
|
|
|
}
|