<?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.bus.OutsidersBlackListMapper">

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

	<!-- 字段用于新增 -->
	<sql id="Field">
		OUTSIDERSBLACKLIST_ID,
		AFFILIATED_UNIT,
		NAME,
		PHONO_NUMBER,
		STATE,
		CREATORID,
		CREATOR,
		CREATTIME,
		OPERATOR,
		OPERATTIME,
		CORPINFO_ID
	</sql>

	<!-- 字段值 -->
	<sql id="FieldValue">
		#{OUTSIDERSBLACKLIST_ID},
		#{AFFILIATED_UNIT},
		#{NAME},
		#{PHONO_NUMBER},
		#{STATE},
		#{CREATORID},
		#{CREATOR},
		#{CREATTIME},
		#{OPERATOR},
		#{OPERATTIME},
		#{CORPINFO_ID}
	</sql>

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

	<update id="edit" parameterType="pd">
		update
			<include refid="tableName"></include>
		set
			STATE = #{STATE}
		where
		OUTSIDERSBLACKLIST_ID = #{OUTSIDERSBLACKLIST_ID}
	</update>

	<select id="listPage" parameterType="page" resultType="pd">
		select
			<include refid="Field"></include>
		from
			<include refid="tableName"></include>
		where 1=1
		and CORPINFO_ID = #{pd.CORPINFO_ID}
		<if test="pd.NAME != null and pd.NAME != ''"><!-- 关键词检索 -->
			AND
			(
			NAME LIKE CONCAT(CONCAT('%', #{pd.NAME}),'%')
			)
		</if>
		<if test="pd.PHONO_NUMBER != null and pd.PHONO_NUMBER != ''"><!-- 关键词检索 -->
			AND
			(
			PHONO_NUMBER LIKE CONCAT(CONCAT('%', #{pd.PHONO_NUMBER}),'%')
			)
		</if>
		<if test="pd.STATE != null and pd.STATE != ''"><!-- 关键词检索 -->
			AND STATE = #{pd.STATE}
		</if>
		order by CREATTIME desc
	</select>



	<select id="findByPhonoNumber" parameterType="pd" resultType="pd">
		select
		<include refid="Field"></include>
		from
		<include refid="tableName"></include>
		where
		PHONO_NUMBER = #{PHONO_NUMBER}
		and
		STATE = 0
		and CORPINFO_ID =#{CORPINFO_ID}
	</select>







</mapper>
