Parcourir la source

增加总课程数量、题目数量、试卷数量服务

wangchangsheng il y a 2 ans
Parent
commit
2f379721c1

+ 16 - 4
exam-06173-api/src/main/java/com/gyee/exam/modules/course/controller/CourseController.java

@@ -23,10 +23,7 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.shiro.authz.annotation.Logical;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 /**
 * <p>
@@ -150,4 +147,19 @@ public class CourseController extends BaseController {
         IPage<UserCourseRespDTO> page = baseService.userPaging(reqDTO);
         return super.success(page);
     }
+
+
+    /**
+     * 统计总课程数
+     * @return
+     */
+    @ApiOperation(value = "统计总课程数")
+    @GetMapping("/course-total")
+    public ApiRest courseAllTotal() {
+        int total = baseService.courseAllTotal();
+        return super.success(total);
+    }
+
+
+
 }

+ 7 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/CourseService.java

@@ -62,4 +62,11 @@ public interface CourseService extends IService<Course> {
      */
     Course findSimple(String courseId);
 
+
+    /**
+     * 统计课程总数
+     * @return
+     */
+    int courseAllTotal();
+
 }

+ 11 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/course/service/impl/CourseServiceImpl.java

@@ -289,4 +289,15 @@ public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> impleme
         return this.getOne(wrapper, false);
     }
 
+    @Override
+    public int courseAllTotal() {
+
+        //查询条件
+        QueryWrapper<Course> wrapper = new QueryWrapper<>();
+        //查询总数量
+        Integer count = baseMapper.selectCount(wrapper);
+
+        return count;
+    }
+
 }

+ 12 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/controller/QuController.java

@@ -298,4 +298,16 @@ public class QuController extends BaseController {
         }
 
     }
+
+
+    /**
+     * 查询题目总数
+     * @return
+     */
+    @ApiOperation(value = "查询题目总数")
+    @GetMapping("/title-total")
+    public ApiRest titleTotal() {
+        int count = baseService.titleTotal();
+        return super.success(count);
+    }
 }

+ 5 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/mapper/QuMapper.java

@@ -44,5 +44,10 @@ public interface QuMapper extends BaseMapper<Qu> {
      */
     List<QuDetailDTO> listByRand(@Param("query") QuQueryReqDTO quDTO, @Param("size") Integer size);
 
+    /**
+     * 统计查询题目总数
+     * @return
+     */
+    int titleTotal();
 
 }

+ 8 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/service/QuService.java

@@ -161,4 +161,12 @@ public interface QuService extends IService<Qu> {
      * @return
      */
     List<QuDetailDTO> listSub(String quId);
+
+
+    /**
+     * 统计查询题目总数
+     * @return
+     */
+    int titleTotal();
+
 }

+ 7 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/qu/service/impl/QuServiceImpl.java

@@ -474,4 +474,11 @@ public class QuServiceImpl extends ServiceImpl<QuMapper, Qu> implements QuServic
         quAnswerService.removeByQuIds(subIds);
 
     }
+
+    @Override
+    public int titleTotal() {
+
+        int count = baseMapper.titleTotal();
+        return count;
+    }
 }

+ 13 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/controller/TmplController.java

@@ -132,4 +132,17 @@ public class TmplController extends BaseController {
         IPage<TmplDTO> page = baseService.paging(reqDTO);
         return super.success(page);
     }
+
+
+    /**
+     * 统计试卷数量
+     * @return
+     */
+    @ApiOperation(value = "统计试卷数量")
+    @GetMapping("/tmpl-total")
+    public ApiRest tmplTotal() {
+        int  count = baseService.tmplTotal();
+        return super.success(count);
+    }
+
 }

+ 6 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/service/TmplService.java

@@ -75,4 +75,10 @@ public interface TmplService extends IService<Tmpl> {
      * @param ids
      */
     void deleteByIds(List<String> ids);
+
+    /**
+     * 统计试卷数量
+     * @return
+     */
+    int tmplTotal();
 }

+ 9 - 0
exam-06173-api/src/main/java/com/gyee/exam/modules/tmpl/service/impl/TmplServiceImpl.java

@@ -330,4 +330,13 @@ public class TmplServiceImpl extends ServiceImpl<TmplMapper, Tmpl> implements Tm
         }
     }
 
+
+    @Override
+    public int tmplTotal() {
+        QueryWrapper<Tmpl> wrapper = new QueryWrapper<>();
+        Integer count = baseMapper.selectCount(wrapper);
+        return count;
+    }
+
+
 }

+ 7 - 0
exam-06173-api/src/main/resources/mapper/qu/QuMapper.xml

@@ -138,4 +138,11 @@
        ORDER BY RAND() LIMIT ${size}
     </select>
 
+    <select id="titleTotal" resultType="java.lang.Integer">
+        SELECT
+        COUNT(IF(qu.child=0, 1, NULL)) AS quCount
+        FROM el_repo repo
+        LEFT JOIN el_qu qu ON qu.repo_id=repo.id
+    </select>
+
 </mapper>