Browse Source

修改方法新增修改账号时的附件图类型

raojiaolong@163.com 2 years ago
parent
commit
4e75a450a9

+ 5 - 5
mhotel/src/com/happy/Model/AdminManager.java

@@ -94,7 +94,7 @@ public class AdminManager {
 	/**
 	 * 营业执照
 	 */
-	private List<File> fileList;
+	private String fileListJson;
 
 	public Integer getId() {
 		return id;
@@ -224,11 +224,11 @@ public class AdminManager {
 		this.status = status;
 	}
 
-	public List<File> getFileList() {
-		return fileList;
+	public String getFileListJson() {
+		return fileListJson;
 	}
 
-	public void setFileList(List<File> fileList) {
-		this.fileList = fileList;
+	public void setFileListJson(String fileListJson) {
+		this.fileListJson = fileListJson;
 	}
 }

+ 153 - 8
mhotel/src/com/happy/action/adminManagerAction.java

@@ -1,5 +1,6 @@
 package com.happy.action;
 
+import com.alibaba.fastjson.JSONArray;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.happy.Model.AdminManager;
@@ -90,7 +91,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     }
 
     /**
-     * 描述:新增民宿账号
+     * 描述:新增管理端民宿账号
      * @return
      */
     public String insertAdmin() {
@@ -135,11 +136,9 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
             }
             admin.setId(Math.toIntExact(UUIDUtil.generateID()));
             //保存详细图附件
-            if(admin.getFileList()!=null && admin.getFileList().size()>0){
-                if(admin.getId()!= null){
-                    fileService.delLinkFile(admin.getId());
-                }
-                for(File file : admin.getFileList()){
+            List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
+            if(fileList!=null && fileList.size()>0){
+                for(File file : fileList){
                     file.setLinkId(admin.getId());
                     fileService.insertFile(file);
                 }
@@ -170,7 +169,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     }
 
     /**
-     * 描述:修改管理端管理员账号
+     * 描述:修改管理端民宿账号
      * @return
      */
     public String updateAdmin() {
@@ -220,6 +219,152 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
             }
+            //修改详细图附件
+            List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
+            if(fileList!=null && fileList.size()>0){
+                if(admin.getId()!= null){
+                    fileService.delLinkFile(admin.getId());
+                }
+                for(File file : fileList){
+                    file.setLinkId(admin.getId());
+                    fileService.insertFile(file);
+                }
+            }else{
+                resultJson.put("message", "请上传详细图");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            int m = adminManagerService.updateAdmin(admin);
+            if (m > 0) {
+                resultJson.put("message", "修改成功");
+                resultJson.put("code", 200);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            } else {
+                resultJson.put("message", "修改失败");
+                resultJson.put("code", 502);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        resultJson.put("message", "未知异常");
+        resultJson.put("code", 205);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        return null;
+    }
+
+    /**
+     * 描述:新增民宿端普通账号
+     * @return
+     */
+    public String insertAdminManager() {
+        JSONObject resultJson = new JSONObject();
+        Gson gson = new Gson();
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
+        if (json == null) {
+            resultJson.put("message", "请传入参数");
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        AdminManager admin = null;
+        try {
+            admin = gson.fromJson(json.toString(), new TypeToken<AdminManager>() {}.getType());
+            if (admin == null) {
+                resultJson.put("message", "数据为空");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            if (admin.getAdminName()==null || admin.getCardName()==null || admin.getCorpnPhone()==null
+                    || admin.getLevel()==null || admin.getPassword()==null){
+                resultJson.put("message", "各参数不能为空");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            if (!PwdDefind.vertify(admin.getPassword())){
+                resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            StringBuilder getOneSqlx = new StringBuilder("");
+            getOneSqlx.append(" and admin_name = '").append(admin.getAdminName()).append("'");
+            AdminManager listc = adminManagerService.getOen(getOneSqlx.toString());
+            if (listc != null) {
+                resultJson.put("message", "该用户已存在");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            int m = adminManagerService.insertAdmin(admin);
+            if (m > 0) {
+                resultJson.put("message", "添加成功");
+                resultJson.put("code", 200);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            } else {
+                resultJson.put("message", "添加失败");
+                resultJson.put("code", 502);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        resultJson.put("message", "未知异常");
+        resultJson.put("code", 205);
+        ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+        return null;
+    }
+
+    /**
+     * 描述:修改民宿端普通账号
+     * @return
+     */
+    public String updateAdminManager() {
+        JSONObject resultJson = new JSONObject();
+        Gson gson = new Gson();
+        com.alibaba.fastjson.JSONObject json = GetHttpParam.getRequestParameters(request);
+        if (json == null) {
+            resultJson.put("message", "请传入参数");
+            ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+            return null;
+        }
+        AdminManager admin = null;
+        try {
+            admin = gson.fromJson(json.toString(), new TypeToken<AdminManager>() {}.getType());
+            if (admin == null) {
+                resultJson.put("message", "数据为空");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            if (admin.getAdminName()==null || admin.getCardName()==null || admin.getCorpnPhone()==null
+                    || admin.getLevel()==null || admin.getPassword()==null){
+                resultJson.put("message", "各参数不能为空");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            if (!PwdDefind.vertify(admin.getPassword())){
+                resultJson.put("message", "密码至少包含:大小写英文字母、数字、特殊符号,密码长度大于8位,小于20位");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
+            StringBuilder getOneSqlx = new StringBuilder("");
+            getOneSqlx.append(" and admin_name = '").append(admin.getAdminName()).append("'");
+            getOneSqlx.append(" and id != '").append(admin.getId()).append("'");
+            AdminManager listc = adminManagerService.getOen(getOneSqlx.toString());
+            if (listc != null) {
+                resultJson.put("message", "该用户已存在");
+                resultJson.put("code", 500);
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
             int m = adminManagerService.updateAdmin(admin);
             if (m > 0) {
                 resultJson.put("message", "修改成功");
@@ -313,7 +458,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
         }
         AdminManager admin = adminManagerService.getById(id);
         if (admin != null && !"".equals(admin)) {
-            admin.setStatus(0);
+            admin.setStatus(2);
             int m = adminManagerService.updateAdmin(admin);
             if(m > 0){
                 resultJson.put("message", "冻结成功");

+ 6 - 0
mhotel/src/struts.xml

@@ -23,14 +23,20 @@
 		</action>
 		<action name="admin*" method = "{1}" class="com.happy.action.adminAction">
 		</action>
+		<action name="managerAdmin*" method = "{1}" class="com.happy.action.adminManagerAction">
+		</action>
 		<action name="config*" method = "{1}" class="com.happy.action.configAction">
 		</action>
+		<action name="hotel*" method = "{1}" class="com.happy.action.hotelAction">
+		</action>
 		<action name="house*" method = "{1}" class="com.happy.action.houseAction">
 		</action>
 		<action name="book*" method = "{1}" class="com.happy.action.bookAction">
 		</action>
 		<action name="app*" method = "{1}" class="com.happy.action.appAction">
 		</action>
+		<action name="upload*" method = "{1}" class="com.happy.action.uploadAction">
+		</action>
 	</package>
 	<package name="interfaces" namespace="/interfaces" extends="struts-default">
 		<!-- 接口总调度开始 -->