<?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.WxFlowModelMapper">

	<resultMap id="BaseResultMap" type="com.iformall.domain.po.WxFlowModel">
		<id column="id" jdbcType="BIGINT" property="id" />
		<result column="tenantId" property="tenantId" />
		<result column="name" property="name" />
		<result column="flow" property="flow" />
		<result column="create_user" property="createUser" />
		<result column="create_date" property="createDate" />
		<result column="update_date" property="updateDate" />
		<result column="flow_id" property="flowId" />
	</resultMap>


	<sql id="dynamicWhereConditions">
		where 1 = 1
		<if test=" null != tenantId ">
			and `tenant_id` = #{tenantId}
		</if>
		<if test=" null != id "> and `id` = #{id} </if>
		<if test="null != name and '' != name "> and `name` like concat('%', #{name},'%') </if>

		<if test=" null != sortColumns"> order by ${sortColumns} </if>
		<if test=" null == sortColumns"> order by id desc </if>
	</sql>

	<select id="findList" parameterType="com.iformall.domain.po.WxFlowModel" resultMap="BaseResultMap">
		select * from wx_flow_model
		<include refid="dynamicWhereConditions" />
	</select>

	<select id="getModelBybusiness" parameterType="com.iformall.domain.po.WxFlowModel" resultMap="BaseResultMap">
		select m.* from wx_flow_config w,wx_flow_model m
		where w.model_id = m.id and w.type = #{flowType}
		<if test=" null != tenantId ">
			and w.tenant_id = #{tenantId}
			and m.tenant_id = #{tenantId}
		</if>
	</select>



</mapper>
