/** * 修改管理员密码,判断数据库是否存在 * * @return */ public boolean CheckUser() { this.CheckLogin(); if (!this.isSlogin()) { MD5Code md5 = new MD5Code(); UserT user = new UserT(); user.setUsername(this.getUsername().trim()); user.setPassword(md5.getMD5ofStr(this.getPassword().trim())); UserT userlist = this.getUsertService().usert(user); if (userlist != null) { return true; } else { return false; } } return true; }
/** * 更改管理员密码 * * @return */ @Action( value = "UpdateUserMember", results = {@Result(name = "json", type = "json")}) public String UpdateUserMember() { this.CheckLogin(); if (!this.isSlogin()) { if (this.CheckUser()) { MD5Code md5 = new MD5Code(); UserT user = new UserT(); user.setUserid(this.getUserid().trim()); user.setUsername(this.getUsername().trim()); user.setPassword(md5.getMD5ofStr(this.getNewpassword().trim())); this.getUsertService().updateUserMember(user); return "json"; } } return "json"; }
/** * 管理员登陆 * * @return * @throws Exception */ @SuppressWarnings("unchecked") @Action( value = "adminlogin", results = { @Result( name = "success", type = "redirect", location = "/jshop/admin/adminindex.jsp?session=${param}"), @Result( name = "input", type = "redirect", location = "/jshop/admin/adminlogin.jsp?msg=${param}") }) public String adminlogin() throws Exception { MD5Code md5 = new MD5Code(); UserT user = new UserT(); user.setUsername(this.getUsername().trim()); user.setPassword(md5.getMD5ofStr(this.getPassword().trim())); user.setState("3"); // 超级管理员 user = this.getUsertService().login(user); if (user != null) { ActionContext.getContext() .getSession() .put(BaseTools.BACK_USER_SESSION_KEY, user.getUserid()); ActionContext.getContext() .getSession() .put(BaseTools.BACK_USER_NAME_SESSION_KEY, user.getUsername()); this.setParam(md5.getMD5ofStr(user.getUserid())); ActionContext.getContext().getSession().put(BaseTools.BACK_SESSION_KEY, param); // 获取默认主题 this.getInitTAction().InitDefaultThemeT(); // 收集权限信息并放入内存 List<FunctionM> userfunctionlist = this.getUserRoleMAction().findUserRoleFunctionList(user.getUserid()); // List<FunctionM>allfunctionlist=this.getUserRoleMAction().findAllFunctionM(); ActionContext.getContext().getSession().put(BaseTools.USERROLEFUNCTION, userfunctionlist); // ActionContext.getContext().getSession().put(BaseTools.ALLROLEFUNCTION, allfunctionlist); return SUCCESS; } this.setParam("1"); return INPUT; }
/** * 管理员增加用户 * * @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"; } }