SysDictDataMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.yami.shop.dao.SysDictDataMapper">
  4. <resultMap type="com.yami.shop.bean.model.SysDictData" id="SysDictDataResult">
  5. <id property="dictCode" column="dict_code" />
  6. <result property="dictSort" column="dict_sort" />
  7. <result property="dictLabel" column="dict_label" />
  8. <result property="dictValue" column="dict_value" />
  9. <result property="dictType" column="dict_type" />
  10. <result property="cssClass" column="css_class" />
  11. <result property="listClass" column="list_class" />
  12. <result property="isDefault" column="is_default" />
  13. <result property="status" column="status" />
  14. <result property="createBy" column="create_by" />
  15. <result property="createTime" column="create_time" />
  16. <result property="updateBy" column="update_by" />
  17. <result property="updateTime" column="update_time" />
  18. </resultMap>
  19. <sql id="selectDictDataVo">
  20. select dict_code, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
  21. from sys_dict_data
  22. </sql>
  23. <select id="selectDictDataList" parameterType="com.yami.shop.bean.model.SysDictData" resultMap="SysDictDataResult">
  24. <include refid="selectDictDataVo"/>
  25. <where>
  26. <if test="dictType != null and dictType != ''">
  27. AND dict_type = #{dictType}
  28. </if>
  29. <if test="dictLabel != null and dictLabel != ''">
  30. AND dict_label like concat('%', #{dictLabel}, '%')
  31. </if>
  32. <if test="status != null and status != ''">
  33. AND status = #{status}
  34. </if>
  35. </where>
  36. order by dict_sort asc
  37. </select>
  38. <select id="selectDictDataByType" parameterType="String" resultMap="SysDictDataResult">
  39. <include refid="selectDictDataVo"/>
  40. where status = '0' and dict_type = #{dictType} order by dict_sort asc
  41. </select>
  42. <select id="selectDictLabel" resultType="String">
  43. select dict_label from sys_dict_data
  44. where dict_type = #{dictType} and dict_value = #{dictValue}
  45. </select>
  46. <select id="selectDictDataById" parameterType="Long" resultMap="SysDictDataResult">
  47. <include refid="selectDictDataVo"/>
  48. where dict_code = #{dictCode}
  49. </select>
  50. <select id="countDictDataByType" resultType="Integer">
  51. select count(1) from sys_dict_data where dict_type=#{dictType} and status =0
  52. </select>
  53. <select id="selectDictTypePage" resultType="com.yami.shop.bean.model.SysDictData">
  54. <include refid="selectDictDataVo"/>
  55. <where>
  56. <if test="dictData.dictType != null and dictData.dictType != ''">
  57. AND dict_type = #{dictData.dictType}
  58. </if>
  59. <if test="dictData.dictLabel != null and dictData.dictLabel != ''">
  60. AND dict_label like concat('%', #{dictData.dictLabel}, '%')
  61. </if>
  62. <if test="dictData.status != null and dictData.status != ''">
  63. AND status = #{dictData.status}
  64. </if>
  65. </where>
  66. order by dict_sort asc
  67. </select>
  68. <select id="findExist" resultType="java.lang.Boolean">
  69. SELECT CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END
  70. FROM sys_dict_data
  71. <where>
  72. <if test="dict.dictType != null and dict.dictType != ''">
  73. AND dict_type = #{dict.dictType}
  74. </if>
  75. <if test="dict.dictValue != null and dict.dictValue != ''">
  76. AND dict_value = #{dict.dictValue}
  77. </if>
  78. <if test="dict.dictCode != null">
  79. AND dict_code != #{dict.dictCode}
  80. </if>
  81. </where>
  82. LIMIT 1
  83. </select>
  84. <delete id="deleteDictDataById" parameterType="Long">
  85. delete from sys_dict_data where dict_code = #{dictCode}
  86. </delete>
  87. <delete id="deleteDictDataByIds" parameterType="Long">
  88. delete from sys_dict_data where dict_code in
  89. <foreach collection="array" item="dictCode" open="(" separator="," close=")">
  90. #{dictCode}
  91. </foreach>
  92. </delete>
  93. <delete id="deleteDictDataByDictType">
  94. delete from sys_dict_data where dict_type = #{dictType}
  95. </delete>
  96. <update id="updateDictData" parameterType="com.yami.shop.bean.model.SysDictData">
  97. update sys_dict_data
  98. <set>
  99. <if test="dictSort != null">dict_sort = #{dictSort},</if>
  100. <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
  101. <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
  102. <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
  103. <if test="cssClass != null">css_class = #{cssClass},</if>
  104. <if test="listClass != null">list_class = #{listClass},</if>
  105. <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
  106. <if test="status != null">status = #{status},</if>
  107. <if test="remark != null">remark = #{remark},</if>
  108. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  109. update_time = sysdate()
  110. </set>
  111. where dict_code = #{dictCode}
  112. </update>
  113. <update id="updateDictDataType" parameterType="String">
  114. update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
  115. </update>
  116. <insert id="insertDictData" parameterType="com.yami.shop.bean.model.SysDictData">
  117. insert into sys_dict_data(
  118. <if test="dictSort != null">dict_sort,</if>
  119. <if test="dictLabel != null and dictLabel != ''">dict_label,</if>
  120. <if test="dictValue != null and dictValue != ''">dict_value,</if>
  121. <if test="dictType != null and dictType != ''">dict_type,</if>
  122. <if test="cssClass != null and cssClass != ''">css_class,</if>
  123. <if test="listClass != null and listClass != ''">list_class,</if>
  124. <if test="isDefault != null and isDefault != ''">is_default,</if>
  125. <if test="status != null">status,</if>
  126. <if test="remark != null and remark != ''">remark,</if>
  127. <if test="createBy != null and createBy != ''">create_by,</if>
  128. create_time
  129. )values(
  130. <if test="dictSort != null">#{dictSort},</if>
  131. <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
  132. <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
  133. <if test="dictType != null and dictType != ''">#{dictType},</if>
  134. <if test="cssClass != null and cssClass != ''">#{cssClass},</if>
  135. <if test="listClass != null and listClass != ''">#{listClass},</if>
  136. <if test="isDefault != null and isDefault != ''">#{isDefault},</if>
  137. <if test="status != null">#{status},</if>
  138. <if test="remark != null and remark != ''">#{remark},</if>
  139. <if test="createBy != null and createBy != ''">#{createBy},</if>
  140. sysdate()
  141. )
  142. </insert>
  143. </mapper>