|
|
|
@ -37,32 +37,42 @@ public class SecUserController { |
|
|
|
|
@Resource |
|
|
|
|
private SecUserLoginLogService secUserLoginLogService; |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/create",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/editUser",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "创建用户") |
|
|
|
|
public ResponseData create(@RequestBody JSONObject body) { |
|
|
|
|
@ApiOperation(value = "编辑用户") |
|
|
|
|
public ResponseData editUser(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
if (body == null |
|
|
|
|
|| StringUtils.isBlank(body.getString("userName")) |
|
|
|
|
|| StringUtils.isBlank(body.getString("loginName")) |
|
|
|
|
|| StringUtils.isBlank(body.getString("telephone")) |
|
|
|
|
|| body.getLong("roleId") == null |
|
|
|
|
) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
SecUser secUser; |
|
|
|
|
if (body.getLong("id") != null) { |
|
|
|
|
// 查询账户
|
|
|
|
|
secUser = secUserService.getDetail(body.getLong("id")); |
|
|
|
|
// 校验重复登录账户
|
|
|
|
|
SecUser user = secUserService.getDetailByLoginName(body.getString("loginName")); |
|
|
|
|
if (user != null && !user.getId().equals(body.getLong("id"))) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户已存在"); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
secUser = new SecUser(); |
|
|
|
|
secUser.setPassword(MD5Util.encode("123456".getBytes())); |
|
|
|
|
|
|
|
|
|
// 校验重复登录账户
|
|
|
|
|
if (secUserService.getDetailByLoginName(body.getString("loginName")) != null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录账户已存在"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
SecUser secUser = new SecUser(); |
|
|
|
|
secUser.setUserName(body.getString("userName")); |
|
|
|
|
secUser.setLoginName(body.getString("loginName")); |
|
|
|
|
secUser.setPassword(MD5Util.encode("123456".getBytes())); |
|
|
|
|
secUser.setTelephone(body.getString("telephone")); |
|
|
|
|
secUser.setRoleId(body.getLong("roleId")); |
|
|
|
|
secUserService.create(secUser); |
|
|
|
|
secUserService.editUser(secUser); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
@ -72,17 +82,12 @@ public class SecUserController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/update",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/delete",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "修改用户") |
|
|
|
|
public ResponseData update(@RequestBody JSONObject body) { |
|
|
|
|
@ApiOperation(value = "删除用户") |
|
|
|
|
public ResponseData delete(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
if (body == null |
|
|
|
|
|| body.getLong("userId") == null |
|
|
|
|
|| StringUtils.isBlank(body.getString("userName")) |
|
|
|
|
|| StringUtils.isBlank(body.getString("telephone")) |
|
|
|
|
|| body.getLong("roleId") == null |
|
|
|
|
) { |
|
|
|
|
if (body == null || body.getLong("userId") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -91,10 +96,8 @@ public class SecUserController { |
|
|
|
|
if (secUser == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
secUser.setUserName(body.getString("userName")); |
|
|
|
|
secUser.setTelephone(body.getString("telephone")); |
|
|
|
|
secUser.setRoleId(body.getLong("roleId")); |
|
|
|
|
secUserService.update(secUser); |
|
|
|
|
secUser.setStatus(SecUserStatusEnum.status0.getCode()); |
|
|
|
|
secUserService.editUser(secUser); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
@ -106,8 +109,8 @@ public class SecUserController { |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/restore",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "删除用户") |
|
|
|
|
public ResponseData delete(@RequestBody JSONObject body) { |
|
|
|
|
@ApiOperation(value = "恢复") |
|
|
|
|
public ResponseData restore(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
if (body == null || body.getLong("userId") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
@ -118,7 +121,7 @@ public class SecUserController { |
|
|
|
|
if (secUser == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
secUser.setStatus(SecUserStatusEnum.status0.getCode()); |
|
|
|
|
secUser.setStatus(SecUserStatusEnum.status1.getCode()); |
|
|
|
|
secUserService.editUser(secUser); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
@ -129,22 +132,16 @@ public class SecUserController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/restore1",method = RequestMethod.POST) |
|
|
|
|
@RequestMapping(value="/resetPwd",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "恢复") |
|
|
|
|
public ResponseData restore1(@RequestBody JSONObject body) { |
|
|
|
|
@ApiOperation(value = "账户密码重置") |
|
|
|
|
public ResponseData resetPwd(@RequestBody JSONObject body) { |
|
|
|
|
try { |
|
|
|
|
if (body == null || body.getLong("userId") == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询用户详情
|
|
|
|
|
SecUser secUser = secUserService.getDetail(body.getLong("userId")); |
|
|
|
|
if (secUser == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
secUser.setStatus(SecUserStatusEnum.status1.getCode()); |
|
|
|
|
secUserService.editUser(secUser); |
|
|
|
|
secUserService.resetPwd(body.getLong("userId")); |
|
|
|
|
|
|
|
|
|
return ResponseMsgUtil.success("操作成功"); |
|
|
|
|
|
|
|
|
@ -154,6 +151,7 @@ public class SecUserController { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/disable",method = RequestMethod.POST) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "禁用") |
|
|
|
@ -200,6 +198,7 @@ public class SecUserController { |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "查询列表") |
|
|
|
|
public ResponseData queryList(@RequestParam(value = "userName", required = false) String userName, |
|
|
|
|
@RequestParam(value = "loginName", required = false) String loginName, |
|
|
|
|
@RequestParam(value = "telephone", required = false) String telephone, |
|
|
|
|
@RequestParam(value = "status", required = false) Integer status, |
|
|
|
|
@RequestParam(value = "pageNum", required = true) Integer pageNum, |
|
|
|
@ -208,11 +207,12 @@ public class SecUserController { |
|
|
|
|
|
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
param.put("userName", userName); |
|
|
|
|
param.put("loginName", loginName); |
|
|
|
|
param.put("telephone", telephone); |
|
|
|
|
param.put("status", status); |
|
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize); |
|
|
|
|
return ResponseMsgUtil.success(secUserService.getList(param)); |
|
|
|
|
return ResponseMsgUtil.success(new PageInfo<>(secUserService.getList(param))); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("error!",e); |
|
|
|
|