VideoLessonGroupMapper.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <mapper namespace="com.yonge.cooleshow.biz.dal.dao.VideoLessonGroupDao">
  5. <resultMap id="BaseResultMap" type="com.yonge.cooleshow.biz.dal.entity.VideoLessonGroup">
  6. <id column="id_" jdbcType="BIGINT" property="id" />
  7. <result column="lesson_name_" jdbcType="VARCHAR" property="lessonName" />
  8. <result column="lesson_subject_" jdbcType="VARCHAR" property="lessonSubject" />
  9. <result column="lesson_desc_" jdbcType="VARCHAR" property="lessonDesc" />
  10. <result column="lesson_price_" jdbcType="INTEGER" property="lessonPrice" />
  11. <result column="lesson_cover_url_" jdbcType="VARCHAR" property="lessonCoverUrl" />
  12. <result column="teacher_id_" jdbcType="BIGINT" property="teacherId" />
  13. <result column="lesson_count_" jdbcType="INTEGER" property="lessonCount" />
  14. <result column="sort_number_" jdbcType="INTEGER" property="sortNumber" />
  15. <result column="lesson_tag_" jdbcType="VARCHAR" property="lessonTag" />
  16. <result column="top_flag_" jdbcType="TINYINT" property="topFlag" />
  17. <result column="hot_flag_" jdbcType="TINYINT" property="hotFlag" />
  18. <result column="audit_status_" jdbcType="TINYINT" property="auditStatus" />
  19. <result column="create_time_" jdbcType="TIMESTAMP" property="createTime" />
  20. <result column="update_time_" jdbcType="TIMESTAMP" property="updateTime" />
  21. </resultMap>
  22. <sql id="baseColumns">
  23. g.id_ AS id,
  24. g.lesson_name_ AS lessonName,
  25. g.lesson_subject_ AS lessonSubject,
  26. g.lesson_desc_ AS lessonDesc,
  27. g.lesson_price_ AS lessonPrice,
  28. g.lesson_cover_url_ AS lessonCoverUrl,
  29. g.teacher_id_ AS teacherId,
  30. g.lesson_count_ AS lessonCount,
  31. g.sort_number_ AS sortNumber,
  32. g.lesson_tag_ AS lessonTag,
  33. g.top_flag_ AS topFlag,
  34. g.hot_flag_ AS hotFlag,
  35. g.audit_status_ AS auditStatus,
  36. g.create_time_ AS createTime,
  37. g.update_time_ AS updateTime
  38. </sql>
  39. <update id="updateGroup" parameterType="com.yonge.cooleshow.biz.dal.vo.VideoLessonGroupUpVo">
  40. UPDATE video_lesson_group
  41. <set>
  42. <if test="lessonName !=null and lessonName !=''">lesson_name_ = #{lessonName},</if>
  43. <if test="lessonSubject !=null and lessonSubject !=''">lesson_subject_ = #{lessonSubject},</if>
  44. <if test="lessonDesc !=null and lessonDesc !=''">lesson_desc_ = #{lessonDesc},</if>
  45. <if test="lessonPrice !=null and lessonPrice !=''">lesson_price_ = #{lessonPrice},</if>
  46. <if test="lessonCoverUrl !=null and lessonCoverUrl !=''">lesson_cover_url_ = #{lessonCoverUrl},</if>
  47. <if test="sortNumber !=null">sort_number_ = #{sortNumber},</if>
  48. <if test="lessonTag !=null and lessonTag !=''">lesson_tag_ = #{lessonTag},</if>
  49. <if test="topFlag !=null">top_flag_ = #{topFlag},</if>
  50. <if test="hotFlag !=null">hot_flag_ = #{hotFlag},</if>
  51. <if test="auditStatus !=null">audit_status_ = #{auditStatus},</if>
  52. update_time_ = SYSDATE(),
  53. lesson_count_ = (SELECT COUNT(1) FROM video_lesson_group_detail WHERE video_lesson_group_id_ = #{id})
  54. </set>
  55. WHERE id_ = #{id}
  56. </update>
  57. <select id="selectPage" resultType="com.yonge.cooleshow.biz.dal.vo.VideoLessonGroupVo">
  58. SELECT
  59. <include refid="baseColumns"/>,
  60. s.username_ AS username,
  61. s.avatar_ AS avatar,
  62. (SELECT COUNT(1) FROM video_lesson_purchase_record r WHERE r.video_lesson_group_id_=g.id_) AS countStudent
  63. FROM video_lesson_group g
  64. LEFT JOIN sys_user s ON g.teacher_id_ = s.id_
  65. <where>
  66. <if test="param.auditStatus !=null">
  67. AND g.audit_status_ = #{param.auditStatus}
  68. </if>
  69. <if test="param.groupId !=null">
  70. AND g.id_ = #{param.groupId}
  71. </if>
  72. </where>
  73. </select>
  74. <select id="selectStudentPage" resultType="com.yonge.cooleshow.biz.dal.vo.VideoLessonStudentDetailVo">
  75. SELECT
  76. g.id_ AS groupId,
  77. g.lesson_name_ AS lessonName,
  78. g.lesson_subject_ AS lessonSubject,
  79. g.lesson_count_ AS lessonCount,
  80. g.lesson_price_ AS lessonPrice,
  81. p.order_no_ AS orderNo,
  82. p.purchase_time_ AS purchaseTime
  83. FROM video_lesson_group g
  84. LEFT JOIN video_lesson_purchase_record p ON g.id_ = p.video_lesson_group_id_
  85. LEFT JOIN sys_user s ON g.teacher_id_ = s.id_
  86. <where>
  87. <if test="param.studentId !=null">
  88. AND p.student_id_ = #{param.studentId}
  89. </if>
  90. <if test="null != param.search and '' != param.search">
  91. AND (
  92. s.id_ LIKE CONCAT('%', #{param.search}, '%') OR
  93. s.username_ LIKE CONCAT('%', #{param.search}, '%') OR
  94. s.phone_ LIKE CONCAT('%', #{param.search}, '%') OR
  95. g.id_ LIKE CONCAT('%', #{param.search}, '%')
  96. )
  97. </if>
  98. <if test="null != param.orderNo and '' != param.orderNo">
  99. AND p.order_no_ = #{param.orderNo}
  100. </if>
  101. <if test="null != param.lessonSubject and '' != param.lessonSubject">
  102. AND g.lesson_subject_ = #{param.lessonSubject}
  103. </if>
  104. <if test="param.auditStatus !=null">
  105. AND g.audit_status_ = #{param.auditStatus}
  106. </if>
  107. <if test="param.startTime !=null">
  108. <![CDATA[AND p.purchase_time_ >= #{param.startTime} ]]>
  109. </if>
  110. <if test="param.endTime !=null">
  111. <![CDATA[AND p.purchase_time_ <= #{param.endTime} ]]>
  112. </if>
  113. </where>
  114. </select>
  115. </mapper>