<?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.product.dao.impl.SysProductMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.product.entity.SysProduct">
		<!--主键 -->
		<result property="id" column="ID" />
		<!--产品编码 -->
		<result property="code" column="code" />
		<!--产品名称 -->
		<result property="name" column="name" />
		<!--产品分类 -->
		<result property="classify" column="classify" />
		<!--产品分类 -->
		<result property="classifyName" column="classify_name" />
		<!--产品描述 -->
		<result property="description" column="description" />
		<!--出品公司 -->
		<result property="productionCompany" column="production_company" />
		<!--产品介绍图片 -->
		<result property="picturePath" column="picture_path" />
		<!--系统类型 -->
		<result property="sysType" column="sys_type" />
		<!--排序号 -->
		<result property="sorts" column="sorts" />
		<!--组织机构ID -->
		<result property="orgId" column="org_id" />
		<!--状态 1有效 0无效 -->
		<result property="sts" column="sts" />
		<!--创建人ID -->
		<result property="createUserId" column="create_user_id" />
		<!--创建时间ID -->
		<result property="createTime" column="create_time" />
		<!--修改时间 -->
		<result property="modifyTime" column="modify_time" />
		<!--修改人ID -->
		<result property="modifyUserId" column="modify_user_id" />
	</resultMap>

	<sql id="Sysproduct_Base_Column_List">
		ID as id,
		code as code,
		name as name,
		classify as classify,
		description as description,
		production_company as production_company,
		picture_path as picture_path,
		sys_type as sys_type,
		sorts as sorts,
		org_id as org_id,
		sts as sts,
		create_user_id as create_user_id,
		create_time as create_time,
		modify_time as modify_time,
		modify_user_id as modify_user_id
	</sql>
	<sql id="Sysproduct_Base_Column_List_by">
		a.ID as id,
		a.code as code,
		a.name as name,
		a.classify as classify,
		d.column_content as classify_name,
		a.description as description,
		a.production_company as production_company,
		a.picture_path as picture_path,
		a.sys_type as sys_type,
		a.sorts as sorts,
		a.org_id as org_id,
		a.sts as sts,
		a.create_user_id as create_user_id,
		a.create_time as create_time,
		a.modify_time as modify_time,
		a.modify_user_id as modify_user_id
	</sql>
	<!--通过ID获取数据 -->
	<select id="entity_get" resultMap="get-entity-result">
		select
		<include refid="Sysproduct_Base_Column_List" />
		from sys_product where sts = 'Y' and  id = #{id}
	</select>
	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		update sys_product set
		<trim suffix="" suffixOverrides=",">
			<if test="id != null ">ID = #{id},</if>
			<if test="code != null and code !='' "> code = #{code},</if>
			<if test="name != null and name !='' "> name = #{name},</if>
			<if test="classify != null and classify !='' "> classify = #{classify},</if>
			<if test="description != null and description !='' "> description = #{description},</if>
			<if test="productionCompany != null and productionCompany !='' "> production_company = #{productionCompany},</if>
			<if test="picturePath != null and picturePath !='' "> picture_path = #{picturePath},</if>
			<if test="sysType != null and sysType !='' "> sys_type = #{sysType},</if>
			<if test="sorts != null ">sorts = #{sorts},</if>
			<if test="orgId != null ">org_id = #{orgId},</if>
			<if test="sts != null ">sts = #{sts},</if>
			<if test="createUserId != null ">create_user_id = #{createUserId},</if>
			<if test="createTime != null ">create_time = #{createTime},</if>
			<if test="modifyTime != null ">modify_time = #{modifyTime},</if>
			<if test="modifyUserId != null ">modify_user_id = #{modifyUserId},</if>
		</trim>
		where id = #{id}
	</update>
	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		select
		<include refid="Sysproduct_Base_Column_List_by" />
		from sys_product a
		left join sys_dictionaryshop_new d on d.tab_name = 'sys_product' and  d.column_name = 'classify' and a.classify = d.column_value

		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">a.ID= #{id} </if>
			<if test="code != null and code !='' "> and a.code = #{code} </if>
			<if test="name != null and name !='' "> and a.name = #{name}</if>
			<if test="classify != null and classify !='' "> and a.classify = #{classify}</if>
			<if test="description != null and description !='' "> and a.description = #{description}</if>
			<if test="productionCompany != null and productionCompany !='' "> and a.production_company = #{productionCompany}</if>
			<if test="picturePath != null and picturePath !='' "> and a.picture_path = #{picturePath}</if>
			<if test="sysType != null and sysType !='' "> and a.sys_type = #{sysType}</if>
			<if test="sorts != null "> and a.sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and a.org_id = #{orgId}</if>
			<if test="sts != null and sts !='' "> and a.sts = #{sts}</if>
			<if test="createUserId != null and createUserId !='' "> and a.create_user_id = #{createUserId}</if>
			<if test="createTime != null and createTime !='' "> and a.create_time = #{createTime}</if>
			<if test="modifyTime != null and modifyTime !='' "> and a.modify_time = #{modifyTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and a.modify_user_id = #{modifyUserId}</if>
		</trim>
		order by a.sorts asc
	</select>


	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_count" resultType="java.lang.Integer" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		select
		count(*)
		from sys_product
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">ID= #{id} </if>
			<if test="code != null and code !='' "> and code = #{code} </if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="classify != null and classify !='' "> and classify = #{classify}</if>
			<if test="description != null and description !='' "> and description = #{description}</if>
			<if test="productionCompany != null and productionCompany !='' "> and production_company = #{productionCompany}</if>
			<if test="picturePath != null and picturePath !='' "> and picture_path = #{picturePath}</if>
			<if test="sysType != null and sysType !='' "> and sys_type = #{sysType}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null and createTime !='' "> and create_time = #{createTime}</if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time = #{modifyTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
		</trim>
	</select>



	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		select
		<include refid="Sysproduct_Base_Column_List_by" />
		from sys_product a
		left join sys_dictionaryshop_new d on d.tab_name = 'sys_product' and  d.column_name = 'classify' and a.classify = d.column_value
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">a.ID = #{id}</if>
			<if test="code != null and code !='' "> and  a.code like concat('%',#{code},'%') </if>
			<if test="name != null and name !='' "> and name like a.concat('%',#{name},'%') </if>
			<if test="classify != null and classify !='' "> and d.column_content like concat('%',#{classify},'%') </if>
			<if test="description != null and description !='' "> and a.description like concat('%',#{description},'%') </if>
			<if test="productionCompany != null and productionCompany !='' "> and a.production_company like concat('%',#{productionCompany},'%') </if>
			<if test="picturePath != null and picturePath !='' "> and a.picture_path like concat('%',#{picturePath},'%') </if>
			<if test="sysType != null and sysType !='' "> and a.sys_type like concat('%',#{sysType},'%') </if>
			<if test="sorts != null "> and a.sorts like concat('%', #{sorts},'%')</if>
			<if test="orgId != null and orgId !='' "> and a.org_id like concat('%', #{orgId},'%')</if>
			<if test="sts != null and sts !='' "> and a.sts like concat('%', #{sts},'%')</if>
			<if test="createUserId != null and createUserId !='' "> and a.create_user_id like concat('%', #{createUserId},'%')</if>
			<if test="createTime != null and createTime !='' "> and a.create_time like concat('%', #{createTime},'%')</if>
			<if test="modifyTime != null and modifyTime !='' "> and a.modify_time like concat('%', #{modifyTime},'%')</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and a.modify_user_id like concat('%', #{modifyUserId},'%')</if>
		</trim>
		order by a.sorts asc
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		select
		<include refid="Sysproduct_Base_Column_List_by" />
		from sys_product a
		left join sys_dictionaryshop_new d on d.tab_name = 'sys_product' and  d.column_name = 'classify' and a.classify = d.column_value

		<trim prefix="where" prefixOverrides="or">
			<if test="id != null ">a.ID = #{id}</if>
			<if test="code != null and code !='' "> or a.code = #{code} </if>
			<if test="name != null and name !='' "> or a.name = #{name} </if>
			<if test="classify != null and classify !='' "> or a.classify = #{classify} </if>
			<if test="description != null and description !='' "> or a.description = #{description} </if>
			<if test="productionCompany != null and productionCompany !='' "> or a.production_company = #{productionCompany} </if>
			<if test="picturePath != null and picturePath !='' "> or a.picture_path = #{picturePath} </if>
			<if test="sysType != null and sysType !='' "> or a.sys_type = #{sysType} </if>
			<if test="sorts != null "> or a.sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> or a.org_id = #{orgId}</if>
			<if test="sts != null and sts !='' "> or a.sts = #{sts}</if>
			<if test="createUserId != null and createUserId !='' "> or a.create_user_id = #{createUserId}</if>
			<if test="createTime != null and createTime !='' "> or a.create_time = #{createTime}</if>
			<if test="modifyTime != null and modifyTime !='' "> or a.modify_time = #{modifyTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> or a.modify_user_id = #{modifyUserId}</if>
		</trim>
		order by a.sorts asc
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		insert into sys_product(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null ">ID,</if>
			<if test="code != null and code !='' "> code, </if>
			<if test="name != null and name !='' "> name, </if>
			<if test="classify != null and classify !='' "> classify, </if>
			<if test="description != null and description !='' "> description, </if>
			<if test="productionCompany != null and productionCompany !='' "> production_company, </if>
			<if test="picturePath != null and picturePath !='' "> picture_path, </if>
			<if test="sysType != null and sysType !='' "> sys_type, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="orgId != null ">org_id,</if>
			<if test="sts != null ">sts,</if>
			<if test="createUserId != null ">create_user_id,</if>
			<if test="createTime != null ">create_time,</if>
			<if test="modifyTime != null ">modify_time,</if>
			<if test="modifyUserId != null ">modify_user_id,</if>
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null ">#{id},</if>
			<if test="code != null and code !='' "> #{code}, </if>
			<if test="name != null and name !='' "> #{name}, </if>
			<if test="classify != null and classify !='' "> #{classify}, </if>
			<if test="description != null and description !='' "> #{description}, </if>
			<if test="productionCompany != null and productionCompany !='' "> #{productionCompany}, </if>
			<if test="picturePath != null and picturePath !='' "> #{picturePath}, </if>
			<if test="sysType != null and sysType !='' "> #{sysType}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="orgId != null ">#{orgId},</if>
			<if test="sts != null ">#{sts},</if>
			<if test="createUserId != null ">#{createUserId},</if>
			<if test="createTime != null ">#{createTime},</if>
			<if test="modifyTime != null ">#{modifyTime},</if>
			<if test="modifyUserId != null ">#{modifyUserId},</if>
		</trim>
		)
	</insert>


	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		delete from sys_product where id =#{id}
	</delete>


	<!-- 修改 -->
	<update id="logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.product.entity.SysProduct">
		update sys_product set
		sts='N',modify_time = #{modifyTime} ,modify_user_id = #{modifyUserId}
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">and ID = #{id}</if>
			<if test="code != null and code !='' "> and code = #{code}</if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="classify != null and classify !='' "> and classify = #{classify}</if>
			<if test="description != null and description !='' "> and description = #{description}</if>
			<if test="productionCompany != null and productionCompany !='' "> and production_company = #{productionCompany}</if>
			<if test="picturePath != null and picturePath !='' "> and picture_path = #{picturePath}</if>
			<if test="sysType != null and sysType !='' "> and sys_type = #{sysType}</if>
			<if test="sorts != null ">and sorts = #{sorts}</if>
			<if test="orgId != null ">and org_id = #{orgId}</if>
			<if test="sts != null ">and sts = #{sts}</if>
			<if test="createUserId != null ">and create_user_id = #{createUserId}</if>
			<if test="createTime != null ">and create_time = #{createTime}</if>
		</trim>
	</update>
</mapper>
