yangdamao преди 2 години
родител
ревизия
2176e9b870

+ 11 - 4
zhongzheng-api/src/main/java/com/zhongzheng/controller/bank/QuestionController.java

@@ -9,10 +9,7 @@ import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
 import com.zhongzheng.modules.bank.service.IQuestionService;
 import com.zhongzheng.modules.exam.service.IExamPaperService;
 import com.zhongzheng.modules.exam.vo.ExamPaperVo;
-import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
-import com.zhongzheng.modules.goods.bo.SpecialExamRecordAddBo;
-import com.zhongzheng.modules.goods.bo.SpecialExamRecordQuery;
-import com.zhongzheng.modules.goods.bo.TodayExamSubscriptionBo;
+import com.zhongzheng.modules.goods.bo.*;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsExamTimeVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
@@ -171,4 +168,14 @@ public class QuestionController extends BaseController {
         bo.setUserId(loginUser.getUser().getUserId());
         return toAjax(iUserExamSubscriptionService.todayExamSubscription(bo)? 1 : 0);
     }
+
+    /**
+     * 每日一练打卡排行榜
+     */
+    @ApiOperation("每日一练打卡排行榜")
+    @GetMapping("/todayExam/tob/{goodsId}")
+    public AjaxResult<List<TodayExamTobVo>> getTodayExamTob(@PathVariable("goodsId") Long goodsId) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        return AjaxResult.success(iQuestionService.getTodayExamTob(goodsId,loginUser.getUser().getUserId()));
+    }
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/IQuestionService.java

@@ -15,6 +15,7 @@ import com.zhongzheng.modules.bank.vo.QuestionVo;
 import com.zhongzheng.modules.goods.bo.BankGoodsExamAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
 import com.zhongzheng.modules.goods.bo.SpecialExamRecordAddBo;
+import com.zhongzheng.modules.goods.bo.TodayExamTobVo;
 import com.zhongzheng.modules.goods.vo.BankGoodsExamVo;
 import com.zhongzheng.modules.goods.vo.GoodsExamTimeVo;
 import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
@@ -95,4 +96,5 @@ public interface IQuestionService extends IService<Question> {
 
 	GoodsExamTimeVo getToDayExam(Long goodsId,Long userId);
 
+	List<TodayExamTobVo> getTodayExamTob(Long goodsId, Long userId);
 }

+ 26 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/bank/service/impl/QuestionServiceImpl.java

@@ -35,6 +35,7 @@ import com.zhongzheng.modules.exam.domain.ExamKnowledge;
 import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
 import com.zhongzheng.modules.goods.bo.BankGoodsExamAddBo;
 import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
+import com.zhongzheng.modules.goods.bo.TodayExamTobVo;
 import com.zhongzheng.modules.goods.domain.Goods;
 import com.zhongzheng.modules.goods.domain.GoodsExamTime;
 import com.zhongzheng.modules.goods.service.IGoodsExamTimeService;
@@ -45,10 +46,12 @@ import com.zhongzheng.modules.goods.vo.GoodsUserQuestionVo;
 
 import com.zhongzheng.modules.user.bo.CheckUserExamRecordBo;
 import com.zhongzheng.modules.user.bo.UserSpecialExamRecord;
+import com.zhongzheng.modules.user.domain.User;
 import com.zhongzheng.modules.user.domain.UserExamRecord;
 import com.zhongzheng.modules.user.domain.UserExamSubscription;
 import com.zhongzheng.modules.user.service.IUserExamRecordService;
 import com.zhongzheng.modules.user.service.IUserExamSubscriptionService;
+import com.zhongzheng.modules.user.service.IUserService;
 import com.zhongzheng.modules.user.service.IUserSpecialExamRecordService;
 import org.apache.poi.openxml4j.opc.PackagePart;
 import org.apache.poi.xwpf.usermodel.XWPFDocument;
@@ -122,6 +125,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
     @Autowired
     private IUserExamSubscriptionService iUserExamSubscriptionService;
 
+    @Autowired
+    private IUserService iUserService;
+
     @Autowired
     private IExamService iExamService;
 
@@ -1870,6 +1876,26 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
         return vo;
     }
 
+    @Override
+    public List<TodayExamTobVo> getTodayExamTob(Long goodsId, Long userId) {
+        //获取商品的打卡记录
+        List<UserSpecialExamRecord> recordList = userSpecialExamRecordService
+                .list(new LambdaQueryWrapper<UserSpecialExamRecord>()
+                .eq(UserSpecialExamRecord::getGoodsId, goodsId));
+        if (CollectionUtils.isEmpty(recordList)){
+            return new ArrayList<>();
+        }
+        List<TodayExamTobVo> voList = new ArrayList<>();
+        recordList.stream().collect(Collectors.groupingBy(UserSpecialExamRecord::getUserId)).forEach((k,v) -> {
+            TodayExamTobVo vo = new TodayExamTobVo();
+            vo.setUserId(k);
+            vo.setRecordCount(v.size());
+            User user = iUserService.getById(k);
+            vo.setUserName(user.getNickname());
+        });
+        return voList.stream().sorted(Comparator.comparing(TodayExamTobVo::getRecordCount).reversed()).collect(Collectors.toList());
+    }
+
     private String getPercent(Integer x,Integer y){
         Double d1 = x * 1.0;
         Double d2 = y * 1.0;

+ 24 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/bo/TodayExamTobVo.java

@@ -0,0 +1,24 @@
+package com.zhongzheng.modules.goods.bo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author yangdamao
+ * @date 2022年11月17日 9:44
+ */
+@Data
+public class TodayExamTobVo implements Serializable {
+
+    @ApiModelProperty("用户ID")
+    private Long userId;
+
+    @ApiModelProperty("用户昵称")
+    private String userName;
+
+    @ApiModelProperty("打卡次数")
+    private Integer recordCount;
+
+}

+ 4 - 1
zhongzheng-system/src/main/resources/mapper/modules/bank/QuestionChapterExamMapper.xml

@@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="doQuestionNum" column="do_question_num"/>
         <result property="recordStatus" column="record_status"/>
         <result property="recordId" column="record_id"/>
+        <result property="paperName" column="paper_name"/>
     </resultMap>
 
     <select id="getList" parameterType="com.zhongzheng.modules.bank.bo.QuestionChapterExamQueryBo" resultMap="QuestionChapterExamResultVo">
@@ -57,10 +58,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN (
                 SELECT
                     e.*,
-                    count( eq.question_id ) question_num
+                    count( eq.question_id ) question_num,
+                    ep.paper_name
                 FROM
                     exam e
                         LEFT JOIN exam_question eq ON e.exam_id = eq.exam_id
+                        LEFT JOIN exam_paper ep ON e.exam_paper_id = ep.paper_id
                 GROUP BY
                     e.exam_id
             ) e ON qce.exam_id = e.exam_id

+ 0 - 1
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamPaperMapper.xml

@@ -61,5 +61,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND e.exam_paper_id IS NOT NULL AND ep.`status` != -1
     </select>
 
-
 </mapper>