gaoxing 8 éve
szülő
commit
cd76b6c0b0

+ 9 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/service/PaperStructService.java

@@ -70,6 +70,14 @@ public class PaperStructService {
      * @return
      */
     public PaperStruct save(PaperStruct paperStruct, AccessUser user) {
+        PaperStruct oldPaperStruct = paperStructRepo.findOne(paperStruct.getId());
+        PaperStruct rps = null;
+        if (oldPaperStruct != null && !paperStruct.getName().equals(oldPaperStruct.getName())) {// 那么就是更新操作
+            rps = this.checkNameUnique(paperStruct.getName(), user.getOrgId().toString());
+        }
+        if (rps != null) {
+            return null;
+        }
         List<PaperDetailStruct> paperDetailStructs = paperStruct.getPaperDetailStructs();
         int number = 0;
         for (PaperDetailStruct paperDetailStruct : paperDetailStructs) {
@@ -94,7 +102,7 @@ public class PaperStructService {
         }
         paperStruct.setDetailCount(paperDetailStructs.size());
         paperStruct.setOrgId(user.getOrgId().toString());
-        paperStruct.setCreator(user.getLoginName());
+        paperStruct.setCreator(user.getName());
         paperStruct.setCreateTime(CommonUtils.getCurDateTime());
         return paperStructRepo.save(paperStruct);
     }

+ 6 - 1
cqb-paper/src/main/java/com/qmth/cqb/paper/web/PaperStructController.java

@@ -90,7 +90,12 @@ public class PaperStructController {
     public ResponseEntity updatePaperStruct(HttpServletRequest request, @RequestBody PaperStruct ps) {
         AccessUser user = (AccessUser) request.getAttribute("accessUser");
         PaperStruct paperStruct = paperStructService.save(ps, user);
-        return new ResponseEntity(paperStruct, HttpStatus.OK);
+        if (paperStruct == null) {
+            return new ResponseEntity(HttpStatus.INTERNAL_SERVER_ERROR);
+        } else {
+            return new ResponseEntity(paperStruct, HttpStatus.OK);
+        }
+
     }
 
     /**