|
@@ -3,7 +3,7 @@ package edu.math.diagnosis.controller;
|
|
|
import edu.math.diagnosis.cache.DbCacheFactory;
|
|
|
import edu.math.diagnosis.cache.instance.OptionCache;
|
|
|
import edu.math.diagnosis.cache.instance.QuestionCache;
|
|
|
-import edu.math.diagnosis.dao.CommitRepo;
|
|
|
+//import edu.math.diagnosis.dao.CommitRepo;
|
|
|
import edu.math.diagnosis.dao.UserRepo;
|
|
|
import edu.math.diagnosis.entity.*;
|
|
|
import edu.math.diagnosis.model.AuthUser;
|
|
@@ -30,39 +30,39 @@ import java.util.Map;
|
|
|
@RestController
|
|
|
@RequestMapping("/commit")
|
|
|
public class CommitController {
|
|
|
- @Resource
|
|
|
- CommitRepo commitRepo;
|
|
|
+// @Resource
|
|
|
+// CommitRepo commitRepo;
|
|
|
@Resource
|
|
|
UserRepo userRepo;
|
|
|
|
|
|
private final OptionCache OptionCache = DbCacheFactory.INSTANCE.getCache(OptionCache.class);
|
|
|
private final QuestionCache QuestionCache = DbCacheFactory.INSTANCE.getCache(QuestionCache.class);
|
|
|
|
|
|
- @RequestMapping(value = "/paper", method = RequestMethod.POST)
|
|
|
- public ResponseMessage commitPaper(@RequestBody Paper paper) {
|
|
|
- AuthUser authUser = SecurityUtil.getCurrentUser();
|
|
|
- Commit commit = new Commit();
|
|
|
- paper.getQuestions().forEach((question -> {
|
|
|
- question.setOptions(null);
|
|
|
- question.setUpdatetime(null);
|
|
|
- question.setCreatetime(null);
|
|
|
- question.setContent(null);
|
|
|
- question.setWrongDesc(null);
|
|
|
- }));
|
|
|
- paper.setCreatetime(null);
|
|
|
- paper.setUpdatetime(null);
|
|
|
- String data = ObjectUtil.object2Json(paper);
|
|
|
- commit.setData(data);
|
|
|
- long uid = authUser.getUser().getId();
|
|
|
- long pid = paper.getId();
|
|
|
- commit.setUid(uid);
|
|
|
- commit.setPid(pid);
|
|
|
- double point = calculatePoint(paper);
|
|
|
- commit.setScore(point);
|
|
|
- commit.setCreatetime(new Date());
|
|
|
- commitRepo.saveAndFlush(commit);
|
|
|
- return ResponseMessage.getInstance(200, NumberUtil.formatDouble(point));
|
|
|
- }
|
|
|
+// @RequestMapping(value = "/paper", method = RequestMethod.POST)
|
|
|
+// public ResponseMessage commitPaper(@RequestBody Paper paper) {
|
|
|
+// AuthUser authUser = SecurityUtil.getCurrentUser();
|
|
|
+// Commit commit = new Commit();
|
|
|
+// paper.getQuestions().forEach((question -> {
|
|
|
+// question.setOptions(null);
|
|
|
+// question.setUpdatetime(null);
|
|
|
+// question.setCreatetime(null);
|
|
|
+// question.setContent(null);
|
|
|
+// question.setWrongDesc(null);
|
|
|
+// }));
|
|
|
+// paper.setCreatetime(null);
|
|
|
+// paper.setUpdatetime(null);
|
|
|
+// String data = ObjectUtil.object2Json(paper);
|
|
|
+// commit.setData(data);
|
|
|
+// long uid = authUser.getUser().getId();
|
|
|
+// long pid = paper.getId();
|
|
|
+// commit.setUid(uid);
|
|
|
+// commit.setPid(pid);
|
|
|
+// double point = calculatePoint(paper);
|
|
|
+// commit.setScore(point);
|
|
|
+// commit.setCreatetime(new Date());
|
|
|
+// commitRepo.saveAndFlush(commit);
|
|
|
+// return ResponseMessage.getInstance(200, NumberUtil.formatDouble(point));
|
|
|
+// }
|
|
|
|
|
|
private double calculatePoint(Paper paper) {
|
|
|
double result = 0.0;
|
|
@@ -106,7 +106,8 @@ public class CommitController {
|
|
|
public boolean checkPaper(@RequestParam long pid) {
|
|
|
AuthUser authUser = SecurityUtil.getCurrentUser();
|
|
|
long uid = authUser.getUser().getId();
|
|
|
- int cnt = commitRepo.countByUidAndPid(uid, pid);
|
|
|
+// int cnt = commitRepo.countByUidAndPid(uid, pid);
|
|
|
+ int cnt=0;
|
|
|
return cnt < 1;
|
|
|
}
|
|
|
|