Browse Source

每天学习节数

he2802 3 năm trước cách đây
mục cha
commit
231c658e32

+ 16 - 0
zhongzheng-api/src/main/java/com/zhongzheng/controller/goods/GoodsController.java

@@ -22,6 +22,8 @@ import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
 import com.zhongzheng.modules.goods.service.IGoodsService;
 import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
 import com.zhongzheng.modules.goods.vo.GoodsVo;
+import com.zhongzheng.modules.grade.bo.UserPeriodQueryBo;
+import com.zhongzheng.modules.grade.service.IUserPeriodService;
 import com.zhongzheng.modules.user.bo.UserExamRecordQueryBo;
 import com.zhongzheng.modules.user.bo.UserExamWrongRecordQueryBo;
 import com.zhongzheng.modules.user.entity.ClientLoginUser;
@@ -66,6 +68,8 @@ public class GoodsController extends BaseController {
 
     private final IQuestionChapterExamService iQuestionChapterExamService;
 
+    private final IUserPeriodService iUserPeriodService;
+
     /**
      * 获取商品详细信息
      */
@@ -161,4 +165,16 @@ public class GoodsController extends BaseController {
         List<ExamVo> list = iQuestionChapterExamService.getDoList(bo);
         return AjaxResult.success(list);
     }
+
+    /**
+     * 查询用户商品今天学习节数
+     */
+    @ApiOperation("查询用户商品今天学习节数")
+    @GetMapping("/todayStudySectionNum")
+    public AjaxResult<Long> todayStudySectionNum(UserPeriodQueryBo bo) {
+        ClientLoginUser loginUser = wxTokenService.getLoginUser(ServletUtils.getRequest());
+        bo.setUserId(loginUser.getUser().getUserId());
+        return AjaxResult.success(iUserPeriodService.todayStudySectionNum(bo));
+    }
+
 }

+ 1 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/goods/service/IGoodsService.java

@@ -74,4 +74,5 @@ public interface IGoodsService extends IService<Goods> {
 	GoodsVo selectUserDetail(CourseQueryBo bo);
 
 	int queryUpGoods();
+
 }

+ 4 - 2
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/bo/UserPeriodQueryBo.java

@@ -67,6 +67,8 @@ public class UserPeriodQueryBo extends BaseEntity {
 	/** 當前位置 */
 	@ApiModelProperty("當前位置")
 	private Long numIndex;
-
-
+	@ApiModelProperty("今天开始时间")
+	private Long todayStartTime;
+	@ApiModelProperty("今天结束时间")
+	private Long todayEndTime;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/mapper/UserPeriodMapper.java

@@ -22,4 +22,6 @@ public interface UserPeriodMapper extends BaseMapper<UserPeriod> {
     Long selectCountPeriod(@Param("userId") Long userId, @Param("id") Long id);
 
     Long selectCountConfirmPeriod(@Param("userId") Long userId, @Param("id") Long id);
+
+    Long todayStudySectionNum(UserPeriodQueryBo bo);
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/IUserPeriodService.java

@@ -59,4 +59,6 @@ public interface IUserPeriodService extends IService<UserPeriod> {
 	Boolean confirmPeriod(UserPeriodEditBo bo);
 
 	Boolean rollbackPeriod(UserPeriodEditBo bo);
+
+	Long todayStudySectionNum(UserPeriodQueryBo bo);
 }

+ 10 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/grade/service/impl/UserPeriodServiceImpl.java

@@ -368,6 +368,16 @@ public class UserPeriodServiceImpl extends ServiceImpl<UserPeriodMapper, UserPer
         return true;
     }
 
+    @Override
+    public Long todayStudySectionNum(UserPeriodQueryBo bo) {
+        long current=System.currentTimeMillis()/1000;
+        long zero=current/(1000*3600*24)*(1000*3600*24)-TimeZone.getDefault().getRawOffset();//今天零点零分零秒的毫秒数
+        long twelve=zero+24*60*60*1000-1;//今天23点59分59秒的毫秒数
+        bo.setTodayStartTime(zero/1000);
+        bo.setTodayEndTime(twelve/1000);
+        return baseMapper.todayStudySectionNum(bo);
+    }
+
     //学时通过处理事件
     private void periodPass(ClassGradeUserQueryBo classGradeUserQueryBo){
         //生成证书

+ 41 - 0
zhongzheng-system/src/main/resources/mapper/modules/grade/UserPeriodMapper.xml

@@ -110,4 +110,45 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
           AND ups.id = #{id}
           and FIND_IN_SET(#{userId},b.period_confirm_user_ids)
     </select>
+
+    <select id="todayStudySectionNum" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
+        SELECT
+        IFNULL(count(*),0)
+        FROM
+        user_period up
+        WHERE
+        1=1
+        <if test="goodsId != null and goodsId != ''">
+            and up.goods_id = #{goodsId}
+        </if>
+        <if test="gradeId != null and gradeId != ''">
+            and up.grade_id = #{gradeId}
+        </if>
+
+        <if test="userId != null and userId != ''">
+            and up.user_id = #{userId}
+        </if>
+        <if test="sectionId != null ">
+            and up.section_id = #{sectionId}
+        </if>
+        <if test="moduleId != null ">
+            and up.module_id = #{moduleId}
+        </if>
+
+        <if test="chapterId != null">
+            and up.chapter_id = #{chapterId}
+        </if>
+        <if test="courseId != null ">
+            and up.course_id = #{courseId}
+        </if>
+        <if test="examId != null ">
+            and up.exam_id = #{examId}
+        </if>
+        <if test="todayStartTime != null ">
+            and up.create_time >= #{todayStartTime}
+        </if>
+        <if test="todayEndTime != null ">
+            and #{todayEndTime} > up.create_time
+        </if>
+    </select>
 </mapper>