OrgWhMapper.xml 6.6 KB

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