<?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.dictionaryshopNew.dao.impl.SysDictionaryshopNewMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		<!--唯一标识码 -->
		<result property="id" column="id" />
		<!--表名 -->
		<result property="tabName" column="tab_name" />
		<!--列名 -->
		<result property="columnName" column="column_name" />
		<!--列说明 -->
		<result property="columnContent" column="column_content" />
		<!--列值 -->
		<result property="columnValue" column="column_value" />
		<!--列数字值用于比较数据字典大小 -->
		<result property="columnNumValue" column="column_num_value" />
		<!--如果数据字典上下级，通过连接上级id，当前表id -->
		<result property="upId" column="up_id" />
		<!--备注 -->
		<result property="memo" column="memo" />
		<!--使用状态,1 使用，2 不使用 -->
		<result property="usedSts" column="used_sts" />
		<!--排序 -->
		<result property="sorts" column="sorts" />
		<!--所属组织机构 -->
		<result property="orgId" column="org_id" />
		<!--创建人 -->
		<result property="createUserId" column="create_user_id" />
		<!--创建时间 -->
		<result property="createTime" column="create_time" />
		<!--修改人 -->
		<result property="modifyUserId" column="modify_user_id" />
		<!--修改时间 -->
		<result property="modifyTime" column="modify_time" />
		<!--状态 -->
		<result property="sts" column="sts" />
	</resultMap>

	<sql id="Base_Column_List">
		id,
		tab_name,
		column_name,
		column_content,
		column_value,
		column_num_value,
		up_id,
		memo,
		used_sts,
		sorts,
		org_id,
		create_user_id,
		create_time,
		modify_user_id,
		modify_time,
		sts
	</sql>

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

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		select
		<include refid="Base_Column_List" />
		from sys_dictionaryshop_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="tabName != null and tabName !='' "> and tab_name = #{tabName}</if>
			<if test="columnName != null and columnName !='' "> and column_name = #{columnName}</if>
			<if test="columnContent != null and columnContent !='' "> and column_content = #{columnContent}</if>
			<if test="columnValue != null and columnValue !='' "> and column_value = #{columnValue}</if>
			<if test="columnNumValue != null "> and column_num_value = #{columnNumValue}</if>
			<if test="upId != null "> and up_id = #{upId}</if>
			<if test="memo != null and memo !='' "> and memo = #{memo}</if>
			<if test="usedSts != null and usedSts !='' "> and used_sts = #{usedSts}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null "> and create_time = #{createTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</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.dictionaryshopNew.entity.SysDictionaryshopNew">
		select count(1) from sys_dictionaryshop_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="tabName != null and tabName !='' "> and tab_name = #{tabName}</if>
			<if test="columnName != null and columnName !='' "> and column_name = #{columnName}</if>
			<if test="columnContent != null and columnContent !='' "> and column_content = #{columnContent}</if>
			<if test="columnValue != null and columnValue !='' "> and column_value = #{columnValue}</if>
			<if test="columnNumValue != null "> and column_num_value = #{columnNumValue}</if>
			<if test="upId != null "> and up_id = #{upId}</if>
			<if test="memo != null and memo !='' "> and memo = #{memo}</if>
			<if test="usedSts != null and usedSts !='' "> and used_sts = #{usedSts}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id = #{createUserId}</if>
			<if test="createTime != null "> and create_time = #{createTime}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
		</trim>
	</select>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		select
		<include refid="Base_Column_List" />
		from sys_dictionaryshop_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="tabName != null and tabName !='' "> and tab_name like concat('%',#{tabName},'%') </if>
			<if test="columnName != null and columnName !='' "> and column_name like concat('%',#{columnName},'%') </if>
			<if test="columnContent != null and columnContent !='' "> and column_content like concat('%',#{columnContent},'%') </if>
			<if test="columnValue != null and columnValue !='' "> and column_value like concat('%',#{columnValue},'%') </if>
			<if test="columnNumValue != null "> and column_num_value = #{columnNumValue}</if>
			<if test="upId != null "> and up_id = #{upId}</if>
			<if test="memo != null and memo !='' "> and memo like concat('%',#{memo},'%') </if>
			<if test="usedSts != null and usedSts !='' "> and used_sts like concat('%',#{usedSts},'%') </if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id like concat('%',#{orgId},'%') </if>
			<if test="createUserId != null and createUserId !='' "> and create_user_id like concat('%',#{createUserId},'%') </if>
			<if test="createTime != null and createTime !='' "> and create_time like concat('%',#{createTime},'%') </if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id like concat('%',#{modifyUserId},'%') </if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time like concat('%',#{modifyTime},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </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.dictionaryshopNew.entity.SysDictionaryshopNew">
		select
		<include refid="Base_Column_List" />
		from sys_dictionaryshop_new
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="tabName != null and tabName !='' "> or tab_name = #{tabName} </if>
			<if test="columnName != null and columnName !='' "> or column_name = #{columnName} </if>
			<if test="columnContent != null and columnContent !='' "> or column_content = #{columnContent} </if>
			<if test="columnValue != null and columnValue !='' "> or column_value = #{columnValue} </if>
			<if test="columnNumValue != null "> or column_num_value = #{columnNumValue}</if>
			<if test="upId != null "> or up_id = #{upId}</if>
			<if test="memo != null and memo !='' "> or memo = #{memo} </if>
			<if test="usedSts != null and usedSts !='' "> or used_sts = #{usedSts} </if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> or org_id = #{orgId} </if>
			<if test="createUserId != null and createUserId !='' "> or create_user_id = #{createUserId} </if>
			<if test="createTime != null and createTime !='' "> or create_time = #{createTime} </if>
			<if test="modifyUserId != null and modifyUserId !='' "> or modify_user_id = #{modifyUserId} </if>
			<if test="modifyTime != null and modifyTime !='' "> or modify_time = #{modifyTime} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </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.dictionaryshopNew.entity.SysDictionaryshopNew">
		insert into sys_dictionaryshop_new(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> id, </if>
			<if test="tabName != null and tabName !='' "> tab_name, </if>
			<if test="columnName != null and columnName !='' "> column_name, </if>
			<if test="columnContent != null and columnContent !='' "> column_content, </if>
			<if test="columnValue != null and columnValue !='' "> column_value, </if>
			<if test="columnNumValue != null ">column_num_value,</if>
			<if test="upId != null ">up_id,</if>
			<if test="memo != null and memo !='' "> memo, </if>
			<if test="usedSts != null and usedSts !='' "> used_sts, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="orgId != null and orgId !='' "> org_id, </if>
			<if test="createUserId != null and createUserId !='' "> create_user_id, </if>
			<if test="createTime != null ">create_time,</if>
			<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id, </if>
			<if test="modifyTime != null ">modify_time,</if>
			<if test="sts != null and sts !='' "> sts, </if>
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null and id !='' "> #{id}, </if>
			<if test="tabName != null and tabName !='' "> #{tabName}, </if>
			<if test="columnName != null and columnName !='' "> #{columnName}, </if>
			<if test="columnContent != null and columnContent !='' "> #{columnContent}, </if>
			<if test="columnValue != null and columnValue !='' "> #{columnValue}, </if>
			<if test="columnNumValue != null ">#{columnNumValue},</if>
			<if test="upId != null ">#{upId},</if>
			<if test="memo != null and memo !='' "> #{memo}, </if>
			<if test="usedSts != null and usedSts !='' "> #{usedSts}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="orgId != null and orgId !='' "> #{orgId}, </if>
			<if test="createUserId != null and createUserId !='' "> #{createUserId}, </if>
			<if test="createTime != null ">#{createTime},</if>
			<if test="modifyUserId != null and modifyUserId !='' "> #{modifyUserId}, </if>
			<if test="modifyTime != null ">#{modifyTime},</if>
			<if test="sts != null and sts !='' "> #{sts}, </if>
		</trim>
		)
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		update sys_dictionaryshop_new set
		<trim suffix="" suffixOverrides=",">
				<if test="tabName != null and tabName !='' "> tab_name = #{tabName},</if>
				<if test="columnName != null and columnName !='' "> column_name = #{columnName},</if>
				<if test="columnContent != null and columnContent !='' "> column_content = #{columnContent},</if>
				<if test="columnValue != null and columnValue !='' "> column_value = #{columnValue},</if>
				<if test="columnNumValue != null ">column_num_value = #{columnNumValue},</if>
				<if test="upId != null ">up_id = #{upId},</if>
				<if test="memo != null and memo !='' "> memo = #{memo},</if>
				<if test="usedSts != null and usedSts !='' "> used_sts = #{usedSts},</if>
				<if test="sorts != null ">sorts = #{sorts},</if>
				<if test="orgId != null and orgId !='' "> org_id = #{orgId},</if>
				<if test="createUserId != null and createUserId !='' "> create_user_id = #{createUserId},</if>
				<if test="createTime != null ">create_time = #{createTime},</if>
				<if test="modifyUserId != null and modifyUserId !='' "> modify_user_id = #{modifyUserId},</if>
				<if test="modifyTime != null ">modify_time = #{modifyTime},</if>
				<if test="sts != null and sts !='' "> sts = #{sts},</if>
		</trim>
		where id = #{id}
	</update>

	<!-- 逻辑删除 -->
	<update id="entity_logicDelete" parameterType="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		update sys_dictionaryshop_new 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.dictionaryshopNew.entity.SysDictionaryshopNew">
		update sys_dictionaryshop_new 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="tabName != null and tabName !='' "> and tab_name = #{tabName}</if>
			<if test="columnName != null and columnName !='' "> and column_name = #{columnName}</if>
			<if test="columnContent != null and columnContent !='' "> and column_content = #{columnContent}</if>
			<if test="columnValue != null and columnValue !='' "> and column_value = #{columnValue}</if>
			<if test="columnNumValue != null "> and column_num_value = #{columnNumValue}</if>
			<if test="upId != null "> and up_id = #{upId}</if>
			<if test="memo != null and memo !='' "> and memo = #{memo}</if>
			<if test="usedSts != null and usedSts !='' "> and used_sts = #{usedSts}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="orgId != null and orgId !='' "> and org_id = #{orgId}</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="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modifyUserId}</if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time = #{modifyTime}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
		</trim>
	</update>

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


	<!--通过ID获取数据 -->
	<select id="entity_get_by_value" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.dictionaryshopNew.entity.SysDictionaryshopNew">
		select
		<include refid="Base_Column_List" />
		from sys_dictionaryshop_new where tab_name = #{tabName} and column_name = #{columnName} and column_value = #{columnValue} and sts='Y'
	</select>
</mapper>
