UnitMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 (position(#{searchText} in unit_code) > 0 OR position(#{searchText} in unit_name) > 0 OR position(#{searchText} in remarks) > 0 )
  74. </if>
  75. </where>
  76. </sql>
  77. <sql id="idsForeach">
  78. <!-- 根据主键unitId批量操作 -->
  79. WHERE unit_id in
  80. <foreach collection="ids" index="index" item="item" separator="," open="(" close=")">
  81. #{item}
  82. </foreach>
  83. </sql>
  84. <!-- 查询表t_mst_unit,(条件查询+分页)列表 -->
  85. <select id="selectByCond" resultMap="BaseResultMap">
  86. SELECT
  87. <include refid="Base_Column_List"/>
  88. FROM dkic_b.t_mst_unit
  89. <include refid="Condition"/>
  90. order by display_no asc
  91. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  92. limit #{end} offset #{start}
  93. </if>
  94. </select>
  95. <!-- 查询表t_mst_unit,(条件查询)个数 -->
  96. <select id="countByCond" resultType="Long">
  97. SELECT
  98. count(1)
  99. FROM dkic_b.t_mst_unit
  100. <include refid="Condition"/>
  101. </select>
  102. <!-- 根据主键查询表t_mst_unit的一行数据 -->
  103. <select id="selectById" resultMap="BaseResultMap">
  104. SELECT
  105. <include refid="Base_Column_List"/>
  106. FROM dkic_b.t_mst_unit
  107. WHERE unit_id = #{unitId}::uuid
  108. </select>
  109. <!-- 根据主键锁定表t_mst_unit的一行数据 -->
  110. <select id="selectByIdForUpdate" resultMap="BaseResultMap">
  111. SELECT
  112. <include refid="Base_Column_List"/>
  113. FROM dkic_b.t_mst_unit
  114. WHERE unit_id = #{unitId}
  115. for update
  116. </select>
  117. <!-- 根据主键锁定表t_mst_unit的多行数据 -->
  118. <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
  119. SELECT
  120. <include refid="Base_Column_List"/>
  121. FROM dkic_b.t_mst_unit
  122. <include refid="idsForeach"/>
  123. for update
  124. </select>
  125. <insert id="insertBatch">
  126. insert into dkic_b.t_mst_unit
  127. (
  128. <trim suffixOverrides=",">
  129. unit_code,
  130. unit_name,
  131. decimal_places,
  132. display_no,
  133. remarks,
  134. cp_id,
  135. op_app_code,
  136. </trim>
  137. )
  138. values
  139. <foreach collection="list" index="index" item="item" separator=",">
  140. (
  141. <trim suffixOverrides=",">
  142. #{item.unitCode},
  143. #{item.unitName},
  144. #{item.decimalPlaces},
  145. #{item.displayNo},
  146. #{item.remarks},
  147. #{item.cpId},
  148. #{item.opAppCode},
  149. </trim>
  150. )
  151. </foreach>
  152. </insert>
  153. </mapper>