StaffMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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.StaffMapper">
  4. <!-- 通用设置 -->
  5. <!-- 通用查询列 -->
  6. <sql id="Base_Column_List">
  7. t.staff_id
  8. , t.staff_code, t.staff_name,t.staff_phone, t.org_id, t.role_ids, t.wx_user_id, t.remarks,
  9. t.flg_valid,t.flg_can_login,
  10. t.cp_id, t.op_create_time, t.op_create_user_id, t.op_update_time, t.op_update_user_id
  11. </sql>
  12. <!-- 通用查询映射结果 -->
  13. <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.core.StaffResponse">
  14. <id column="staff_id" property="staffId"/>
  15. <result column="staff_code" property="staffCode"/>
  16. <result column="staff_name" property="staffName"/>
  17. <result column="staff_phone" property="staffPhone"/>
  18. <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
  19. <result column="org_name" property="orgName"/>
  20. <result column="role_ids" property="roleIds" typeHandler="UuidListTypeHandler"/>
  21. <result column="wx_user_id" property="wxUserId" typeHandler="UuidTypeHandler"/>
  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. <result column="flg_can_login" property="flgCanLogin"/>
  33. </resultMap>
  34. <!-- 通用条件列 -->
  35. <sql id="Condition">
  36. <where>
  37. <if test="staffId != null">
  38. AND t.staff_id = #{staffId}
  39. </if>
  40. <if test="staffCode != null and staffCode != ''">
  41. AND position (#{staffCode} in t.staff_code ) >0
  42. </if>
  43. <if test="staffName != null and staffName != ''">
  44. AND position (#{staffName} in t.staff_name ) >0
  45. </if>
  46. <if test="staffPhone != null and staffPhone != ''">
  47. AND position (#{staffPhone} in t.staff_phone ) >0
  48. </if>
  49. <if test="orgId != null">
  50. AND t.org_id = #{orgId}
  51. </if>
  52. <if test="remarks != null and remarks != ''">
  53. AND t.remarks = #{remarks}
  54. </if>
  55. <if test="flgValid != null">
  56. AND t.flg_valid = #{flgValid}
  57. </if>
  58. <if test="cpId != null">
  59. AND t.cp_id = #{cpId}
  60. </if>
  61. <if test="roleIds != null and roleIds.size()>0">
  62. AND t.role_ids =
  63. any(#{roleIds, typeHandler=StringListTypeHandler})
  64. </if>
  65. <if test="searchText !=null">
  66. AND ( t.staff_name LIKE concat('%', #{searchText}, '%')
  67. or t.staff_phone LIKE concat('%', #{searchText}, '%'))
  68. </if>
  69. </where>
  70. </sql>
  71. <!-- 根据主键修改 -->
  72. <!-- <update id="update">-->
  73. <!-- update dkic_b.t_mst_staff-->
  74. <!-- <set>-->
  75. <!-- <if test="staffCode != null">staff_code = #{staffCode},</if>-->
  76. <!-- <if test="staffName != null" >staff_name = #{staffName},</if>-->
  77. <!-- <if test="staffPhone != null">staff_phone = #{staffPhone},</if>-->
  78. <!-- <if test="orgId != null">org_id = #{orgId},</if>-->
  79. <!-- <if test="roleIds != null">role_ids = #{roleIds},</if>-->
  80. <!-- <if test="remarks != null">remarks = #{remarks},</if>-->
  81. <!-- <if test="flgCanLogin != null">flg_can_login = #{flgCanLogin},</if>-->
  82. <!-- <if test="updateUserId != null">update_user_id = #{updateUserId},</if>-->
  83. <!-- <if test="updateUserName != null">update_user_name = #{updateUserName},</if>-->
  84. <!-- <if test="updateTime != null">update_time = #{updateTime},</if>-->
  85. <!-- </set>-->
  86. <!-- where staff_id = #{staffId}::uuid-->
  87. <!-- </update>-->
  88. <!-- 查询表t_mst_staff,(条件查询+分页)列表 -->
  89. <select id="selectByCond" resultMap="BaseResultMap">
  90. SELECT
  91. <include refid="Base_Column_List"/>
  92. , org.org_name
  93. FROM dkic_b.t_mst_staff t
  94. LEFT JOIN dkic_b.t_mst_org org
  95. ON t.org_Id = org.org_Id
  96. <include refid="Condition"/>
  97. ORDER BY t.flg_valid DESC,t.staff_code
  98. <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
  99. limit #{end} offset #{start}
  100. </if>
  101. </select>
  102. <!-- 查询表t_mst_staff,(条件查询)个数 -->
  103. <select id="countByCond" resultType="Long">
  104. SELECT
  105. count(1)
  106. FROM dkic_b.t_mst_staff t
  107. <include refid="Condition"/>
  108. </select>
  109. <!-- 根据主键查询表t_mst_staff的一行数据 -->
  110. <select id="selectById" resultMap="BaseResultMap">
  111. SELECT
  112. <include refid="Base_Column_List"/>
  113. , org.org_name
  114. FROM dkic_b.t_mst_staff t
  115. LEFT JOIN dkic_b.t_mst_org org
  116. ON t.org_Id = org.org_Id
  117. WHERE t.staff_id = #{staffId}::uuid
  118. </select>
  119. <insert id="insertBatch">
  120. insert into dkic_b.t_mst_staff
  121. (
  122. <trim suffixOverrides=",">
  123. staff_code,
  124. staff_name,
  125. staff_phone,
  126. org_id,
  127. role_ids,
  128. wx_user_id,
  129. remarks,
  130. cp_id,
  131. op_app_code,
  132. flg_can_login,
  133. </trim>
  134. )
  135. values
  136. <foreach collection="list" index="index" item="item" separator=",">
  137. (
  138. <trim suffixOverrides=",">
  139. #{item.staffCode},
  140. #{item.staffName},
  141. #{item.staffPhone},
  142. #{item.orgId}::uuid,
  143. #{item.roleIds},
  144. #{item.wxUserId}::uuid,
  145. #{item.remarks},
  146. #{item.cpId},
  147. #{item.opAppCode},
  148. #{item.flgCanLogin},
  149. </trim>
  150. )
  151. </foreach>
  152. </insert>
  153. </mapper>