예제 #1
0
 @WebMethod
 public ModelAndView save(User user, Integer groupId, String roleIds) {
   ModelAndView mv = new ModelAndView();
   if (StringUtils.isEmpty(user.account)) {
     throw new GException(PlatformExceptionType.BusinessException, "用户账号不能为空");
   }
   if (StringUtils.isEmpty(user.name)) {
     throw new GException(PlatformExceptionType.BusinessException, "用户姓名不能为空");
   }
   if (StringUtils.isEmpty(user.pwd)) {
     throw new GException(PlatformExceptionType.BusinessException, "请先设置密码");
   }
   user.isSuperAdmin = 0;
   user.addtime = new Date();
   user.pwd = SecurityHelper.Md5(user.pwd);
   // TODO
   dao.saveOrUpdate(user);
   if (groupId != null) {
     UserGroup ug = new UserGroup();
     ug.gid = groupId;
     ug.uid = user.id;
     dao.saveOrUpdate(ug);
   }
   if (roleIds != null && roleIds.length() != 0) {
     String[] Ids = roleIds.split(",");
     for (int i = 0; i < Ids.length; i++) {
       UserRole rg = new UserRole();
       rg.roleId = Integer.valueOf(Ids[i]);
       rg.uid = user.id;
       dao.saveOrUpdate(rg);
     }
   }
   return mv;
 }
예제 #2
0
 @WebMethod
 public ModelAndView addToGroup(int groupId, String ids) {
   ModelAndView mv = new ModelAndView();
   for (String uid : ids.split(",")) {
     if (StringUtils.isEmpty(uid)) {
       continue;
     }
     UserGroup po =
         dao.getUniqueByParams(
             UserGroup.class,
             new String[] {"gid", "uid"},
             new Object[] {groupId, Integer.valueOf(uid)});
     if (po != null) {
       continue;
     }
     UserGroup ug = new UserGroup();
     ug.gid = groupId;
     ug.uid = Integer.valueOf(uid);
     dao.saveOrUpdate(ug);
   }
   return mv;
 }