<?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.iformall.mapper.MallUserRoleMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.MallUserRole">
		<id column="id" jdbcType="VARCHAR" property="id" />
		<result column="uid" jdbcType="VARCHAR" property="uid" />
		<result column="role_id" jdbcType="VARCHAR" property="roleId" />
	</resultMap>
	
	<sql id="allColumns">
	    `uid`,`role_id`,`id` 
	</sql>

	<sql id="dynamicWhereConditions">
	        where 1 = 1
	    
		<if test=" null != uid "> 
		and `uid`  like concat('%', #{uid},'%')
       	
		</if>    
	    
		<if test=" null != roleId "> 
		and `role_id`  like concat('%', #{roleId},'%')
       	
		</if>    
	    
		<if test=" null != id "> 
		and `id`  like concat('%', #{id},'%')
       	
		</if>    
		<if test=" null != ids ">
		 	and id in  
			<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
			#{idItem}
			</foreach>
		</if>		
		<if test=" null != sortColumns"> order by ${sortColumns} </if>
	</sql>
	
	<select id="findList" parameterType="com.iformall.domain.po.MallUserRole" resultMap="BaseResultMap">
		select <include refid="allColumns" /> from mall_user_role
		<include refid="dynamicWhereConditions" />
	</select>
	
	<delete id="deleteByUserId">
	delete from mall_user_role where uid=#{userId}
	</delete>
	
	
	
</mapper>
