|
|
@ -52,47 +52,46 @@ public class PermissionServiceImpl implements PermissionService { |
|
|
|
@Override |
|
|
|
public PageInfo<Permission> getpermission(Integer pageNum, Integer pageSize, Permission permission) { |
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
List<Permission> list= permissionMapper.getPermission(permission); |
|
|
|
List<Permission> list = permissionMapper.getPermission(permission); |
|
|
|
return new PageInfo<>(list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer addpermission(Admin admin) throws Exception { |
|
|
|
public Integer addpermission(Admin admin) throws Exception { |
|
|
|
|
|
|
|
if(!ObjectUtils.isEmpty(adminMapper.getAdmin(admin.getAccount()))){ |
|
|
|
if (!ObjectUtils.isEmpty(adminMapper.getAdmin(admin.getAccount()))) { |
|
|
|
throw new Exception("账号已存在"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty(admin.getAccount())){ |
|
|
|
throw new Exception("账号为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty( admin.getMarket())){ |
|
|
|
throw new Exception("地区为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty( admin.getPostiton())){ |
|
|
|
throw new Exception("职位为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty( admin.getRoleId())){ |
|
|
|
throw new Exception("权限类别为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty( admin.getAdminName())){ |
|
|
|
throw new Exception("用户名为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty( admin.getMachineId())){ |
|
|
|
throw new Exception("机器编号为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getAccount())) { |
|
|
|
throw new Exception("账号为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getMarket())) { |
|
|
|
throw new Exception("地区为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getPostiton())) { |
|
|
|
throw new Exception("职位为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getRoleId())) { |
|
|
|
throw new Exception("权限类别为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getAdminName())) { |
|
|
|
throw new Exception("用户名为空!"); |
|
|
|
} |
|
|
|
if (ObjectUtils.isEmpty(admin.getMachineId())) { |
|
|
|
throw new Exception("机器编号为空!"); |
|
|
|
} |
|
|
|
if (admin.getMachineId().contains(",")) { |
|
|
|
throw new Exception("机器编号格式错误"); |
|
|
|
} else { |
|
|
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
|
admin.setPassword(passwordEncoder.encode(("123456"))); |
|
|
|
permissionMapper.addPermission(admin); |
|
|
|
AdminRole adminRole = new AdminRole(); |
|
|
|
adminRole.setAdminId(admin.getId()); |
|
|
|
adminRole.setRoleId(admin.getRoleId()); |
|
|
|
return permissionMapper.addadminRole(adminRole); |
|
|
|
} |
|
|
|
else { |
|
|
|
BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); |
|
|
|
admin.setPassword(passwordEncoder.encode(("123456"))); |
|
|
|
permissionMapper.addPermission(admin); |
|
|
|
AdminRole adminRole = new AdminRole(); |
|
|
|
adminRole.setAdminId(admin.getId()); |
|
|
|
adminRole.setRoleId(admin.getRoleId()); |
|
|
|
return permissionMapper.addadminRole(adminRole); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -103,7 +102,7 @@ public class PermissionServiceImpl implements PermissionService { |
|
|
|
@Override |
|
|
|
@Transactional |
|
|
|
public Integer deleteAdmin(Integer id) { |
|
|
|
if (id == null){ |
|
|
|
if (id == null) { |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
@ -123,41 +122,45 @@ public class PermissionServiceImpl implements PermissionService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Result updateAdmin(AdminVo adminVo)throws Exception { |
|
|
|
public Result updateAdmin(AdminVo adminVo) throws Exception { |
|
|
|
|
|
|
|
if(ObjectUtils.isEmpty(adminVo.getAccount())){ |
|
|
|
if (ObjectUtils.isEmpty(adminVo.getAccount())) { |
|
|
|
throw new Exception("账号为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty(adminVo.getAdminName())){ |
|
|
|
if (ObjectUtils.isEmpty(adminVo.getAdminName())) { |
|
|
|
throw new Exception("用户名为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty(adminVo.getMarket())){ |
|
|
|
if (ObjectUtils.isEmpty(adminVo.getMarket())) { |
|
|
|
throw new Exception("地区为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty(adminVo.getPostiton())){ |
|
|
|
if (ObjectUtils.isEmpty(adminVo.getPostiton())) { |
|
|
|
throw new Exception("职位为空!"); |
|
|
|
} |
|
|
|
if(ObjectUtils.isEmpty(adminVo.getMachineId())){ |
|
|
|
if (ObjectUtils.isEmpty(adminVo.getMachineId())) { |
|
|
|
throw new Exception("机器编号为空!"); |
|
|
|
} |
|
|
|
if (adminVo.getMachineId().contains(",")) { |
|
|
|
throw new Exception("机器编号格式错误"); |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
Admin admin = new Admin(); |
|
|
|
admin.setAccount(adminVo.getAccount()); |
|
|
|
admin.setAdminName(adminVo.getAdminName()); |
|
|
|
admin.setMarket(adminVo.getMarket()); |
|
|
|
admin.setPostiton(adminVo.getPostiton()); |
|
|
|
admin.setMachineId(adminVo.getMachineId()+","+adminVo.getMachineIds()); |
|
|
|
if (adminVo.getMachineIds() == null) { |
|
|
|
admin.setMachineId(adminVo.getMachineId()); |
|
|
|
} else { |
|
|
|
admin.setMachineId(adminVo.getMachineId() + "," + adminVo.getMachineIds()); |
|
|
|
} |
|
|
|
admin.setRemark(adminVo.getRemark()); |
|
|
|
permissionMapper.updateAdmin(admin); |
|
|
|
Password password = new Password(); |
|
|
|
password.setAccount(adminVo.getAccount()); |
|
|
|
password.setNewPassword(adminVo.getPassword()); |
|
|
|
if(adminService.resetPassword(password)==0){ |
|
|
|
if (adminService.resetPassword(password) == 0) { |
|
|
|
return Result.error("密码更改失败"); |
|
|
|
}; |
|
|
|
} |
|
|
|
; |
|
|
|
return Result.success("成功"); |
|
|
|
} |
|
|
|
} |
|
|
|