SysDictDataMapper.xml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.system.mapper.SysDictDataMapper">
  6. <resultMap type="SysDictData" id="SysDictDataResult">
  7. <id property="dictCode" column="dict_code"/>
  8. <result property="dictSort" column="dict_sort"/>
  9. <result property="dictLabel" column="dict_label"/>
  10. <result property="dictValue" column="dict_value"/>
  11. <result property="dictType" column="dict_type"/>
  12. <result property="cssClass" column="css_class"/>
  13. <result property="listClass" column="list_class"/>
  14. <result property="isDefault" column="is_default"/>
  15. <result property="status" column="status"/>
  16. <result property="createBy" column="create_by"/>
  17. <result property="createTime" column="create_time"/>
  18. <result property="updateBy" column="update_by"/>
  19. <result property="updateTime" column="update_time"/>
  20. </resultMap>
  21. <sql id="selectDictDataVo">
  22. select dict_code,
  23. dict_sort,
  24. dict_label,
  25. dict_value,
  26. dict_type,
  27. css_class,
  28. list_class,
  29. is_default,
  30. status,
  31. create_by,
  32. create_time,
  33. remark
  34. from sys_dict_data
  35. </sql>
  36. <select id="selectDictDataList" parameterType="SysDictData" resultMap="SysDictDataResult">
  37. <include refid="selectDictDataVo"/>
  38. <where>
  39. <if test="dictType != null and dictType != ''">
  40. AND dict_type = #{dictType}
  41. </if>
  42. <if test="dictLabel != null and dictLabel != ''">
  43. AND dict_label like concat('%', #{dictLabel}, '%')
  44. </if>
  45. <if test="status != null and status != ''">
  46. AND status = #{status}
  47. </if>
  48. </where>
  49. order by dict_sort asc
  50. </select>
  51. <select id="selectDictDataByType" parameterType="SysDictData" resultMap="SysDictDataResult">
  52. <include refid="selectDictDataVo"/>
  53. where status = '0' and dict_type = #{dictType} order by dict_sort asc
  54. </select>
  55. <select id="selectDictLabel" resultType="String">
  56. select GROUP_CONCAT(dict_label SEPARATOR ', ') AS dict_label
  57. from sys_dict_data
  58. where dict_type = #{dictType}
  59. and dict_value = #{dictValue}
  60. </select>
  61. <select id="selectDictValue" resultType="String">
  62. select dict_value
  63. from sys_dict_data
  64. where dict_type = #{dictType}
  65. and dict_label = #{dictLabel}
  66. </select>
  67. <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
  68. <include refid="selectDictDataVo"/>
  69. where dict_code = #{dictCode}
  70. </select>
  71. <select id="countDictDataByType" resultType="Integer">
  72. select count(1)
  73. from sys_dict_data
  74. where dict_type = #{dictType}
  75. </select>
  76. <select id="selectByTypes" resultMap="SysDictDataResult">
  77. select
  78. dict_code, dict_label, dict_value, dict_type
  79. from sys_dict_data where dict_type in
  80. <foreach collection="typeList" item="dictCode" open="(" separator="," close=")">
  81. #{dictCode}
  82. </foreach>
  83. and status = 0
  84. </select>
  85. <select id="getDictLabelMultipleChoice" resultType="java.lang.String">
  86. select dict_label
  87. from sys_dict_data
  88. where dict_type = #{dictType}
  89. and FIND_IN_SET(dict_value, #{dictValue})
  90. </select>
  91. <select id="selectDictLabels" resultType="java.lang.String">
  92. select GROUP_CONCAT(dict_label SEPARATOR ', ') AS dict_label
  93. from sys_dict_data
  94. where dict_type = #{dictType}
  95. and find_in_set(dict_value, #{dictValues})
  96. </select>
  97. <select id="getOne" parameterType="SysDictData" resultMap="SysDictDataResult">
  98. <include refid="selectDictDataVo"/>
  99. <where>
  100. <if test="dictType != null and dictType != ''">
  101. AND dict_type = #{dictType}
  102. </if>
  103. <if test="dictValue != null and dictValue != ''">
  104. AND dict_value = #{dictValue}
  105. </if>
  106. </where>
  107. </select>
  108. <delete id="deleteDictDataById" parameterType="Long">
  109. delete
  110. from sys_dict_data
  111. where dict_code = #{dictCode}
  112. </delete>
  113. <delete id="deleteDictDataByIds" parameterType="Long">
  114. delete from sys_dict_data where dict_code in
  115. <foreach collection="array" item="dictCode" open="(" separator="," close=")">
  116. #{dictCode}
  117. </foreach>
  118. </delete>
  119. <update id="updateDictData" parameterType="SysDictData">
  120. update sys_dict_data
  121. <set>
  122. <if test="dictSort != null">dict_sort = #{dictSort},</if>
  123. <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
  124. <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
  125. <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
  126. <if test="cssClass != null">css_class = #{cssClass},</if>
  127. <if test="listClass != null">list_class = #{listClass},</if>
  128. <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
  129. <if test="status != null">status = #{status},</if>
  130. <if test="remark != null">remark = #{remark},</if>
  131. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  132. update_time = sysdate()
  133. </set>
  134. where dict_code = #{dictCode}
  135. </update>
  136. <update id="updateDictDataType" parameterType="String">
  137. update sys_dict_data
  138. set dict_type = #{newDictType}
  139. where dict_type = #{oldDictType}
  140. </update>
  141. <insert id="insertDictData" parameterType="SysDictData">
  142. insert into sys_dict_data(
  143. <if test="dictSort != null">dict_sort,</if>
  144. <if test="dictLabel != null and dictLabel != ''">dict_label,</if>
  145. <if test="dictValue != null and dictValue != ''">dict_value,</if>
  146. <if test="dictType != null and dictType != ''">dict_type,</if>
  147. <if test="cssClass != null and cssClass != ''">css_class,</if>
  148. <if test="listClass != null and listClass != ''">list_class,</if>
  149. <if test="isDefault != null and isDefault != ''">is_default,</if>
  150. <if test="status != null">status,</if>
  151. <if test="remark != null and remark != ''">remark,</if>
  152. <if test="createBy != null and createBy != ''">create_by,</if>
  153. create_time
  154. )values(
  155. <if test="dictSort != null">#{dictSort},</if>
  156. <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
  157. <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
  158. <if test="dictType != null and dictType != ''">#{dictType},</if>
  159. <if test="cssClass != null and cssClass != ''">#{cssClass},</if>
  160. <if test="listClass != null and listClass != ''">#{listClass},</if>
  161. <if test="isDefault != null and isDefault != ''">#{isDefault},</if>
  162. <if test="status != null">#{status},</if>
  163. <if test="remark != null and remark != ''">#{remark},</if>
  164. <if test="createBy != null and createBy != ''">#{createBy},</if>
  165. sysdate()
  166. )
  167. </insert>
  168. </mapper>