123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- package com.qxgmat.controller.api;
- import com.github.pagehelper.Page;
- import com.nuliji.tools.*;
- import com.qxgmat.data.dao.entity.ExercisePaper;
- import com.qxgmat.data.dao.entity.User;
- import com.qxgmat.data.dao.entity.UserClass;
- import com.qxgmat.data.relation.entity.UserHomeworkPreviewRelation;
- import com.qxgmat.dto.extend.UserHomeworkPreviewExtendDto;
- import com.qxgmat.dto.response.UserClassDetailDto;
- import com.qxgmat.help.ShiroHelp;
- import com.qxgmat.service.HomeworkPreviewService;
- import com.qxgmat.service.UserPaperService;
- import com.qxgmat.service.inline.*;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RequestParam;
- import org.springframework.web.bind.annotation.RestController;
- import javax.servlet.http.HttpSession;
- import java.util.Collection;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/api/question")
- @Api(tags = "题目", description = "题目接口")
- public class QuestionController {
- @Autowired
- private ShiroHelp shiroHelp;
- @Autowired
- private QuestionNoService questionNoService;
- @Autowired
- private UserPaperService userPaperService;
- @Autowired
- private UserReportService userReportService;
- @Autowired
- private UserQuestionService userQuestionService;
- @Autowired
- private HomeworkPreviewService homeworkPreviewService;
- @Autowired
- private UserClassService userClassService;
- @RequestMapping(value = "/class/process", method = RequestMethod.GET)
- @ApiOperation(value = "获取课程进度", notes = "获取所有课程及状态进度", httpMethod = "GET")
- public Response<List<UserClassDetailDto>> classProcess() {
- User user = (User) shiroHelp.getLoginUser();
- List<UserClass> userClassList = userClassService.getByUser(user.getId());
- // 获取每个科目的最后3次作业
- Map<Object, Collection<UserHomeworkPreviewRelation>> previewMap = homeworkPreviewService.groupByCategory(user.getId(), 3);
- List<UserClassDetailDto> dtos = Transform.convert(userClassList, UserClassDetailDto.class);
- Transform.combine(dtos, previewMap, UserClassDetailDto.class, "moduleId", "previews", UserHomeworkPreviewExtendDto.class);
- return ResponseHelp.success(dtos);
- }
- @RequestMapping(value = "/preview/list", method = RequestMethod.GET)
- @ApiOperation(value = "获取预习作业列表", notes = "获取预习作业列表", httpMethod = "GET")
- public Response<PageMessage<UserHomeworkPreviewExtendDto>> listPreview(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = false) Number category,
- @RequestParam(required = false) String endTime,
- @RequestParam(required = false) Boolean finish
- ) {
- User user = (User) shiroHelp.getLoginUser();
- PageResult<UserHomeworkPreviewRelation> p = homeworkPreviewService.list(page, size, category, user.getId(), endTime, finish);
- List<UserHomeworkPreviewExtendDto> pr = Transform.convert(p, UserHomeworkPreviewExtendDto.class);
- return ResponseHelp.success(pr, page, size, p.getTotal());
- }
- @RequestMapping(value = "/exercise/process", method = RequestMethod.GET)
- @ApiOperation(value = "练习进度", httpMethod = "GET")
- public Response<PageMessage<ExercisePaper>> exerciseProcess(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- HttpSession session) {
- Page<ExercisePaper> p=null;
- return ResponseHelp.success(p, page, size, p.getTotal());
- }
- @RequestMapping(value = "/exercise/paper", method = RequestMethod.GET)
- @ApiOperation(value = "练习组卷列表", httpMethod = "GET")
- public Response<PageMessage<ExercisePaper>> listExercisePaper(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- HttpSession session) {
- Page<ExercisePaper> p = null;
- return ResponseHelp.success(p, page, size, p.getTotal());
- }
- @RequestMapping(value = "/examination/process", method = RequestMethod.GET)
- @ApiOperation(value = "模考进度", httpMethod = "GET")
- public Response<PageMessage<ExercisePaper>> examinationProcess(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- HttpSession session) {
- Page<ExercisePaper> p=null;
- return ResponseHelp.success(p, page, size, p.getTotal());
- }
- @RequestMapping(value = "/examination/paper", method = RequestMethod.GET)
- @ApiOperation(value = "模考组卷列表", httpMethod = "GET")
- public Response<PageMessage<ExercisePaper>> examinationPaperList(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- HttpSession session) {
- Page<ExercisePaper> p = null;
- return ResponseHelp.success(p, page, size, p.getTotal());
- }
- @RequestMapping(value = "/detail", method = RequestMethod.GET)
- @ApiOperation(value = "获取题目详情", notes = "获取题目详情", httpMethod = "GET")
- public Response<User> detail(
- @RequestParam(required = false) String questionNoId
- ) {
- User user = (User) shiroHelp.getLoginUser();
- return ResponseHelp.success(null);
- }
- @RequestMapping(value = "/start", method = RequestMethod.POST)
- @ApiOperation(value = "开始考试", notes = "提交考试设置", httpMethod = "POST")
- public Response<User> start(
- @RequestParam(required = false) String paperId
- ) {
- User user = (User) shiroHelp.getLoginUser();
- return ResponseHelp.success(null);
- }
- @RequestMapping(value = "/next", method = RequestMethod.POST)
- @ApiOperation(value = "获取下一题", notes = "获取下一题", httpMethod = "POST")
- public Response<User> next(
- @RequestParam(required = false) String reportId
- ) {
- User user = (User) shiroHelp.getLoginUser();
- return ResponseHelp.success(null);
- }
- @RequestMapping(value = "/submit", method = RequestMethod.POST)
- @ApiOperation(value = "提交题目答案", notes = "提交题目", httpMethod = "POST")
- public Response<User> submit(
- @RequestParam(required = false) String questionNoId
- ) {
- User user = (User) shiroHelp.getLoginUser();
- return ResponseHelp.success(null);
- }
- @RequestMapping(value = "/finish", method = RequestMethod.POST)
- @ApiOperation(value = "完成考试", notes = "完成考试", httpMethod = "POST")
- public Response<User> finish(
- @RequestParam(required = false) String paperId
- ) {
- User user = (User) shiroHelp.getLoginUser();
- return ResponseHelp.success(null);
- }
- }
|