|
@@ -7,7 +7,9 @@ import com.nuliji.tools.exception.ParameterException;
|
|
|
import com.nuliji.tools.exception.SystemException;
|
|
|
import com.qxgmat.data.constants.enums.QuestionType;
|
|
|
import com.qxgmat.data.constants.enums.SettingKey;
|
|
|
+import com.qxgmat.data.constants.enums.module.FeedbackModule;
|
|
|
import com.qxgmat.data.constants.enums.module.PaperModule;
|
|
|
+import com.qxgmat.data.constants.enums.module.PaperOrigin;
|
|
|
import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
import com.qxgmat.data.constants.enums.status.DirectionStatus;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
@@ -18,6 +20,7 @@ import com.qxgmat.dto.request.UserNoteDto;
|
|
|
import com.qxgmat.dto.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
import com.qxgmat.service.*;
|
|
|
+import com.qxgmat.service.extend.QuestionFlowService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -36,6 +39,7 @@ import java.io.IOException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* Created by GaoJie on 2017/10/31.
|
|
@@ -58,6 +62,9 @@ public class MyController {
|
|
|
private ShiroHelp shiroHelp;
|
|
|
|
|
|
@Autowired
|
|
|
+ private SettingService settingService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ExerciseStructService exerciseStructService;
|
|
|
|
|
|
@Autowired
|
|
@@ -67,22 +74,25 @@ public class MyController {
|
|
|
private ClassCourseNoService classCourseNoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UsersService usersService;
|
|
|
+ private QuestionNoService questionNoService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserMessageService userMessageService;
|
|
|
+ private SentenceQuestionService sentenceQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
- private SettingService settingService;
|
|
|
+ private TextbookQuestionService textbookQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserCourseRecordService userCourseRecordService;
|
|
|
+ private UsersService usersService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserSentenceRecordService userSentenceRecordService;
|
|
|
+ private UserMessageService userMessageService;
|
|
|
|
|
|
@Autowired
|
|
|
- private QuestionNoService questionNoService;
|
|
|
+ private UserCourseRecordService userCourseRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserSentenceRecordService userSentenceRecordService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserServiceService userServiceService;
|
|
@@ -108,6 +118,12 @@ public class MyController {
|
|
|
@Autowired
|
|
|
private UserPaperService userPaperService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserPaperQuestionService userPaperQuestionService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private QuestionFlowService questionFlowService;
|
|
|
+
|
|
|
@RequestMapping(value = "/email", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "绑定邮箱", httpMethod = "POST")
|
|
|
public Response<Boolean> email(@RequestBody @Validated UserEmailDto dto, HttpSession session, HttpServletRequest request) {
|
|
@@ -327,7 +343,7 @@ public class MyController {
|
|
|
dto.setDays((int)((user.getCreateTime().getTime() - new Date().getTime()) / (1000*3600*24)));
|
|
|
Integer totalTime = 0;
|
|
|
Map<String, Integer> categoryMap = new HashMap<>();
|
|
|
- // 按模块类型分组查询: module=> sentence, examination, collect+error, 忽略exercise
|
|
|
+ // 按模块来源分组查询: module=> sentence, examination, collect+error, 忽略exercise,preview
|
|
|
List<UserStudyStatRelation> moduleList = userReportService.statGroupModule(user.getId());
|
|
|
for(UserStudyStatRelation module:moduleList){
|
|
|
// 练习时间过滤
|
|
@@ -338,16 +354,24 @@ public class MyController {
|
|
|
String key = module.getModule();
|
|
|
totalTime += time;
|
|
|
// 收藏及错误组卷合并
|
|
|
- if (module.getModule().equals(PaperModule.COLLECT.key)
|
|
|
- || module.getModule().equals(PaperModule.ERROR.key)){
|
|
|
+ if (module.getModule().equals(PaperOrigin.COLLECT.key)
|
|
|
+ || module.getModule().equals(PaperOrigin.ERROR.key)){
|
|
|
key = "freedom";
|
|
|
time += categoryMap.getOrDefault(key, 0);
|
|
|
+ }else if (module.getModule().equals(PaperOrigin.PREVIEW.key)){
|
|
|
+ key = PaperOrigin.EXERCISE.key;
|
|
|
}
|
|
|
categoryMap.put(key, time);
|
|
|
}
|
|
|
// 按题型统计练习
|
|
|
- List<UserStudyStatRelation> typeList = userReportService.statGroupExerciseType(user.getId(), null, null);
|
|
|
- for(UserStudyStatRelation type:typeList){
|
|
|
+ List<UserStudyStatRelation> exerciseList = userReportService.statGroupExerciseType(user.getId(), null, null);
|
|
|
+ for(UserStudyStatRelation type:exerciseList){
|
|
|
+ totalTime += type.getUserTime();
|
|
|
+ categoryMap.put(type.getModule(), type.getUserTime());
|
|
|
+ }
|
|
|
+ // 按题型统计预习作业
|
|
|
+ List<UserStudyStatRelation> previewList = userReportService.statGroupExerciseType(user.getId(), null, null);
|
|
|
+ for(UserStudyStatRelation type:previewList){
|
|
|
totalTime += type.getUserTime();
|
|
|
categoryMap.put(type.getModule(), type.getUserTime());
|
|
|
}
|
|
@@ -400,38 +424,64 @@ public class MyController {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserStudyDayDto dto = new UserStudyDayDto();
|
|
|
|
|
|
+ // todo
|
|
|
+
|
|
|
return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/collect", method = RequestMethod.PUT)
|
|
|
+ @RequestMapping(value = "/collect/add", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "添加收藏", notes = "添加收藏", httpMethod = "PUT")
|
|
|
public Response<Boolean> addCollect(@RequestBody @Validated UserCollectDto dto) {
|
|
|
UserCollectQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
- entity.setQuestionId(questionNo.getQuestionId());
|
|
|
- entity.setModule(questionNo.getModule());
|
|
|
+ switch (QuestionModule.ValueOf(dto.getQuestionModule())){
|
|
|
+ case BASE:
|
|
|
+ entity.setQuestionModule(QuestionModule.BASE.key);
|
|
|
+ QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(questionNo.getQuestionId());
|
|
|
+ entity.setQuestionNoId(questionNo.getId());
|
|
|
+ break;
|
|
|
+ case SENTENCE:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ SentenceQuestion sentenceQuestion = sentenceQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(sentenceQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(sentenceQuestion.getId());
|
|
|
+ break;
|
|
|
+ case TEXTBOOK:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ TextbookQuestion textbookQuestion = textbookQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(textbookQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(textbookQuestion.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
entity.setUserId(user.getId());
|
|
|
userCollectQuestionService.addQuestion(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/collect", method = RequestMethod.DELETE)
|
|
|
+ @RequestMapping(value = "/collect/delete", method = RequestMethod.DELETE)
|
|
|
@ApiOperation(value = "移除收藏", notes = "移除收藏", httpMethod = "DELETE")
|
|
|
- public Response<Boolean> deleteCollect(Integer questionNoId) {
|
|
|
+ public Response<Boolean> deleteCollect(String questionModule, Integer questionNoId) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), questionNoId);
|
|
|
+ Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), QuestionModule.ValueOf(questionModule), questionNoId);
|
|
|
|
|
|
return ResponseHelp.success(result);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/collect/bind", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "收藏组卷", notes = "收藏组卷", httpMethod = "POST")
|
|
|
- public Response<Boolean> bindCollect(@RequestBody @Validated UserQuestionIdsDto dto) {
|
|
|
+ public Response<Boolean> bindCollect(@RequestBody @Validated UserCustomBindDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
|
|
|
- // todo 绑定数据
|
|
|
+ questionFlowService.makePaper(
|
|
|
+ user.getId(),
|
|
|
+ QuestionModule.ValueOf(dto.getQuestionModule()),
|
|
|
+ PaperOrigin.COLLECT,
|
|
|
+ Arrays.stream(dto.getQuestionNoIds()).collect(Collectors.toList()),
|
|
|
+ dto.getFilterTimes()
|
|
|
+ );
|
|
|
+
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
@@ -477,10 +527,17 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/error/bind", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "错题组卷", notes = "错题组卷", httpMethod = "POST")
|
|
|
- public Response<Boolean> bindError(@RequestBody @Validated UserErrorBindDto dto) {
|
|
|
+ public Response<Boolean> bindError(@RequestBody @Validated UserCustomBindDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
|
|
|
- // todo 绑定数据
|
|
|
+ questionFlowService.makePaper(
|
|
|
+ user.getId(),
|
|
|
+ QuestionModule.ValueOf(dto.getQuestionModule()),
|
|
|
+ PaperOrigin.ERROR,
|
|
|
+ Arrays.stream(dto.getQuestionNoIds()).collect(Collectors.toList()),
|
|
|
+ dto.getFilterTimes()
|
|
|
+ );
|
|
|
+
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
@@ -489,6 +546,24 @@ public class MyController {
|
|
|
public Response<Boolean> clearError(@RequestBody @Validated UserQuestionIdsDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
|
|
|
+ List<UserQuestion> questionList = userQuestionService.select(dto.getQuestionNoIds());
|
|
|
+ userPaperQuestionService.addRemoveError(questionList);
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/error/remove", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "移除正确题", notes = "移除正确题", httpMethod = "POST")
|
|
|
+ public Response<Boolean> removeError(@RequestBody @Validated ErrorReportDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ UserReport report = userReportService.get(dto.getUserReportId());
|
|
|
+ if (report.getIsFinish() == 0){
|
|
|
+ throw new ParameterException("试卷未完成");
|
|
|
+ }
|
|
|
+ List<UserQuestion> questionList = userQuestionService.listByReport(user.getId(), dto.getUserReportId());
|
|
|
+ userPaperQuestionService.addRemoveError(questionList);
|
|
|
+
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
@@ -498,9 +573,27 @@ public class MyController {
|
|
|
UserNoteQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
entity.setUserId(user.getId());
|
|
|
- QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
- entity.setQuestionId(questionNo.getQuestionId());
|
|
|
- entity.setModule(questionNo.getModule());
|
|
|
+ switch (QuestionModule.ValueOf(dto.getQuestionModule())){
|
|
|
+ case BASE:
|
|
|
+ entity.setQuestionModule(QuestionModule.BASE.key);
|
|
|
+ QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(questionNo.getQuestionId());
|
|
|
+ entity.setQuestionNoId(questionNo.getId());
|
|
|
+ break;
|
|
|
+ case SENTENCE:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ SentenceQuestion sentenceQuestion = sentenceQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(sentenceQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(sentenceQuestion.getId());
|
|
|
+ break;
|
|
|
+ case TEXTBOOK:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ TextbookQuestion textbookQuestion = textbookQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(textbookQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(textbookQuestion.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
userNoteQuestionService.update(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
@@ -562,20 +655,52 @@ public class MyController {
|
|
|
UserAskQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
entity.setUserId(user.getId());
|
|
|
- QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
- entity.setQuestionId(questionNo.getQuestionId());
|
|
|
- entity.setModule(questionNo.getModule());
|
|
|
+ switch (QuestionModule.ValueOf(dto.getQuestionModule())){
|
|
|
+ case BASE:
|
|
|
+ entity.setQuestionModule(QuestionModule.BASE.key);
|
|
|
+ QuestionNo questionNo = questionNoService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(questionNo.getQuestionId());
|
|
|
+ entity.setQuestionNoId(questionNo.getId());
|
|
|
+ break;
|
|
|
+ case SENTENCE:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ SentenceQuestion sentenceQuestion = sentenceQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(sentenceQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(sentenceQuestion.getId());
|
|
|
+ break;
|
|
|
+ case TEXTBOOK:
|
|
|
+ entity.setQuestionModule(QuestionModule.SENTENCE.key);
|
|
|
+ TextbookQuestion textbookQuestion = textbookQuestionService.get(dto.getQuestionNoId());
|
|
|
+ entity.setQuestionId(textbookQuestion.getQuestionId());
|
|
|
+ entity.setQuestionNoId(textbookQuestion.getId());
|
|
|
+ break;
|
|
|
+ }
|
|
|
userAskQuestionService.add(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/feedback/question/error", method = RequestMethod.POST)
|
|
|
+ @RequestMapping(value = "/feedback/error/question", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "添加题目勘误", notes = "添加勘误", httpMethod = "POST")
|
|
|
+ public Response<Boolean> addFeedbackErrorQuestion(@RequestBody @Validated UserFeedbackErrorDto dto) {
|
|
|
+ UserFeedbackError entity = Transform.dtoToEntity(dto);
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+ entity.setUserId(user.getId());
|
|
|
+ entity.setModule(FeedbackModule.QUESTION.key);
|
|
|
+ entity.setStatus(0);
|
|
|
+ userFeedbackErrorService.add(entity);
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/feedback/error/data", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "添加资料勘误", notes = "添加勘误", httpMethod = "POST")
|
|
|
public Response<Boolean> addFeedbackError(@RequestBody @Validated UserFeedbackErrorDto dto) {
|
|
|
UserFeedbackError entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
entity.setUserId(user.getId());
|
|
|
+ entity.setModule(FeedbackModule.DATA.key);
|
|
|
+ entity.setStatus(0);
|
|
|
userFeedbackErrorService.add(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|