Пример #1
0
 @DELETE
 @Path("{id}")
 @DescriptionAuth(description = "删除用户", module = "用户管理")
 public ExtJSResponse remove(@PathParam("id") Integer id) {
   // 逻辑删除,将Status置为2
   User user = new User();
   user.setId(id);
   user.setStatus(Status.DELETED.getCode());
   user.setUpdateTime(new Date());
   userMapper.updateByPrimaryKeySelective(user);
   return ExtJSResponse.successRes();
 }
Пример #2
0
 @POST
 @Path("/add")
 @Auth(resourceCode = "10010")
 @DescriptionAuth(description = "新增用户", module = "用户管理")
 public ExtJSResponse add(User user) {
   if (user == null) {
     logger.error("新增用户出错,用户信息为空!");
     return ExtJSResponse.errorRes("新增用户出错,用户信息为空!");
   }
   //        通过login_name查出已注册的用户,确保login_name的唯一性
   UserExample example = new UserExample();
   example.createCriteria().andLoginNameEqualTo(user.getLoginName()).andStatusGreaterThan(0);
   List<User> list = userMapper.selectByExample(example);
   if (list != null && !list.isEmpty()) {
     return ExtJSResponse.errorRes("用户名已存在,请重新输入!");
   }
   Integer currentUserId = SysContent.getUser().getId();
   user.setCreator(currentUserId);
   user.setModifier(currentUserId);
   //        user.setPassword(MD5.md5(user.getPassword()));
   user.setStatus(Status.NORMAL.getCode());
   userMapper.insert(user);
   List<Integer> roleList = user.getRoleList();
   if (roleList == null || roleList.isEmpty()) {
     return ExtJSResponse.successRes();
   }
   List<UserRole> userRoleList = new ArrayList<UserRole>(roleList.size());
   for (Integer roleId : roleList) {
     UserRole userRole = new UserRole();
     userRole.setUserId(user.getId());
     userRole.setRoleId(roleId);
     userRole.setCreator(currentUserId);
     userRoleList.add(userRole);
   }
   userRoleMapper.insertBatch(userRoleList);
   return ExtJSResponse.successRes();
 }