Browse Source

修改bug

raojiaolong@163.com 2 years ago
parent
commit
549d4ff23f

+ 0 - 13
mhotel/src/com/happy/Model/AdminManager.java

@@ -105,11 +105,6 @@ public class AdminManager {
 	/**
 	/**
 	 * 营业执照
 	 * 营业执照
 	 */
 	 */
-	private String fileListJson;
-
-	/**
-	 * 营业执照
-	 */
 	private List<File> fileList;
 	private List<File> fileList;
 
 
 	public Integer getId() {
 	public Integer getId() {
@@ -256,14 +251,6 @@ public class AdminManager {
 		this.remake = remake;
 		this.remake = remake;
 	}
 	}
 
 
-	public String getFileListJson() {
-		return fileListJson;
-	}
-
-	public void setFileListJson(String fileListJson) {
-		this.fileListJson = fileListJson;
-	}
-
 	public List<File> getFileList() {
 	public List<File> getFileList() {
 		return fileList;
 		return fileList;
 	}
 	}

+ 1 - 1
mhotel/src/com/happy/Model/House.java

@@ -72,7 +72,7 @@ public class House {
 	private Integer status;
 	private Integer status;
 
 
 	/**
 	/**
-	 * 附件列表
+	 * 房型详细图
 	 */
 	 */
 	private List<File> fileList;
 	private List<File> fileList;
 
 

+ 3 - 2
mhotel/src/com/happy/action/adminManagerAction.java

@@ -49,6 +49,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
     public String level;//权限
     public String level;//权限
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
+    private String fileListJson;
 
 
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
@@ -155,7 +156,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
             admin.setId(Math.toIntExact(UUIDUtil.generateID()));
             admin.setId(Math.toIntExact(UUIDUtil.generateID()));
             admin.setManagerId(admin.getId());
             admin.setManagerId(admin.getId());
             //保存详细图附件
             //保存详细图附件
-            List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
+            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
             if(fileList!=null && fileList.size()>0){
             if(fileList!=null && fileList.size()>0){
                 for(File file : fileList){
                 for(File file : fileList){
                     file.setLinkId(admin.getId());
                     file.setLinkId(admin.getId());
@@ -239,7 +240,7 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 return null;
                 return null;
             }
             }
             //修改详细图附件
             //修改详细图附件
-            List<File> fileList = JSONArray.parseArray(admin.getFileListJson(), File.class);
+            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
             if(fileList!=null && fileList.size()>0){
             if(fileList!=null && fileList.size()>0){
                 if(admin.getId()!= null){
                 if(admin.getId()!= null){
                     fileService.delLinkFile(admin.getId());
                     fileService.delLinkFile(admin.getId());

+ 14 - 10
mhotel/src/com/happy/action/hotelAction.java

@@ -1,5 +1,6 @@
 package com.happy.action;
 package com.happy.action;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.google.gson.Gson;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.google.gson.reflect.TypeToken;
 import com.happy.Model.*;
 import com.happy.Model.*;
@@ -44,6 +45,8 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
 
 
+    public String fileListJson;
+
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
     }
     }
@@ -84,16 +87,9 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
             BeanUtils.copyProperties(hotelEto,hotel);
             BeanUtils.copyProperties(hotelEto,hotel);
             int hotelId = hotel.getId()!= null ? hotel.getId():Math.toIntExact(UUIDUtil.generateID());
             int hotelId = hotel.getId()!= null ? hotel.getId():Math.toIntExact(UUIDUtil.generateID());
             int m = 0;
             int m = 0;
-            //保存详细图附件
-            if(hotelEto.getFileList()!=null && hotelEto.getFileList().size()>0){
-                if(hotel.getId()!= null){
-                    fileService.delLinkFile(hotel.getId());
-                }
-                for(File file : hotelEto.getFileList()){
-                    file.setLinkId(hotelId);
-                    fileService.insertFile(file);
-                }
-            }else{
+            //详细图附件
+            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+            if(fileList==null){
                 resultJson.put("message", "请上传详细图");
                 resultJson.put("message", "请上传详细图");
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
@@ -105,7 +101,15 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
                 hotel.setId(hotelId);
                 hotel.setId(hotelId);
                 m = hotelService.insertHotel(hotel);
                 m = hotelService.insertHotel(hotel);
             }
             }
+
             if (m > 0) {
             if (m > 0) {
+                if(hotel.getId()!= null){
+                    fileService.delLinkFile(hotel.getId());
+                }
+                for(File file : fileList){
+                    file.setLinkId(hotelId);
+                    fileService.insertFile(file);
+                }
                 resultJson.put("message", "维护成功");
                 resultJson.put("message", "维护成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());

+ 38 - 8
mhotel/src/com/happy/action/houseAction.java

@@ -1,17 +1,13 @@
 package com.happy.action;
 package com.happy.action;
 
 
+import com.alibaba.fastjson.JSONArray;
 import com.google.gson.Gson;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import com.google.gson.reflect.TypeToken;
-import com.happy.Model.Admin;
-import com.happy.Model.AdminManager;
-import com.happy.Model.Booking;
-import com.happy.Model.House;
-import com.happy.Until.GetHttpParam;
-import com.happy.Until.PwdDefind;
-import com.happy.Until.ResUtil;
-import com.happy.Until.ResponseUtil;
+import com.happy.Model.*;
+import com.happy.Until.*;
 import com.happy.dto.IPage;
 import com.happy.dto.IPage;
 import com.happy.service.BookService;
 import com.happy.service.BookService;
+import com.happy.service.FileService;
 import com.happy.service.HouseService;
 import com.happy.service.HouseService;
 import com.opensymphony.xwork2.ActionSupport;
 import com.opensymphony.xwork2.ActionSupport;
 import net.sf.json.JSONObject;
 import net.sf.json.JSONObject;
@@ -33,12 +29,16 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
     public HouseService houseService;
     public HouseService houseService;
     @Resource
     @Resource
     public BookService bookService;
     public BookService bookService;
+    @Resource
+    public FileService fileService;
 
 
     public Integer id;
     public Integer id;
     public String hName;//房型名称
     public String hName;//房型名称
     public int page; // 当前页
     public int page; // 当前页
     public int rows;// 每页显示的行数rows
     public int rows;// 每页显示的行数rows
 
 
+    public String fileListJson;
+
     public HttpServletRequest getRequest() {
     public HttpServletRequest getRequest() {
         return request;
         return request;
     }
     }
@@ -87,6 +87,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            //详细图附件
+            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+            if(fileList==null){
+                resultJson.put("message", "请上传详细图");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             House listc = houseService.getOen(getOneSqlx.toString());
             House listc = houseService.getOen(getOneSqlx.toString());
@@ -96,8 +103,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            house.setId(Math.toIntExact(UUIDUtil.generateID()));
             int m = houseService.insertHouse(house);
             int m = houseService.insertHouse(house);
             if (m > 0) {
             if (m > 0) {
+                for(File file : fileList){
+                    file.setLinkId(house.getId());
+                    fileService.insertFile(file);
+                }
                 resultJson.put("message", "新增成功");
                 resultJson.put("message", "新增成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -151,6 +163,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 return null;
                 return null;
             }
             }
+            //详细图附件
+            List<File> fileList = JSONArray.parseArray(fileListJson, File.class);
+            if(fileList==null){
+                resultJson.put("message", "请上传详细图");
+                ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
+                return null;
+            }
             StringBuilder getOneSqlx = new StringBuilder("");
             StringBuilder getOneSqlx = new StringBuilder("");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and h_name = '").append(house.gethName()).append("'");
             getOneSqlx.append(" and id != '").append(house.getId()).append("'");
             getOneSqlx.append(" and id != '").append(house.getId()).append("'");
@@ -163,6 +182,13 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             }
             }
             int m = houseService.updateHouse(house);
             int m = houseService.updateHouse(house);
             if (m > 0) {
             if (m > 0) {
+                if(house.getId()!= null){
+                    fileService.delLinkFile(house.getId());
+                }
+                for(File file : fileList){
+                    file.setLinkId(house.getId());
+                    fileService.insertFile(file);
+                }
                 resultJson.put("message", "修改成功");
                 resultJson.put("message", "修改成功");
                 resultJson.put("code", 200);
                 resultJson.put("code", 200);
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
                 ResUtil.writeJson(ServletActionContext.getResponse(), resultJson.toString());
@@ -220,6 +246,10 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             return null;
             return null;
         }
         }
         House house = houseService.getById(id);
         House house = houseService.getById(id);
+        StringBuilder fileSqlx = new StringBuilder("");
+        fileSqlx.append("and link_id = '").append(id).append("'");
+        List<File> fileList = fileService.queryList(fileSqlx.toString());
+        house.setFileList(fileList);
         if (house != null) {
         if (house != null) {
             resultJson.put("message", "查询成功");
             resultJson.put("message", "查询成功");
             resultJson.put("code", 200);
             resultJson.put("code", 200);