DataDictionary.xml 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  4. <!-- namespace必须指向DAO接口 -->
  5. <mapper namespace="com.jpsoft.employment.modules.sys.dao.DataDictionaryDAO">
  6. <resultMap id="DataDictionaryMap" type="com.jpsoft.employment.modules.sys.entity.DataDictionary">
  7. <id property="id" column="id_"/>
  8. <result property="name" column="name_"/>
  9. <result property="value" column="value_"/>
  10. <result property="sortNo" column="sort_no"/>
  11. <result property="parentId" column="parent_id"/>
  12. <result property="parentName" column="parent_name"/>
  13. <result property="dataType" column="data_type"/>
  14. <result property="createBy" column="create_by"/>
  15. <result property="createDate" column="create_date"/>
  16. <result property="updateBy" column="update_by"/>
  17. <result property="updateDate" column="update_date"/>
  18. <result property="activated" column="activated_"/>
  19. <result property="delFlag" column="del_flag"/>
  20. </resultMap>
  21. <insert id="insert" parameterType="com.jpsoft.employment.modules.sys.entity.DataDictionary">
  22. <!--
  23. <selectKey resultType="java.lang.String" order="BEFORE" keyProperty="id">
  24. select sys_guid() from dual
  25. </selectKey>
  26. -->
  27. <![CDATA[
  28. insert into sys_data_dictionary
  29. (id_,name_,value_,sort_no,parent_id,data_type,create_by,create_date,update_by,update_date,activated_,del_flag)
  30. values
  31. (
  32. #{id,jdbcType=VARCHAR}
  33. ,#{name,jdbcType=VARCHAR}
  34. ,#{value,jdbcType=VARCHAR}
  35. ,#{sortNo,jdbcType= NUMERIC }
  36. ,#{parentId,jdbcType=VARCHAR}
  37. ,#{dataType,jdbcType= NUMERIC }
  38. ,#{createBy,jdbcType=VARCHAR}
  39. ,#{createDate,jdbcType= TIMESTAMP }
  40. ,#{updateBy,jdbcType=VARCHAR}
  41. ,#{updateDate,jdbcType= TIMESTAMP }
  42. ,#{activated,jdbcType= NUMERIC }
  43. ,#{delFlag,jdbcType= NUMERIC }
  44. )
  45. ]]>
  46. </insert>
  47. <delete id="delete" parameterType="string">
  48. delete from sys_data_dictionary where id_=#{id,jdbcType=VARCHAR}
  49. </delete>
  50. <update id="update" parameterType="com.jpsoft.employment.modules.sys.entity.DataDictionary">
  51. update sys_data_dictionary
  52. <set>
  53. <if test="name!=null">
  54. name_=#{name,jdbcType=VARCHAR},
  55. </if>
  56. <if test="value!=null">
  57. value_=#{value,jdbcType=VARCHAR},
  58. </if>
  59. <if test="sortNo!=null">
  60. sort_no=#{sortNo,jdbcType= NUMERIC },
  61. </if>
  62. <if test="parentId!=null">
  63. parent_id=#{parentId,jdbcType=VARCHAR},
  64. </if>
  65. <if test="dataType!=null">
  66. data_type=#{dataType,jdbcType= NUMERIC },
  67. </if>
  68. <if test="createBy!=null">
  69. create_by=#{createBy,jdbcType=VARCHAR},
  70. </if>
  71. <if test="createDate!=null">
  72. create_date=#{createDate,jdbcType= TIMESTAMP },
  73. </if>
  74. <if test="updateBy!=null">
  75. update_by=#{updateBy,jdbcType=VARCHAR},
  76. </if>
  77. <if test="updateDate!=null">
  78. update_date=#{updateDate,jdbcType= TIMESTAMP },
  79. </if>
  80. <if test="activated!=null">
  81. activated_=#{activated,jdbcType= NUMERIC },
  82. </if>
  83. <if test="delFlag!=null">
  84. del_flag=#{delFlag,jdbcType= NUMERIC },
  85. </if>
  86. </set>
  87. where id_=#{id}
  88. </update>
  89. <select id="get" parameterType="string" resultMap="DataDictionaryMap">
  90. select a.*,b.name_ as parent_name
  91. from sys_data_dictionary a left join sys_data_dictionary b on a.parent_id = b.id_
  92. where a.id_=#{0} and a.del_flag = 0
  93. </select>
  94. <select id="exist" parameterType="string" resultType="int">
  95. select count(*) from sys_data_dictionary where id_=#{0} and del_flag = 0
  96. </select>
  97. <select id="list" resultMap="DataDictionaryMap">
  98. select * from sys_data_dictionary where del_flag = 0
  99. </select>
  100. <select id="findParentId" parameterType="string" resultType="string">
  101. select a.name_ as name
  102. from sys_data_dictionary a
  103. where a.parent_id =#{parentId} and a.value_=#{value} and a.del_flag = 0
  104. order by a.sort_no asc
  105. </select>
  106. <select id="search" parameterType="hashmap" resultMap="DataDictionaryMap">
  107. <![CDATA[
  108. SELECT
  109. a.*,b.name_ AS parent_name
  110. FROM
  111. sys_data_dictionary a
  112. LEFT JOIN sys_data_dictionary b ON a.parent_id = b.id_
  113. ]]>
  114. <where>
  115. a.del_flag = 0
  116. <if test="searchParams.id != null">
  117. and a.ID_ like #{searchParams.id}
  118. </if>
  119. <if test="searchParams.name != null">
  120. and a.name_ like #{searchParams.name}
  121. </if>
  122. <if test="searchParams.excludeId != null">
  123. <![CDATA[
  124. and a.ID_ <> #{searchParams.excludeId}
  125. ]]>
  126. </if>
  127. <if test="searchParams.dataType != null">
  128. and a.data_type = #{searchParams.dataType}
  129. </if>
  130. <if test="searchParams.parentId != null">
  131. <![CDATA[
  132. and a.parent_id = #{searchParams.parentId}
  133. ]]>
  134. </if>
  135. </where>
  136. <foreach item="sort" collection="sortList" open="order by" separator=",">
  137. ${sort.name} ${sort.order}
  138. </foreach>
  139. </select>
  140. <select id="queryChildren" resultType="java.util.HashMap" parameterType="string">
  141. SELECT
  142. a.id_ as id,a.name_ as name,a.value_ as value
  143. FROM
  144. sys_data_dictionary a where a.del_flag = 0
  145. and data_type = 2
  146. and a.parent_id = #{0} order by a.sort_no asc
  147. </select>
  148. <select id="getName" parameterType="string" resultType="string">
  149. select a.name_ as name
  150. from sys_data_dictionary a
  151. where a.id_=#{0} and a.del_flag = 0
  152. </select>
  153. <select id="getValue" parameterType="string" resultType="string">
  154. select a.value_ as value
  155. from sys_data_dictionary a
  156. where a.id_=#{0} and a.del_flag = 0
  157. </select>
  158. <select id="findByCatalogName" resultMap="DataDictionaryMap">
  159. select a.*
  160. from sys_data_dictionary a,sys_data_dictionary b
  161. where a.parent_id =b.id_ and b.name_=#{0}
  162. and a.del_flag = 0
  163. order by a.sort_no asc
  164. </select>
  165. <select id="findNameByCatalogNameAndValue" parameterType="map" resultType="string">
  166. select a.name_
  167. from sys_data_dictionary a,sys_data_dictionary b
  168. where a.parent_id =b.id_ and b.name_=#{catalogName}
  169. and a.del_flag = 0
  170. and a.value_=#{value}
  171. order by a.sort_no asc
  172. limit 1
  173. </select>
  174. <select id="findValueByCatalogNameAndName" parameterType="map" resultType="string">
  175. select a.value_
  176. from sys_data_dictionary a,sys_data_dictionary b
  177. where a.parent_id =b.id_ and b.name_=#{catalogName}
  178. and a.del_flag = 0
  179. and a.name_=#{name}
  180. order by a.sort_no asc
  181. limit 1
  182. </select>
  183. <select id="findValueByName" parameterType="map" resultType="string">
  184. SELECT
  185. value_
  186. FROM
  187. sys_data_dictionary
  188. WHERE
  189. name_ = #{name}
  190. AND del_flag = 0
  191. ORDER BY
  192. sort_no ASC
  193. LIMIT 1
  194. </select>
  195. </mapper>