UnitMapper.xml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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.dk.mdm.mapper.mst.UnitMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. unit_id, unit_code, unit_name, decimal_places, display_no, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
  8. </sql>
  9. <!-- 通用查询映射结果 -->
  10. <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.Unit">
  11. <id column="unit_id" property="unitId"/>
  12. <result column="unit_code" property="unitCode"/>
  13. <result column="unit_name" property="unitName"/>
  14. <result column="decimal_places" property="decimalPlaces"/>
  15. <result column="display_no" property="displayNo"/>
  16. <result column="remarks" property="remarks"/>
  17. <result column="flg_valid" property="flgValid"/>
  18. <result column="cp_id" property="cpId"/>
  19. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  20. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  21. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  22. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  23. <result column="op_app_code" property="opAppCode"/>
  24. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  25. <result column="op_db_user" property="opDbUser"/>
  26. </resultMap>
  27. <!-- 通用条件列 -->
  28. <sql id="Condition">
  29. <where>
  30. <if test="unitCode != null and unitCode != ''">
  31. AND unit_code = #{unitCode}
  32. </if>
  33. <if test="unitName != null and unitName != ''">
  34. AND unit_name = #{unitName}
  35. </if>
  36. <if test="decimalPlaces != null">
  37. AND decimal_places = #{decimalPlaces}
  38. </if>
  39. <if test="displayNo != null">
  40. AND display_no = #{displayNo}
  41. </if>
  42. <if test="remarks != null and remarks != ''">
  43. AND remarks = #{remarks}
  44. </if>
  45. <if test="flgValid != null">
  46. AND flg_valid = #{flgValid}
  47. </if>
  48. <if test="cpId != null">
  49. AND cp_id = #{cpId}
  50. </if>
  51. <if test="opCreateTime != null">
  52. AND op_create_time = #{opCreateTime}
  53. </if>
  54. <if test="opCreateUserId != null and opCreateUserId != ''">
  55. AND op_create_user_id = #{opCreateUserId}
  56. </if>
  57. <if test="opUpdateTime != null">
  58. AND op_update_time = #{opUpdateTime}
  59. </if>
  60. <if test="opUpdateUserId != null and opUpdateUserId != ''">
  61. AND op_update_user_id = #{opUpdateUserId}
  62. </if>
  63. <if test="opAppCode != null and opAppCode != ''">
  64. AND op_app_code = #{opAppCode}
  65. </if>
  66. <if test="opTimestamp != null">
  67. AND op_timestamp = #{opTimestamp}
  68. </if>
  69. <if test="opDbUser != null and opDbUser != ''">
  70. AND op_db_user = #{opDbUser}
  71. </if>
  72. <if test="searchText != null">
  73. AND (unit_code like concat('%', my_ex.likequery(#{searchText}) , '%')
  74. OR unit_name like concat('%', my_ex.likequery(#{searchText}) , '%')
  75. OR remarks like concat('%', my_ex.likequery(#{searchText}) , '%')
  76. )
  77. </if>
  78. </where>
  79. </sql>
  80. <sql id="idsForeach">
  81. <!-- 根据主键unitId批量操作 -->
  82. WHERE unit_id in
  83. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  84. #{item}
  85. </foreach>
  86. </sql>
  87. <!-- 查询表t_mst_unit,(条件查询+分页)列表 -->
  88. <select id="selectByCond" resultMap="BaseResultMap">
  89. SELECT
  90. <include refid="Base_Column_List"/>
  91. FROM dkic_b.t_mst_unit
  92. <include refid="Condition"/>
  93. order by display_no asc
  94. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  95. limit #{end} offset #{start}
  96. </if>
  97. </select>
  98. <!-- 查询表t_mst_unit,(条件查询)个数 -->
  99. <select id="countByCond" resultType="Long">
  100. SELECT
  101. count(1)
  102. FROM dkic_b.t_mst_unit
  103. <include refid="Condition"/>
  104. </select>
  105. <!-- 根据主键查询表t_mst_unit的一行数据 -->
  106. <select id="selectById" resultMap="BaseResultMap">
  107. SELECT
  108. <include refid="Base_Column_List"/>
  109. FROM dkic_b.t_mst_unit
  110. WHERE unit_id = #{unitId}::uuid
  111. </select>
  112. <!-- 根据主键锁定表t_mst_unit的一行数据 -->
  113. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  114. SELECT
  115. <include refid="Base_Column_List"/>
  116. FROM dkic_b.t_mst_unit
  117. WHERE unit_id = #{unitId}
  118. for update
  119. </select>
  120. <!-- 根据主键锁定表t_mst_unit的多行数据 -->
  121. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  122. SELECT
  123. <include refid="Base_Column_List"/>
  124. FROM dkic_b.t_mst_unit
  125. <include refid="idsForeach"/>
  126. for update
  127. </select>
  128. <insert id="insertBatch">
  129. insert into dkic_b.t_mst_unit
  130. (
  131. <trim suffixOverrides=",">
  132. unit_code,
  133. unit_name,
  134. decimal_places,
  135. display_no,
  136. remarks,
  137. cp_id,
  138. op_app_code,
  139. </trim>
  140. )
  141. values
  142. <foreach collection="list" index="index" item="item" separator=",">
  143. (
  144. <trim suffixOverrides=",">
  145. #{item.unitCode},
  146. #{item.unitName},
  147. #{item.decimalPlaces},
  148. #{item.displayNo},
  149. #{item.remarks},
  150. #{item.cpId},
  151. #{item.opAppCode},
  152. </trim>
  153. )
  154. </foreach>
  155. </insert>
  156. </mapper>