Bladeren bron

单题保存新增word二进制

宋悦 7 jaren geleden
bovenliggende
commit
1338d37f3c

+ 10 - 3
cqb-question-resource/src/main/java/com/qmth/cqb/question/service/impl/QuesServiceImpl.java

@@ -322,9 +322,16 @@ public class QuesServiceImpl implements QuesService{
                 }
             }
             byte [] pkgByte = DocxProcessUtil.getPkgByte(wordMLPackage);
-            QuestionPkgPath quesPkgPath = quesPkgPathRepo.findFirstById(question.getQuesPkgPathId());
-            quesPkgPath.setQuesPkg(pkgByte);
-            quesPkgPathRepo.save(quesPkgPath);
+            if(question.getQuesPkgPathId() == null){
+                QuestionPkgPath quesPkgPath = new QuestionPkgPath(pkgByte);
+                QuestionPkgPath returnQuesPkgPath = quesPkgPathRepo.save(quesPkgPath);
+                question.setQuesPkgPathId(returnQuesPkgPath.getId());
+                quesRepo.save(question);
+            }else{
+                QuestionPkgPath quesPkgPath = quesPkgPathRepo.findFirstById(question.getQuesPkgPathId());
+                quesPkgPath.setQuesPkg(pkgByte);
+                quesPkgPathRepo.save(quesPkgPath);
+            }
             pkgByte = null;
         } catch (Exception e) {
             e.printStackTrace();