|
@@ -2,22 +2,27 @@ package com.qxgmat.controller.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.pagehelper.Page;
|
|
|
-import com.nuliji.tools.PageMessage;
|
|
|
-import com.nuliji.tools.Response;
|
|
|
-import com.nuliji.tools.ResponseHelp;
|
|
|
-import com.nuliji.tools.Transform;
|
|
|
+import com.nuliji.tools.*;
|
|
|
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.PaperModule;
|
|
|
+import com.qxgmat.data.constants.enums.module.QuestionModule;
|
|
|
+import com.qxgmat.data.constants.enums.status.DirectionStatus;
|
|
|
import com.qxgmat.data.dao.entity.*;
|
|
|
+import com.qxgmat.data.relation.entity.UserCollectQuestionRelation;
|
|
|
import com.qxgmat.data.relation.entity.UserHomeworkPreviewRelation;
|
|
|
+import com.qxgmat.data.relation.entity.UserNoteRelation;
|
|
|
import com.qxgmat.dto.extend.UserHomeworkPreviewExtendDto;
|
|
|
+import com.qxgmat.dto.extend.UserReportExtendDto;
|
|
|
import com.qxgmat.dto.request.*;
|
|
|
-import com.qxgmat.dto.response.UserClassDetailDto;
|
|
|
-import com.qxgmat.dto.response.UserPrepareDetailDto;
|
|
|
-import com.qxgmat.dto.response.UserRealDto;
|
|
|
+import com.qxgmat.dto.request.UserNoteDto;
|
|
|
+import com.qxgmat.dto.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
-import com.qxgmat.service.HomeworkPreviewService;
|
|
|
+import com.qxgmat.service.UserCollectQuestionService;
|
|
|
+import com.qxgmat.service.UserNoteService;
|
|
|
+import com.qxgmat.service.UserPaperService;
|
|
|
import com.qxgmat.service.UsersService;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -36,9 +41,7 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.UUID;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by GaoJie on 2017/10/31.
|
|
@@ -73,13 +76,10 @@ public class MyController {
|
|
|
private StatDayService statDayService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserClassService userClassService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
private UserServiceService userServiceService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserCollectService userCollectService;
|
|
|
+ private UserCollectQuestionService userCollectQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserNoteService userNoteService;
|
|
@@ -87,6 +87,12 @@ public class MyController {
|
|
|
@Autowired
|
|
|
private UserQuestionService userQuestionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private UserReportService userReportService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserPaperService userPaperService;
|
|
|
+
|
|
|
@RequestMapping(value = "/email", method = RequestMethod.POST)
|
|
|
@ApiOperation(value = "绑定邮箱", httpMethod = "POST")
|
|
|
public Response<Boolean> email(@RequestBody @Validated UserEmailDto dto, HttpSession session, HttpServletRequest request) {
|
|
@@ -208,9 +214,9 @@ public class MyController {
|
|
|
@RequestMapping(value = "/collect", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "添加收藏", notes = "添加收藏", httpMethod = "PUT")
|
|
|
public Response<Boolean> collectAdd(@RequestBody @Validated UserCollectDto dto) {
|
|
|
- UserCollect entity = Transform.dtoToEntity(dto);
|
|
|
+ UserCollectQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- userCollectService.addQuestion(user.getId(), entity.getQuestionNoId());
|
|
|
+ userCollectQuestionService.addQuestion(user.getId(), entity.getQuestionNoId());
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
@@ -219,43 +225,46 @@ public class MyController {
|
|
|
@ApiOperation(value = "移除收藏", notes = "移除收藏", httpMethod = "DELETE")
|
|
|
public Response<Boolean> collectDelete(int id) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Boolean result = userCollectService.deleteQuestion(user.getId(), id);
|
|
|
+ Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), id);
|
|
|
|
|
|
return ResponseHelp.success(result);
|
|
|
}
|
|
|
|
|
|
- @RequestMapping(value = "/collect/list", method = RequestMethod.GET)
|
|
|
- @ApiOperation(value = "获取收藏列表", notes = "获取收藏列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<UserHomeworkPreviewExtendDto>> collectList(
|
|
|
+ @RequestMapping(value = "/collect/question", method = RequestMethod.GET)
|
|
|
+ @ApiOperation(value = "获取收藏题目列表", notes = "获取收藏题目列表", httpMethod = "GET")
|
|
|
+ public Response<PageMessage<UserCollectQuestionDto>> collectList(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) String module,
|
|
|
- @RequestParam(required = false) Number category,
|
|
|
- @RequestParam(required = false) String endTime,
|
|
|
- @RequestParam(required = false) Boolean finish
|
|
|
- ) {
|
|
|
+ @RequestParam(required = false) String type,
|
|
|
+ @RequestParam(required = false, name="start_time") String startTime,
|
|
|
+ @RequestParam(required = false, name="end_time") String endTime,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order,
|
|
|
+ @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
+ HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Page<UserHomeworkPreviewRelation> p = userCollectService.list(page, size, category, user.getId(), endTime, finish);
|
|
|
+ PageResult<UserCollectQuestionRelation> p = userCollectQuestionService.listQuestion(page, size, user.getId(), QuestionModule.ValueOf(module), QuestionType.ValueOf(type), startTime, endTime, order, DirectionStatus.ValueOf(direction));
|
|
|
+
|
|
|
+ List<UserCollectQuestionDto> pr = Transform.convert(p, UserCollectQuestionDto.class);
|
|
|
+
|
|
|
+ // 绑定做题数据
|
|
|
|
|
|
- List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/error/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取错题列表", notes = "获取错题列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<UserHomeworkPreviewExtendDto>> errorList(
|
|
|
+ public Response<PageMessage<UserQuestionListDto>> errorList(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) String module,
|
|
|
- @RequestParam(required = false) Number category,
|
|
|
- @RequestParam(required = false) String endTime,
|
|
|
- @RequestParam(required = false) Boolean finish
|
|
|
+ @RequestParam(required = false) Number category
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Page<UserHomeworkPreviewRelation> p = userQuestionService.list(page, size, category, user.getId(), endTime, finish);
|
|
|
+ PageResult<UserQuestion> p = userQuestionService.listError(page, size, user.getId());
|
|
|
|
|
|
- List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
+ List<UserQuestionListDto> pr = Transform.convert(p, UserQuestionListDto.class);
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
@@ -277,12 +286,14 @@ public class MyController {
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) String module,
|
|
|
- @RequestParam(required = false) Number category,
|
|
|
- @RequestParam(required = false) String endTime,
|
|
|
- @RequestParam(required = false) Boolean finish
|
|
|
- ) {
|
|
|
+ @RequestParam(required = false) String type,
|
|
|
+ @RequestParam(required = false, name="start_time") String startTime,
|
|
|
+ @RequestParam(required = false, name="end_time") String endTime,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order,
|
|
|
+ @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
+ HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Page<UserHomeworkPreviewRelation> p = userNoteService.list(page, size, category, user.getId(), endTime, finish);
|
|
|
+ PageResult<UserNoteRelation> p = userNoteService.list(page, size, user.getId(), QuestionModule.ValueOf(module), QuestionType.ValueOf(type), startTime, endTime, order, DirectionStatus.ValueOf(direction));
|
|
|
|
|
|
List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
|
|
@@ -291,18 +302,25 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/report/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取报告列表", notes = "获取报告列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<UserHomeworkPreviewExtendDto>> reportList(
|
|
|
+ public Response<PageMessage<UserPaperDto>> reportList(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) String module,
|
|
|
- @RequestParam(required = false) Number category,
|
|
|
- @RequestParam(required = false) String endTime,
|
|
|
- @RequestParam(required = false) Boolean finish
|
|
|
- ) {
|
|
|
+ @RequestParam(required = false) String type,
|
|
|
+ @RequestParam(required = false, name="start_time") String startTime,
|
|
|
+ @RequestParam(required = false, name="end_time") String endTime,
|
|
|
+ @RequestParam(required = false, defaultValue = "id") String order,
|
|
|
+ @RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
+ HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Page<UserHomeworkPreviewRelation> p = userNoteService.list(page, size, category, user.getId(), endTime, finish);
|
|
|
+ PageResult<UserPaper> p = userPaperService.list(page, size, user.getId(), PaperModule.ValueOf(module), QuestionType.ValueOf(type), startTime, endTime, order, DirectionStatus.ValueOf(direction));
|
|
|
|
|
|
- List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
+ List<UserPaperDto> pr = Transform.convert(p, UserPaperDto.class);
|
|
|
+
|
|
|
+ Collection paperIds = Transform.getIds(p, UserPaper.class, "id");
|
|
|
+ // 绑定用户报告
|
|
|
+ Map<Object, Collection<UserReport>> reportByPaper = userReportService.mapByPaper(paperIds);
|
|
|
+ Transform.combine(pr, reportByPaper, UserPaperDto.class, "id", "reports", UserReportExtendDto.class);
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|