UserCompanyMapper.xml 1.4 KB
<?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 id, userId, companyId, companyCode
		FROM sys_user_company
		<where>
			<if test="id != null">
				AND id = #{id}
			</if>
			<if test="userId != null">
				AND userId = #{userId}
			</if>
			<if test="companyId != null">
				AND companyId = #{companyId}
			</if>
			<if test="companyCode != null">
				AND 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" parameterType="Integer">
		delete from sys_user_company where userId=#{userId}
	</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>