<?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.hzya.frame.sys.testReturn.dao.impl.TestReturnMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.testReturn.entity.TestReturn">
		<!--唯一标识码 -->
		<result property="id" column="id" />
		<!--类型 -->
		<result property="type" column="type" />
		<!--值 -->
		<result property="value" column="value" />
	</resultMap>

	<sql id="Base_Column_List">
		id,
		type,
		value
	</sql>

	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-entity-result">
		select
		<include refid="Base_Column_List" />
		from sys_test_return where id = #{ id }
	</select>

	<!--通过ID获取数据 -->
	<select id="entity_get_by_type" resultMap="get-entity-result">
		select
		<include refid="Base_Column_List" />
		from sys_test_return where type = #{ type }
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		select
		<include refid="Base_Column_List" />
		from sys_test_return
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="type != null and type !='' "> and type = #{type}</if>
			<if test="value != null and value !='' "> and value = #{value}</if>
		</trim>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		select count(1) from sys_test_return
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="type != null and type !='' "> and type = #{type}</if>
			<if test="value != null and value !='' "> and value = #{value}</if>
		</trim>
	</select>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		select
		<include refid="Base_Column_List" />
		from sys_test_return
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="type != null and type !='' "> and type like concat('%',#{type},'%') </if>
			<if test="value != null and value !='' "> and value like concat('%',#{value},'%') </if>
		</trim>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		select
		<include refid="Base_Column_List" />
		from sys_test_return
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="type != null and type !='' "> or type = #{type} </if>
			<if test="value != null and value !='' "> or value = #{value} </if>
		</trim>
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		insert into sys_test_return(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="type != null and type !='' "> type, </if>
			<if test="value != null and value !='' "> value, </if>
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="type != null and type !='' "> #{type}, </if>
			<if test="value != null and value !='' "> #{value}, </if>
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		update sys_test_return set
		<trim suffix="" suffixOverrides=",">
				<if test="type != null and type !='' "> type = #{type},</if>
				<if test="value != null and value !='' "> value = #{value},</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.testReturn.entity.TestReturn">
		delete from sys_test_return where id =#{id}
	</delete>
</mapper>
