예제 #1
0
 /**
  * 管理员增加用户
  *
  * @return
  */
 @Action(
     value = "adminregister",
     results = {@Result(name = "json", type = "json")})
 public String adminregister() {
   MD5Code md5 = new MD5Code();
   UserT u = new UserT();
   u.setUsername(this.getUsername().trim());
   u.setEmail(this.getEmail().trim());
   u = this.getUsertService().checkUserByUsername(u);
   if (u != null) {
     this.setMsg("4"); // 表示用户已经存在
     return "json";
   } else {
     u = new UserT();
     u.setUsername(this.getUsername().trim());
     u.setEmail(this.getEmail().trim());
     u = this.getUsertService().checkUserByEmail(u);
     if (u != null) {
       this.setMsg("5"); // 表示用户邮箱存在
       return "json";
     }
     UserT user = new UserT();
     user.setUserid(this.getSerial().Serialid(Serial.USER));
     user.setUid(md5.getMD5ofStr(user.getUserid()));
     user.setUsername(this.getUsername().trim());
     user.setRealname(null);
     user.setEmail(this.getEmail().trim());
     user.setTelno(null);
     user.setMobile(null);
     user.setQuestion(null);
     user.setAnswer(null);
     user.setPassword(md5.getMD5ofStr("111111")); // 默认密码6个1
     user.setUserstate(this.getUserstate());
     user.setPoints(Double.parseDouble(this.getPoints().trim()));
     user.setPostingcount(0);
     user.setSex(null);
     user.setRegisttime(BaseTools.systemtime());
     user.setDisablebegin(null);
     user.setDisableend(null);
     user.setSection(null);
     user.setPosition(null);
     user.setGroupid(null);
     user.setParttime1(null);
     user.setParttime2(null);
     user.setParttime3(null);
     user.setParttime4(null);
     user.setParttime5(null);
     user.setParttime6(null);
     user.setHobby(null);
     user.setQq(null);
     user.setMsn(null);
     user.setOthercontract(null);
     user.setAddress(null);
     user.setPostcode(null);
     user.setBirthday(null);
     user.setGrade(this.getGrade());
     user.setGradename(this.getGradename().trim());
     if (this.getGrade().equals("0")) {
       user.setGradetime(null);
     } else {
       user.setGradetime(BaseTools.systemtime());
     }
     user.setState(this.getState());
     user.setRolemid("0");
     user.setRolemname("");
     if (this.getUsertService().save(user) > 0) {
       // 重新获取后台登录时保存的加密session key
       this.setParam(
           ActionContext.getContext().getSession().get(BaseTools.BACK_SESSION_KEY).toString());
       this.setSucflag(true);
       return "json";
     }
     this.setSucflag(false);
     return "json";
   }
 }
예제 #2
0
 /**
  * 查询所有用户
  *
  * @return
  */
 @SuppressWarnings("unchecked")
 @Action(
     value = "findAllUsert",
     results = {@Result(name = "json", type = "json")})
 public String findAllUsert() {
   int currentPage = page;
   int lineSize = rp;
   String queryString = "from UserT order by " + sortname + " " + sortorder + " ";
   if (Validate.StrNotNull(sortname) && Validate.StrNotNull(sortorder)) {
     List<UserT> list = this.getUsertService().sortAllUsert(currentPage, lineSize, queryString);
     if (list != null) {
       total = this.getUsertService().countfindAllUsert();
       rows.clear();
       for (Iterator it = list.iterator(); it.hasNext(); ) {
         UserT u = (UserT) it.next();
         if ("0".equals(u.getSex())) {
           u.setSex("女");
         }
         if ("1".equals(u.getSex())) {
           u.setSex("男");
         }
         if ("1".equals(u.getState())) {
           u.setState("普通用户");
         }
         if ("2".equals(u.getState())) {
           u.setState("管理员");
         }
         if ("3".equals(u.getState())) {
           u.setState("超级管理员");
         }
         if ("4".equals(u.getState())) {
           u.setState("手机用户");
         }
         if ("0".equals(u.getUserstate())) {
           u.setUserstate("未激活");
         }
         if ("1".equals(u.getUserstate())) {
           u.setUserstate("激活");
         }
         if ("2".equals(u.getUserstate())) {
           u.setUserstate("禁止访问");
         }
         if ("3".equals(u.getUserstate())) {
           u.setUserstate("禁止发帖");
         }
         if (u.getGradetime() != null) {
           this.setGradetime(BaseTools.formateDbDate(u.getGradetime()));
         } else {
           this.setGradetime("");
         }
         Map cellMap = new HashMap();
         cellMap.put("id", u.getUserid());
         cellMap.put(
             "cell",
             new Object[] {
               u.getUsername(),
               u.getRealname(),
               u.getEmail(),
               u.getSex(),
               u.getPoints(),
               u.getQq(),
               u.getMsn(),
               u.getGradename(),
               u.getUserstate(),
               u.getGradetime(),
               BaseTools.formateDbDate(u.getRegisttime())
             });
         rows.add(cellMap);
       }
       return "json";
     }
   }
   this.setTotal(0);
   rows.clear();
   return "json";
 }