<?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.WxCUserFromBMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxCUserFromB">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
		<result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
		<result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
		<result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
		<result column="info" jdbcType="VARCHAR" property="info" />
		<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
		<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
		<result column="openid" jdbcType="VARCHAR" property="openid" />
		<result column="app_id" jdbcType="VARCHAR" property="appId" />
	
	</resultMap>
	
	<sql id="allColumns">
	    `id`,`tenant_id`,`merchant_id`,`b_user_id`,`c_user_id`,`info`,`create_time`,`update_time`,`openid`,`app_id`
	</sql>

	<sql id="dynamicWhereConditions">
	        where 1 = 1
		<if test=" null != id "> and `id` = #{id} </if>    
		<if test=" null != tenantId "> and `tenant_id` = #{tenantId} </if>    
		<if test=" null != merchantId "> and `merchant_id` = #{merchantId} </if>    
		<if test=" null != bUserId "> and `b_user_id` = #{bUserId} </if>    
		<if test=" null != cUserId "> and `c_user_id` = #{cUserId} </if>    
		<if test=" null != info "> and `info` = #{info} </if>    
		<if test=" null != createTime "> and `create_time` = #{createTime} </if>    
		<if test=" null != updateTime "> and `update_time` = #{updateTime} </if>    
		<if test=" null != openid "> and `openid` = #{openid} </if>
		<if test=" null != appId "> and `app_id` = #{appId} </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.WxCUserFromB" resultMap="BaseResultMap">
		select <include refid="allColumns" /> from wx_c_user_from_b
		<include refid="dynamicWhereConditions" />
		order by id desc
	</select>
	
	<select id="getByOpenidAndAppId" resultMap="BaseResultMap" parameterType="com.iformall.domain.dto.WxCUserFromBDto">
		select * from wx_c_user_from_b where app_id=#{appId} and openid=#{openid} and merchant_id=#{merchantId}
	</select>
	
	
	
	
</mapper>
