瀏覽代碼

添加修改密码

溪鸭夏 2 年之前
父節點
當前提交
76bc4d9b97
共有 1 個文件被更改,包括 38 次插入0 次删除
  1. 38 0
      mhotel/src/com/happy/action/adminManagerAction.java

+ 38 - 0
mhotel/src/com/happy/action/adminManagerAction.java

@@ -49,6 +49,8 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     public String hotelTownship;
     public String hotelTownship;
     public Integer managerId;//商户Id
     public Integer managerId;//商户Id
     public Integer id;
     public Integer id;
+    public String newPassword;//新密码
+    public String confirmPassword;//确认密码
     public String level;//权限
     public String level;//权限
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
@@ -75,6 +77,42 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
         this.response = response;
         this.response = response;
     }
     }
 
 
+
+    public String changePassword(){
+        JSONObject resultJson = new JSONObject();
+        if(!newPassword.equals(confirmPassword)){
+            resultJson.put("message", "新密码和确认密码不一致");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        AdminManager data =  adminManagerService.getById(id);
+        if(data == null){
+            resultJson.put("message", "账号无效,修改失败!");
+            resultJson.put("code", 205);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+
+        data.setPassword(newPassword);
+
+        int m = adminManagerService.updateAdmin(data);
+
+        if (m <= 0) {
+            resultJson.put("message", "修改失败");
+            resultJson.put("code", 502);
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+
+        }
+
+        resultJson.put("message", "修改成功");
+        resultJson.put("code", 200);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        return null;
+    }
+
+
     /**
     /**
      * 描述:登录
      * 描述:登录
      * @return
      * @return