修复告警信息

This commit is contained in:
houwei 2024-06-28 15:52:43 +08:00
parent 6476418b5d
commit da91bb7ef2
8 changed files with 29 additions and 20 deletions

View File

@ -51,5 +51,5 @@ public class SysUserDto implements Serializable {
/** /**
* 角色列表 * 角色列表
*/ */
private List<Long> roleList; private List<String> roleList;
} }

View File

@ -30,6 +30,7 @@ public class SysMenuVo implements Serializable {
/** 权限ID */ /** 权限ID */
private Integer authorityId ; private Integer authorityId ;
/** 上级菜单ID */ /** 上级菜单ID */
@JsonSerialize(using = ToStringSerializer.class)
private Long parentMenuId ; private Long parentMenuId ;
/** 乐观锁 */ /** 乐观锁 */
private Integer revision ; private Integer revision ;

View File

@ -30,6 +30,7 @@ public class SysOrgVo implements Serializable {
/** 机构简称 */ /** 机构简称 */
private String aliasName; private String aliasName;
/** 上级组织机构id */ /** 上级组织机构id */
@JsonSerialize(using = ToStringSerializer.class)
private Long parentOrgId ; private Long parentOrgId ;
private String parentOrgName ; private String parentOrgName ;

View File

@ -8,7 +8,7 @@ import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
/** /**
* 账号信息 * 权限信息
* *
* @author guchengwei * @author guchengwei
*/ */
@ -17,7 +17,7 @@ public class SysRoleAuthVo implements Serializable {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 账号ID * 主键ID
*/ */
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long id; private Long id;

View File

@ -1,5 +1,7 @@
package com.das.modules.auth.domain.vo; package com.das.modules.auth.domain.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data; import lombok.Data;
import java.io.Serial; import java.io.Serial;
@ -29,5 +31,6 @@ public class TokenVo implements Serializable {
/** /**
* 账号ID * 账号ID
*/ */
@JsonSerialize(using = ToStringSerializer.class)
public long accountId; public long accountId;
} }

View File

@ -146,7 +146,7 @@ public class LoginServiceImpl implements LoginService {
throw new ServiceException("原密码不正确"); throw new ServiceException("原密码不正确");
} }
String newPassword =""; String newPassword ="";
if (!StringUtils.isEmpty(changePasswordDto.getNewPassword())) { if (StringUtils.hasText(changePasswordDto.getNewPassword())) {
newPassword = BCrypt.hashpw(changePasswordDto.getNewPassword(), BCrypt.gensalt()); newPassword = BCrypt.hashpw(changePasswordDto.getNewPassword(), BCrypt.gensalt());
sysUser.setPassword(newPassword); sysUser.setPassword(newPassword);
} }

View File

@ -44,7 +44,7 @@ public class SysRoleServiceImpl implements SysRoleService {
@Override @Override
public SysRoleDto createRole(SysRoleDto sysRoleDto) { public SysRoleDto createRole(SysRoleDto sysRoleDto) {
if (sysRoleDto.getRoleName() == null || sysRoleDto.getAuthList() == null || StringUtils.isEmpty(sysRoleDto.getRoleCode())) { if (sysRoleDto.getRoleName() == null || sysRoleDto.getAuthList() == null || !StringUtils.hasText(sysRoleDto.getRoleCode())) {
throw new ServiceException("非法调用,参数缺失"); throw new ServiceException("非法调用,参数缺失");
} }
//判断角色编码code是否存在 //判断角色编码code是否存在
@ -112,7 +112,7 @@ public class SysRoleServiceImpl implements SysRoleService {
@Override @Override
public SysRoleDto updateRole(SysRoleDto sysRoleDto) { public SysRoleDto updateRole(SysRoleDto sysRoleDto) {
if (StringUtils.isEmpty(sysRoleDto.getId())) { if (sysRoleDto.getId() == null) {
throw new ServiceException("参数缺失"); throw new ServiceException("参数缺失");
} }
SysRole sysRole = sysRoleMapper.selectById(sysRoleDto.getId()); SysRole sysRole = sysRoleMapper.selectById(sysRoleDto.getId());
@ -163,7 +163,7 @@ public class SysRoleServiceImpl implements SysRoleService {
@Override @Override
public void deleteRole(DeleteDto deleteDto) { public void deleteRole(DeleteDto deleteDto) {
SysRole sysRole = sysRoleMapper.selectById(deleteDto.getId()); SysRole sysRole = sysRoleMapper.selectById(deleteDto.getId());
if (StringUtils.isEmpty(deleteDto.getId())) { if (deleteDto.getId()==null) {
throw new ServiceException("参数缺失"); throw new ServiceException("参数缺失");
} }
long roleCount = sysRoleMapper.existRoleByRoleCode(sysRole.getRoleCode()); long roleCount = sysRoleMapper.existRoleByRoleCode(sysRole.getRoleCode());

View File

@ -57,7 +57,7 @@ public class SysUserServiceImpl implements SysUserService {
BeanCopyUtils.copy(sysUserDto,sysUser); BeanCopyUtils.copy(sysUserDto,sysUser);
//密码加密 //密码加密
String passwordEncode = ""; String passwordEncode = "";
if (StringUtils.isEmpty(sysUserDto.getPassword())) { if (!StringUtils.hasText(sysUserDto.getPassword())) {
passwordEncode = BCrypt.hashpw("123456789", BCrypt.gensalt()); passwordEncode = BCrypt.hashpw("123456789", BCrypt.gensalt());
} else { } else {
passwordEncode = BCrypt.hashpw(sysUserDto.getPassword(), BCrypt.gensalt()); passwordEncode = BCrypt.hashpw(sysUserDto.getPassword(), BCrypt.gensalt());
@ -80,7 +80,11 @@ public class SysUserServiceImpl implements SysUserService {
accountRoleQueryWrapper.eq("user_id",sysUser.getId()); accountRoleQueryWrapper.eq("user_id",sysUser.getId());
sysUserRoleMapper.delete(accountRoleQueryWrapper); sysUserRoleMapper.delete(accountRoleQueryWrapper);
//绑定角色 //绑定角色
for (Long roleId : sysUserDto.getRoleList()) { for (String srtRoleId : sysUserDto.getRoleList()) {
long roleId = Long.getLong(srtRoleId);
if (roleId == 0) {
continue;
}
SysUserRole accountRole = new SysUserRole(); SysUserRole accountRole = new SysUserRole();
accountRole.setUserId(sysUser.getId()); accountRole.setUserId(sysUser.getId());
accountRole.setRoleId(roleId); accountRole.setRoleId(roleId);
@ -98,18 +102,18 @@ public class SysUserServiceImpl implements SysUserService {
/** /**
* 验证角色是否存在 * 验证角色是否存在
*/ */
private String checkErrorRole(List<Long> roles) { private String checkErrorRole(List<String> roles) {
if (roles != null && !roles.isEmpty()) { if (roles != null && !roles.isEmpty()) {
List<Long> errorRole = new ArrayList<>(); List<Long> errorRole = new ArrayList<>();
for (Long roleId : roles) { for (String strRoleId : roles) {
if (roleId == null) { if (StringUtils.hasText(strRoleId)) {
continue; long roleId=Long.getLong(strRoleId);
}
long roleCount = sysRoleMapper.existRoleByRoleId(roleId); long roleCount = sysRoleMapper.existRoleByRoleId(roleId);
if (roleCount == 0) { if (roleCount == 0) {
errorRole.add(roleId); errorRole.add(roleId);
} }
} }
}
if (!errorRole.isEmpty()) { if (!errorRole.isEmpty()) {
try { try {
return JSON_MAPPER.writeValueAsString(errorRole); return JSON_MAPPER.writeValueAsString(errorRole);
@ -157,8 +161,8 @@ public class SysUserServiceImpl implements SysUserService {
accountRoleQueryWrapper.eq("user_id",newSysUser.getId()); accountRoleQueryWrapper.eq("user_id",newSysUser.getId());
sysUserRoleMapper.delete(accountRoleQueryWrapper); sysUserRoleMapper.delete(accountRoleQueryWrapper);
//绑定角色 //绑定角色
for (Long roleId : sysUserDto.getRoleList()) { for (String strRoleId : sysUserDto.getRoleList()) {
long roleId = Long.getLong(strRoleId);
SysUserRole accountRole = new SysUserRole(); SysUserRole accountRole = new SysUserRole();
accountRole.setUserId(sysUser.getId()); accountRole.setUserId(sysUser.getId());
accountRole.setRoleId(roleId); accountRole.setRoleId(roleId);
@ -190,7 +194,7 @@ public class SysUserServiceImpl implements SysUserService {
@Override @Override
public void deleteUser(DeleteDto deleteDto) { public void deleteUser(DeleteDto deleteDto) {
if (StringUtils.isEmpty(deleteDto.getId())) { if (deleteDto.getId() ==null) {
throw new ServiceException("参数缺失"); throw new ServiceException("参数缺失");
} }
SysUser sysUser = sysUserMapper.selectById(deleteDto.getId()); SysUser sysUser = sysUserMapper.selectById(deleteDto.getId());