Browse Source

添加修改密码

溪鸭夏 2 years ago
parent
commit
76bc4d9b97
1 changed files with 38 additions and 0 deletions
  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 Integer managerId;//商户Id
     public Integer id;
+    public String newPassword;//新密码
+    public String confirmPassword;//确认密码
     public String level;//权限
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
@@ -75,6 +77,42 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
         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