|
@@ -12,18 +12,13 @@ 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.request.UserNoteDto;
|
|
|
import com.qxgmat.dto.response.*;
|
|
|
import com.qxgmat.help.ShiroHelp;
|
|
|
-import com.qxgmat.service.UserCollectQuestionService;
|
|
|
-import com.qxgmat.service.UserNoteService;
|
|
|
-import com.qxgmat.service.UserPaperService;
|
|
|
-import com.qxgmat.service.UsersService;
|
|
|
+import com.qxgmat.service.*;
|
|
|
import com.qxgmat.service.inline.*;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -82,7 +77,7 @@ public class MyController {
|
|
|
private UserCollectQuestionService userCollectQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
- private UserNoteService userNoteService;
|
|
|
+ private UserNoteQuestionService userNoteQuestionService;
|
|
|
|
|
|
@Autowired
|
|
|
private UserQuestionService userQuestionService;
|
|
@@ -129,7 +124,8 @@ public class MyController {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
UserRealDto dto = new UserRealDto();
|
|
|
|
|
|
- // todo 随机文件名
|
|
|
+ // todo 第三方验证
|
|
|
+
|
|
|
String file = UUID.randomUUID().toString();
|
|
|
try {
|
|
|
File dest = new File(localPath + File.separator+file);
|
|
@@ -165,9 +161,14 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/message/read", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "读取消息", notes = "读取用户消息/全部", httpMethod = "PUT")
|
|
|
- public Response<Boolean> readMessage() {
|
|
|
+ public Response<Boolean> readMessage(@RequestBody @Validated MessageReadDto dto) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- userMessageService.clear(user.getId());
|
|
|
+
|
|
|
+ if (dto.getAll()){
|
|
|
+ userMessageService.clearAll(user.getId());
|
|
|
+ }else{
|
|
|
+ userMessageService.clear(user.getId(), dto.getId());
|
|
|
+ }
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
@@ -177,7 +178,8 @@ public class MyController {
|
|
|
public Response<Boolean> editPrepare(@RequestBody @Validated UserPrepareDto dto) {
|
|
|
User entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- userMessageService.clear(user.getId());
|
|
|
+ entity.setId(user.getId());
|
|
|
+ usersService.edit(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
@@ -188,6 +190,8 @@ public class MyController {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
User entity = usersService.get(user.getId());
|
|
|
UserPrepareDetailDto dto = Transform.convert(entity, UserPrepareDetailDto.class);
|
|
|
+
|
|
|
+ // todo 获取备考统计
|
|
|
Setting setting = settingService.getByKey(SettingKey.PREPARE_INFO);
|
|
|
JSONObject value = setting.getValue();
|
|
|
return ResponseHelp.success(dto);
|
|
@@ -195,7 +199,7 @@ public class MyController {
|
|
|
|
|
|
@RequestMapping(value = "/study", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取学习记录", notes = "获取选择那天的做题信息", httpMethod = "GET")
|
|
|
- public Response<UserPrepareDetailDto> studyTime(
|
|
|
+ public Response<UserStudyDetailDto> studyTime(
|
|
|
@RequestParam(required = false) String date
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
@@ -204,10 +208,9 @@ public class MyController {
|
|
|
} catch (ParseException e) {
|
|
|
throw new ParameterException("日期格式错误");
|
|
|
}
|
|
|
- User entity = usersService.get(user.getId());
|
|
|
- UserPrepareDetailDto dto = Transform.convert(entity, UserPrepareDetailDto.class);
|
|
|
- Setting setting = settingService.getByKey(SettingKey.PREPARE_INFO);
|
|
|
- JSONObject value = setting.getValue();
|
|
|
+ UserStudyDetailDto dto = new UserStudyDetailDto();
|
|
|
+
|
|
|
+ // todo 获取学习统计
|
|
|
return ResponseHelp.success(dto);
|
|
|
}
|
|
|
|
|
@@ -216,20 +219,28 @@ public class MyController {
|
|
|
public Response<Boolean> addCollect(@RequestBody @Validated UserCollectDto dto) {
|
|
|
UserCollectQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- userCollectQuestionService.addQuestion(user.getId(), entity.getQuestionNoId());
|
|
|
+ userCollectQuestionService.addQuestion(user.getId(), QuestionModule.ValueOf(entity.getModule()), entity.getQuestionNoId());
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/collect", method = RequestMethod.DELETE)
|
|
|
@ApiOperation(value = "移除收藏", notes = "移除收藏", httpMethod = "DELETE")
|
|
|
- public Response<Boolean> deleteCollect(int id) {
|
|
|
+ public Response<Boolean> deleteCollect(String module, int id) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), id);
|
|
|
+ Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), QuestionModule.ValueOf(module), id);
|
|
|
|
|
|
return ResponseHelp.success(result);
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/collect/bind", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "收藏组卷", notes = "收藏组卷", httpMethod = "POST")
|
|
|
+ public Response<Boolean> bindCollect(@RequestBody @Validated UserCollectBindDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/collect/question", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取收藏题目列表", notes = "获取收藏题目列表", httpMethod = "GET")
|
|
|
public Response<PageMessage<UserCollectQuestionDto>> listCollect(
|
|
@@ -247,7 +258,7 @@ public class MyController {
|
|
|
|
|
|
List<UserCollectQuestionDto> pr = Transform.convert(p, UserCollectQuestionDto.class);
|
|
|
|
|
|
- // 绑定做题数据
|
|
|
+ // todo 绑定做题数据
|
|
|
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
@@ -263,26 +274,43 @@ public class MyController {
|
|
|
) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
PageResult<UserQuestion> p = userQuestionService.listError(page, size, user.getId());
|
|
|
-
|
|
|
List<UserQuestionListDto> pr = Transform.convert(p, UserQuestionListDto.class);
|
|
|
|
|
|
+ // todo 绑定数据
|
|
|
+
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/error/bind", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "错题组卷", notes = "错题组卷", httpMethod = "POST")
|
|
|
+ public Response<Boolean> bindError(@RequestBody @Validated UserErrorBindDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/error/clear", method = RequestMethod.POST)
|
|
|
+ @ApiOperation(value = "错题移除", notes = "错题移除", httpMethod = "POST")
|
|
|
+ public Response<Boolean> clearError(@RequestBody @Validated UserCollectBindDto dto) {
|
|
|
+ User user = (User) shiroHelp.getLoginUser();
|
|
|
+
|
|
|
+ return ResponseHelp.success(true);
|
|
|
+ }
|
|
|
+
|
|
|
@RequestMapping(value = "/note", method = RequestMethod.PUT)
|
|
|
@ApiOperation(value = "更新笔记", notes = "更新笔记", httpMethod = "PUT")
|
|
|
public Response<Boolean> updateNote(@RequestBody @Validated UserNoteDto dto) {
|
|
|
- UserNote entity = Transform.dtoToEntity(dto);
|
|
|
+ UserNoteQuestion entity = Transform.dtoToEntity(dto);
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
entity.setUserId(user.getId());
|
|
|
- userNoteService.update(entity);
|
|
|
+ userNoteQuestionService.update(entity);
|
|
|
|
|
|
return ResponseHelp.success(true);
|
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/note/list", method = RequestMethod.GET)
|
|
|
@ApiOperation(value = "获取笔记列表", notes = "获取笔记列表", httpMethod = "GET")
|
|
|
- public Response<PageMessage<UserHomeworkPreviewExtendDto>> listNote(
|
|
|
+ public Response<PageMessage<UserNoteDetailDto>> listNote(
|
|
|
@RequestParam(required = false, defaultValue = "1") int page,
|
|
|
@RequestParam(required = false, defaultValue = "100") int size,
|
|
|
@RequestParam(required = true) String module,
|
|
@@ -293,9 +321,10 @@ public class MyController {
|
|
|
@RequestParam(required = false, defaultValue = "desc") String direction,
|
|
|
HttpSession session) {
|
|
|
User user = (User) shiroHelp.getLoginUser();
|
|
|
- PageResult<UserNoteRelation> p = userNoteService.list(page, size, user.getId(), QuestionModule.ValueOf(module), QuestionType.ValueOf(type), startTime, endTime, order, DirectionStatus.ValueOf(direction));
|
|
|
+ PageResult<UserNoteRelation> p = userNoteQuestionService.list(page, size, user.getId(), QuestionModule.ValueOf(module), QuestionType.ValueOf(type), startTime, endTime, order, DirectionStatus.ValueOf(direction));
|
|
|
+ List<UserNoteDetailDto> pr = Transform.convert(p, UserNoteDetailDto.class);
|
|
|
|
|
|
- List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
|
|
|
+ // todo 绑定数据
|
|
|
|
|
|
return ResponseHelp.success(pr, page, size, p.getTotal());
|
|
|
}
|
|
@@ -322,6 +351,10 @@ public class MyController {
|
|
|
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());
|
|
|
}
|
|
|
}
|