<?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.moduleNew.entity.SysModuleNewEntity">
	<resultMap id="get-SysModuleNewEntity-result" type="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		<!--主键ID -->
		<result property="id" column="id" />
		<!--Spring bean名称 -->
		<result property="service_name" column="service_name" />
		<!--等级 -->
		<result property="lvl" column="lvl" />
		<!--名称 -->
		<result property="name" column="name" />
		<!--编码 -->
		<result property="code" column="code" />
		<!--类型  0、menu 1、tree  2、list 3、view -->
		<result property="form_type" column="form_type" />
		<!--模块操作级别Superadministrator -->
		<result property="level" column="level" />
		<!--模块图标 -->
		<result property="icon" column="icon" />
		<!--上级id -->
		<result property="up_ids" column="up_ids" />
		<!--bean表名称映射key -->
		<result property="table_name" column="table_name" />
		<!--是否关键模块(Y是N否) -->
		<result property="key_modular" column="key_modular" />
		<!--跳转目标 -->
		<result property="target" column="target" />
		<!--排序编号 -->
		<result property="sorts" column="sorts" />
		<!--备注 -->
		<result property="remark" column="remark" />
		<!--菜单打开方式 -->
		<result property="open_type" column="open_type" />
		<!--表单ID -->
		<result property="form_id" column="form_id" />
		<!--应用id -->
		<result property="app_id" column="app_id" />
		<!--创建人id -->
		<result property="create_user_id" column="create_user_id" />
		<!--创建时间 -->
		<result property="create_time" column="create_time" />
		<!--修改人id -->
		<result property="modify_user_id" column="modify_user_id" />
		<!--修改时间 -->
		<result property="modify_time" column="modify_time" />
		<!--状态(Y正常N删除) -->
		<result property="sts" column="sts" />
		<!--组织机构ID -->
		<result property="org_id" column="org_id" />
	</resultMap>

	<sql id="SysModuleNewEntity_Base_Column_List">
		id,
		service_name,
		lvl,
		name,
		code,
		form_type,
		level,
		icon,
		up_ids,
		table_name,
		key_modular,
		target,
		sorts,
		remark,
		open_type,
		form_id,
		app_id,
		create_user_id,
		create_time,
		modify_user_id,
		modify_time,
		sts,
		org_id
	</sql>

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

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-SysModuleNewEntity-result" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		select
		<include refid="SysModuleNewEntity_Base_Column_List" />
		from sys_module_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="service_name != null and service_name !='' "> and service_name = #{service_name}</if>
			<if test="lvl != null and lvl !='' "> and lvl = #{lvl}</if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="code != null and code !='' "> and code = #{code}</if>
			<if test="form_type != null and form_type !='' "> and form_type = #{form_type}</if>
			<if test="level != null and level !='' "> and level = #{level}</if>
			<if test="icon != null and icon !='' "> and icon = #{icon}</if>
			<if test="up_ids != null and up_ids !='' "> and up_ids = #{up_ids}</if>
			<if test="table_name != null and table_name !='' "> and table_name = #{table_name}</if>
			<if test="key_modular != null and key_modular !='' "> and key_modular = #{key_modular}</if>
			<if test="target != null and target !='' "> and target = #{target}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="remark != null and remark !='' "> and remark = #{remark}</if>
			<if test="open_type != null and open_type !='' "> and open_type = #{open_type}</if>
			<if test="form_id != null and form_id !='' "> and form_id = #{form_id}</if>
			<if test="app_id != null and app_id !='' "> and app_id = #{app_id}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
			and sts='Y'
		</trim>
	</select>

	<!-- 查询符合条件的数量 -->
	<select id="entity_count" resultType="Integer" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		select count(1) from sys_module_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="service_name != null and service_name !='' "> and service_name = #{service_name} </if>
			<if test="lvl != null and lvl !='' "> and lvl = #{lvl} </if>
			<if test="name != null and name !='' "> and name = #{name} </if>
			<if test="code != null and code !='' "> and code = #{code} </if>
			<if test="form_type != null and form_type !='' "> and form_type = #{form_type} </if>
			<if test="level != null and level !='' "> and level = #{level} </if>
			<if test="icon != null and icon !='' "> and icon = #{icon} </if>
			<if test="up_ids != null and up_ids !='' "> and up_ids = #{up_ids} </if>
			<if test="table_name != null and table_name !='' "> and table_name = #{table_name} </if>
			<if test="key_modular != null and key_modular !='' "> and key_modular = #{key_modular} </if>
			<if test="target != null and target !='' "> and target = #{target} </if>
			<if test="sorts != null "> and sorts = #{sorts}  </if>
			<if test="remark != null and remark !='' "> and remark = #{remark} </if>
			<if test="open_type != null and open_type !='' "> and open_type = #{open_type} </if>
			<if test="form_id != null and form_id !='' "> and form_id = #{form_id} </if>
			<if test="app_id != null and app_id !='' "> and app_id = #{app_id} </if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id} </if>
			<if test="create_time != null "> and create_time = #{create_time}  </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null "> and modify_time = #{modify_time}  </if>
			<if test="sts != null and sts !='' "> and sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id} </if>
			and sts='Y'
		</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>

	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-SysModuleNewEntity-result" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		select
		<include refid="SysModuleNewEntity_Base_Column_List" />
		from sys_module_new
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' "> id like concat('%',#{id},'%') </if>
			<if test="service_name != null and service_name !='' "> and service_name like concat('%',#{service_name},'%') </if>
			<if test="lvl != null and lvl !='' "> and lvl like concat('%',#{lvl},'%') </if>
			<if test="name != null and name !='' "> and name like concat('%',#{name},'%') </if>
			<if test="code != null and code !='' "> and code like concat('%',#{code},'%') </if>
			<if test="form_type != null and form_type !='' "> and form_type like concat('%',#{form_type},'%') </if>
			<if test="level != null and level !='' "> and level like concat('%',#{level},'%') </if>
			<if test="icon != null and icon !='' "> and icon like concat('%',#{icon},'%') </if>
			<if test="up_ids != null and up_ids !='' "> and up_ids like concat('%',#{up_ids},'%') </if>
			<if test="table_name != null and table_name !='' "> and table_name like concat('%',#{table_name},'%') </if>
			<if test="key_modular != null and key_modular !='' "> and key_modular like concat('%',#{key_modular},'%') </if>
			<if test="target != null and target !='' "> and target like concat('%',#{target},'%') </if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="remark != null and remark !='' "> and remark like concat('%',#{remark},'%') </if>
			<if test="open_type != null and open_type !='' "> and open_type like concat('%',#{open_type},'%') </if>
			<if test="form_id != null and form_id !='' "> and form_id like concat('%',#{form_id},'%') </if>
			<if test="app_id != null and app_id !='' "> and app_id like concat('%',#{app_id},'%') </if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id like concat('%',#{create_user_id},'%') </if>
			<if test="create_time != null and create_time !='' "> and create_time like concat('%',#{create_time},'%') </if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id like concat('%',#{modify_user_id},'%') </if>
			<if test="modify_time != null and modify_time !='' "> and modify_time like concat('%',#{modify_time},'%') </if>
			<if test="sts != null and sts !='' "> and sts like concat('%',#{sts},'%') </if>
			<if test="org_id != null and org_id !='' "> and org_id like concat('%',#{org_id},'%') </if>
			and sts='Y'
		</trim>
	</select>

	<!-- 查询列表 字段采用or格式 -->
	<select id="entity_list_or" resultMap="get-SysModuleNewEntity-result" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		select
		<include refid="SysModuleNewEntity_Base_Column_List" />
		from sys_module_new
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="service_name != null and service_name !='' "> or service_name = #{service_name} </if>
			<if test="lvl != null and lvl !='' "> or lvl = #{lvl} </if>
			<if test="name != null and name !='' "> or name = #{name} </if>
			<if test="code != null and code !='' "> or code = #{code} </if>
			<if test="form_type != null and form_type !='' "> or form_type = #{form_type} </if>
			<if test="level != null and level !='' "> or level = #{level} </if>
			<if test="icon != null and icon !='' "> or icon = #{icon} </if>
			<if test="up_ids != null and up_ids !='' "> or up_ids = #{up_ids} </if>
			<if test="table_name != null and table_name !='' "> or table_name = #{table_name} </if>
			<if test="key_modular != null and key_modular !='' "> or key_modular = #{key_modular} </if>
			<if test="target != null and target !='' "> or target = #{target} </if>
			<if test="sorts != null "> or sorts = #{sorts}</if>
			<if test="remark != null and remark !='' "> or remark = #{remark} </if>
			<if test="open_type != null and open_type !='' "> or open_type = #{open_type} </if>
			<if test="form_id != null and form_id !='' "> or form_id = #{form_id} </if>
			<if test="app_id != null and app_id !='' "> or app_id = #{app_id} </if>
			<if test="create_user_id != null and create_user_id !='' "> or create_user_id = #{create_user_id} </if>
			<if test="create_time != null and create_time !='' "> or create_time = #{create_time} </if>
			<if test="modify_user_id != null and modify_user_id !='' "> or modify_user_id = #{modify_user_id} </if>
			<if test="modify_time != null and modify_time !='' "> or modify_time = #{modify_time} </if>
			<if test="sts != null and sts !='' "> or sts = #{sts} </if>
			<if test="org_id != null and org_id !='' "> or org_id = #{org_id} </if>
			and sts='Y'
		</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.moduleNew.entity.SysModuleNewEntity">
		insert into sys_module_new(
		<trim suffix="" suffixOverrides=",">
			<if test="service_name != null and service_name !='' "> service_name, </if>
			<if test="lvl != null and lvl !='' "> lvl, </if>
			<if test="name != null and name !='' "> name, </if>
			<if test="code != null and code !='' "> code, </if>
			<if test="form_type != null and form_type !='' "> form_type, </if>
			<if test="level != null and level !='' "> level, </if>
			<if test="icon != null and icon !='' "> icon, </if>
			<if test="up_ids != null and up_ids !='' "> up_ids, </if>
			<if test="table_name != null and table_name !='' "> table_name, </if>
			<if test="key_modular != null and key_modular !='' "> key_modular, </if>
			<if test="target != null and target !='' "> target, </if>
			<if test="sorts != null ">sorts,</if>
			<if test="remark != null and remark !='' "> remark, </if>
			<if test="open_type != null and open_type !='' "> open_type, </if>
			<if test="form_id != null and form_id !='' "> form_id, </if>
			<if test="app_id != null and app_id !='' "> app_id, </if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id, </if>
			<if test="org_id != null and org_id !='' "> org_id, </if>
			create_time,
			modify_time,
			sts
		</trim>
		)values
		(
		<trim suffix="" suffixOverrides=",">
			<if test="service_name != null and service_name !='' "> #{service_name}, </if>
			<if test="lvl != null and lvl !='' "> #{lvl}, </if>
			<if test="name != null and name !='' "> #{name}, </if>
			<if test="code != null and code !='' "> #{code}, </if>
			<if test="form_type != null and form_type !='' "> #{form_type}, </if>
			<if test="level != null and level !='' "> #{level}, </if>
			<if test="icon != null and icon !='' "> #{icon}, </if>
			<if test="up_ids != null and up_ids !='' "> #{up_ids}, </if>
			<if test="table_name != null and table_name !='' "> #{table_name}, </if>
			<if test="key_modular != null and key_modular !='' "> #{key_modular}, </if>
			<if test="target != null and target !='' "> #{target}, </if>
			<if test="sorts != null ">#{sorts},</if>
			<if test="remark != null and remark !='' "> #{remark}, </if>
			<if test="open_type != null and open_type !='' "> #{open_type}, </if>
			<if test="form_id != null and form_id !='' "> #{form_id}, </if>
			<if test="app_id != null and app_id !='' "> #{app_id}, </if>
			<if test="create_user_id != null and create_user_id !='' "> #{create_user_id}, </if>
			<if test="modify_user_id != null and modify_user_id !='' "> #{modify_user_id}, </if>
			<if test="org_id != null and org_id !='' "> #{org_id}, </if>
			<if test="create_time != null "> #{create_time} ,</if>
			<if test="create_time  == null "> now(),</if>
			<if test="modify_time != null "> #{modify_time},</if>
			<if test="modify_time  == null "> now(),</if>
			'Y'
		</trim>
		)
		<selectKey keyProperty="id" resultType="Long" order="AFTER">
			select
			last_insert_id() as id
		</selectKey>
	</insert>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		update sys_module_new set
		<trim suffix="" suffixOverrides=",">
			<if test="service_name != null and service_name !='' "> service_name = #{service_name},</if>
			<if test="lvl != null and lvl !='' "> lvl = #{lvl},</if>
			<if test="name != null and name !='' "> name = #{name},</if>
			<if test="code != null and code !='' "> code = #{code},</if>
			<if test="form_type != null and form_type !='' "> form_type = #{form_type},</if>
			<if test="level != null and level !='' "> level = #{level},</if>
			<if test="icon != null and icon !='' "> icon = #{icon},</if>
			<if test="up_ids != null and up_ids !='' "> up_ids = #{up_ids},</if>
			<if test="table_name != null and table_name !='' "> table_name = #{table_name},</if>
			<if test="key_modular != null and key_modular !='' "> key_modular = #{key_modular},</if>
			<if test="target != null and target !='' "> target = #{target},</if>
			<if test="sorts != null ">sorts = #{sorts},</if>
			<if test="remark != null and remark !='' "> remark = #{remark},</if>
			<if test="open_type != null and open_type !='' "> open_type = #{open_type},</if>
			<if test="form_id != null and form_id !='' "> form_id = #{form_id},</if>
			<if test="app_id != null and app_id !='' "> app_id = #{app_id},</if>
			<if test="create_user_id != null and create_user_id !='' "> create_user_id = #{create_user_id},</if>
			<if test="modify_user_id != null and modify_user_id !='' "> modify_user_id = #{modify_user_id},</if>
			<if test="org_id != null and org_id !='' "> org_id = #{org_id},</if>
			<if test="modify_time != null "> modify_time =#{modify_time}  </if>
			<if test="modify_time  == null "> modify_time = now()</if>
		</trim>
		where id = #{id}
	</update>

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

	<!-- 逻辑删除多条件 -->
	<update id="entity_logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.moduleNew.entity.SysModuleNewEntity">
		update sys_module_new set
		sts='N',modify_time = now(),modify_user_id = #{modify_user_id}
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null and id !='' ">id = #{id} </if>
			<if test="service_name != null and service_name !='' "> and service_name = #{service_name}</if>
			<if test="lvl != null and lvl !='' "> and lvl = #{lvl}</if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="code != null and code !='' "> and code = #{code}</if>
			<if test="form_type != null and form_type !='' "> and form_type = #{form_type}</if>
			<if test="level != null and level !='' "> and level = #{level}</if>
			<if test="icon != null and icon !='' "> and icon = #{icon}</if>
			<if test="up_ids != null and up_ids !='' "> and up_ids = #{up_ids}</if>
			<if test="table_name != null and table_name !='' "> and table_name = #{table_name}</if>
			<if test="key_modular != null and key_modular !='' "> and key_modular = #{key_modular}</if>
			<if test="target != null and target !='' "> and target = #{target}</if>
			<if test="sorts != null "> and sorts = #{sorts}</if>
			<if test="remark != null and remark !='' "> and remark = #{remark}</if>
			<if test="open_type != null and open_type !='' "> and open_type = #{open_type}</if>
			<if test="form_id != null and form_id !='' "> and form_id = #{form_id}</if>
			<if test="app_id != null and app_id !='' "> and app_id = #{app_id}</if>
			<if test="create_user_id != null and create_user_id !='' "> and create_user_id = #{create_user_id}</if>
			<if test="create_time != null and create_time !='' "> and create_time = #{create_time}</if>
			<if test="modify_user_id != null and modify_user_id !='' "> and modify_user_id = #{modify_user_id}</if>
			<if test="modify_time != null and modify_time !='' "> and modify_time = #{modify_time}</if>
			<if test="sts != null and sts !='' "> and sts = #{sts}</if>
			<if test="org_id != null and org_id !='' "> and org_id = #{org_id}</if>
		</trim>
	</update>

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