<?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.yunfeiyun.agmp.common.web.system.mapper.PtsUserBindMapper">

	<resultMap type="PtsUserBind" id="PtsUserBindResult">
		<result property="userId"     	 column="userId"      />
		<result property="userbindSys"     	 column="userbindSys"      />
		<result property="userbindSysuser"     column="userbindSysuser"      />
	</resultMap>

	<select id="selectPtsSysUserBind" parameterType="PtsUserBind" resultMap="PtsUserBindResult">
	    select * from  PtsUserbind where userId=#{userId} and userbindSys=#{userbindSys}
	</select>

	<select id="hasPtsSysUserBind" parameterType="PtsUserBind" resultType="Integer">
	    select count(1) from PtsUserbind  where userId=#{userId} and userbindSys=#{userbindSys}  and  userbindSysuser = #{userbindSysuser}
	</select>

	<insert id="insertPtsUserBind" parameterType="PtsUserBind">
		insert into PtsUserbind(
		<if test="userbindId != null and userbindId != ''">userbindId,</if>
		<if test="userId != null and userId != ''">userId,</if>
		<if test="userbindSys != null and userbindSys != ''">userbindSys,</if>
		<if test="userbindSysuser != null and userbindSysuser != ''">userbindSysuser</if>
		)values(
		<if test="userbindId != null and userbindId != ''">#{userbindId},</if>
		<if test="userId != null and userId != ''">#{userId},</if>
		<if test="userbindSys != null and userbindSys != ''">#{userbindSys},</if>
		<if test="userbindSysuser != null and userbindSysuser != ''">#{userbindSysuser}</if>
		)
	</insert>

	<delete id="deletePtsUserBindById" parameterType="PtsUserBind">
		delete from PtsUserbind where  userId=#{userId} and  userbindSys=#{userbindSys}
	</delete>

	<delete id="deletePtsUserBind" parameterType="java.util.List">
		delete  from  PtsUserbind  where 1=1
		<foreach collection="list" item="item" index="index" separator="or">
			(
			userbindSys=#{userbindSys},
			and userId=#{userId},
			and userbindSysuser=#{userbindSysuser}
			)
		</foreach>
	</delete>

	
</mapper> 