EntmicroStaffDepartRelationMapper.xml
4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?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="cn.com.glsx.entmicro.mapper.EntmicroStaffDepartRelationMapper">
<resultMap id="BaseResultMap" type="cn.com.glsx.entmicro.entity.EntmicroStaffDepartRelation">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="INTEGER" property="id"/>
<result column="staff_id" jdbcType="INTEGER" property="staffId"/>
<result column="department_id" jdbcType="INTEGER" property="departmentId"/>
<result column="relevance_merchant" jdbcType="INTEGER" property="relevanceMerchant"/>
<result column="created_by" jdbcType="INTEGER" property="createdBy"/>
<result column="created_time" jdbcType="TIMESTAMP" property="createdTime"/>
<result column="updated_by" jdbcType="INTEGER" property="updatedBy"/>
<result column="updated_time" jdbcType="TIMESTAMP" property="updatedTime"/>
<result column="del_flag" jdbcType="TINYINT" property="delFlag"/>
<result column="user_oneid" jdbcType="VARCHAR" property="userOneid"/>
<result column="staff_phone" jdbcType="VARCHAR" property="staffPhone"/>
</resultMap>
<resultMap id="channelCodeStaffInfoResultMap"
type="cn.com.glsx.entmicro.model.response.ChannelCodeStaffInfoResponse">
<result column="staff_name" jdbcType="VARCHAR" property="staffName"/>
<result column="id" jdbcType="INTEGER" property="relationId"/>
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
</resultMap>
<sql id="Base_Column_List">
<!--
WARNING - @mbg.generated
-->
id, staff_id, department_id, relevance_merchant, created_by, created_time, updated_by,
updated_time, del_flag,user_oneid
</sql>
<update id="deleteStaffDepartment">
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update entmicro_staff_depart_relation
<set>
del_flag = -1,
updated_time = NOW(),
</set>
where staff_id=#{item.staffId}
and department_id=#{item.departmentId}
</foreach>
</update>
<update id="deleteStaff">
update entmicro_staff_depart_relation
<set>
del_flag = -1,
updated_time = NOW(),
</set>
where staff_id=#{staffId}
</update>
<select id="findDepartByStaffId" resultMap="BaseResultMap">
select ea.*,es.staff_phone from entmicro_staff_depart_relation ea
left join entmicro_staff es on ea.staff_id=es.id
where staff_id=#{staffId} and ea.del_flag=0
</select>
<!--根据关联表主键id获取活码配置员工信息-->
<select id="getStaffByIdList" resultMap="channelCodeStaffInfoResultMap">
select es.staff_name,
esdr.id,
es.user_id
from entmicro_staff es
left join entmicro_staff_depart_relation esdr on es.id = esdr.staff_id
where es.follower_type_id is not null
and es.del_flag != -1
and esdr.del_flag = 0
and esdr.id in
<foreach collection="staffIdList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
and esdr.relevance_merchant = #{merchantId}
</select>
<select id="findByIds" resultMap="BaseResultMap">
select * from
entmicro_staff_depart_relation where id in
<foreach collection="ids" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</select>
<select id="findByoneIds" resultMap="BaseResultMap">
select * from
entmicro_staff_depart_relation where user_oneid=#{oneIds} and del_flag=0 limit 1
</select>
<!--根据staffId集合和商户号获取员工的uid-->
<select id="findStaffUidDepartForMerchantList" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from entmicro_staff_depart_relation
<where>
and del_flag = 0
and relevance_merchant=#{merchantId}
and staff_id in
<foreach collection="staffIdList" open="(" separator="," close=")" item="item">
#{item}
</foreach>
</where>
GROUP BY staff_id
</select>
<select id="findDepartByStaffIdForMerchant" resultMap="BaseResultMap">
select * from entmicro_staff_depart_relation where staff_id=#{staffId} and del_flag=0 and relevance_merchant=#{merchantId} GROUP BY staff_id
</select>
<select id="findRelevanceMerchantByStaffId" resultType="INTEGER">
select ea.relevance_merchant from entmicro_staff es
left join entmicro_staff_depart_relation ea on es.id = ea.staff_id
left join drac_rescue_card_config drcc on ea.relevance_merchant = drcc.merchant_id
where drcc.id is not null
and es.id = #{staffId}
group by ea.relevance_merchant
</select>
</mapper>