UserPeriodMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.zhongzheng.modules.grade.mapper.UserPeriodMapper">
  6. <resultMap type="com.zhongzheng.modules.grade.domain.UserPeriod" id="UserPeriodResult">
  7. <result property="id" column="id"/>
  8. <result property="userId" column="user_id"/>
  9. <result property="courseId" column="course_id"/>
  10. <result property="sectionId" column="section_id"/>
  11. <result property="goodsId" column="goods_id"/>
  12. <result property="type" column="type"/>
  13. <result property="examId" column="exam_id"/>
  14. <result property="createTime" column="create_time"/>
  15. <result property="updateTime" column="update_time"/>
  16. <result property="moduleId" column="module_id"/>
  17. <result property="chapterId" column="chapter_id"/>
  18. </resultMap>
  19. <select id="checkGoodsChange" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  20. SELECT
  21. IFNULL(count(*),0)
  22. FROM
  23. user_period up
  24. LEFT JOIN class_grade_user cgu ON up.grade_id = cgu.grade_id
  25. WHERE
  26. cgu.period_status = 1
  27. <if test="goodsId != null and goodsId != ''">
  28. and up.goods_id = #{goodsId}
  29. </if>
  30. <if test="gradeId != null and gradeId != ''">
  31. and up.grade_id = #{gradeId}
  32. </if>
  33. <if test="userId != null and userId != ''">
  34. and up.user_id = #{userId}
  35. </if>
  36. <if test="sectionId != null ">
  37. and up.section_id = #{sectionId}
  38. </if>
  39. <if test="moduleId != null ">
  40. and up.module_id = #{moduleId}
  41. </if>
  42. <if test="chapterId != null">
  43. and up.chapter_id = #{chapterId}
  44. </if>
  45. <if test="courseId != null ">
  46. and up.course_id = #{courseId}
  47. </if>
  48. <if test="examId != null ">
  49. and up.exam_id = #{examId}
  50. </if>
  51. </select>
  52. <select id="checkGoodsStudy" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  53. SELECT
  54. IFNULL(count(*),0)
  55. FROM
  56. user_period up
  57. WHERE
  58. 1=1
  59. <if test="goodsId != null and goodsId != ''">
  60. and up.goods_id = #{goodsId}
  61. </if>
  62. <if test="gradeId != null and gradeId != ''">
  63. and up.grade_id = #{gradeId}
  64. </if>
  65. <if test="userId != null and userId != ''">
  66. and up.user_id = #{userId}
  67. </if>
  68. <if test="sectionId != null ">
  69. and up.section_id = #{sectionId}
  70. </if>
  71. <if test="moduleId != null ">
  72. and up.module_id = #{moduleId}
  73. </if>
  74. <if test="chapterId != null">
  75. and up.chapter_id = #{chapterId}
  76. </if>
  77. <if test="courseId != null ">
  78. and up.course_id = #{courseId}
  79. </if>
  80. <if test="examId != null ">
  81. and up.exam_id = #{examId}
  82. </if>
  83. </select>
  84. <select id="selectCountPeriod" parameterType="map" resultType="Long">
  85. SELECT
  86. COUNT(1)
  87. FROM
  88. user_period_status ups JOIN user_period up on ups.period_id = up.id JOIN goods g on g.goods_id = up.goods_id JOIN course_business b on g.business_id = b.id
  89. WHERE
  90. 1 = 1
  91. AND ups.id = #{id}
  92. and FIND_IN_SET(#{userId},b.period_user_ids)
  93. </select>
  94. <select id="selectCountConfirmPeriod" parameterType="map" resultType="Long">
  95. SELECT
  96. COUNT(1)
  97. FROM
  98. goods g LEFT JOIN course_business b on g.business_id = b.id
  99. WHERE
  100. 1 = 1
  101. AND g.goods_id = #{goodsId}
  102. and FIND_IN_SET(#{userId},b.period_confirm_user_ids)
  103. </select>
  104. <select id="todayStudySectionNum" parameterType="com.zhongzheng.modules.grade.bo.UserPeriodQueryBo" resultType="Long">
  105. SELECT
  106. IFNULL(count(*),0)
  107. FROM
  108. user_period up
  109. WHERE
  110. 1=1
  111. <if test="goodsId != null and goodsId != ''">
  112. and up.goods_id = #{goodsId}
  113. </if>
  114. <if test="gradeId != null and gradeId != ''">
  115. and up.grade_id = #{gradeId}
  116. </if>
  117. <if test="userId != null and userId != ''">
  118. and up.user_id = #{userId}
  119. </if>
  120. <if test="sectionId != null ">
  121. and up.section_id = #{sectionId}
  122. </if>
  123. <if test="moduleId != null ">
  124. and up.module_id = #{moduleId}
  125. </if>
  126. <if test="chapterId != null">
  127. and up.chapter_id = #{chapterId}
  128. </if>
  129. <if test="courseId != null ">
  130. and up.course_id = #{courseId}
  131. </if>
  132. <if test="examId != null ">
  133. and up.exam_id = #{examId}
  134. </if>
  135. <if test="todayStartTime != null ">
  136. and up.create_time >= #{todayStartTime}
  137. </if>
  138. <if test="todayEndTime != null ">
  139. and #{todayEndTime} >= up.create_time
  140. </if>
  141. </select>
  142. </mapper>