<?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.zcloud.mapper.datasource.corp.CorpStopMapper">

	<!--表名 -->
	<sql id="tableName">
		BUS_SMALl_CORP_STOPUSE
	</sql>

	<!-- 字段 -->
	<sql id="Field">
		f.STOPUSE_ID,
		f.STOPRUSE_CONTENT,
		f.CORPINFO_ID,
		f.CREATOR,
		f.CREATTIME,
		f.OPERATOR,
		f.OPERATTIME,
		f.ISDELETE,
		f.REASON,
		f.ISHANDLE,
		f.TYPE
	</sql>

	<!-- 字段用于新增 -->
	<sql id="Field2">
		STOPUSE_ID,
		STOPRUSE_CONTENT,
		CORPINFO_ID,
		CREATOR,
		CREATTIME,
		OPERATOR,
		OPERATTIME,
		ISDELETE,
		REASON,
		ISHANDLE,
		TYPE
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{STOPUSE_ID},
		#{STOPRUSE_CONTENT},
		#{CORPINFO_ID},
		#{CREATOR},
		#{CREATTIME},
		#{OPERATOR},
		#{OPERATTIME},
		#{ISDELETE},
		#{REASON},
		#{ISHANDLE},
		#{TYPE}
	</sql>

	<!-- 新增-->
	<insert id="save" parameterType="pd">
		insert into
		<include refid="tableName"></include>
		(
		<include refid="Field2"></include>
		) values (
		<include refid="FieldValue"></include>
		)
	</insert>

	<!-- 删除-->
	<delete id="delete" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
			ISDELETE = '1'
		where
			CORPINFO_ID = #{CORPINFO_ID}
	</delete>





	<!-- 修改 -->
	<update id="edit" parameterType="pd">
		update
		<include refid="tableName"></include>
		set
		ISSTOP = '0'
		where
		STOPUSE_ID = #{STOPUSE_ID}
	</update>

	<!-- 列表 -->
	<select id="findById" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>,b.CORP_NAME as CORPNAME
		from
		<include refid="tableName"></include> f
		left join bus_corp_info b on f.CORPINFO_ID = b.CORPINFO_ID
		where f.ISDELETE = '0'
		and f.STOPUSE_ID = #{STOPUSE_ID}
	</select>

	<!-- 列表 -->
	<select id="datalistPage" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include> f
		where f.ISDELETE = '0' and f.CORPINFO_ID = #{pd.CORPINFO_ID}
		<if test="pd.KEYWORDS != null and pd.KEYWORDS != ''"><!-- 关键词检索 -->
			and
			(
			-- 			f.CORP_NAME LIKE CONCAT(CONCAT('%', #{pd.KEYWORDS}),'%')
			)
		</if>

		order by f.CREATTIME desc
	</select>

	<!-- 列表 -->
	<select id="isHandle" parameterType="page" resultType="pd">
		select
		<include refid="Field"></include>,b.CORP_NAME as CORPNAME
		from
		<include refid="tableName"></include> f
		left join bus_corp_info b on f.CORPINFO_ID = b.CORPINFO_ID
		where f.ISDELETE = '0'
		and f.CORPINFO_ID = #{CORPINFO_ID}
		and f.ishandle = '0'
		and f.TYPE = #{TYPE}
	</select>

</mapper>
