FsUserCourseTrainingCampMapper.xml 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.fs.course.mapper.FsUserCourseTrainingCampMapper">
  6. <!-- 查询训练营列表 -->
  7. <select id="selectFsUserCourseTrainingCampVOListByMap" resultType="com.fs.course.vo.FsUserCourseTrainingCampVO">
  8. select
  9. ctc.training_camp_id,
  10. ctc.training_camp_name,
  11. ctc.order_number,
  12. min(if(ctp.period_starting_time >= CURDATE(), ctp.period_starting_time, null)) as recent_date,
  13. count(distinct ctp.period_id) as period_count
  14. from fs_user_course_training_camp ctc
  15. left join fs_user_course_period ctp on ctc.training_camp_id = ctp.training_camp_id
  16. <if test="params.userId != null and params.userId != ''">
  17. left join fs_course_watch_log cu on cu.period_id = ctp.period_id
  18. </if>
  19. <where>
  20. ctc.del_flag ='0'
  21. <if test="params.trainingCampName != null and params.trainingCampName != ''">
  22. and ctc.training_camp_name like concat('%',#{params.trainingCampName},'%')
  23. </if>
  24. <if test="params.companyId != null and params.companyId != ''">
  25. and ctp.company_id like concat('%',#{params.companyId},'%')
  26. </if>
  27. <if test="params.userIds != null and params.userIds != ''">
  28. and ctc.user_id =#{params.userIds}
  29. </if>
  30. <if test="params.userId != null and params.userId != ''">
  31. and cu.user_id = #{params.userId}
  32. </if>
  33. </where>
  34. group by ctc.training_camp_id, ctc.training_camp_name, ctc.order_number
  35. order by
  36. <choose>
  37. <when test="params.scs != null and params.scs.size() > 0">
  38. <foreach collection="params.scs" item="sc" separator=",">
  39. ${sc.column} ${sc.order}
  40. </foreach>
  41. </when>
  42. <otherwise>
  43. ctc.order_number desc, ctc.training_camp_id desc
  44. </otherwise>
  45. </choose>
  46. </select>
  47. <select id="selectCampListByMap" resultType="com.fs.his.vo.OptionsVO">
  48. select
  49. ctc.training_camp_id dictValue,
  50. ctc.training_camp_name dictLabel
  51. from fs_user_course_training_camp ctc
  52. <where>
  53. ctc.del_flag ='0'
  54. <if test="params.name != null and params.name != ''">
  55. and ctc.training_camp_name like concat('%', #{params.name}, '%')
  56. </if>
  57. </where>
  58. </select>
  59. <!-- APP端-查询训练营下拉列表 -->
  60. <select id="selectTrainingCampListForApp" resultType="com.fs.course.vo.FsUserCourseTrainingCampVO">
  61. SELECT DISTINCT
  62. ctc.training_camp_id AS trainingCampId,
  63. ctc.training_camp_name AS trainingCampName,
  64. ctc.order_number
  65. FROM fs_user_course_training_camp ctc
  66. INNER JOIN fs_user_course_period period
  67. ON ctc.training_camp_id = period.training_camp_id
  68. AND period.del_flag = '0'
  69. <where>
  70. ctc.del_flag = '0'
  71. <if test="params.companyId != null and params.companyId != ''">
  72. AND period.company_id LIKE CONCAT('%', #{params.companyId}, '%')
  73. </if>
  74. <if test="params.trainingCampName != null and params.trainingCampName != ''">
  75. AND ctc.training_camp_name LIKE CONCAT('%', #{params.trainingCampName}, '%')
  76. </if>
  77. </where>
  78. ORDER BY ctc.order_number DESC, ctc.training_camp_id DESC
  79. </select>
  80. </mapper>