<?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.WxMsgMapper">
	<resultMap id="BaseResultMap" type="com.iformall.domain.po.msg.WxMsg">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
		<result column="model_id" jdbcType="BIGINT" property="modelId" />
		<result column="msg" jdbcType="VARCHAR" property="msg" />
		<result column="sendtime" jdbcType="TIMESTAMP" property="sendtime" />
		<result column="createtime" jdbcType="TIMESTAMP" property="createtime" />
		<result column="expect_send_number" jdbcType="VARCHAR" property="expectSendNumber" />
		<result column="success_number" jdbcType="VARCHAR" property="successNumber" />
		<result column="error_number" jdbcType="VARCHAR" property="errorNumber" />
		<result column="return_result" jdbcType="VARCHAR" property="returnResult" />
		<result column="phones" jdbcType="VARCHAR" property="phones" />
		<result column="signature" jdbcType="VARCHAR" property="signature" />
		<result column="isright" jdbcType="INTEGER" property="isright" />
		<result column="name" jdbcType="VARCHAR" property="name" />
		<result column="sendstatus" jdbcType="INTEGER" property="sendstatus" />
		<result column="excelpath" jdbcType="VARCHAR" property="excelpath" />
		<result column="label" jdbcType="VARCHAR" property="label" />
		<result column="tags" jdbcType="VARCHAR" property="tags" />
		<result column="status" jdbcType="INTEGER" property="status" />
		<result column="way" jdbcType="INTEGER" property="way" />
		<result column="coupon_inject_id" jdbcType="BIGINT" property="couponInjectId" />
	</resultMap>
	
	<sql id="allColumns">
	    `id`,`tenant_id`,`model_id`,`msg`,`sendtime`,`createtime`,`expect_send_number`,`success_number`,`error_number`,`return_result`,`phones`,`signature`,`isright`,`name`,`sendstatus`,`excelpath`,`label`,`tags`,`status`,`way`,`coupon_inject_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 != modelId "> 
		and `model_id` = #{modelId} 
       	
		</if>    
	    
		<if test=" null != msg "> 
		and `msg`  like concat('%', #{msg},'%')
       	
		</if>    
	    
		<if test=" null != sendtime "> 
		and `sendtime` = #{sendtime} 
       	
		</if>    
	    
		<if test=" null != createtime "> 
		and `createtime` = #{createtime} 
       	
		</if>    
	    
		<if test=" null != expectSendNumber "> 
		and `expect_send_number`  like concat('%', #{expectSendNumber},'%')
       	
		</if>    
	    
		<if test=" null != successNumber "> 
		and `success_number`  like concat('%', #{successNumber},'%')
       	
		</if>    
	    
		<if test=" null != errorNumber "> 
		and `error_number`  like concat('%', #{errorNumber},'%')
       	
		</if>    
	    
		<if test=" null != returnResult "> 
		and `return_result`  like concat('%', #{returnResult},'%')
       	
		</if>    
	    
		<if test=" null != phones "> 
		and `phones`  like concat('%', #{phones},'%')
       	
		</if>    
	    
		<if test=" null != signature "> 
		and `signature`  like concat('%', #{signature},'%')
       	
		</if>    
	    
		<if test=" null != isright "> 
		and `isright` = #{isright} 
       	
		</if>    
	    
		<if test=" null != name "> 
		and `name`  like concat('%', #{name},'%')
       	
		</if>    
	    
		<if test=" null != sendstatus "> 
		and `sendstatus` = #{sendstatus} 
       	
		</if>
		<if test=" null != status ">
			and `status` = #{status}

		</if>
		<if test=" null != way ">
			and `way` = #{way}
		</if>
		<if test=" null != couponInjectId ">
			and `coupon_inject_id` = #{couponInjectId}
		</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.msg.WxMsg" resultMap="BaseResultMap">
		select <include refid="allColumns" /> from wx_msg
		<include refid="dynamicWhereConditions" />
	</select>
	

</mapper>
