DictDataMapper.xml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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.juxiao.xchat.module.system.mapper.DictDataMapper">
  6. <resultMap type="com.juxiao.xchat.module.system.domain.DictData" id="DictDataResult">
  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, dict_sort, dict_label, dict_value, dict_type, css_class, list_class, is_default, status, create_by, create_time, remark
  23. from sys_dict_data
  24. </sql>
  25. <select id="selectDictDataList" parameterType="com.juxiao.xchat.module.system.domain.DictData" resultMap="DictDataResult">
  26. <include refid="selectDictDataVo"/>
  27. <where>
  28. <if test="dictType != null and dictType != ''">
  29. AND dict_type = #{dictType}
  30. </if>
  31. <if test="dictLabel != null and dictLabel != ''">
  32. AND dict_label like concat('%', #{dictLabel}, '%')
  33. </if>
  34. <if test="status != null and status != ''">
  35. AND status = #{status}
  36. </if>
  37. </where>
  38. </select>
  39. <select id="selectDictDataByType" parameterType="com.juxiao.xchat.module.system.domain.DictData" resultMap="DictDataResult">
  40. <include refid="selectDictDataVo"/>
  41. where status = '0' and dict_type = #{dictType} order by dict_sort asc
  42. </select>
  43. <select id="selectDictLabel" resultType="java.lang.String">
  44. select dict_label from sys_dict_data
  45. where dict_type = #{dictType} and dict_value = #{dictValue}
  46. </select>
  47. <select id="selectDictDataById" parameterType="java.lang.Long" resultMap="DictDataResult">
  48. <include refid="selectDictDataVo"/>
  49. where dict_code = #{dictCode}
  50. </select>
  51. <select id="countDictDataByType" resultType="java.lang.Integer">
  52. select count(1) from sys_dict_data where dict_type=#{dictType}
  53. </select>
  54. <delete id="deleteDictDataById" parameterType="java.lang.Long">
  55. delete from sys_dict_data where dict_code = #{dictCode}
  56. </delete>
  57. <delete id="deleteDictDataByIds" parameterType="java.lang.String">
  58. delete from sys_dict_data where dict_code in
  59. <foreach collection="array" item="dictCode" open="(" separator="," close=")">
  60. #{dictCode}
  61. </foreach>
  62. </delete>
  63. <update id="updateDictData" parameterType="com.juxiao.xchat.module.system.domain.DictData">
  64. update sys_dict_data
  65. <set>
  66. <if test="dictSort != null and dictSort != ''">dict_sort = #{dictSort},</if>
  67. <if test="dictLabel != null and dictLabel != ''">dict_label = #{dictLabel},</if>
  68. <if test="dictValue != null and dictValue != ''">dict_value = #{dictValue},</if>
  69. <if test="dictType != null and dictType != ''">dict_type = #{dictType},</if>
  70. <if test="cssClass != null">css_class = #{cssClass},</if>
  71. <if test="listClass != null">list_class = #{listClass},</if>
  72. <if test="isDefault != null and isDefault != ''">is_default = #{isDefault},</if>
  73. <if test="status != null">status = #{status},</if>
  74. <if test="remark != null">remark = #{remark},</if>
  75. <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
  76. update_time = sysdate()
  77. </set>
  78. where dict_code = #{dictCode}
  79. </update>
  80. <update id="updateDictDataType" parameterType="java.lang.String">
  81. update sys_dict_data set dict_type = #{newDictType} where dict_type = #{oldDictType}
  82. </update>
  83. <insert id="insertDictData" parameterType="com.juxiao.xchat.module.system.domain.DictData">
  84. insert into sys_dict_data(
  85. <if test="dictSort != null and dictSort != ''">dict_sort,</if>
  86. <if test="dictLabel != null and dictLabel != ''">dict_label,</if>
  87. <if test="dictValue != null and dictValue != ''">dict_value,</if>
  88. <if test="dictType != null and dictType != ''">dict_type,</if>
  89. <if test="cssClass != null and cssClass != ''">css_class,</if>
  90. <if test="listClass != null and listClass != ''">list_class,</if>
  91. <if test="isDefault != null and isDefault != ''">is_default,</if>
  92. <if test="status != null">status,</if>
  93. <if test="remark != null and remark != ''">remark,</if>
  94. <if test="createBy != null and createBy != ''">create_by,</if>
  95. create_time
  96. )values(
  97. <if test="dictSort != null and dictSort != ''">#{dictSort},</if>
  98. <if test="dictLabel != null and dictLabel != ''">#{dictLabel},</if>
  99. <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
  100. <if test="dictType != null and dictType != ''">#{dictType},</if>
  101. <if test="cssClass != null and cssClass != ''">#{cssClass},</if>
  102. <if test="listClass != null and listClass != ''">#{listClass},</if>
  103. <if test="isDefault != null and isDefault != ''">#{isDefault},</if>
  104. <if test="status != null">#{status},</if>
  105. <if test="remark != null and remark != ''">#{remark},</if>
  106. <if test="createBy != null and createBy != ''">#{createBy},</if>
  107. sysdate()
  108. )
  109. </insert>
  110. <select id="selectDictLabelByDictValue" resultType="java.lang.String">
  111. select dict_value from sys_dict_data
  112. where dict_type = #{dictType} and dict_label = #{dictLabel}
  113. </select>
  114. </mapper>