UserPeriodMapper.xml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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="selectCountPeriodStatus" parameterType="map" resultType="Long">
  53. SELECT
  54. COUNT(1)
  55. FROM
  56. user_period_status ups JOIN user_period up on ups.period_id = up.id JOIN goods g on goods_id = up.goods_id JOIN course_business b on g.business_id = b.id
  57. WHERE
  58. 1 = 1
  59. AND ups.id = #{id}
  60. and FIND_IN_SET(#{userId},b.period_user_ids)
  61. </select>
  62. </mapper>