UserCompanyMapper.xml
1.76 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
<?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.huaheng.pc.system.user.mapper.UserCompanyMapper">
<select id="selectListEntityByEqual" resultType="com.huaheng.pc.system.user.domain.UserCompany">
SELECT sc.id, sc.userId, sc.companyId, sc.companyCode, c.name
FROM sys_user_company sc
inner join company c on c.id = sc.companyId
<where>
<if test="id != null">
AND sc.id = #{id}
</if>
<if test="userId != null">
AND sc.userId = #{userId}
</if>
<if test="companyId != null">
AND sc.companyId = #{companyId}
</if>
<if test="companyCode != null">
AND sc.companyCode = #{companyCode}
</if>
</where>
</select>
<select id="countUserCompanyById" resultType="java.lang.Integer">
select count(1) from sys_user_company where companyId=#{companyId}
</select>
<insert id="batchUserCompany">
insert into sys_user_company(userId, companyId) values
<foreach item="item" index="index" collection="list" separator=",">
(#{item.userId},#{item.companyId})
</foreach>
</insert>
<delete id="deleteUserCompanyByUserId" >
delete from sys_user_company where id in
(select a.id from (SELECT uc.id from sys_user_company uc
left join company c on uc.companyId=c.id
where uc.userId=${userId} and c.warehouseCode='${warehouseCode}') a)
</delete>
<delete id="deleteUserCompany" parameterType="Integer">
delete from sys_user_company where userId in
<foreach collection="array" item="userId" open="(" separator="," close=")">
#{userId}
</foreach>
</delete>
</mapper>