DictionariesMapper.xml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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="DictionariesMapper">
  4. <resultMap type="Dictionaries" id="dictResultMap">
  5. <id column="DICTIONARIES_ID" property="DICTIONARIES_ID"/>
  6. <result column="NAME" property="NAME"/>
  7. <result column="PARENT_ID" property="PARENT_ID"/>
  8. </resultMap>
  9. <!--表名 -->
  10. <sql id="tableName">
  11. SYS_DICTIONARIES
  12. </sql>
  13. <!-- 字段 -->
  14. <sql id="Field">
  15. NAME,
  16. NAME_EN,
  17. BIANMA,
  18. ORDER_BY,
  19. PARENT_ID,
  20. BZ,
  21. TBSNAME,
  22. TBFIELD,
  23. YNDEL,
  24. DICTIONARIES_ID
  25. </sql>
  26. <!-- 字段值 -->
  27. <sql id="FieldValue">
  28. #{NAME},
  29. #{NAME_EN},
  30. #{BIANMA},
  31. #{ORDER_BY},
  32. #{PARENT_ID},
  33. #{BZ},
  34. #{TBSNAME},
  35. #{TBFIELD},
  36. #{YNDEL},
  37. #{DICTIONARIES_ID}
  38. </sql>
  39. <!-- 新增-->
  40. <insert id="save" parameterType="pd">
  41. insert into
  42. <include refid="tableName"></include>
  43. (
  44. <include refid="Field"></include>
  45. ) values (
  46. <include refid="FieldValue"></include>
  47. )
  48. </insert>
  49. <!-- 删除-->
  50. <delete id="delete" parameterType="pd">
  51. delete from
  52. <include refid="tableName"></include>
  53. where
  54. DICTIONARIES_ID = #{DICTIONARIES_ID}
  55. </delete>
  56. <!-- 修改 -->
  57. <update id="edit" parameterType="pd">
  58. update
  59. <include refid="tableName"></include>
  60. set
  61. NAME = #{NAME},
  62. NAME_EN = #{NAME_EN},
  63. ORDER_BY = #{ORDER_BY},
  64. BZ = #{BZ},
  65. TBSNAME = #{TBSNAME},
  66. TBFIELD = #{TBFIELD},
  67. DICTIONARIES_ID = DICTIONARIES_ID
  68. where
  69. DICTIONARIES_ID = #{DICTIONARIES_ID}
  70. </update>
  71. <!-- 通过ID获取数据 -->
  72. <select id="findById" parameterType="pd" resultType="pd">
  73. select
  74. <include refid="Field"></include>
  75. from
  76. <include refid="tableName"></include>
  77. where
  78. DICTIONARIES_ID = #{DICTIONARIES_ID}
  79. </select>
  80. <!-- 通过编码获取数据 -->
  81. <select id="findByBianma" parameterType="pd" resultType="pd">
  82. select
  83. <include refid="Field"></include>
  84. from
  85. <include refid="tableName"></include>
  86. where
  87. BIANMA = #{BIANMA}
  88. </select>
  89. <!-- 列表 -->
  90. <select id="datalistPage" parameterType="page" resultType="pd">
  91. select
  92. <include refid="Field"></include>
  93. from
  94. <include refid="tableName"></include>
  95. where
  96. 1=1
  97. <if test="pd.DICTIONARIES_ID!= null and pd.DICTIONARIES_ID != ''"><!-- 检索 -->
  98. and PARENT_ID = #{pd.DICTIONARIES_ID}
  99. </if>
  100. <if test="pd.keywords != null and pd.keywords != ''"><!-- 关键词检索 -->
  101. and
  102. (
  103. NAME LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  104. or
  105. NAME_EN LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  106. or
  107. BIANMA LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
  108. )
  109. </if>
  110. order by ORDER_BY
  111. </select>
  112. <!-- 通过ID获取其子级列表 -->
  113. <select id="listSubDictByParentId" parameterType="String" resultMap="dictResultMap">
  114. select
  115. <include refid="Field"></include>
  116. from
  117. <include refid="tableName"></include>
  118. where
  119. PARENT_ID = #{parentId} order by ORDER_BY
  120. </select>
  121. <!-- 排查表检查是否被占用 -->
  122. <select id="findFromTbs" parameterType="pd" resultType="pd">
  123. select
  124. count(*) zs
  125. from
  126. ${thisTable}
  127. where
  128. ${TBFIELD} = #{BIANMA}
  129. </select>
  130. <!-- fh313596790qq(青苔) -->
  131. </mapper>