重构用户实体类
This commit is contained in:
parent
54faad2d67
commit
e85d818b67
@ -31,7 +31,7 @@ public class PushController {
|
||||
|
||||
@PostMapping("/bindUserPushInfo")
|
||||
public String bindUserPushInfo(@RequestBody SysUserPushAccountQo sysUserPushAccountQo) {
|
||||
Integer id = sysUserPushAccountQo.getId();
|
||||
Long id = sysUserPushAccountQo.getId();
|
||||
String regID = sysUserPushAccountQo.getRegID();
|
||||
String userAccount = sysUserPushAccountQo.getUserAccount();
|
||||
if (null == id) {
|
||||
|
@ -88,7 +88,7 @@ public class SysUserController {
|
||||
List<String> failureIdList = new ArrayList<>();//操作失败的ID集合
|
||||
for (String userId : userIdList) {
|
||||
try {
|
||||
Optional<SysUserEntity> targetEntityOptional = sysUserDao.findById(Integer.parseInt(userId));
|
||||
Optional<SysUserEntity> targetEntityOptional = sysUserDao.findById(Long.parseLong(userId));
|
||||
if (targetEntityOptional.isPresent()) {
|
||||
SysUserEntity targetEntity = targetEntityOptional.get();
|
||||
if (!TextUtils.isEmpty(overTime)) {
|
||||
@ -125,18 +125,16 @@ public class SysUserController {
|
||||
@RequestMapping(value = "/updateviplevel", method = RequestMethod.POST)
|
||||
public String updateVipLevel(@RequestBody SysUserVipLevelQo sysUserVipLevelQo) {
|
||||
String ids = sysUserVipLevelQo.getIds();
|
||||
List<Integer> idList = new ArrayList<>();
|
||||
List<Long> idList = new ArrayList<>();
|
||||
if (ids.contains(",")) {
|
||||
String[] splits = ids.split(",");
|
||||
if (splits != null && splits.length > 0) {
|
||||
for (String split : splits) {
|
||||
idList.add(Integer.parseInt(split));
|
||||
}
|
||||
idList.add(Long.parseLong(split));
|
||||
}
|
||||
} else {
|
||||
idList.add(Integer.parseInt(ids));
|
||||
idList.add(Long.parseLong(ids));
|
||||
}
|
||||
for (Integer id : idList) {
|
||||
for (Long id : idList) {
|
||||
sysUserDao.updateVipLevel(id, sysUserVipLevelQo.getVipLevel());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
@ -149,18 +147,16 @@ public class SysUserController {
|
||||
@RequestMapping(value = "/updatereceivesms", method = RequestMethod.POST)
|
||||
public String updateReceiveSms(@RequestBody SysUserReceiveSmsQo sysUserReceiveSmsQo) {
|
||||
String ids = sysUserReceiveSmsQo.getIds();
|
||||
List<Integer> idList = new ArrayList<>();
|
||||
List<Long> idList = new ArrayList<>();
|
||||
if (ids.contains(",")) {
|
||||
String[] splits = ids.split(",");
|
||||
if (splits != null && splits.length > 0) {
|
||||
for (String split : splits) {
|
||||
idList.add(Integer.parseInt(split));
|
||||
}
|
||||
idList.add(Long.parseLong(split));
|
||||
}
|
||||
} else {
|
||||
idList.add(Integer.parseInt(ids));
|
||||
idList.add(Long.parseLong(ids));
|
||||
}
|
||||
for (Integer id : idList) {
|
||||
for (Long id : idList) {
|
||||
sysUserDao.updateReceiveSms(id, sysUserReceiveSmsQo.getReceiveSms());
|
||||
}
|
||||
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
|
||||
@ -169,7 +165,7 @@ public class SysUserController {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@RequestMapping(value = "/updateremark", method = RequestMethod.POST)
|
||||
public String updateRemark(@RequestBody SysUserRemarkQo sysUserRemarkQo) {
|
||||
Integer id = sysUserRemarkQo.getId();
|
||||
Long id = sysUserRemarkQo.getId();
|
||||
Optional<SysUserEntity> optionalById = sysUserDao.findById(id);
|
||||
if (optionalById.isEmpty()) {
|
||||
return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL, "修改失败,用户找不到", locale);
|
||||
@ -231,7 +227,7 @@ public class SysUserController {
|
||||
* 软删除指定id的普通用户
|
||||
*/
|
||||
@RequestMapping(value = "/general/delete", method = RequestMethod.DELETE)
|
||||
public String deleteCustomUser(@RequestParam(value = "userId", required = false) int id) {
|
||||
public String deleteCustomUser(@RequestParam(value = "userId", required = false) Long id) {
|
||||
// 验证数据合法性
|
||||
int res = sysUserService.softDeleteGeneralUser(id);
|
||||
if (res == 1) {
|
||||
@ -291,7 +287,7 @@ public class SysUserController {
|
||||
*/
|
||||
@PostMapping("/operateActiveFlag")
|
||||
public String operateActiveFlag(@RequestBody Map map, @RequestHeader(value = "Authorization") String token) {
|
||||
Integer userId = (Integer) map.get("userId");
|
||||
Long userId = (Long) map.get("userId");
|
||||
String keepType = (String) map.get("keepType");
|
||||
// 验证token
|
||||
String tokenUserName = TokenUtil.getTokenUserName(token);
|
||||
|
@ -10,51 +10,37 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* SysRoleDao
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysRoleDao extends JpaRepository<SysRoleEntity,Integer> {
|
||||
public interface SysRoleDao extends JpaRepository<SysRoleEntity, Integer> {
|
||||
|
||||
/**
|
||||
* 查询用户角色列表根据用户id
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " +
|
||||
"FROM sys_role,rel_user_role " +
|
||||
"WHERE sys_role.id = rel_user_role.role_id " +
|
||||
"AND rel_user_role.user_id = :id ", nativeQuery = true)
|
||||
List<SysRoleEntity> selectByUserId(@Param("id") Integer id);
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc FROM sys_role,rel_user_role WHERE sys_role.id = rel_user_role.role_id AND rel_user_role.user_id = :id ", nativeQuery = true)
|
||||
List<SysRoleEntity> selectByUserId(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 查询用户角色列表根据用户名
|
||||
*
|
||||
* @param userName
|
||||
* @return
|
||||
*/
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " +
|
||||
"FROM sys_role.ID = rel_user_role.role_id " +
|
||||
"WHERE rel_user_role.user_id = sys_user.id " +
|
||||
"AND rel_user_role.user_id = sys_user.id " +
|
||||
"AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
@Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc FROM sys_role.ID = rel_user_role.role_id WHERE rel_user_role.user_id = sys_user.id AND rel_user_role.user_id = sys_user.id AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
List<SysRoleEntity> selectByUserName(@Param("userName") String userName);
|
||||
|
||||
|
||||
// /**
|
||||
// * 根据用户名修改用户角色
|
||||
// */
|
||||
// @Modifying
|
||||
// @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " +
|
||||
// "WHERE user_name = :userName ;", nativeQuery = true)
|
||||
// int updateUserRoleByUserName(@Param("userName") String userName);
|
||||
|
||||
/**
|
||||
* 添加用户角色根据用户名和角色名
|
||||
*
|
||||
* @param userName
|
||||
* @param roleName
|
||||
* @return
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) " +
|
||||
"SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user " +
|
||||
"WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
@Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true)
|
||||
int insertRelUserRole(@Param("userName") String userName, @Param("roleName") String roleName);
|
||||
}
|
||||
|
@ -15,19 +15,19 @@ import java.util.List;
|
||||
*
|
||||
* @author tajochen
|
||||
*/
|
||||
public interface SysUserDao extends JpaRepository<SysUserEntity, Integer>, JpaSpecificationExecutor<SysUserEntity> {
|
||||
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(Integer id, Integer vipLevel);
|
||||
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(Integer id, Integer receiveSms);
|
||||
void updateReceiveSms(Long id, Integer receiveSms);
|
||||
|
||||
@Modifying(clearAutomatically = true)
|
||||
@Query(value = "UPDATE sys_user SET remark = ?2 WHERE id = ?1", nativeQuery = true)
|
||||
void updateRemark(Integer id, String remark);
|
||||
void updateRemark(Long id, String remark);
|
||||
|
||||
/**
|
||||
* 检查系统用户名是否存在
|
||||
@ -58,7 +58,7 @@ public interface SysUserDao extends JpaRepository<SysUserEntity, Integer>, JpaSp
|
||||
*/
|
||||
@Modifying
|
||||
@Query(value = "UPDATE sys_user SET delete_flag = 1 " + "WHERE id = :id ;", nativeQuery = true)
|
||||
int softDeleteGeneralUserById(@Param("id") Integer id);
|
||||
int softDeleteGeneralUserById(@Param("id") Long id);
|
||||
|
||||
/**
|
||||
* 删除系统用户(危险操作!)
|
||||
@ -84,14 +84,14 @@ public interface SysUserDao extends JpaRepository<SysUserEntity, Integer>, JpaSp
|
||||
*/
|
||||
@Query(value = "update sys_user set active_flag = 0 where id = ?", nativeQuery = true)
|
||||
@Modifying(clearAutomatically = true)
|
||||
void updateEnable(Integer userId);
|
||||
void updateEnable(Long userId);
|
||||
|
||||
/**
|
||||
* 禁用
|
||||
*/
|
||||
@Query(value = "update sys_user set active_flag = 1 where id = ?", nativeQuery = true)
|
||||
@Modifying(clearAutomatically = true)
|
||||
void updateDisable(Integer userId);
|
||||
void updateDisable(Long userId);
|
||||
|
||||
/**
|
||||
* 用户修改密码
|
||||
|
@ -2,7 +2,7 @@ package com.xkrs.model.qo;
|
||||
|
||||
public class SysUserPushAccountQo {
|
||||
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
private String regID;
|
||||
|
||||
@ -11,11 +11,11 @@ public class SysUserPushAccountQo {
|
||||
public SysUserPushAccountQo() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ import javax.validation.constraints.NotNull;
|
||||
public class SysUserRemarkQo {
|
||||
|
||||
@NotNull(message = "{SysUser.id.blank}", groups = {SysUserQoUpdate.class})
|
||||
private Integer id;
|
||||
private Long id;
|
||||
|
||||
@NotNull(message = "{SysUser.remark.blank}", groups = {SysUserQoUpdate.class})
|
||||
private String remark;
|
||||
@ -15,11 +15,11 @@ public class SysUserRemarkQo {
|
||||
public SysUserRemarkQo() {
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,7 @@ public interface SysUserService {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int softDeleteGeneralUser(Integer id);
|
||||
int softDeleteGeneralUser(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户的信息
|
||||
@ -90,14 +90,14 @@ public interface SysUserService {
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void updateEnable(Integer userId);
|
||||
void updateEnable(Long userId);
|
||||
|
||||
/**
|
||||
* 禁用
|
||||
*
|
||||
* @param userId
|
||||
*/
|
||||
void updateDisable(Integer userId);
|
||||
void updateDisable(Long userId);
|
||||
|
||||
/**
|
||||
* 用户修改密码
|
||||
|
@ -253,10 +253,9 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int softDeleteGeneralUser(Integer id) {
|
||||
public int softDeleteGeneralUser(Long id) {
|
||||
String adminRole = "role_administor";
|
||||
String sysRole = "role_system_manager";
|
||||
|
||||
List<SysRoleEntity> list = sysRoleDao.selectByUserId(id);
|
||||
if (list.size() > 0) {
|
||||
SysRoleEntity sysRoleEntity = list.get(1);
|
||||
@ -285,7 +284,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateEnable(Integer userId) {
|
||||
public void updateEnable(Long userId) {
|
||||
sysUserDao.updateEnable(userId);
|
||||
}
|
||||
|
||||
@ -296,7 +295,7 @@ public class SysUserServiceImpl implements SysUserService {
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public void updateDisable(Integer userId) {
|
||||
public void updateDisable(Long userId) {
|
||||
sysUserDao.updateDisable(userId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user