SyMajorMapper.xml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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.ruoyi.sy.mapper.SyMajorMapper">
  6. <resultMap type="SyMajor" id="SyMajorResult">
  7. <result property="id" column="id" />
  8. <result property="code" column="code" />
  9. <result property="parentCode" column="parent_code" />
  10. <result property="name" column="name" />
  11. <result property="examType" column="exam_type" />
  12. <result property="type" column="type" />
  13. <result property="level" column="level" />
  14. <result property="ancestors" column="ancestors" />
  15. <result property="childCount" column="child_count" />
  16. <result property="grandchildCount" column="grandchild_count" />
  17. <result property="learnYearArab" column="learn_year_arab" />
  18. </resultMap>
  19. <sql id="selectSyMajorVo">
  20. select id, code, parent_code, name, exam_type, type, level, ancestors, child_count, grandchild_count, learn_year_arab from sy_major
  21. </sql>
  22. <select id="selectSyMajorList" parameterType="SyMajor" resultMap="SyMajorResult">
  23. <include refid="selectSyMajorVo"/>
  24. <where>
  25. <if test="code != null and code != ''"> and code = #{code}</if>
  26. <if test="parentCode != null and parentCode != ''"> and parent_code = #{parentCode}</if>
  27. <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  28. <if test="examType != null and examType != ''"> and exam_type = #{examType}</if>
  29. <if test="type != null and type != ''"> and type = #{type}</if>
  30. <if test="level != null "> and level &lt;= #{level}</if>
  31. <if test="ancestors != null and ancestors != ''"> and ancestors = #{ancestors}</if>
  32. <if test="childCount != null "> and child_count = #{childCount}</if>
  33. <if test="grandchildCount != null "> and grandchild_count = #{grandchildCount}</if>
  34. </where>
  35. order by code
  36. </select>
  37. <select id="selectSyMajorAndChildrenByCode" parameterType="SyMajor" resultMap="SyMajorResult">
  38. <include refid="selectSyMajorVo"/>
  39. <where>
  40. <if test="level != null"> and level &gt; #{level}</if>
  41. <if test="examType != null"> and exam_type = #{examType}</if>
  42. <if test="code != null and code != ''">
  43. and ( code=#{code} or find_in_set(#{code}, ancestors) )
  44. </if>
  45. </where>
  46. </select>
  47. <select id="selectSyMajorById" parameterType="Long" resultMap="SyMajorResult">
  48. <include refid="selectSyMajorVo"/>
  49. where id = #{id}
  50. </select>
  51. <select id="selectSyMajorByLevel" resultMap="SyMajorResult">
  52. <include refid="selectSyMajorVo"/>
  53. where level = #{level} and exam_type = #{examType}
  54. </select>
  55. <select id="selectSyMajorByCode" resultMap="SyMajorResult">
  56. <include refid="selectSyMajorVo"/>
  57. where exam_type = #{examType} and code = #{code}
  58. </select>
  59. <insert id="insertSyMajor" parameterType="SyMajor" useGeneratedKeys="true" keyProperty="id">
  60. insert into sy_major
  61. <trim prefix="(" suffix=")" suffixOverrides=",">
  62. <if test="code != null">code,</if>
  63. <if test="parentCode != null">parent_code,</if>
  64. <if test="name != null">name,</if>
  65. <if test="examType != null">exam_type,</if>
  66. <if test="type != null">type,</if>
  67. <if test="level != null">level,</if>
  68. <if test="ancestors != null">ancestors,</if>
  69. <if test="childCount != null">child_count,</if>
  70. <if test="grandchildCount != null">grandchild_count,</if>
  71. </trim>
  72. <trim prefix="values (" suffix=")" suffixOverrides=",">
  73. <if test="code != null">#{code},</if>
  74. <if test="parentCode != null">#{parentCode},</if>
  75. <if test="name != null">#{name},</if>
  76. <if test="examType != null">#{examType},</if>
  77. <if test="type != null">#{type},</if>
  78. <if test="level != null">#{level},</if>
  79. <if test="ancestors != null">#{ancestors},</if>
  80. <if test="childCount != null">#{childCount},</if>
  81. <if test="grandchildCount != null">#{grandchildCount},</if>
  82. </trim>
  83. </insert>
  84. <update id="updateSyMajor" parameterType="SyMajor">
  85. update sy_major
  86. <trim prefix="SET" suffixOverrides=",">
  87. <if test="code != null">code = #{code},</if>
  88. <if test="parentCode != null">parent_code = #{parentCode},</if>
  89. <if test="name != null">name = #{name},</if>
  90. <if test="examType != null">exam_type = #{examType},</if>
  91. <if test="type != null">type = #{type},</if>
  92. <if test="level != null">level = #{level},</if>
  93. <if test="ancestors != null">ancestors = #{ancestors},</if>
  94. <if test="childCount != null">child_count = #{childCount},</if>
  95. <if test="grandchildCount != null">grandchild_count = #{grandchildCount},</if>
  96. </trim>
  97. where id = #{id}
  98. </update>
  99. <delete id="deleteSyMajorById" parameterType="Long">
  100. delete from sy_major where id = #{id}
  101. </delete>
  102. <delete id="deleteSyMajorByIds" parameterType="String">
  103. delete from sy_major where id in
  104. <foreach item="id" collection="array" open="(" separator="," close=")">
  105. #{id}
  106. </foreach>
  107. </delete>
  108. </mapper>