| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.core.domain.KeyValueVo; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.crm.common.web.BaseController; |
| | | import com.zy.crm.manager.entity.result.KeyValueVo; |
| | | import com.zy.crm.manager.service.CstmrService; |
| | | import com.zy.crm.system.entity.Role; |
| | | import com.zy.crm.system.entity.User; |
| | | import com.zy.crm.system.service.RoleService; |
| | |
| | | private UserService userService; |
| | | @Autowired |
| | | private RoleService roleService; |
| | | @Autowired |
| | | private CstmrService cstmrService; |
| | | |
| | | @RequestMapping(value = "/user/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | |
| | | @RequestMapping(value = "/user/update/auth") |
| | | @ManagerAuth(memo = "系统用户修改") |
| | | @Transactional |
| | | public R update(User user){ |
| | | if (Cools.isEmpty(user) || null==user.getId()){ |
| | | return R.error(); |
| | | } |
| | | int count = userService.selectCount(new EntityWrapper<User>().ne("id", user.getId()).eq("username", user.getUsername())); |
| | | if (count > 0) { |
| | | if (userService.selectCount(new EntityWrapper<User>().ne("id", user.getId()).eq("username", user.getUsername())) > 0) { |
| | | return R.error("账号已存在"); |
| | | } |
| | | userService.updateById(user); |
| | | User one = userService.selectById(user.getId()); |
| | | if (!one.getDeptId().equals(user.getDeptId())) { |
| | | // todo: 修改关联数据的deptId字段 |
| | | cstmrService.updateDeptIdByUserId(user.getId(), user.getDeptId()); |
| | | } |
| | | user.setNickname(user.getUsername()); |
| | | if (!userService.updateById(user)) { |
| | | throw new CoolException("修改用户失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |