MajorMapper.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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.course.mapper.MajorMapper">
  6. <resultMap type="com.zhongzheng.modules.course.domain.Major" id="MajorResult">
  7. <result property="id" column="id"/>
  8. <result property="remark" column="remark"/>
  9. <result property="createTime" column="create_time"/>
  10. <result property="updateTime" column="update_time"/>
  11. <result property="categoryName" column="category_name"/>
  12. <result property="majorReferral" column="major_referral"/>
  13. <result property="labelId" column="label_id"/>
  14. <result property="status" column="status"/>
  15. <result property="encoder" column="encoder"/>
  16. <result property="sort" column="sort"/>
  17. </resultMap>
  18. <resultMap type="com.zhongzheng.modules.course.vo.CourseProjectTypeVo" id="CourseProjectTypeVoResult">
  19. <result property="id" column="id"/>
  20. <result property="projectName" column="project_name"/>
  21. <result property="encoder" column="encoder"/>
  22. <result property="remark" column="remark"/>
  23. <result property="educationId" column="education_id"/>
  24. <result property="educationName" column="education_name"/>
  25. <result property="status" column="status"/>
  26. </resultMap>
  27. <select id="selectProject" parameterType="com.zhongzheng.modules.course.bo.CourseProjectTypeQueryBo" resultMap="CourseProjectTypeVoResult">
  28. SELECT
  29. p.*,
  30. e.education_name
  31. FROM
  32. major_project j
  33. LEFT JOIN course_project_type p on p.id=j.project_id
  34. LEFT JOIN course_education_type e ON p.education_id = e.id
  35. where 1=1
  36. <if test="status != null and status.size()!=0 ">
  37. AND p.status in
  38. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  39. #{item}
  40. </foreach>
  41. </if>
  42. <if test="id != null and id!=0 ">
  43. AND j.major_id = #{id}
  44. </if>
  45. order by j.update_time desc
  46. </select>
  47. <select id="queryList" parameterType="com.zhongzheng.modules.course.bo.MajorQueryBo" resultMap="MajorResult">
  48. SELECT
  49. m.*
  50. FROM
  51. major m
  52. LEFT JOIN major_project p ON p.major_id = m.id
  53. LEFT JOIN course_business b on b.project_id =p.project_id
  54. LEFT JOIN course_project_type t on p.project_id=t.id
  55. LEFT JOIN course_education_type e on t.education_id = e.id
  56. WHERE
  57. 1 =1
  58. <if test="status != null and status.size()!=0 ">
  59. AND m.status in
  60. <foreach collection="status" item="item" index="index" open="(" close=")" separator=",">
  61. #{item}
  62. </foreach>
  63. </if>
  64. <if test="id != null and id!=0 ">
  65. AND m.id = #{id}
  66. </if>
  67. <if test="educationId != null and educationId!=0 ">
  68. AND e.id = #{educationId}
  69. </if>
  70. <if test="projectId != null and projectId!=0 ">
  71. AND t.id = #{projectId}
  72. </if>
  73. <if test="categoryName != null and categoryName!='' ">
  74. AND m.category_name like concat('%', #{categoryName}, '%')
  75. </if>
  76. <if test="businessId != null and businessId!=0 ">
  77. AND b.id = #{businessId}
  78. </if>
  79. group by m.id
  80. order by m.sort
  81. </select>
  82. <select id="countNum" parameterType="com.zhongzheng.modules.course.bo.MajorQueryBo" resultType="Integer">
  83. SELECT
  84. count(*)
  85. FROM
  86. major m
  87. LEFT JOIN major_project mp ON m.id = mp.major_id
  88. WHERE
  89. m.`status` != -1 and
  90. m.category_name = #{categoryName}
  91. <if test="majorProjects != null and majorProjects.length!=0 ">
  92. AND mp.project_id in
  93. <foreach collection="majorProjects" item="item" index="index" open="(" close=")" separator=",">
  94. #{item}
  95. </foreach>
  96. </if>
  97. <if test="id != null and id!='' ">
  98. and m.id != #{id}
  99. </if>
  100. </select>
  101. <select id="getMajorByTenant" parameterType="map" resultType="com.zhongzheng.modules.course.domain.Major">
  102. SELECT * FROM major where encoder = #{encoder} and tenant_id = #{newTenantId}
  103. </select>
  104. <select id="getMajorByIdNoTenant" parameterType="java.lang.Long" resultType="com.zhongzheng.modules.course.domain.Major">
  105. SELECT * FROM major where id = #{majorId}
  106. </select>
  107. <select id="getOnebyName" resultType="com.zhongzheng.modules.course.domain.Major">
  108. SELECT
  109. cs.*
  110. FROM
  111. major cs
  112. LEFT JOIN major_project csp ON cs.id = csp.major_id
  113. WHERE
  114. csp.project_id = #{projectId}
  115. AND cs.category_name = #{name}
  116. AND cs.`status` = 1
  117. LIMIT 1
  118. </select>
  119. </mapper>