BaseDictDao.xml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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.liang.dao.BaseDictDao">
  4. <!--查询一个枚举,公共方法-->
  5. <select id="getDictByCode" parameterType="string" resultType="map">
  6. select dict_id, dict_key as code, dict_value as name
  7. from sys_dict_info
  8. where status = '0'
  9. and del_flag = '0'
  10. and dict_code = #{_parameter}
  11. order by order_num
  12. </select>
  13. <resultMap id="SysDict" type="com.liang.entity.DictInfo">
  14. <id column="dict_id" jdbcType="VARCHAR" property="dictId"/>
  15. <result column="descript" jdbcType="VARCHAR" property="descript"/>
  16. <result column="dict_code" jdbcType="VARCHAR" property="dictCode"/>
  17. <result column="dict_name" jdbcType="VARCHAR" property="dictName"/>
  18. <result column="dict_key" jdbcType="VARCHAR" property="dictKey"/>
  19. <result column="dict_value" jdbcType="VARCHAR" property="dictValue"/>
  20. <result column="order_num" jdbcType="INTEGER" property="orderNum"/>
  21. <result column="status" jdbcType="CHAR" property="status"/>
  22. <result column="create_user" jdbcType="VARCHAR" property="createUser"/>
  23. <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
  24. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
  25. <result column="del_flag" jdbcType="CHAR" property="delFlag"/>
  26. <result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
  27. </resultMap>
  28. <!--根据条件,查询所有枚举-->
  29. <select id="getAllBaseDict" resultMap="SysDict" parameterType="map">
  30. select
  31. max(dict_code) as dict_code,
  32. max(dict_name) as dict_name,
  33. max(status) as status,
  34. max(create_user) as create_user,
  35. max(create_time) as create_time,
  36. max(del_flag) as del_flag,
  37. max(update_time) as update_time,
  38. max(update_user) as update_user,
  39. max(descript) as descript
  40. from sys_dict_info
  41. where del_flag = '0'
  42. <if test="dictCode != null and dictCode != ''">
  43. and dict_code like CONCAT('%',#{dictCode},'%')
  44. </if>
  45. <if test="dictName != null and dictName != ''">
  46. and dict_name like CONCAT('%',#{dictName},'%')
  47. </if>
  48. <if test="status != null and status != ''">
  49. and status = #{status}
  50. </if>
  51. group by dict_code
  52. order by dict_code
  53. </select>
  54. <!-- 判断字典code是否已存在 -->
  55. <select id="checkExistByDictCode" parameterType="string" resultType="integer">
  56. SELECT 1 FROM sys_dict_info WHERE del_flag = '0' and dict_code = #{_parameter} LIMIT 1
  57. </select>
  58. <!--根据条件,查询所有枚举-->
  59. <select id="getDictByDictCode" resultMap="SysDict" parameterType="java.lang.String">
  60. select * from sys_dict_info where del_flag = '0' and dict_code = #{_parameter}
  61. </select>
  62. <!--插入一个枚举-->
  63. <insert id="addOneDict" parameterType="com.liang.entity.DictInfo">
  64. insert into sys_dict_info (
  65. <if test="dictId != null and dictId != ''">dict_id,</if>
  66. <if test="dictCode != null and dictCode != ''">dict_code,</if>
  67. <if test="dictName != null and dictName != ''">dict_name,</if>
  68. <if test="dictKey != null and dictKey != ''">dict_key,</if>
  69. <if test="dictValue != null and dictValue != ''">dict_value,</if>
  70. <if test="orderNum != null">order_num,</if>
  71. <if test="createUser != null and createUser != ''">create_user,</if>
  72. <if test="descript != null and descript != ''">descript,</if>
  73. status,
  74. del_flag
  75. )
  76. values (
  77. <if test="dictId != null and dictId != ''">#{dictId},</if>
  78. <if test="dictCode != null and dictCode != ''">#{dictCode},</if>
  79. <if test="dictName != null and dictName != ''">#{dictName},</if>
  80. <if test="dictKey != null and dictKey != ''">#{dictKey},</if>
  81. <if test="dictValue != null and dictValue != ''">#{dictValue},</if>
  82. <if test="orderNum != null"> #{orderNum},</if>
  83. <if test="createUser != null and createUser != ''">#{createUser},</if>
  84. <if test="descript != null and descript != ''">#{descript},</if>
  85. #{status},
  86. #{delFlag}
  87. )
  88. </insert>
  89. <!--逻辑删除一个枚举-->
  90. <update id="deleteDict" parameterType="java.lang.String">
  91. update sys_dict_info set del_flag = '1' where dict_code = #{_parameter}
  92. </update>
  93. <!--物理删除一个枚举-->
  94. <delete id="realDeleteDict" parameterType="java.lang.String">
  95. delete from sys_dict_info where dict_code = #{_parameter}
  96. </delete>
  97. <!--禁用一个枚举-->
  98. <update id="forbidDict" parameterType="java.lang.String">
  99. update sys_dict_info set status = '1' where dict_code = #{_parameter}
  100. </update>
  101. <!--启用一个枚举-->
  102. <update id="enableDict" parameterType="java.lang.String">
  103. update sys_dict_info set status = '0' where dict_code = #{_parameter}
  104. </update>
  105. </mapper>