123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- package com.qxgmat.controller.api;
- import com.alibaba.fastjson.JSONObject;
- import com.nuliji.tools.Response;
- import com.nuliji.tools.ResponseHelp;
- import com.nuliji.tools.Transform;
- import com.qxgmat.data.constants.enums.SettingKey;
- import com.qxgmat.data.dao.entity.*;
- import com.qxgmat.dto.request.UserSentenceCodeDto;
- import com.qxgmat.dto.request.UserSentenceProcessDto;
- import com.qxgmat.dto.response.UserSentenceArticleDto;
- import com.qxgmat.help.ShiroHelp;
- import com.qxgmat.service.SentencePaperService;
- import com.qxgmat.service.UserPaperService;
- import com.qxgmat.service.UsersService;
- 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.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import javax.servlet.http.HttpSession;
- import java.util.List;
- import java.util.Map;
- @RestController
- @RequestMapping("/api/sentence")
- @Api(tags = "长难句", description = "长难句接口")
- public class SentenceController
- {
- @Autowired
- private ShiroHelp shiroHelp;
- @Autowired
- private UserPaperService userPaperService;
- @Autowired
- private UserReportService userReportService;
- @Autowired
- private UserQuestionService userQuestionService;
- @Autowired
- private SentenceArticleService sentenceArticleService;
- @Autowired
- private SentenceQuestionService sentenceQuestionService;
- @Autowired
- private SentencePaperService sentencePaperService;
- @Autowired
- private UserSentenceProcessService userSentenceProcessService;
- @Autowired
- private UsersService usersService;
- @Autowired
- private SentenceCodeService sentenceCodeService;
- @Autowired
- private SettingService settingService;
- @RequestMapping(value = "/info", method = RequestMethod.GET)
- @ApiOperation(value = "所有长难句信息", httpMethod = "GET")
- public Response<JSONObject> sentenceInfo(HttpSession session) {
- Setting entity = settingService.getByKey(SettingKey.SENTENCE);
- JSONObject value = entity.getValue();
-
- User user = (User) shiroHelp.getLoginUser();
- SentenceCode code = sentenceCodeService.isActive(user.getId());
- if (code != null){
- value.put("code", code.getCode());
- }
-
- List<UserSentenceProcess> processList = userSentenceProcessService.listTotal(user.getId());
- Map process = Transform.getMap(processList,UserSentenceProcess.class, "chapter", "process");
- value.put("process", process);
- return ResponseHelp.success(value);
- }
- @RequestMapping(value = "/active", method = RequestMethod.PUT)
- @ApiOperation(value = "激活长难句", httpMethod = "PUT")
- public Response<Boolean> active(@RequestBody @Validated UserSentenceCodeDto dto) {
- UserSentenceProcess entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
- if (sentenceCodeService.isActive(user.getId()) == null){
- sentenceCodeService.active(user.getId(), dto.getCode());
- }
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/article/list", method = RequestMethod.GET)
- @ApiOperation(value = "长难句文章列表", httpMethod = "GET")
- public Response<List<UserSentenceArticleDto>> listArticle(
- @RequestParam(required = true) Integer chapter,
- HttpSession session) {
- User user = (User) shiroHelp.getLoginUser();
-
- if (sentenceCodeService.isActive(user.getId()) != null){
- List<SentenceArticle> p = sentenceArticleService.listByChapter(chapter);
- List<UserSentenceArticleDto> pr = Transform.convert(p, UserSentenceArticleDto.class);
-
- List<UserSentenceProcess> processList = userSentenceProcessService.listByChapter(user.getId(), chapter);
- Map process = Transform.getMap(processList,UserSentenceProcess.class, "part", "process");
- Transform.combine(pr, process, UserSentenceArticleDto.class, "part", "process");
- return ResponseHelp.success(pr);
- } else {
- List<SentenceArticle> p = sentenceArticleService.listByTrail();
- List<UserSentenceArticleDto> pr = Transform.convert(p, UserSentenceArticleDto.class);
- List<UserSentenceProcess> processList = userSentenceProcessService.listAllByTrail(user.getId());
- return ResponseHelp.success(pr);
- }
- }
- @RequestMapping(value = "/article/process", method = RequestMethod.PUT)
- @ApiOperation(value = "更新长难句文章进度", httpMethod = "PUT")
- public Response<Boolean> articleProcess(@RequestBody @Validated UserSentenceProcessDto dto) {
- UserSentenceProcess entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
-
- Integer max = sentenceArticleService.maxPart(dto.getChapter());
- userSentenceProcessService.updateProcess(user.getId(), dto.getChapter(), dto.getPart(), dto.getProcess(), max);
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/paper/list", method = RequestMethod.GET)
- @ApiOperation(value = "长难句组卷列表", httpMethod = "GET")
- public Response<List<UserSentenceArticleDto>> listPaper(
- HttpSession session) {
- User user = (User) shiroHelp.getLoginUser();
-
- if (sentenceCodeService.isActive(user.getId()) != null){
- } else {
- }
- return ResponseHelp.success(null);
- }
- @RequestMapping(value = "/question/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 = "/paper/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 = "/paper/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 = "/paper/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 = "/paper/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);
- }
- }
|