DictMapper.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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.huaxu.dao.DictMapper">
  4. <!-- 结果集 -->
  5. <resultMap type="com.huaxu.entity.Dict" id="DictMap">
  6. <result property="id" column="ID" jdbcType="INTEGER"/>
  7. <result property="dictName" column="DICT_NAME" jdbcType="VARCHAR"/>
  8. <result property="dictCode" column="DICT_CODE" jdbcType="VARCHAR"/>
  9. <result property="dictValue" column="DICT_VALUE" jdbcType="VARCHAR"/>
  10. <result property="parentDictId" column="PARENT_DICT_ID" jdbcType="INTEGER"/>
  11. <result property="remark" column="REMARK" jdbcType="VARCHAR"/>
  12. <result property="status" column="STATUS" jdbcType="INTEGER"/>
  13. <result property="createBy" column="CREATE_BY" jdbcType="VARCHAR"/>
  14. <result property="dateCreate" column="DATE_CREATE" jdbcType="TIMESTAMP"/>
  15. <result property="updateBy" column="UPDATE_BY" jdbcType="VARCHAR"/>
  16. <result property="dateUpdate" column="DATE_UPDATE" jdbcType="TIMESTAMP"/>
  17. </resultMap>
  18. <!-- 基本字段 -->
  19. <sql id="Base_Column_List">
  20. ID,DICT_NAME,DICT_CODE,DICT_VALUE, PARENT_DICT_ID, REMARK, STATUS, DATE_CREATE,CREATE_BY,DATE_UPDATE,UPDATE_BY</sql>
  21. <!-- 查询单个 -->
  22. <select id="selectById" resultMap="DictMap">
  23. select
  24. <include refid="Base_Column_List"/>
  25. from uims_dict
  26. where ID = #{id}
  27. </select>
  28. <!-- 查询全部 -->
  29. <select id="selectAll" resultMap="DictMap">
  30. select
  31. <include refid="Base_Column_List"/>
  32. from uims_dict
  33. </select>
  34. <!--通过实体作为筛选条件查询-->
  35. <select id="selectList" resultMap="DictMap">
  36. select
  37. <include refid="Base_Column_List"/>
  38. from uims_dict
  39. <where>
  40. <if test="id != null">
  41. and ID = #{id}
  42. </if>
  43. <if test="dictName != null and dictName != ''">
  44. and DICT_NAME = #{dictName}
  45. </if>
  46. <if test="dictCode != null and dictCode != ''">
  47. and (DICT_CODE LIKE CONCAT('%',#{dictCode},'%')
  48. or DICT_VALUE LIKE CONCAT('%',#{dictCode},'%'))
  49. </if>
  50. <if test="parentDictId != null and parentDictId != ''">
  51. and PARENT_DICT_ID = #{parentDictId}
  52. </if>
  53. <if test="parentDictCode != null and parentDictCode != ''">
  54. and PARENT_DICT_ID in (select ID from uims_dict where DICT_CODE=#{parentDictCode})
  55. </if>
  56. and STATUS =1
  57. </where>
  58. order by DICT_NAME,DICT_VALUE
  59. </select>
  60. <!-- 新增所有列 -->
  61. <insert id="insert" keyProperty="id" useGeneratedKeys="true">
  62. insert into uims_dict(ID,DICT_NAME,DICT_CODE,DICT_VALUE,PARENT_DICT_ID, REMARK, STATUS, CREATE_BY,DATE_CREATE,UPDATE_BY,DATE_UPDATE)
  63. values ( #{id}, #{dictName}, #{dictCode}, #{dictValue}, #{parentDictId}, #{remark}, 1, #{createBy}, #{dateCreate}, #{updateBy}, #{dateUpdate})
  64. </insert>
  65. <!-- 批量新增 -->
  66. <insert id="batchInsert">
  67. insert into uims_dict(ID,DICT_NAME,DICT_CODE,DICT_VALUE,PARENT_DICT_ID, REMARK, STATUS, CREATE_BY,DATE_CREATE,UPDATE_BY,DATE_UPDATE)
  68. values
  69. <foreach collection="dicts" item="item" index="index" separator=",">
  70. (
  71. #{item.id}, #{item.dictName}, #{item.dictCode}, #{item.dictValue}, #{item.parentDictId}, #{item.remark}, 1,
  72. #{item.createBy}, #{item.dateCreate}, #{item.updateBy}, #{item.dateUpdate})
  73. </foreach>
  74. </insert>
  75. <!-- 通过主键修改数据 -->
  76. <update id="update">
  77. update uims.uims_dict
  78. <set>
  79. <if test="dictName != null and dictName != ''">
  80. DICT_NAME = #{dictName},
  81. </if>
  82. <if test="dictCode != null and dictCode != ''">
  83. DICT_CODE = #{dictCode},
  84. </if>
  85. <if test="dictValue != null and dictValue != ''">
  86. DICT_VALUE = #{dictValue},
  87. </if>
  88. <if test="parentDictId != null and parentDictId != ''">
  89. PARENT_DICT_ID = #{parentDictId},
  90. </if>
  91. <if test="remark != null and remark != ''">
  92. REMARK = #{remark},
  93. </if>
  94. <if test="status != null">
  95. STATUS = #{status},
  96. </if>
  97. <if test="createBy != null and createBy != ''">
  98. CREATE_BY = #{createBy},
  99. </if>
  100. <if test="dateCreate != null">
  101. DATE_CREATE = #{dateCreate},
  102. </if>
  103. <if test="updateBy != null and updateBy != ''">
  104. UPDATE_BY = #{updateBy},
  105. </if>
  106. <if test="dateUpdate != null">
  107. DATE_UPDATE = #{dateUpdate},
  108. </if>
  109. </set>
  110. where ID = #{id}
  111. </update>
  112. <!--通过主键删除-物理删除-->
  113. <!--<delete id="deleteById" parameterType="java.util.List">
  114. delete from uims_dict where ID IN
  115. <foreach item="item" index="index" collection="ids" open="("
  116. separator="," close=")">
  117. #{item}
  118. </foreach>
  119. or PARENT_DICT_ID in
  120. <foreach item="item" index="index" collection="ids" open="("
  121. separator="," close=")">
  122. #{item}
  123. </foreach>
  124. </delete>-->
  125. <!--通过主键删除-逻辑删除-->
  126. <update id="deleteById" parameterType="java.util.List">
  127. update uims.uims_dict
  128. set STATUS=0
  129. where ID in
  130. <foreach item="item" index="index" collection="ids" open="("
  131. separator="," close=")">
  132. #{item}
  133. </foreach>
  134. or PARENT_DICT_ID in
  135. <foreach item="item" index="index" collection="ids" open="("
  136. separator="," close=")">
  137. #{item}
  138. </foreach>
  139. </update>
  140. <!-- 总数 -->
  141. <select id="count" resultType="int">
  142. select count(*) from uims_dict
  143. </select>
  144. <select id="selectPage" resultMap="DictMap">
  145. select
  146. <include refid="Base_Column_List"/>
  147. from uims_dict
  148. <where>
  149. <if test="dict.id != null">
  150. and ID = #{dict.id}
  151. </if>
  152. <if test="dict.parentDictId == null and dict.dictCode != null and dict.dictCode != ''">
  153. and (DICT_NAME LIKE CONCAT('%',#{dict.dictCode},'%')
  154. or DICT_CODE LIKE CONCAT('%',#{dict.dictCode},'%'))
  155. </if>
  156. <if test="dict.parentDictId != null and dict.dictCode != null and dict.dictCode != ''">
  157. and (DICT_VALUE LIKE CONCAT('%',#{dict.dictCode},'%')
  158. or DICT_CODE LIKE CONCAT('%',#{dict.dictCode},'%'))
  159. </if>
  160. <if test="dict.parentDictId != null ">
  161. and PARENT_DICT_ID = #{dict.parentDictId}
  162. </if>
  163. <if test="dict.parentDictId == null">
  164. and PARENT_DICT_ID IS NULL
  165. </if>
  166. and STATUS =1
  167. </where>
  168. order by DICT_NAME,DICT_VALUE
  169. </select>
  170. </mapper>