<?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.thirdparty.product.dao.impl.SysThirdpartyProductMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		<!--唯一标识码 -->
		<result property="id" column="id" />
		<!--产品id -->
		<result property="productId" column="product_id" />
		<!--编码 -->
		<result property="productCode" column="product_code" />
		<!--名称 -->
		<result property="productName" column="product_name" />
		<!--产品版本id -->
		<result property="productVersionId" column="product_version_id" />
		<!--产品版本号 -->
		<result property="versionNumber" column="version_number" />
		<!--上级id -->
		<result property="upId" column="up_id" />
		<!--层级 -->
		<result property="lvl" column="lvl" />
		<!--排序号 -->
		<result property="sorts" column="sorts" />
		<!--创建人id -->
		<result property="orgId" column="org_id" />
		<!--状态(Y正常N删除) -->
		<result property="sts" column="sts" />
		<!--创建时间 -->
		<result property="createTime" column="create_time" />
		<!--创建人id -->
		<result property="createUserId" column="create_user_id" />
		<!--修改时间 -->
		<result property="modifyTime" column="modify_time" />
		<!--修改人id -->
		<result property="modifyUserId" column="modify_user_id" />
	</resultMap>

	<sql id="Base_Column_List">
		id,
		product_id,
		product_code,
		product_name,
		product_version_id,
		version_number,
		up_id,
		lvl,
		sorts,
		org_id,
		sts,
		create_time,
		create_user_id,
		modify_time,
		modify_user_id
	</sql>

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

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		select
		<include refid="Base_Column_List" />
		from sys_thirdparty_product
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="productId != null and productId !='' "> and product_id = #{productId}</if>
			<if test="productCode != null and productCode !='' "> and product_code = #{productCode}</if>
			<if test="productName != null and productName !='' "> and product_name = #{productName}</if>
			<if test="productVersionId != null and productVersionId !='' "> and product_version_id = #{productVersionId}</if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number = #{versionNumber}</if>
			<if test="upId != null and upId !='' "> and up_id = #{upId}</if>
			<if test="lvl != null "> and lvl = #{lvl}</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="createTime != null "> and create_time = #{createTime}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by ${sort} ${order}</if>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		select count(1) from sys_thirdparty_product
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="productId != null and productId !='' "> and product_id = #{productId}</if>
			<if test="productCode != null and productCode !='' "> and product_code = #{productCode}</if>
			<if test="productName != null and productName !='' "> and product_name = #{productName}</if>
			<if test="productVersionId != null and productVersionId !='' "> and product_version_id = #{productVersionId}</if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number = #{versionNumber}</if>
			<if test="upId != null and upId !='' "> and up_id = #{upId}</if>
			<if test="lvl != null "> and lvl = #{lvl}</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="createTime != null "> and create_time = #{createTime}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="modifyTime != null "> 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.thirdparty.product.entity.SysThirdpartyProduct">
		select
		<include refid="Base_Column_List" />
		from sys_thirdparty_product
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="productId != null and productId !='' "> and product_id like concat('%',#{productId},'%') </if>
			<if test="productCode != null and productCode !='' "> and product_code like concat('%',#{productCode},'%') </if>
			<if test="productName != null and productName !='' "> and product_name like concat('%',#{productName},'%') </if>
			<if test="productVersionId != null and productVersionId !='' "> and product_version_id like concat('%',#{productVersionId},'%') </if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number like concat('%',#{versionNumber},'%') </if>
			<if test="upId != null and upId !='' "> and up_id like concat('%',#{upId},'%') </if>
			<if test="lvl != null "> and lvl = #{lvl}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id like concat('%',#{orgId},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </if>
			<if test="createTime != null and createTime !='' "> and create_time like concat('%',#{createTime},'%') </if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id like concat('%',#{createUserId},'%') </if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time like concat('%',#{modifyTime},'%') </if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id like concat('%',#{modifyUserId},'%') </if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		select
		<include refid="Base_Column_List" />
		from sys_thirdparty_product
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="productId != null and productId !='' "> or product_id = #{productId} </if>
			<if test="productCode != null and productCode !='' "> or product_code = #{productCode} </if>
			<if test="productName != null and productName !='' "> or product_name = #{productName} </if>
			<if test="productVersionId != null and productVersionId !='' "> or product_version_id = #{productVersionId} </if>
			<if test="versionNumber != null and versionNumber !='' "> or version_number = #{versionNumber} </if>
			<if test="upId != null and upId !='' "> or up_id = #{upId} </if>
			<if test="lvl != null "> or lvl = #{lvl}</if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> or org_id = #{orgId} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </if>
			<if test="createTime != null and createTime !='' "> or create_time = #{createTime} </if>
			<if test="createUserId != null and createUserId !='' "> or create_user_id = #{createUserId} </if>
			<if test="modifyTime != null and modifyTime !='' "> or modify_time = #{modifyTime} </if>
			<if test="modifyUserId != null and modifyUserId !='' "> or modify_user_id = #{modifyUserId} </if>
		</trim>
		<if test=" sort == null or sort =='' "> order by sorts asc</if>
		<if test=" sort !='' and sort!=null and order !='' and order!=null ">order by  ${sort} ${order}</if>
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		insert into sys_thirdparty_product(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="productId != null and productId !='' "> product_id, </if>
			<if test="productCode != null and productCode !='' "> product_code, </if>
			<if test="productName != null and productName !='' "> product_name, </if>
			<if test="productVersionId != null and productVersionId !='' "> product_version_id, </if>
			<if test="versionNumber != null and versionNumber !='' "> version_number, </if>
			<if test="upId != null and upId !='' "> up_id, </if>
			<if test="lvl != null ">lvl,</if>
			<if test="sorts != null ">sorts,</if>
			<if test="orgId != null and orgId !='' "> org_id, </if>
			<if test="sts != null and sts !='' "> sts, </if>
			<if test="createTime != null ">create_time,</if>
			<if test="createUserId != null and createUserId !='' "> create_user_id, </if>
			<if test="modifyTime != null ">modify_time,</if>
			<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id, </if>
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="productId != null and productId !='' "> #{productId}, </if>
			<if test="productCode != null and productCode !='' "> #{productCode}, </if>
			<if test="productName != null and productName !='' "> #{productName}, </if>
			<if test="productVersionId != null and productVersionId !='' "> #{productVersionId}, </if>
			<if test="versionNumber != null and versionNumber !='' "> #{versionNumber}, </if>
			<if test="upId != null and upId !='' "> #{upId}, </if>
			<if test="lvl != null ">#{lvl},</if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="orgId != null and orgId !='' "> #{orgId}, </if>
			<if test="sts != null and sts !='' "> #{sts}, </if>
			<if test="createTime != null ">#{createTime},</if>
			<if test="createUserId != null and createUserId !='' "> #{createUserId}, </if>
			<if test="modifyTime != null ">#{modifyTime},</if>
			<if test="modifyUserId != null and modifyUserId !='' "> #{modifyUserId}, </if>
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		update sys_thirdparty_product set
		<trim suffix="" suffixOverrides=",">
				<if test="productId != null and productId !='' "> product_id = #{productId},</if>
				<if test="productCode != null and productCode !='' "> product_code = #{productCode},</if>
				<if test="productName != null and productName !='' "> product_name = #{productName},</if>
				<if test="productVersionId != null and productVersionId !='' "> product_version_id = #{productVersionId},</if>
				<if test="versionNumber != null and versionNumber !='' "> version_number = #{versionNumber},</if>
				<if test="upId != null and upId !='' "> up_id = #{upId},</if>
				<if test="lvl != null ">lvl = #{lvl},</if>
				<if test="sorts != null ">sorts = #{sorts},</if>
				<if test="orgId != null and orgId !='' "> org_id = #{orgId},</if>
				<if test="sts != null and sts !='' "> sts = #{sts},</if>
				<if test="createTime != null ">create_time = #{createTime},</if>
				<if test="createUserId != null and createUserId !='' "> create_user_id = #{createUserId},</if>
				<if test="modifyTime != null ">modify_time = #{modifyTime},</if>
				<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id = #{modifyUserId},</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 逻辑删除 -->
	<update id="entity_logicDelete" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		update sys_thirdparty_product set
		sts='N',modify_time = now(),modify_user_id = #{modifyUserId} where
		id = #{id}
	</update>

	<!-- 逻辑删除多条件 -->
	<update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.thirdparty.product.entity.SysThirdpartyProduct">
		update sys_thirdparty_product set
		sts='N',modify_time = now(),modify_user_id = #{modifyUserId}
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="productId != null and productId !='' "> and product_id = #{productId}</if>
			<if test="productCode != null and productCode !='' "> and product_code = #{productCode}</if>
			<if test="productName != null and productName !='' "> and product_name = #{productName}</if>
			<if test="productVersionId != null and productVersionId !='' "> and product_version_id = #{productVersionId}</if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number = #{versionNumber}</if>
			<if test="upId != null and upId !='' "> and up_id = #{upId}</if>
			<if test="lvl != null "> and lvl = #{lvl}</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>
		</trim>
	</update>

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

	<!-- 逻辑删除多条件 -->
	<update id="delect_by_Id" parameterType="java.lang.String">
		update sys_thirdparty_product set
		sts='N',modify_time = now()
		WHERE id in
		<foreach item="ids" collection="list" open="(" separator="," close=")">
			#{ids}
		</foreach>
	</update>

</mapper>
