| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.dk.mdm.mapper.mst.StaffMapper">
- <!-- 通用设置 -->
- <!-- 通用查询列 -->
- <sql id="Base_Column_List">
- t.staff_id
- , t.staff_code, t.staff_name,t.staff_phone, t.org_id, t.role_ids, t.wx_user_id, t.remarks,
- t.flg_valid,t.flg_can_login,
- t.cp_id, t.op_create_time, t.op_create_user_id, t.op_update_time, t.op_update_user_id
- </sql>
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.core.StaffResponse">
- <id column="staff_id" property="staffId"/>
- <result column="staff_code" property="staffCode"/>
- <result column="staff_name" property="staffName"/>
- <result column="staff_phone" property="staffPhone"/>
- <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
- <result column="org_name" property="orgName"/>
- <result column="role_ids" property="roleIds" typeHandler="UuidListTypeHandler"/>
- <result column="wx_user_id" property="wxUserId" typeHandler="UuidTypeHandler"/>
- <result column="remarks" property="remarks"/>
- <result column="flg_valid" property="flgValid"/>
- <result column="cp_id" property="cpId"/>
- <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
- <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
- <result column="op_app_code" property="opAppCode"/>
- <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
- <result column="op_db_user" property="opDbUser"/>
- <result column="flg_can_login" property="flgCanLogin"/>
- </resultMap>
- <!-- 通用条件列 -->
- <sql id="Condition">
- <where>
- <if test="staffId != null">
- AND t.staff_id = #{staffId}
- </if>
- <if test="staffCode != null and staffCode != ''">
- AND position (#{staffCode} in t.staff_code ) >0
- </if>
- <if test="staffName != null and staffName != ''">
- AND position (#{staffName} in t.staff_name ) >0
- </if>
- <if test="staffPhone != null and staffPhone != ''">
- AND position (#{staffPhone} in t.staff_phone ) >0
- </if>
- <if test="orgId != null">
- AND t.org_id = #{orgId}
- </if>
- <if test="remarks != null and remarks != ''">
- AND t.remarks = #{remarks}
- </if>
- <if test="flgValid != null">
- AND t.flg_valid = #{flgValid}
- </if>
- <if test="cpId != null">
- AND t.cp_id = #{cpId}
- </if>
- <if test="roleIds != null and roleIds.size()>0">
- AND t.role_ids =
- any(#{roleIds, typeHandler=StringListTypeHandler})
- </if>
- <if test="searchText !=null">
- AND ( t.staff_name LIKE concat('%', #{searchText}, '%')
- or t.staff_phone LIKE concat('%', #{searchText}, '%'))
- </if>
- </where>
- </sql>
- <!-- 根据主键修改 -->
- <!-- <update id="update">-->
- <!-- update dkic_b.t_mst_staff-->
- <!-- <set>-->
- <!-- <if test="staffCode != null">staff_code = #{staffCode},</if>-->
- <!-- <if test="staffName != null" >staff_name = #{staffName},</if>-->
- <!-- <if test="staffPhone != null">staff_phone = #{staffPhone},</if>-->
- <!-- <if test="orgId != null">org_id = #{orgId},</if>-->
- <!-- <if test="roleIds != null">role_ids = #{roleIds},</if>-->
- <!-- <if test="remarks != null">remarks = #{remarks},</if>-->
- <!-- <if test="flgCanLogin != null">flg_can_login = #{flgCanLogin},</if>-->
- <!-- <if test="updateUserId != null">update_user_id = #{updateUserId},</if>-->
- <!-- <if test="updateUserName != null">update_user_name = #{updateUserName},</if>-->
- <!-- <if test="updateTime != null">update_time = #{updateTime},</if>-->
- <!-- </set>-->
- <!-- where staff_id = #{staffId}::uuid-->
- <!-- </update>-->
- <!-- 查询表t_mst_staff,(条件查询+分页)列表 -->
- <select id="selectByCond" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- , org.org_name
- FROM dkic_b.t_mst_staff t
- LEFT JOIN dkic_b.t_mst_org org
- ON t.org_Id = org.org_Id
- <include refid="Condition"/>
- ORDER BY t.flg_valid DESC,t.staff_code
- <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
- limit #{end} offset #{start}
- </if>
- </select>
- <!-- 查询表t_mst_staff,(条件查询)个数 -->
- <select id="countByCond" resultType="Long">
- SELECT
- count(1)
- FROM dkic_b.t_mst_staff t
- <include refid="Condition"/>
- </select>
- <!-- 根据主键查询表t_mst_staff的一行数据 -->
- <select id="selectById" resultMap="BaseResultMap">
- SELECT
- <include refid="Base_Column_List"/>
- , org.org_name
- FROM dkic_b.t_mst_staff t
- LEFT JOIN dkic_b.t_mst_org org
- ON t.org_Id = org.org_Id
- WHERE t.staff_id = #{staffId}::uuid
- </select>
- <insert id="insertBatch">
- insert into dkic_b.t_mst_staff
- (
- <trim suffixOverrides=",">
- staff_code,
- staff_name,
- staff_phone,
- org_id,
- role_ids,
- wx_user_id,
- remarks,
- cp_id,
- op_app_code,
- flg_can_login,
- </trim>
- )
- values
- <foreach collection="list" index="index" item="item" separator=",">
- (
- <trim suffixOverrides=",">
- #{item.staffCode},
- #{item.staffName},
- #{item.staffPhone},
- #{item.orgId}::uuid,
- #{item.roleIds},
- #{item.wxUserId}::uuid,
- #{item.remarks},
- #{item.cpId},
- #{item.opAppCode},
- #{item.flgCanLogin},
- </trim>
- )
- </foreach>
- </insert>
- </mapper>
|