Browse Source

修改附件上传

raojiaolong@163.com 2 years ago
parent
commit
acc98f60a5

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

@@ -169,8 +169,13 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
             List<FileInfo> fileInfoList = JSONArray.parseArray(fileListJson, FileInfo.class);
             if(fileInfoList!=null && fileInfoList.size()>0){
                 for(FileInfo file : fileInfoList){
+                    FileInfo fileInfo = fileService.getById(file.getId());
                     file.setLinkId(admin.getId());
-                    fileService.updateFile(file);
+                    if(fileInfo==null){
+                        fileService.insertFile(file);
+                    }else{
+                        fileService.updateFile(file);
+                    }
                 }
             }
             int m = adminManagerService.insertAdmin(admin);
@@ -253,10 +258,10 @@ public class adminManagerAction extends ActionSupport implements ServletRequestA
                 }
                 for(FileInfo file : fileInfoList){
                     FileInfo fileInfo = fileService.getById(file.getId());
+                    file.setLinkId(admin.getId());
                     if(fileInfo==null){
                         fileService.insertFile(file);
                     }else{
-                        file.setLinkId(admin.getId());
                         fileService.updateFile(file);
                     }
                 }

+ 1 - 1
mhotel/src/com/happy/action/hotelAction.java

@@ -112,10 +112,10 @@ public class hotelAction extends ActionSupport implements ServletRequestAware {
                 }
                 for(FileInfo file : fileList){
                     FileInfo fileInfo = fileService.getById(file.getId());
+                    file.setLinkId(hotelId);
                     if(fileInfo==null){
                         fileService.insertFile(file);
                     }else{
-                        file.setLinkId(hotelId);
                         fileService.updateFile(file);
                     }
                 }

+ 7 - 3
mhotel/src/com/happy/action/houseAction.java

@@ -112,8 +112,12 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
             int m = houseService.insertHouse(house);
             if (m > 0) {
                 for(FileInfo file : fileList){
-                    file.setLinkId(house.getId());
-                    fileService.updateFile(file);
+                    file.setLinkId(hotelId);
+                    if(fileInfo==null){
+                        fileService.insertFile(file);
+                    }else{
+                        fileService.updateFile(file);
+                    }
                 }
                 resultJson.put("message", "新增成功");
                 resultJson.put("code", 200);
@@ -192,10 +196,10 @@ public class houseAction extends ActionSupport implements ServletRequestAware {
                 }
                 for(FileInfo file : fileList){
                     FileInfo fileInfo = fileService.getById(file.getId());
+                    file.setLinkId(house.getId());
                     if(fileInfo==null){
                         fileService.insertFile(file);
                     }else{
-                        file.setLinkId(house.getId());
                         fileService.updateFile(file);
                     }
                 }