MoneyAccountMapper.xml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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.MoneyAccountMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. mac_id, mac_code, mac_name, mac_type, balance, display_no, flg_default, mac_receipt_code, 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. <sql id="Base_Column_List_">
  10. tmma.mac_id, tmma.mac_code, tmma.mac_name, tmma.mac_type, tmma.balance, tmma.display_no, tmma.flg_default, tmma.mac_receipt_code, tmma.remarks, tmma.flg_valid, tmma.cp_id, tmma.op_create_time, tmma.op_create_user_id, tmma.op_update_time, tmma.op_update_user_id, tmma.op_app_code, tmma.op_timestamp, tmma.op_db_user
  11. </sql>
  12. <!-- 通用查询映射结果 -->
  13. <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.MoneyAccountResponse">
  14. <id column="mac_id" property="macId"/>
  15. <result column="mac_code" property="macCode"/>
  16. <result column="mac_name" property="macName"/>
  17. <result column="mac_type" property="macType" typeHandler="UuidTypeHandler"/>
  18. <result column="balance" property="balance"/>
  19. <result column="display_no" property="displayNo"/>
  20. <result column="flg_default" property="flgDefault"/>
  21. <result column="mac_receipt_code" property="macReceiptCode"/>
  22. <result column="remarks" property="remarks"/>
  23. <result column="flg_valid" property="flgValid"/>
  24. <result column="cp_id" property="cpId"/>
  25. <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
  26. <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
  27. <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
  28. <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
  29. <result column="op_app_code" property="opAppCode"/>
  30. <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
  31. <result column="op_db_user" property="opDbUser"/>
  32. </resultMap>
  33. <!-- 通用条件列 -->
  34. <sql id="Condition">
  35. <where>
  36. <if test="macCode != null and macCode != ''">
  37. AND ma.mac_code LIKE concat('%',my_ex.likequery(#{macCode}),'%')
  38. </if>
  39. <if test="macName != null and macName != ''">
  40. AND ma.mac_name LIKE concat('%',my_ex.likequery(#{macName}),'%')
  41. </if>
  42. <if test="remarks != null and remarks != ''">
  43. AND ma.remarks = LIKE concat('%',my_ex.likequery(#{remarks}),'%')
  44. </if>
  45. <if test="cpId != null">
  46. AND ma.cp_id = #{cpId}
  47. </if>
  48. <if test="opTimestamp != null">
  49. AND ma.op_timestamp = #{opTimestamp}
  50. </if>
  51. <if test="flgValidList != null and flgValidList.size>0">
  52. AND ma.flg_valid =any(#{flgValidList, typeHandler=BooleanListTypeHandler})
  53. </if>
  54. <if test="macTypeList != null and macTypeList.size() > 0">
  55. AND ma.mac_Type =any(#{macTypeList, typeHandler=UuidListTypeHandler})
  56. </if>
  57. </where>
  58. </sql>
  59. <!-- 查询表t_mst_money_account,(条件查询+分页)列表 -->
  60. <select id="selectByCond" resultMap="BaseResultMap">
  61. SELECT ma.mac_Type,ma.mac_code,ma.mac_name,ma.remarks
  62. ,ma.cp_id,ma.flg_valid
  63. ,dd.data_value AS "macTypeName"
  64. ,ma.mac_id,ma.balance,ma.display_no
  65. FROM dkic_b.t_mst_money_account ma
  66. left join dkic_b.t_mst_dictionary_data dd on ma.mac_type=dd.data_id
  67. <include refid="Condition"/>
  68. </select>
  69. <!-- 查询表t_mst_money_account,(条件查询)个数 -->
  70. <select id="countByCond" resultType="Long">
  71. SELECT
  72. count(1)
  73. FROM dkic_b.t_mst_money_account ma
  74. <include refid="Condition"/>
  75. </select>
  76. <!-- 王英杰 2024年3月6日 微信小程序用 -->
  77. <select id="wxSelectByCond" resultType="java.util.Map">
  78. SELECT T
  79. .*
  80. FROM
  81. (
  82. SELECT
  83. null AS "macType",
  84. null AS "macCode",
  85. tmdd.data_value AS "macName",
  86. null AS "Remarks",
  87. null AS "flgValid",
  88. null AS "macTypeName",
  89. null AS "macId",
  90. null AS "balance",
  91. null AS "displayNo"
  92. FROM
  93. dkic_b.t_mst_dictionary_data tmdd
  94. WHERE
  95. tmdd.dict_code = '账户类别' UNION ALL
  96. SELECT
  97. ma.mac_Type as "macType",
  98. ma.mac_code AS "macCode",
  99. ma.mac_name AS "macName",
  100. ma.remarks AS "Remarks",
  101. ma.flg_valid AS "flgValid",
  102. dd.data_value AS "macTypeName",
  103. ma.mac_id AS "macId",
  104. ma.balance AS "balance",
  105. ma.display_no AS "displayNo"
  106. FROM
  107. dkic_b.t_mst_money_account ma
  108. LEFT JOIN dkic_b.t_mst_dictionary_data dd ON ma.mac_type = dd.data_id
  109. <include refid="Condition"/>
  110. ) T
  111. </select>
  112. <!-- 王英杰 2024年3月6日 微信小程序用 -->
  113. <select id="wxCountByCond" resultType="Long">
  114. SELECT
  115. count(1)
  116. FROM
  117. (
  118. SELECT
  119. null AS "macType",
  120. tmdd.data_value AS "macCode",
  121. null AS "macName",
  122. null AS "Remarks",
  123. null AS "flgValid",
  124. null AS "macTypeName",
  125. null AS "macId",
  126. null AS "balance",
  127. null AS "displayNo"
  128. FROM
  129. dkic_b.t_mst_dictionary_data tmdd
  130. WHERE
  131. tmdd.dict_code = '账户类别' UNION ALL
  132. SELECT
  133. ma.mac_Type as "macType",
  134. ma.mac_code AS "macCode",
  135. ma.mac_name AS "macName",
  136. ma.remarks AS "Remarks",
  137. ma.flg_valid AS "flgValid",
  138. dd.data_value AS "macTypeName",
  139. ma.mac_id AS "macId",
  140. ma.balance AS "balance",
  141. ma.display_no AS "displayNo"
  142. FROM
  143. dkic_b.t_mst_money_account ma
  144. LEFT JOIN dkic_b.t_mst_dictionary_data dd ON ma.mac_type = dd.data_id
  145. <include refid="Condition"/>
  146. ) T
  147. </select>
  148. <!-- 根据主键查询表t_mst_money_account的一行数据 -->
  149. <select id="selectById" resultMap="BaseResultMap">
  150. SELECT
  151. <include refid="Base_Column_List_"/>
  152. ,tmdd.data_value AS "macTypeName"
  153. FROM dkic_b.t_mst_money_account tmma
  154. left join dkic_b.t_mst_dictionary_data tmdd on tmma.mac_type=tmdd.data_id
  155. WHERE tmma.mac_id = #{macId}::uuid
  156. </select>
  157. <select id="selectDisplayNo" resultType="Integer">
  158. SELECT MAX(display_no) + 1 FROM dkic_b.t_mst_money_account ma
  159. WHERE ma.cp_id = #{cpId}
  160. </select>
  161. </mapper>