1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009 |
- package com.qxgmat.controller.api;
- import com.alibaba.fastjson.JSONObject;
- import com.github.pagehelper.Page;
- import com.nuliji.tools.*;
- import com.nuliji.tools.exception.ParameterException;
- import com.nuliji.tools.exception.SystemException;
- import com.qxgmat.data.constants.enums.QuestionSubject;
- 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.*;
- import com.qxgmat.data.inline.UserQuestionStat;
- import com.qxgmat.data.relation.entity.*;
- import com.qxgmat.dto.extend.*;
- import com.qxgmat.dto.request.*;
- import com.qxgmat.dto.request.UserNoteQuestionDto;
- import com.qxgmat.dto.response.*;
- import com.qxgmat.help.AiHelp;
- import com.qxgmat.help.MailHelp;
- 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;
- import org.apache.logging.log4j.util.Strings;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.MediaType;
- import org.springframework.validation.annotation.Validated;
- import org.springframework.web.bind.annotation.*;
- import org.springframework.web.multipart.MultipartFile;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpSession;
- import javax.validation.Validator;
- import java.io.File;
- import java.io.IOException;
- import java.text.DateFormat;
- import java.text.ParseException;
- import java.util.*;
- import java.util.stream.Collectors;
- @RestController
- @RequestMapping("/api/my")
- @Api(tags = "用户接口", description = "获取与操作当前用户信息", produces = MediaType.APPLICATION_JSON_VALUE)
- public class MyController {
- @Value("${upload.local_path}")
- private String localPath;
- @Value("${upload.web_url}")
- private String webUrl;
- @Autowired
- private Validator validator;
- @Autowired
- private ShiroHelp shiroHelp;
- @Autowired
- private AiHelp aiHelp;
- @Autowired
- private MailHelp mailHelp;
- @Autowired
- private SettingService settingService;
- @Autowired
- private ExerciseStructService exerciseStructService;
- @Autowired
- private CourseService courseService;
- @Autowired
- private CourseNoService courseNoService;
- @Autowired
- private QuestionService questionService;
- @Autowired
- private QuestionNoService questionNoService;
- @Autowired
- private SentenceQuestionService sentenceQuestionService;
- @Autowired
- private TextbookQuestionService textbookQuestionService;
- @Autowired
- private UsersService usersService;
- @Autowired
- private UserMessageService userMessageService;
- @Autowired
- private UserCourseRecordService userCourseRecordService;
- @Autowired
- private UserSentenceRecordService userSentenceRecordService;
- @Autowired
- private UserServiceService userServiceService;
- @Autowired
- private UserCollectQuestionService userCollectQuestionService;
- @Autowired
- private UserNoteQuestionService userNoteQuestionService;
- @Autowired
- private UserAskQuestionService userAskQuestionService;
- @Autowired
- private UserFeedbackErrorService userFeedbackErrorService;
- @Autowired
- private UserQuestionService userQuestionService;
- @Autowired
- private UserReportService userReportService;
- @Autowired
- private UserPaperService userPaperService;
- @Autowired
- private UserPaperQuestionService userPaperQuestionService;
- @Autowired
- private UserOrderRecordService userOrderRecordService;
- @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) {
- User user = (User) shiroHelp.getLoginUser();
- usersService.edit(User.builder()
- .id(user.getId())
- .email(dto.getEmail())
- .build());
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/info", method = RequestMethod.POST)
- @ApiOperation(value = "修改用户信息", httpMethod = "POST")
- public Response<Boolean> info(@RequestBody @Validated UserInfoDto dto){
- User user = (User) shiroHelp.getLoginUser();
- usersService.edit(User.builder()
- .id(user.getId())
- .nickname(dto.getNickname())
- .avatar(dto.getAvatar())
- .build());
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/real/front", produces = MediaType.IMAGE_JPEG_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "实名认证", notes = "保存用户实名信息", httpMethod = "POST")
- public Response<UserRealDto> realFront(@RequestParam("file") MultipartFile file) throws IOException {
- if (file.isEmpty()) {
- throw new ParameterException("上传文件为空");
- }
- User user = (User) shiroHelp.getLoginUser();
- UserRealDto dto = new UserRealDto();
- Map<String, String> map = aiHelp.orcIdcardFront(file.getBytes());
- dto.setName(map.get("name"));
- dto.setAddress(map.get("address"));
- dto.setIdentity(map.get("identity"));
- User in = usersService.getByIdentity(map.get("identity"));
- if (in != null){
- throw new ParameterException("该身份证已被其他账号认证");
- }
- String frontName = UUID.randomUUID().toString();
- try {
- File frontDest = new File(localPath + File.separator+frontName);
- file.transferTo(frontDest);
- dto.setPhotoFront(webUrl+frontName);
- usersService.edit(User.builder()
- .id(user.getId())
- .realAddress(dto.getAddress())
- .realName(dto.getName())
- .realIdentity(dto.getIdentity())
- .realPhotoFront(dto.getPhotoFront())
- .build());
- return ResponseHelp.success(dto);
- } catch (IOException e) {
- e.printStackTrace();
- return ResponseHelp.exception(new SystemException("图片上传失败"));
- }
- }
- @RequestMapping(value = "/real/back", produces = MediaType.IMAGE_JPEG_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "实名认证", notes = "保存用户实名信息", httpMethod = "POST")
- public Response<UserRealDto> realBack(@RequestParam("file") MultipartFile file) throws IOException {
- if (file.isEmpty()) {
- throw new ParameterException("上传文件为空");
- }
- User user = (User) shiroHelp.getLoginUser();
- UserRealDto dto = new UserRealDto();
- aiHelp.orcIdcardBack(file.getBytes());
- String backName = UUID.randomUUID().toString();
- try {
- File backDest = new File(localPath + File.separator+backName);
- file.transferTo(backDest);
- dto.setPhotoBack(webUrl+backName);
- usersService.edit(User.builder()
- .id(user.getId())
- .realPhotoBack(dto.getPhotoBack())
- .build());
- return ResponseHelp.success(dto);
- } catch (IOException e) {
- e.printStackTrace();
- return ResponseHelp.exception(new SystemException("图片上传失败"));
- }
- }
- @RequestMapping(value = "/real/finish", produces = MediaType.IMAGE_JPEG_VALUE, method = RequestMethod.POST)
- @ApiOperation(value = "实名认证", notes = "保存用户实名信息", httpMethod = "POST")
- public Response<UserRealDto> realFinish() {
- User user = (User) shiroHelp.getLoginUser();
- UserRealDto dto = new UserRealDto();
- User in = usersService.get(user.getId());
- if (in.getRealAddress() == null || !in.getRealAddress().equals("")){
- throw new ParameterException("实名认证流程错误");
- }
- if (in.getRealIdentity() == null || !in.getRealIdentity().equals("")){
- throw new ParameterException("实名认证流程错误");
- }
- if (in.getRealName() == null || !in.getRealName().equals("")){
- throw new ParameterException("实名认证流程错误");
- }
- if (in.getRealPhotoFront() == null || !in.getRealPhotoFront().equals("")){
- throw new ParameterException("实名认证流程错误");
- }
- if (in.getRealPhotoBack() == null || !in.getRealPhotoBack().equals("")){
- throw new ParameterException("实名认证流程错误");
- }
- usersService.edit(User.builder()
- .id(user.getId())
- .realStatus(1)
- .realTime(new Date())
- .build());
-
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/invite/email", method = RequestMethod.POST)
- @ApiOperation(value = "发送邮件邀请", httpMethod = "POST")
- public Response<Boolean> inviteEmail(@RequestBody @Validated InviteEmailDto dto) {
- User user = (User) shiroHelp.getLoginUser();
- Map<String, String> map = new HashMap<>();
- mailHelp.sendBaseMail(
- Strings.join(Arrays.stream(dto.getEmails()).collect(Collectors.toList()), ';'),
- "邮件邀请",
- "",
- map);
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/message", method = RequestMethod.GET)
- @ApiOperation(value = "用户站内信", notes = "用户消息列表", httpMethod = "GET")
- public Response<PageMessage<UserMessage>> message(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = false) String type,
- @RequestParam(required = false) Integer read
- ) {
- User user = (User) shiroHelp.getLoginUser();
- Page<UserMessage> p = userMessageService.select(page, size, user.getId(), type, read);
- return ResponseHelp.success(p, page, size, p.getTotal());
- }
- @RequestMapping(value = "/message/read", method = RequestMethod.PUT)
- @ApiOperation(value = "读取消息", notes = "读取用户消息/全部", httpMethod = "PUT")
- public Response<Boolean> readMessage(@RequestBody @Validated MessageReadDto dto) {
- User user = (User) shiroHelp.getLoginUser();
- if (dto.getAll()){
- userMessageService.clearAll(user.getId());
- }else{
- userMessageService.clear(user.getId(), dto.getId());
- }
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/clear/exercise/latest", method = RequestMethod.PUT)
- @ApiOperation(value = "清除最后一次做题记录", notes = "清除最后一次做题记录", httpMethod = "PUT")
- public Response<Boolean> clearLatestExercise() {
- User user = (User) shiroHelp.getLoginUser();
- usersService.edit(User.builder().id(user.getId()).latestExercise(0).build());
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/clear/error/latest", method = RequestMethod.PUT)
- @ApiOperation(value = "清除最后一次错题组卷做题记录", notes = "清除最后一次错题组卷做题记录", httpMethod = "PUT")
- public Response<Boolean> clearLatestError() {
- User user = (User) shiroHelp.getLoginUser();
- usersService.edit(User.builder().id(user.getId()).latestError(0).build());
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/prepare", method = RequestMethod.PUT)
- @ApiOperation(value = "修改备考信息", notes = "修改用户备考信息", httpMethod = "PUT")
- public Response<Boolean> editPrepare(@RequestBody @Validated UserPrepareDto dto) {
- User entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
- entity.setId(user.getId());
- entity.setPrepareTime(new Date());
- usersService.edit(entity);
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/prepare", method = RequestMethod.GET)
- @ApiOperation(value = "获取备考信息", notes = "获取备考信息及分布", httpMethod = "GET")
- public Response<UserPrepareDetailDto> getPrepare() {
- User user = (User) shiroHelp.getLoginUser();
- User entity = usersService.get(user.getId());
- UserPrepareDetailDto dto = Transform.convert(entity, UserPrepareDetailDto.class);
- Setting setting = settingService.getByKey(SettingKey.PREPARE_INFO);
- JSONObject value = setting.getValue();
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/study", method = RequestMethod.GET)
- @ApiOperation(value = "获取学习记录", notes = "获取选择那天的做题信息", httpMethod = "GET")
- public Response<UserStudyDayDto> studyTime(
- @RequestParam(required = false) String date
- ) {
- User user = (User) shiroHelp.getLoginUser();
- Date day;
- try {
- day = DateFormat.getDateInstance().parse(date);
- } catch (ParseException e) {
- throw new ParameterException("日期格式错误");
- }
- Date endDay = Tools.addDate(day, 1);
- String startTime = day.toString();
- String endTime = endDay.toString();
- UserStudyDayDto dto = new UserStudyDayDto();
- List<ExerciseStruct> p = exerciseStructService.main();
- Map<String, String> m = new HashMap<>();
- for (ExerciseStruct struct : p){
- if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
- m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
- }
-
- Integer total = usersService.count();
-
- Integer exerciseTime = 0;
- Integer exerciseQuestion = 0;
- List<UserExerciseExtendDto> exerciseList = new ArrayList<>();
- List<UserStudyStatRelation> typeList = userReportService.statGroupExerciseType(user.getId(), startTime, endTime);
- for(UserStudyStatRelation type:typeList){
- exerciseTime += type.getUserTime();
- exerciseQuestion += type.getUserNumber();
- exerciseList.add(new UserExerciseExtendDto(m.get(type.getModule()), type.getUserNumber(), type.getUserTime(), type.getUserCorrect()));
- }
-
- UserRankStatRelation exerciseRank = userReportService.rankExerciseByTime(user.getId(), startTime, endTime);
- exerciseRank.setTotal(total);
- dto.setExerciseTime(exerciseTime);
- dto.setExerciseQuestion(exerciseQuestion);
- dto.setExerciseList(exerciseList);
- dto.setExerciseExceed(exerciseRank);
-
- Integer examinationTime = 0;
- Integer examinationPaper = 0;
- List<UserReport> userReportList = userReportService.getByModule(user.getId(), PaperModule.EXAMINATION, startTime, endTime);
- Collection paperIds = Transform.getIds(userReportList, UserReport.class, "paperId");
- List<UserPaper> userPaperList = userPaperService.select(paperIds);
- Map userPaper = Transform.getMap(userPaperList, UserPaper.class, "id");
- List<UserPaperDetailExtendDto> examinationPaperList = new ArrayList<>(userReportList.size());
- for(UserReport report: userReportList){
- examinationTime += report.getUserTime();
- examinationPaper += 1;
- UserPaperDetailExtendDto d = Transform.convert(userPaper.get(report.getPaperId()), UserPaperDetailExtendDto.class);
- d.setReport(Transform.convert(report, UserReportExtendDto.class));
- examinationPaperList.add(d);
- }
-
- UserRankStatRelation examinationRank = userReportService.rankExaminationByTime(user.getId(), startTime, endTime);
- examinationRank.setTotal(total);
- dto.setExaminationTime(examinationTime);
- dto.setExaminationPaper(examinationPaper);
- dto.setExaminationList(examinationPaperList);
- dto.setExaminationExceed(examinationRank);
-
- Integer courseTime = 0;
- Integer courseNumber = 0;
- List<UserCourseRecord> userCourseRecordList = userCourseRecordService.getByTime(user.getId(), startTime, endTime);
- Collection courseIds = Transform.getIds(userCourseRecordList, UserCourseRecord.class, "courseId");
- Collection courseNoIds = Transform.getIds(userCourseRecordList, UserCourseRecord.class, "noId");
- List<Course> courseList = courseService.select(courseIds);
- Map courseMap = Transform.getMap(courseList, Course.class, "id", "title");
- List<CourseNo> courseNoList = courseNoService.select(courseNoIds);
- Map classCourseNoMap = Transform.getMap(courseNoList, CourseNo.class, "id", "content");
- List<UserCourseResultExtendDto> courseResultList = new ArrayList<>(userCourseRecordList.size());
- for(UserCourseRecord record:userCourseRecordList){
- courseTime += record.getUserTime();
- courseNumber += 1;
- UserCourseResultExtendDto d = Transform.convert(record, UserCourseResultExtendDto.class);
- d.setTitle((String)courseMap.get(record.getCourseId()));
- d.setContent((String)classCourseNoMap.get(record.getCourseNoId()));
- courseResultList.add(d);
- }
-
- UserRankStatRelation classRank = userCourseRecordService.rankByTime(user.getId(), startTime, endTime);
- classRank.setTotal(total);
- dto.setCourseTime(courseTime);
- dto.setCourseNumber(courseNumber);
- dto.setCourseList(courseResultList);
- dto.setCourseExceed(classRank);
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/study/week", method = RequestMethod.GET)
- @ApiOperation(value = "获取本周记录", notes = "获取本周学习记录", httpMethod = "GET")
- public Response<UserStudyDetailDto> studyWeekTime() {
- User user = (User) shiroHelp.getLoginUser();
- UserStudyDetailDto dto = new UserStudyDetailDto();
- dto.setCreateTime(user.getCreateTime());
- dto.setDays((int)((user.getCreateTime().getTime() - new Date().getTime()) / (1000*3600*24)));
- Integer totalTime = 0;
- Map<String, Integer> categoryMap = new HashMap<>();
-
- List<UserStudyStatRelation> moduleList = userReportService.statGroupModule(user.getId());
- for(UserStudyStatRelation module:moduleList){
-
- if (module.getModule().equals(PaperModule.EXERCISE.key)){
- continue;
- }
- Integer time = module.getUserTime();
- String key = module.getModule();
- totalTime += time;
-
- 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> 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());
- }
-
- List<UserCourseStatRelation> recordList = userCourseRecordService.statGroupType(user.getId(), null, null);
- for (UserCourseStatRelation record : recordList){
- totalTime += record.getUserTime();
-
- Integer time = categoryMap.getOrDefault(record.getModule(), 0);
- categoryMap.put(record.getModule(), time);
- }
-
- UserSentenceStatRelation sentenceStatRelation = userSentenceRecordService.stat(user.getId(), null, null);
- if (sentenceStatRelation != null){
- Integer sentenceTime = categoryMap.getOrDefault(PaperModule.SENTENCE.key, 0);
- categoryMap.put(PaperModule.SENTENCE.key, sentenceTime + sentenceStatRelation.getUserTime());
- }
- List<ExerciseStruct> p = exerciseStructService.main();
- Map<String, String> m = new HashMap<>();
- for (ExerciseStruct struct : p){
- if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
- m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
- }
-
- List<UserStudyExtendDto> categorys = new ArrayList<>();
- if (categoryMap.containsKey(PaperModule.SENTENCE.key)) categorys.add(new UserStudyExtendDto(m.get(PaperModule.SENTENCE.key), categoryMap.get(PaperModule.SENTENCE.key)));
- if (categoryMap.containsKey(QuestionType.SC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.SC.key), categoryMap.get(QuestionType.SC.key)));
- if (categoryMap.containsKey(QuestionType.RC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.RC.key), categoryMap.get(QuestionType.RC.key)));
- if (categoryMap.containsKey(QuestionType.CR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.CR.key), categoryMap.get(QuestionType.CR.key)));
- if (categoryMap.containsKey(QuestionType.PS.key)){
-
- Integer time = categoryMap.getOrDefault(QuestionSubject.QUANT.key, 0);
- categoryMap.put(QuestionSubject.QUANT.key, time + categoryMap.get(QuestionType.PS.key));
- }
- if (categoryMap.containsKey(QuestionType.DS.key)){
-
- Integer time = categoryMap.getOrDefault(QuestionSubject.QUANT.key, 0);
- categoryMap.put(QuestionSubject.QUANT.key, time + categoryMap.get(QuestionType.DS.key));
- }
- if (categoryMap.containsKey(QuestionSubject.QUANT.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionSubject.QUANT.key), categoryMap.get(QuestionSubject.QUANT.key)));
- if (categoryMap.containsKey(QuestionType.IR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.IR.key), categoryMap.get(QuestionType.IR.key)));
- if (categoryMap.containsKey(QuestionType.AWA.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.AWA.key), categoryMap.get(QuestionType.AWA.key)));
- if (categoryMap.containsKey(PaperModule.EXAMINATION.key)) categorys.add(new UserStudyExtendDto("模考", categoryMap.get(PaperModule.EXAMINATION.key)));
- if (categoryMap.containsKey("freedom")) categorys.add(new UserStudyExtendDto("自由组卷", categoryMap.get("freedom")));
- dto.setTime(totalTime);
- dto.setCategorys(categorys);
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/study/total", method = RequestMethod.GET)
- @ApiOperation(value = "获取总学习记录", notes = "获取总学习记录", httpMethod = "GET")
- public Response<UserStudyDetailDto> studyTotalTime() {
- User user = (User) shiroHelp.getLoginUser();
- UserStudyDetailDto dto = new UserStudyDetailDto();
- dto.setCreateTime(user.getCreateTime());
- dto.setDays((int)((user.getCreateTime().getTime() - new Date().getTime()) / (1000*3600*24)));
- Integer totalTime = 0;
- Map<String, Integer> categoryMap = new HashMap<>();
-
- List<UserStudyStatRelation> moduleList = userReportService.statGroupModule(user.getId());
- for(UserStudyStatRelation module:moduleList){
-
- if (module.getModule().equals(PaperModule.EXERCISE.key)){
- continue;
- }
- Integer time = module.getUserTime();
- String key = module.getModule();
- totalTime += time;
-
- 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> 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());
- }
-
- List<UserCourseStatRelation> recordList = userCourseRecordService.statGroupType(user.getId(), null, null);
- for (UserCourseStatRelation record : recordList){
- totalTime += record.getUserTime();
-
- Integer time = categoryMap.getOrDefault(record.getModule(), 0);
- categoryMap.put(record.getModule(), time);
- }
-
- UserSentenceStatRelation sentenceStatRelation = userSentenceRecordService.stat(user.getId(), null, null);
- if (sentenceStatRelation != null){
- Integer sentenceTime = categoryMap.getOrDefault(PaperModule.SENTENCE.key, 0);
- categoryMap.put(PaperModule.SENTENCE.key, sentenceTime + sentenceStatRelation.getUserTime());
- }
- List<ExerciseStruct> p = exerciseStructService.main();
- Map<String, String> m = new HashMap<>();
- for (ExerciseStruct struct : p){
- if (struct.getExtend() == null || struct.getExtend().isEmpty()) continue;
- m.put(struct.getExtend(), struct.getTitleZh() + (struct.getTitleEn().isEmpty() ? "":" "+struct.getTitleEn()));
- }
-
- List<UserStudyExtendDto> categorys = new ArrayList<>();
- if (categoryMap.containsKey(PaperModule.SENTENCE.key)) categorys.add(new UserStudyExtendDto(m.get(PaperModule.SENTENCE.key), categoryMap.get(PaperModule.SENTENCE.key)));
- if (categoryMap.containsKey(QuestionType.SC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.SC.key), categoryMap.get(QuestionType.SC.key)));
- if (categoryMap.containsKey(QuestionType.RC.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.RC.key), categoryMap.get(QuestionType.RC.key)));
- if (categoryMap.containsKey(QuestionType.CR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.CR.key), categoryMap.get(QuestionType.CR.key)));
- if (categoryMap.containsKey(QuestionType.PS.key)){
-
- Integer time = categoryMap.getOrDefault(QuestionSubject.QUANT.key, 0);
- categoryMap.put(QuestionSubject.QUANT.key, time + categoryMap.get(QuestionType.PS.key));
- }
- if (categoryMap.containsKey(QuestionType.DS.key)){
-
- Integer time = categoryMap.getOrDefault(QuestionSubject.QUANT.key, 0);
- categoryMap.put(QuestionSubject.QUANT.key, time + categoryMap.get(QuestionType.DS.key));
- }
- if (categoryMap.containsKey(QuestionSubject.QUANT.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionSubject.QUANT.key), categoryMap.get(QuestionSubject.QUANT.key)));
- if (categoryMap.containsKey(QuestionType.IR.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.IR.key), categoryMap.get(QuestionType.IR.key)));
- if (categoryMap.containsKey(QuestionType.AWA.key)) categorys.add(new UserStudyExtendDto(m.get(QuestionType.AWA.key), categoryMap.get(QuestionType.AWA.key)));
- if (categoryMap.containsKey(PaperModule.EXAMINATION.key)) categorys.add(new UserStudyExtendDto("模考", categoryMap.get(PaperModule.EXAMINATION.key)));
- if (categoryMap.containsKey("freedom")) categorys.add(new UserStudyExtendDto("自由组卷", categoryMap.get("freedom")));
- dto.setTime(totalTime);
- dto.setCategorys(categorys);
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/data", method = RequestMethod.GET)
- @ApiOperation(value = "获取做题数据", notes = "获取做题数据", httpMethod = "GET")
- public Response<UserStudyDayDto> questionData(
- @RequestParam(required = false) String startTime,
- @RequestParam(required = false) String endTime
- ) {
- User user = (User) shiroHelp.getLoginUser();
- UserStudyDayDto dto = new UserStudyDayDto();
-
- return ResponseHelp.success(dto);
- }
- @RequestMapping(value = "/collect/question/add", method = RequestMethod.PUT)
- @ApiOperation(value = "添加收藏", notes = "添加收藏", httpMethod = "PUT")
- public Response<Boolean> addQuestionCollect(@RequestBody @Validated UserCollectDto dto) {
- UserCollectQuestion entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
- 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/question/delete", method = RequestMethod.DELETE)
- @ApiOperation(value = "移除收藏", notes = "移除收藏", httpMethod = "DELETE")
- public Response<Boolean> deleteQuestionCollect(String questionModule, Integer questionNoId) {
- User user = (User) shiroHelp.getLoginUser();
- Boolean result = userCollectQuestionService.deleteQuestion(user.getId(), QuestionModule.ValueOf(questionModule), questionNoId);
- return ResponseHelp.success(result);
- }
- @RequestMapping(value = "/collect/question/bind", method = RequestMethod.POST)
- @ApiOperation(value = "收藏组卷", notes = "收藏组卷", httpMethod = "POST")
- public Response<Boolean> bindQuestionCollect(@RequestBody @Validated UserCustomBindDto dto) {
- User user = (User) shiroHelp.getLoginUser();
- questionFlowService.makePaper(
- user.getId(),
- QuestionModule.ValueOf(dto.getQuestionModule()),
- PaperOrigin.COLLECT,
- Arrays.stream(dto.getQuestionNoIds()).collect(Collectors.toList()),
- dto.getFilterTimes()
- );
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/collect/question/list", method = RequestMethod.GET)
- @ApiOperation(value = "获取收藏题目列表", notes = "获取收藏题目列表", httpMethod = "GET")
- public Response<PageMessage<UserCollectQuestionDto>> listQuestionCollect(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = true) String questionModule,
- @RequestParam(required = false) String questionType,
- @RequestParam(required = false) String startTime,
- @RequestParam(required = false) String endTime,
- @RequestParam(required = false, defaultValue = "id") String order,
- @RequestParam(required = false, defaultValue = "desc") String direction,
- HttpSession session) {
- User user = (User) shiroHelp.getLoginUser();
- QuestionModule qm = QuestionModule.ValueOf(questionModule);
- PageResult<UserCollectQuestionRelation> p = userCollectQuestionService.listQuestion(page, size, user.getId(), qm, QuestionType.ValueOf(questionType), startTime, endTime, order, DirectionStatus.ValueOf(direction));
- List<UserCollectQuestionDto> pr = Transform.convert(p, UserCollectQuestionDto.class);
-
- Collection questionIds = Transform.getIds(pr, UserCollectQuestionDto.class, "questionId");
- List<Question> questionList = questionService.select(questionIds);
- Transform.combine(pr, questionList, UserCollectQuestionDto.class, "questionId", "question", Question.class, "id", QuestionExtendDto.class);
- Collection questionNoIds = Transform.getIds(pr, UserCollectQuestionDto.class, "questionNoId");
- switch(qm){
- case BASE:
- List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
- Transform.combine(pr, questionNoList, UserCollectQuestionDto.class, "questionNoId", "questionNo", QuestionNo.class, "id", QuestionNoExtendDto.class);
- break;
- case SENTENCE:
- List<SentenceQuestion> sentenceQuestionList = sentenceQuestionService.select(questionNoIds);
- Transform.combine(pr, sentenceQuestionList, UserCollectQuestionDto.class, "questionNoId", "questionNo", SentenceQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- case TEXTBOOK:
- List<TextbookQuestion> textbookQuestionList = textbookQuestionService.select(questionNoIds);
- Transform.combine(pr, textbookQuestionList, UserCollectQuestionDto.class, "questionNoId", "questionNo", TextbookQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- }
-
- List<UserQuestion> userQuestionList = userQuestionService.listByQuestion(user.getId(), questionIds);
- Map<Object, UserQuestionStat> stats = userQuestionService.statQuestionMap(userQuestionList);
- Transform.combine(pr, stats, UserCollectQuestionDto.class, "questionId", "stat");
- return ResponseHelp.success(pr, page, size, p.getTotal());
- }
- @RequestMapping(value = "/error/list", method = RequestMethod.GET)
- @ApiOperation(value = "获取错题列表", notes = "获取错题列表", httpMethod = "GET")
- public Response<PageMessage<UserQuestionErrorListDto>> listError(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = true) String questionModule
- ) {
- User user = (User) shiroHelp.getLoginUser();
- QuestionModule qm = QuestionModule.ValueOf(questionModule);
- PageResult<UserQuestion> p = userQuestionService.listError(page, size, user.getId());
- List<UserQuestionErrorListDto> pr = Transform.convert(p, UserQuestionErrorListDto.class);
-
- Collection questionIds = Transform.getIds(pr, UserQuestionErrorListDto.class, "questionId");
- List<Question> questionList = questionService.select(questionIds);
- Transform.combine(pr, questionList, UserQuestionErrorListDto.class, "questionId", "question", Question.class, "id", QuestionExtendDto.class);
- Collection questionNoIds = Transform.getIds(pr, UserQuestionErrorListDto.class, "questionNoId");
- switch(qm){
- case BASE:
- List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
- Transform.combine(pr, questionNoList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", QuestionNo.class, "id", QuestionNoExtendDto.class);
- break;
- case SENTENCE:
- List<SentenceQuestion> sentenceQuestionList = sentenceQuestionService.select(questionNoIds);
- Transform.combine(pr, sentenceQuestionList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", SentenceQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- case TEXTBOOK:
- List<TextbookQuestion> textbookQuestionList = textbookQuestionService.select(questionNoIds);
- Transform.combine(pr, textbookQuestionList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", TextbookQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- }
- 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 UserCustomBindDto dto) {
- User user = (User) shiroHelp.getLoginUser();
- questionFlowService.makePaper(
- user.getId(),
- QuestionModule.ValueOf(dto.getQuestionModule()),
- PaperOrigin.ERROR,
- Arrays.stream(dto.getQuestionNoIds()).collect(Collectors.toList()),
- dto.getFilterTimes()
- );
- return ResponseHelp.success(true);
- }
- @RequestMapping(value = "/error/clear", method = RequestMethod.POST)
- @ApiOperation(value = "错题移除", notes = "错题移除", httpMethod = "POST")
- 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);
- }
- @RequestMapping(value = "/note/question", method = RequestMethod.PUT)
- @ApiOperation(value = "更新笔记", notes = "更新笔记", httpMethod = "PUT")
- public Response<Boolean> updateNoteQuestion(@RequestBody @Validated UserNoteQuestionDto dto) {
- UserNoteQuestion entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
- entity.setUserId(user.getId());
- 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);
- }
- @RequestMapping(value = "/note/question/list", method = RequestMethod.GET)
- @ApiOperation(value = "获取题目笔记列表", notes = "获取笔记列表", httpMethod = "GET")
- public Response<PageMessage<com.qxgmat.dto.response.UserNoteQuestionDto>> listNoteQuestion(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = true) String questionModule,
- @RequestParam(required = false) String questionType,
- @RequestParam(required = false) String startTime,
- @RequestParam(required = false) String endTime,
- @RequestParam(required = false, defaultValue = "id") String order,
- @RequestParam(required = false, defaultValue = "desc") String direction,
- HttpSession session) {
- User user = (User) shiroHelp.getLoginUser();
- QuestionModule qm = QuestionModule.ValueOf(questionModule);
- PageResult<UserNoteQuestionRelation> p = userNoteQuestionService.list(page, size, user.getId(), qm, QuestionType.ValueOf(questionType), startTime, endTime, order, DirectionStatus.ValueOf(direction));
- List<com.qxgmat.dto.response.UserNoteQuestionDto> pr = Transform.convert(p, com.qxgmat.dto.response.UserNoteQuestionDto.class);
-
- Collection questionIds = Transform.getIds(pr, com.qxgmat.dto.response.UserNoteQuestionDto.class, "questionId");
- List<Question> questionList = questionService.select(questionIds);
- Transform.combine(pr, questionList, com.qxgmat.dto.response.UserNoteQuestionDto.class, "questionId", "question", Question.class, "id", QuestionExtendDto.class);
- Collection questionNoIds = Transform.getIds(pr, UserQuestionErrorListDto.class, "questionNoId");
- switch(qm){
- case BASE:
- List<QuestionNo> questionNoList = questionNoService.select(questionNoIds);
- Transform.combine(pr, questionNoList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", QuestionNo.class, "id", QuestionNoExtendDto.class);
- break;
- case SENTENCE:
- List<SentenceQuestion> sentenceQuestionList = sentenceQuestionService.select(questionNoIds);
- Transform.combine(pr, sentenceQuestionList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", SentenceQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- case TEXTBOOK:
- List<TextbookQuestion> textbookQuestionList = textbookQuestionService.select(questionNoIds);
- Transform.combine(pr, textbookQuestionList, UserQuestionErrorListDto.class, "questionNoId", "questionNo", TextbookQuestion.class, "id", QuestionNoExtendDto.class);
- break;
- }
- return ResponseHelp.success(pr, page, size, p.getTotal());
- }
- @RequestMapping(value = "/report/list", method = RequestMethod.GET)
- @ApiOperation(value = "获取报告列表", notes = "获取报告列表", httpMethod = "GET")
- public Response<PageMessage<UserPaperDto>> reportList(
- @RequestParam(required = false, defaultValue = "1") int page,
- @RequestParam(required = false, defaultValue = "100") int size,
- @RequestParam(required = true) String origin,
- @RequestParam(required = false) Integer structId,
- @RequestParam(required = false) String startTime,
- @RequestParam(required = false) String endTime,
- @RequestParam(required = false, defaultValue = "id") String order,
- @RequestParam(required = false, defaultValue = "desc") String direction,
- HttpSession session) {
- User user = (User) shiroHelp.getLoginUser();
- PaperOrigin paperOrigin = PaperOrigin.ValueOf(origin);
- PageResult<UserPaper> p = userPaperService.list(page, size, user.getId(), paperOrigin, structId, startTime, endTime, order, DirectionStatus.ValueOf(direction));
- 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());
- }
- @RequestMapping(value = "/ask/question", method = RequestMethod.POST)
- @ApiOperation(value = "添加提问", notes = "添加提问", httpMethod = "POST")
- public Response<Boolean> addAskQuestion(@RequestBody @Validated UserAskDto dto) {
- UserAskQuestion entity = Transform.dtoToEntity(dto);
- User user = (User) shiroHelp.getLoginUser();
- entity.setUserId(user.getId());
- 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/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);
- }
- @RequestMapping(value = "/order/record", method = RequestMethod.GET)
- @ApiOperation(value = "获取订单记录", notes = "获取订单记录", httpMethod = "GET")
- public Response<UserOrderRecord> getOrderRecord(
- @RequestParam(required = true) Integer id
- ) {
- User user = (User) shiroHelp.getLoginUser();
- UserOrderRecord record = userOrderRecordService.get(id);
- if (!record.getUserId().equals(user.getId())){
- throw new ParameterException("记录不存在");
- }
- return ResponseHelp.success(record);
- }
- @RequestMapping(value = "/record/use", method = RequestMethod.GET)
- @ApiOperation(value = "开通", notes = "开通", httpMethod = "GET")
- public Response<UserOrderRecord> useRecord(
- @RequestParam(required = true) Integer id
- ) {
- User user = (User) shiroHelp.getLoginUser();
- UserOrderRecord record = userOrderRecordService.get(id);
- if (!record.getUserId().equals(user.getId())){
- throw new ParameterException("记录不存在");
- }
- return ResponseHelp.success(record);
- }
- }
|