merge
This commit is contained in:
@@ -40,7 +40,7 @@ public class SysAuthority extends BaseEntity {
|
||||
@Column(name = "parent_id")
|
||||
private String parentId;
|
||||
/**
|
||||
* 类型 2按钮 1菜单
|
||||
* 类型 1菜单 2按钮
|
||||
*/
|
||||
private Integer type;
|
||||
/**
|
||||
|
||||
@@ -103,10 +103,6 @@ public class SysAuthorityService {
|
||||
SysAuthority old = getById(id);
|
||||
if (old == null)
|
||||
throw new BusinessException("该权限不存在");
|
||||
// boolean b = uniqueCode(sysAuthority.getCode(), id);
|
||||
// if (!b)
|
||||
// throw new BusinessException("该编码已存在");
|
||||
// old.setCode(sysAuthority.getCode());
|
||||
//检查排序
|
||||
boolean sorted = uniqueSort(sysAuthority.getSort(), id);
|
||||
if (!sorted)
|
||||
@@ -294,11 +290,7 @@ public class SysAuthorityService {
|
||||
if (StringUtils.isEmpty(code))
|
||||
throw new BusinessException("code不能为空");
|
||||
SysAuthority one = sysAuthorityRepository.getByCode(code);
|
||||
if (one != null) {
|
||||
return StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return one == null || StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,10 +304,6 @@ public class SysAuthorityService {
|
||||
if (sort == null)
|
||||
throw new BusinessException("sort不能为空");
|
||||
SysAuthority one = sysAuthorityRepository.getBySort(sort);
|
||||
if (one != null) {
|
||||
return StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return one == null || StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,10 +167,6 @@ public class SysRoleService {
|
||||
if (StringUtils.isEmpty(code))
|
||||
throw new BusinessException("code不能为空");
|
||||
SysRole one = sysRoleRepository.getByCode(code);
|
||||
if (one != null) {
|
||||
return StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return one == null || StringUtils.isNotEmpty(id) && id.equals(one.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SysUserService {
|
||||
*/
|
||||
public RestMessage removeById(String id) {
|
||||
RestMessage result = new RestMessage();
|
||||
SysUser old = getOne(id);
|
||||
SysUser old = getById(id);
|
||||
if (old == null) {
|
||||
throw new BusinessException("该用户不存在");
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public class SysUserService {
|
||||
*/
|
||||
public RestMessage update(SysUser sysUser) {
|
||||
RestMessage result = new RestMessage();
|
||||
SysUser old = getOne(sysUser.getId());
|
||||
SysUser old = getById(sysUser.getId());
|
||||
if (old == null) {
|
||||
throw new BusinessException("该用户不存在");
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class SysUserService {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public SysUser getOne(String id) {
|
||||
public SysUser getById(String id) {
|
||||
return sysUserRepository.findOne(id);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public class SysUserService {
|
||||
*/
|
||||
public RestMessage resetPassWord(String id) {
|
||||
RestMessage result = new RestMessage();
|
||||
SysUser old = getOne(id);
|
||||
SysUser old = getById(id);
|
||||
if (old == null)
|
||||
throw new BusinessException("未查询到用户信息");
|
||||
if (CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID).equals(id))
|
||||
@@ -216,7 +216,7 @@ public class SysUserService {
|
||||
*/
|
||||
public RestMessage updatePassWord(String newPassWord, String oldPassWord, String id) {
|
||||
RestMessage result = new RestMessage();
|
||||
SysUser sysUser = getOne(id);
|
||||
SysUser sysUser = getById(id);
|
||||
if (sysUser == null)
|
||||
throw new BusinessException("该用户不存在");
|
||||
boolean flag = checkPassWord(oldPassWord, sysUser.getPassword(), sysUser.getSalt());
|
||||
@@ -283,7 +283,7 @@ public class SysUserService {
|
||||
public RestMessage logout(HttpServletRequest request) {
|
||||
RestMessage restMessage = new RestMessage();
|
||||
String userId = (String) CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID);
|
||||
SysUser user = getOne(userId);
|
||||
SysUser user = getById(userId);
|
||||
if (user != null) {
|
||||
//清空公共数据
|
||||
CommonDataUtil.clearMap();
|
||||
@@ -312,7 +312,7 @@ public class SysUserService {
|
||||
* @param enable
|
||||
* @return
|
||||
*/
|
||||
public List<SysAuthority> queryAuthority(String userId, String enable) {
|
||||
public List<SysAuthority> listAuthorityByIdAndEnable(String userId, String enable) {
|
||||
List<SysAuthority> list = new ArrayList<>();
|
||||
//根据用戶id和是否启用获取获取角色
|
||||
List<SysRole> sysRoles = sysRoleService.listByUserIdEnable(userId, enable);
|
||||
@@ -348,7 +348,7 @@ public class SysUserService {
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
List<UserDto> listDto = getReportList();//内容list
|
||||
List<UserDto> listDto = listReport();//内容list
|
||||
if (CollectionUtils.isEmpty(listDto)) {
|
||||
return;
|
||||
}
|
||||
@@ -369,7 +369,7 @@ public class SysUserService {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<UserDto> getReportList() {
|
||||
private List<UserDto> listReport() {
|
||||
List<UserDto> listDto = new ArrayList<>();
|
||||
List<SysUser> list = sysUserRepository.findAll();
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SysUserControl {
|
||||
public JSONObject getById(@RequestParam String id) {
|
||||
if (StringUtils.isEmpty(id))
|
||||
return JSONObjResult.toJSONObj("主键不能为空");
|
||||
SysUser sysUser = sysUserService.getOne(id);
|
||||
SysUser sysUser = sysUserService.getById(id);
|
||||
if (sysUser == null)
|
||||
return JSONObjResult.toJSONObj("未查到该对象");
|
||||
return JSONObjResult.toJSONObj(sysUser, true, "");
|
||||
@@ -142,7 +142,7 @@ public class SysUserControl {
|
||||
@ApiOperation(value = "获取当前登录用户信息")
|
||||
@GetMapping("getLoginUserInfo")
|
||||
public JSONObject getLoginUserInfo() {
|
||||
SysUser sysUser = sysUserService.getOne((String) CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID));
|
||||
SysUser sysUser = sysUserService.getById((String) CommonDataUtil.getToken(CommonConstant.CURRENT_USER_ID));
|
||||
if (sysUser == null)
|
||||
return JSONObjResult.toJSONObj("未获取到当前登录用户信息");
|
||||
List<SysAuthority> button = new ArrayList<>();
|
||||
@@ -151,7 +151,7 @@ public class SysUserControl {
|
||||
if (CommonEnum.YesOrNoEnum.YES.getCode().equalsIgnoreCase(sysUser.getAdmin()))
|
||||
list = sysAuthorityService.listByEnable(CommonEnum.YesOrNoEnum.YES.getCode());
|
||||
else
|
||||
list = sysUserService.queryAuthority(sysUser.getId(), CommonEnum.YesOrNoEnum.YES.getCode());
|
||||
list = sysUserService.listAuthorityByIdAndEnable(sysUser.getId(), CommonEnum.YesOrNoEnum.YES.getCode());
|
||||
if (CollectionUtils.isNotEmpty(list)) {
|
||||
for (SysAuthority sysAuthority : list) {
|
||||
if (sysAuthority.getType() == CommonEnum.MenuOrButtonEnum.MENU.getCode())
|
||||
@@ -173,7 +173,7 @@ public class SysUserControl {
|
||||
return JSONObjResult.toJSONObj("角色主键不能为空");
|
||||
if (StringUtils.isEmpty(userId))
|
||||
return JSONObjResult.toJSONObj("用户主键不能为空");
|
||||
SysUser old = sysUserService.getOne(userId);
|
||||
SysUser old = sysUserService.getById(userId);
|
||||
if (old == null)
|
||||
return JSONObjResult.toJSONObj("该用户不存在");
|
||||
if (CommonEnum.YesOrNoEnum.YES.getCode().equalsIgnoreCase(old.getAdmin()))
|
||||
@@ -209,7 +209,7 @@ public class SysUserControl {
|
||||
public JSONObject listAuthorityByUserId(@RequestParam String userId, String enable) {
|
||||
if (StringUtils.isEmpty(userId))
|
||||
return JSONObjResult.toJSONObj("用户主键不能为空");
|
||||
List<SysAuthority> list = sysUserService.queryAuthority(userId, enable);
|
||||
List<SysAuthority> list = sysUserService.listAuthorityByIdAndEnable(userId, enable);
|
||||
return JSONObjResult.toJSONObj(list, true, "");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user