Explorar o código

接口改成框架的数据格式,创建章节 作业 测验与试卷的关联

zhaosongshan hai 7 meses
pai
achega
235552431a

+ 8 - 11
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/controller/admin/EducationController.java

@@ -31,9 +31,8 @@ public class EducationController extends BaseApiController {
     }
 
     @RequestMapping(value = "/subject/list", method = RequestMethod.POST)
-    public RestResponse<List<Subject>> list() {
-        List<Subject> subjects = subjectService.allSubject();
-        return RestResponse.ok(subjects);
+    public CommonResult<List<Subject>> list() {
+        return CommonResult.data(subjectService.allSubject());
     }
 
     @RequestMapping(value = "/subject/page", method = RequestMethod.POST)
@@ -42,7 +41,7 @@ public class EducationController extends BaseApiController {
     }
 
     @RequestMapping(value = "/subject/edit", method = RequestMethod.POST)
-    public RestResponse edit(@RequestBody @Valid SubjectEditRequestVM model) {
+    public CommonResult edit(@RequestBody @Valid SubjectEditRequestVM model) {
         Subject subject = modelMapper.map(model, Subject.class);
         if (model.getId() == null) {
             subject.setDeleted(false);
@@ -50,21 +49,19 @@ public class EducationController extends BaseApiController {
         } else {
             subjectService.updateByIdFilter(subject);
         }
-        return RestResponse.ok();
+        return CommonResult.ok();
     }
 
     @RequestMapping(value = "/subject/select/{id}", method = RequestMethod.POST)
-    public RestResponse<SubjectEditRequestVM> select(@PathVariable Integer id) {
-        Subject subject = subjectService.selectById(id);
-        SubjectEditRequestVM vm = modelMapper.map(subject, SubjectEditRequestVM.class);
-        return RestResponse.ok(vm);
+    public CommonResult<Subject> select(@PathVariable Integer id) {
+        return CommonResult.data(subjectService.selectById(id));
     }
 
     @RequestMapping(value = "/subject/delete/{id}", method = RequestMethod.POST)
-    public RestResponse delete(@PathVariable Integer id) {
+    public CommonResult delete(@PathVariable Integer id) {
         Subject subject = subjectService.selectById(id);
         subject.setDeleted(true);
         subjectService.updateByIdFilter(subject);
-        return RestResponse.ok();
+        return CommonResult.ok();
     }
 }

+ 29 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/domain/CollectCoursePaper.java

@@ -0,0 +1,29 @@
+package vip.xiaonuo.exam.domain;
+
+/**
+ * @PackageName:vip.xiaonuo.exam.domain
+ * @ClassName:CollectCoursePaper
+ * @Author ZSS
+ * @Date 2025-07-11 17:50
+ * @Note: 章节与试卷关系
+ **/
+public class CollectCoursePaper {
+    String collectId;
+    String paperId;
+
+    public String getCollectId() {
+        return collectId;
+    }
+
+    public void setCollectId(String collectId) {
+        this.collectId = collectId;
+    }
+
+    public String getPaperId() {
+        return paperId;
+    }
+
+    public void setPaperId(String paperId) {
+        this.paperId = paperId;
+    }
+}

+ 14 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/mapper/CollectCoursePaperMapper.java

@@ -0,0 +1,14 @@
+package vip.xiaonuo.exam.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import vip.xiaonuo.exam.domain.CollectCoursePaper;
+import vip.xiaonuo.exam.domain.ExamPaperAnswer;
+
+import java.util.List;
+
+@Mapper
+public interface CollectCoursePaperMapper extends BaseMapper<CollectCoursePaper>{
+    List<CollectCoursePaper> queryList(CollectCoursePaper cp);
+    int add(CollectCoursePaper cp);
+    int delete(CollectCoursePaper cp);
+}

+ 37 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/mapper/mapping/CollectCoursePaperMapper.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="vip.xiaonuo.exam.mapper.CollectCoursePaperMapper">
+    <resultMap id="BaseResultMap" type="vip.xiaonuo.exam.domain.CollectCoursePaper">
+        <result column="COLLECT_ID" jdbcType="VARCHAR" property="collectId" />
+        <result column="PAPER_ID" jdbcType="VARCHAR" property="paperId" />
+    </resultMap>
+    <sql id="Base_Column_List">
+        COLLECT_ID, PAPER_ID
+    </sql>
+    <select id="queryList" resultMap="BaseResultMap" parameterType="vip.xiaonuo.exam.domain.CollectCoursePaper">
+        select
+        <include refid="Base_Column_List" />
+        from COLLECT_COURSE_PAPER
+        where 1=1
+        <if test="collectId != null">
+            and COLLECT_ID = #{collectId,jdbcType=VARCHAR}
+        </if>
+        <if test="paperId != null">
+            and PAPER_ID = #{paperId,jdbcType=VARCHAR}
+        </if>
+    </select>
+    <insert id="add" parameterType="vip.xiaonuo.exam.domain.CollectCoursePaper">
+        insert into COLLECT_COURSE_PAPER (COLLECT_ID, PAPER_ID)
+        values (#{collectId,jdbcType=VARCHAR}, #{paperId,jdbcType=VARCHAR})
+    </insert>
+    <delete id="delete" parameterType="vip.xiaonuo.exam.domain.CollectCoursePaper">
+        delete from COLLECT_COURSE_PAPER
+        where 1=1
+        <if test="collectId != null">
+            and COLLECT_ID = #{collectId,jdbcType=VARCHAR}
+        </if>
+        <if test="paperId != null">
+            and PAPER_ID = #{paperId,jdbcType=VARCHAR}
+        </if>
+    </delete>
+</mapper>

+ 13 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/CollectCoursePaperService.java

@@ -0,0 +1,13 @@
+package vip.xiaonuo.exam.service;
+
+import vip.xiaonuo.exam.domain.CollectCoursePaper;
+
+import java.util.List;
+
+public interface CollectCoursePaperService {
+    List<CollectCoursePaper> queryList(CollectCoursePaper cp);
+
+    int add(CollectCoursePaper cp);
+
+    int delete(CollectCoursePaper cp);
+}

+ 38 - 0
snowy-plugin/snowy-plugin-exam/snowy-plugin-exam-func/src/main/java/vip/xiaonuo/exam/service/impl/CollectCoursePaperServiceImpl.java

@@ -0,0 +1,38 @@
+package vip.xiaonuo.exam.service.impl;
+
+import org.springframework.stereotype.Service;
+import vip.xiaonuo.exam.domain.CollectCoursePaper;
+import vip.xiaonuo.exam.mapper.CollectCoursePaperMapper;
+import vip.xiaonuo.exam.service.CollectCoursePaperService;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+/**
+ * @PackageName:vip.xiaonuo.exam.service.impl
+ * @ClassName:CollectCoursePaperServiceImpl
+ * @Author ZSS
+ * @Date 2025-07-11 17:55
+ * @Note: 章节-试卷关联服务实现类
+ **/
+@Service
+public class CollectCoursePaperServiceImpl implements CollectCoursePaperService {
+
+    @Resource
+    private CollectCoursePaperMapper cpm;
+
+    @Override
+    public List<CollectCoursePaper> queryList(CollectCoursePaper cp) {
+        return cpm.queryList(cp);
+    }
+
+    @Override
+    public int add(CollectCoursePaper cp) {
+        return cpm.add(cp);
+    }
+
+    @Override
+    public int delete(CollectCoursePaper cp) {
+        return cpm.delete(cp);
+    }
+}