Commit c90fb460 authored by 周健威's avatar 周健威

后台员工管理

parent 817681e1
......@@ -146,40 +146,63 @@ public class ChwUserController extends CommonBaseController implements UserRestI
@RequestMapping(value = "/operate/{id}", method = RequestMethod.PUT)
@ResponseBody
public ObjectRestResponse<User> update(@RequestBody UserController.UserVO vo) {
if (!edit(vo, BIZ_TYPE_OPERATE)){
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
}
return new ObjectRestResponse<User>();
}
@RequestMapping(value = "/business/{id}", method = RequestMethod.PUT)
@ResponseBody
public ObjectRestResponse<User> businessUpdate(@RequestBody UserController.UserVO vo) {
if (!edit(vo, BIZ_TYPE_BUSINESS)){
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
}
return new ObjectRestResponse<User>();
}
private boolean edit(UserController.UserVO vo, Integer bizType) {
handleDataLimit(vo);
String username = vo.getUsername();
if (StringUtils.isNotBlank(username)) {
List<User> list = userBiz.getCountByUsername(username);
if (list.size() > 1) {
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
return false;
}
if (list.size() == 1) {
User user = list.get(0);
if (!user.getId().equals(vo.getId())) {
return ObjectRestResponse.createFailedResult(ResCode.USER_IS_EXIST.getCode(), ResCode.USER_IS_EXIST.getDesc());
if (!user.getId().equals(vo.getId()) && bizType != user.getBizType()) {
return false;
}
}
}
userBiz.updateSelectiveById(vo);
//添加权限关系
groupBiz.modifyUserGroups(vo.getId(), vo.getMembers());
return new ObjectRestResponse<User>();
return true;
}
@RequestMapping(value = "/operate/{id}", method = RequestMethod.DELETE)
@ResponseBody
public ObjectRestResponse<User> remove(@PathVariable int id) {
userBiz.deleteById(id);
return new ObjectRestResponse<User>();
del(id, BIZ_TYPE_OPERATE);
return new ObjectRestResponse();
}
@RequestMapping(value = "/business/{id}", method = RequestMethod.DELETE)
@ResponseBody
public ObjectRestResponse businessRemove(@PathVariable int id) {
del(id, BIZ_TYPE_BUSINESS);
return new ObjectRestResponse();
}
private void del (int id, Integer bizType) {
User user = userBiz.selectById(id);
if(null != user && user.getBizType() == bizType) {
del(new User(){{
setId(id);
}});
return new ObjectRestResponse<User>();
}
}
private void handleDataLimit(@RequestBody UserController.UserVO dto) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment