From c6974a68972be7f26e61df42de7d9e1605379725 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 03 六月 2024 11:27:58 +0800
Subject: [PATCH] 分页工具类

---
 src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java |   57 +++++++++++++++++++++++++--------------------------------
 1 files changed, 25 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
index 7776dc5..227d86f 100644
--- a/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
+++ b/src/main/java/com/ycl/jxkg/service/impl/ExamPaperServiceImpl.java
@@ -1,6 +1,7 @@
 package com.ycl.jxkg.service.impl;
 
-import com.ycl.jxkg.domain.TextContent;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ycl.jxkg.domain.entity.TextContent;
 import com.ycl.jxkg.domain.enums.ExamPaperTypeEnum;
 import com.ycl.jxkg.domain.exam.ExamPaperQuestionItemObject;
 import com.ycl.jxkg.domain.exam.ExamPaperTitleItemObject;
@@ -15,20 +16,20 @@
 import com.ycl.jxkg.utils.DateTimeUtil;
 import com.ycl.jxkg.utils.JsonUtil;
 import com.ycl.jxkg.utils.ExamUtil;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperEditRequestVO;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperPageRequestVO;
-import com.ycl.jxkg.vo.admin.exam.ExamPaperTitleItemVO;
-import com.ycl.jxkg.vo.admin.question.QuestionEditRequestVO;
-import com.ycl.jxkg.vo.student.dashboard.PaperFilter;
-import com.ycl.jxkg.vo.student.dashboard.PaperInfo;
-import com.ycl.jxkg.vo.student.exam.ExamPaperPageVO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperEditRequestVO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperPageRequestVO;
+import com.ycl.jxkg.domain.vo.admin.exam.ExamPaperTitleItemVO;
+import com.ycl.jxkg.domain.vo.admin.question.QuestionEditRequestVO;
+import com.ycl.jxkg.domain.vo.student.dashboard.PaperFilter;
+import com.ycl.jxkg.domain.vo.student.dashboard.PaperInfo;
+import com.ycl.jxkg.domain.vo.student.exam.ExamPaperPageVO;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.ycl.jxkg.domain.ExamPaper;
-import com.ycl.jxkg.domain.Question;
-import com.ycl.jxkg.domain.User;
+import com.ycl.jxkg.domain.entity.ExamPaper;
+import com.ycl.jxkg.domain.entity.Question;
+import com.ycl.jxkg.domain.entity.User;
+import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -39,23 +40,14 @@
 import java.util.stream.Collectors;
 
 @Service
-public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaper> implements ExamPaperService {
+@RequiredArgsConstructor
+public class ExamPaperServiceImpl extends ServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
 
     private final ExamPaperMapper examPaperMapper;
     private final QuestionMapper questionMapper;
     private final TextContentService textContentService;
     private final QuestionService questionService;
     private final SubjectService subjectService;
-
-    @Autowired
-    public ExamPaperServiceImpl(ExamPaperMapper examPaperMapper, QuestionMapper questionMapper, TextContentService textContentService, QuestionService questionService, SubjectService subjectService) {
-        super(examPaperMapper);
-        this.examPaperMapper = examPaperMapper;
-        this.questionMapper = questionMapper;
-        this.textContentService = textContentService;
-        this.questionService = questionService;
-        this.subjectService = subjectService;
-    }
 
 
     @Override
@@ -92,31 +84,30 @@
             TextContent frameTextContent = new TextContent();
             frameTextContent.setContent(frameTextContentStr);
             frameTextContent.setCreateTime(now);
-            textContentService.insertByFilter(frameTextContent);
+            textContentService.save(frameTextContent);
             examPaper.setFrameTextContentId(frameTextContent.getId());
             examPaper.setCreateTime(now);
             examPaper.setCreateUser(user.getId());
-            examPaper.setDeleted(false);
             examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
-            examPaperMapper.insertSelective(examPaper);
+            examPaperMapper.insert(examPaper);
         } else {
-            examPaper = examPaperMapper.selectByPrimaryKey(examPaperEditRequestVO.getId());
-            TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId());
+            examPaper = examPaperMapper.selectById(examPaperEditRequestVO.getId());
+            TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
             frameTextContent.setContent(frameTextContentStr);
-            textContentService.updateByIdFilter(frameTextContent);
+            textContentService.updateById(frameTextContent);
             examPaperFromVM(examPaperEditRequestVO, examPaper, titleItemsVM);
-            examPaperMapper.updateByPrimaryKeySelective(examPaper);
+            examPaperMapper.updateById(examPaper);
         }
         return examPaper;
     }
 
     @Override
     public ExamPaperEditRequestVO examPaperToVM(Integer id) {
-        ExamPaper examPaper = examPaperMapper.selectByPrimaryKey(id);
+        ExamPaper examPaper = examPaperMapper.selectById(id);
         ExamPaperEditRequestVO vo = new ExamPaperEditRequestVO();
         BeanUtils.copyProperties(examPaper, vo);
         vo.setLevel(examPaper.getGradeLevel());
-        TextContent frameTextContent = textContentService.selectById(examPaper.getFrameTextContentId());
+        TextContent frameTextContent = textContentService.getById(examPaper.getFrameTextContentId());
         List<ExamPaperTitleItemObject> examPaperTitleItemObjects = JsonUtil.toJsonListObject(frameTextContent.getContent(), ExamPaperTitleItemObject.class);
         List<Integer> questionIds = examPaperTitleItemObjects.stream()
                 .flatMap(t -> t.getQuestionItems().stream()
@@ -202,4 +193,6 @@
             return titleItem;
         }).collect(Collectors.toList());
     }
+
+
 }

--
Gitblit v1.8.0