<?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.app.dao.impl.SysAppMapperImpl">
	<resultMap id="get-entity-result" type="com.hzya.frame.sys.app.entity.SysApp">
		<!--主键 -->
		<result property="id" column="ID" />
		<!--产品id -->
		<result property="productId" column="product_id" />
		<!--应用名称 -->
		<result property="name" column="name" />
		<!--应用编号 -->
		<result property="code" column="code" />
		<!--应用图标PC地址 -->
		<result property="pcPath" column="pc_path" />
		<!--应用图标移动端地址 -->
		<result property="phonePath" column="phone_path" />
		<!--登记产品编码 -->
		<result property="registeredProductCode" column="registered_product_code" />
		<!--登记产品编码 -->
		<result property="registeredProductCodeName" column="registered_product_code_name" />
		<!--版本号 -->
		<result property="versionNumber" column="version_number" />
		<!--版本号 -->
		<result property="versionNumberName" column="version_number_name" />
		<!--版本说明 -->
		<result property="versionDescription" column="version_description" />
		<!--应用说明 -->
		<result property="appDescription" column="app_description" />
		<!--应用标签 -->
		<result property="appLabel" column="app_label" />
		<!--应用服务商 -->
		<result property="appServiceProvider" column="app_service_provider" />
		<!--接入方式 -->
		<result property="accessMode" column="access_mode" />
		<!--接入方式 -->
		<result property="accessModeName" column="access_mode_name" />
		<!--排序号 -->
		<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="Sysapp_Base_Column_List">
		ID as id,
		product_id as product_id,
		name as name,
		code as code,
		pc_path as pc_path,
		phone_path as phone_path,
		registered_product_code as registered_product_code,
		version_number as version_number,
		version_description as version_description,
		app_description as app_description,
		app_label as app_label,
		app_service_provider as app_service_provider,
		access_mode as access_mode,
		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="Sysapp_Base_Column_List_page">
		a.ID as id,
		a.product_id as product_id,
		a.name as name,
		a.code as code,
		a.pc_path as pc_path,
		a.phone_path as phone_path,
		a.registered_product_code as registered_product_code,
		b.code as registered_product_code_name,
		a.version_number as version_number,
		c.version_number as version_number_name,
		a.version_description as version_description,
		a.app_description as app_description,
		a.app_label as app_label,
		a.app_service_provider as app_service_provider,
		a.access_mode as access_mode,
		d.column_content as access_mode_name,
		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="Sysapp_Base_Column_List" />
		from sys_app where sts = 'Y' and  id = #{id}
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		select
		<include refid="Sysapp_Base_Column_List" />
		from sys_app
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">ID= #{id} </if>
			<if test="productId != null and productId !='' "> and product_id = #{productId} </if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="code != null and code !='' "> and code = #{code}</if>
			<if test="pcPath != null and pcPath !='' "> and pc_path = #{pcPath}</if>
			<if test="phonePath != null and phonePath !='' "> and phone_path = #{phonePath}</if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> and registered_product_code = #{registeredProductCode}</if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number = #{versionNumber}</if>
			<if test="versionDescription != null and versionDescription !='' "> and version_description = #{versionDescription}</if>
			<if test="appDescription != null and appDescription !='' "> and app_description = #{appDescription}</if>
			<if test="appLabel != null and appLabel !='' "> and app_label = #{appLabel}</if>
			<if test="appServiceProvider != null and appServiceProvider !='' "> and app_service_provider = #{appServiceProvider}</if>
			<if test="accessMode != null and accessMode !='' "> and access_mode = #{accessMode}</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 = #{create_user_id}</if>
			<if test="createTime != null and createTime !='' "> and create_time = #{create_time}</if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time = #{modify_time}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modify_user_id}</if>
		</trim>
		order by id asc
	</select>

	<!-- 查询 采用==查询 -->
	<select id="entity_list_base_count" resultType="java.lang.Integer" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		select
			count(*)
		from sys_app
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">ID= #{id} </if>
			<if test="productId != null and productId !='' "> and product_id = #{productId} </if>
			<if test="name != null and name !='' "> and name = #{name}</if>
			<if test="code != null and code !='' "> and code = #{code}</if>
			<if test="pcPath != null and pcPath !='' "> and pc_path = #{pcPath}</if>
			<if test="phonePath != null and phonePath !='' "> and phone_path = #{phonePath}</if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> and registered_product_code = #{registeredProductCode}</if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number = #{versionNumber}</if>
			<if test="versionDescription != null and versionDescription !='' "> and version_description = #{versionDescription}</if>
			<if test="appDescription != null and appDescription !='' "> and app_description = #{appDescription}</if>
			<if test="appLabel != null and appLabel !='' "> and app_label = #{appLabel}</if>
			<if test="appServiceProvider != null and appServiceProvider !='' "> and app_service_provider = #{appServiceProvider}</if>
			<if test="accessMode != null and accessMode !='' "> and access_mode = #{accessMode}</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 = #{create_user_id}</if>
			<if test="createTime != null and createTime !='' "> and create_time = #{create_time}</if>
			<if test="modifyTime != null and modifyTime !='' "> and modify_time = #{modify_time}</if>
			<if test="modifyUserId != null and modifyUserId !='' "> and modify_user_id = #{modify_user_id}</if>
		</trim>
	</select>



	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		select
		<include refid="Sysapp_Base_Column_List" />
		from sys_app
		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">ID = #{id}</if>
			<if test="productId != null and productId !='' "> and  product_id like concat('%',#{productId},'%') </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="pcPath != null and pcPath !='' "> and pc_path like concat('%',#{pcPath},'%') </if>
			<if test="phonePath != null and phonePath !='' "> and phone_path like concat('%',#{phonePath},'%') </if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> and registered_product_code like concat('%',#{registeredProductCode},'%') </if>
			<if test="versionNumber != null and versionNumber !='' "> and version_number like concat('%',#{versionNumber},'%') </if>
			<if test="versionDescription != null and versionDescription !='' "> and version_description like concat('%',#{versionDescription},'%') </if>
			<if test="appDescription != null and appDescription !='' "> and app_description like concat('%',#{appDescription},'%') </if>
			<if test="appLabel != null and appLabel !='' "> and app_label like concat('%',#{appLabel},'%') </if>
			<if test="appServiceProvider != null and appServiceProvider !=''"> and app_service_provider like concat('%',#{appServiceProvider},'%') </if>
			<if test="accessMode != null and accessMode !='' "> and access_mode like concat('%',#{accessMode},'%') </if>

			<if test="sorts != null "> and sorts like concat('%', #{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="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="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>
		order by sorts asc
	</select>



	<!-- 分页查询列表 采用like格式 -->
	<select id="entity_list_like_page" resultMap="get-entity-result" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		select
		<include refid="Sysapp_Base_Column_List_page" />
		from sys_app a
		left join sys_product b on a.registered_product_code = b.id
		left join sys_product_version c on a.registered_product_code = c.product_id and  a.version_number = c.id
		left join sys_dictionaryshop_new d on d.tab_name = 'sys_app' and  d.column_name = 'access_mode' and a.access_mode = d.column_value

		<trim prefix="where" prefixOverrides="and">
			<if test="id != null ">a.ID = #{id}</if>
			<if test="productId != null and productId !='' "> and  a.product_id like concat('%',#{productId},'%') </if>
			<if test="name != null and name !='' "> and a.name like concat('%',#{name},'%') </if>
			<if test="code != null and code !='' "> and a.code like concat('%',#{code},'%') </if>
			<if test="pcPath != null and pcPath !='' "> and a.pc_path like concat('%',#{pcPath},'%') </if>
			<if test="phonePath != null and phonePath !='' "> and a.phone_path like concat('%',#{phonePath},'%') </if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> and b.code like concat('%',#{registeredProductCode},'%') </if>
			<if test="versionNumber != null and versionNumber !='' "> and c.version_number like concat('%',#{versionNumber},'%') </if>
			<if test="versionDescription != null and versionDescription !='' "> and a.version_description like concat('%',#{versionDescription},'%') </if>
			<if test="appDescription != null and appDescription !='' "> and a.app_description like concat('%',#{appDescription},'%') </if>
			<if test="appLabel != null and appLabel !='' "> and a.app_label like concat('%',#{appLabel},'%') </if>
			<if test="appServiceProvider != null and appServiceProvider !=''"> and a.app_service_provider like concat('%',#{appServiceProvider},'%') </if>
			<if test="accessMode != null and accessMode !='' "> and a.access_mode like concat('%',#{accessMode},'%') </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.app.entity.SysApp">
		select
		<include refid="Sysapp_Base_Column_List" />
		from sys_app
		<trim prefix="where" prefixOverrides="or">
			<if test="id != null ">ID = #{id}</if>
			<if test="productId != null and productId !='' "> or product_id = #{productId} </if>
			<if test="name != null and name !='' "> or name = #{name} </if>
			<if test="code != null and code !='' "> or code = #{code} </if>
			<if test="pcPath != null and pcPath !='' "> or pc_path = #{pcPath} </if>
			<if test="phonePath != null and phonePath !='' "> or phone_path = #{phonePath} </if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> or registered_product_code = #{registeredProductCode} </if>
			<if test="versionNumber != null and versionNumber !='' "> or version_number = #{versionNumber} </if>
			<if test="versionDescription != null and versionDescription !='' "> or version_description = #{versionDescription} </if>
			<if test="appDescription != null and appDescription !='' "> or app_description = #{appDescription} </if>
			<if test="appLabel != null and appLabel !='' "> or app_label = #{appLabel} </if>
			<if test="appServiceProvider != null and appServiceProvider !=''"> or app_service_provider = #{appServiceProvider} </if>
			<if test="accessMode != null and accessMode !='' "> or access_mode = #{accessMode} </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="createUserId != null and createUserId !='' "> or create_user_id = #{createUserId}</if>
			<if test="createTime != null and createTime !='' "> or create_time = #{createTime}</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>
		order by sorts asc
	</select>
	<!-- 新增 -->
	<insert id="entity_insert" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		insert into sys_app(
		<trim suffix="" suffixOverrides=",">
			<if test="id != null ">ID,</if>
			<if test="productId != null and productId !='' "> product_id, </if>
			<if test="name != null and name !='' "> name, </if>
			<if test="code != null and code !='' "> code, </if>
			<if test="pcPath != null and pcPath !='' "> pc_path, </if>
			<if test="phonePath != null and phonePath !='' "> phone_path, </if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> registered_product_code, </if>
			<if test="versionNumber != null and versionNumber !='' "> version_number, </if>
			<if test="versionDescription != null and versionDescription !='' "> version_description, </if>
			<if test="appDescription != null and appDescription !='' "> app_description, </if>
			<if test="appLabel != null and appLabel !='' "> app_label, </if>
			<if test="appServiceProvider != null and appServiceProvider !=''"> app_service_provider, </if>
			<if test="accessMode != null and accessMode !='' "> access_mode, </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="productId != null and productId !='' "> #{productId}, </if>
			<if test="name != null and name !='' "> #{name}, </if>
			<if test="code != null and code !='' "> #{code}, </if>
			<if test="pcPath != null and pcPath !='' "> #{pcPath}, </if>
			<if test="phonePath != null and phonePath !='' "> #{phonePath}, </if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> #{registeredProductCode}, </if>
			<if test="versionNumber != null and versionNumber !='' "> #{versionNumber}, </if>
			<if test="versionDescription != null and versionDescription !='' "> #{versionDescription}, </if>
			<if test="appDescription != null and appDescription !='' "> #{appDescription}, </if>
			<if test="appLabel != null and appLabel !='' "> #{appLabel}, </if>
			<if test="appServiceProvider != null and appServiceProvider !=''"> #{appServiceProvider}, </if>
			<if test="accessMode != null and accessMode !='' "> #{accessMode}, </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>

	<!-- 修改 -->
	<update id="entity_update" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		update sys_app set
		<trim suffix="" suffixOverrides=",">
			<if test="id != null ">ID = #{id},</if>
			<if test="productId != null and productId !='' "> product_id = #{productId},</if>
			<if test="name != null and name !='' "> name = #{name},</if>
			<if test="code != null and code !='' "> code = #{code},</if>
			<if test="pcPath != null and pcPath !='' "> pc_path = #{pcPath},</if>
			<if test="phonePath != null and phonePath !='' "> phone_path = #{phonePath},</if>
			<if test="registeredProductCode != null and registeredProductCode !='' "> registered_product_code = #{registeredProductCode},</if>
			<if test="versionNumber != null and versionNumber !='' "> version_number = #{versionNumber},</if>
			<if test="versionDescription != null and versionDescription !='' "> version_description = #{versionDescription},</if>
			<if test="appDescription != null and appDescription !='' "> app_description = #{appDescription},</if>
			<if test="appLabel != null and appLabel !='' "> app_label = #{appLabel},</if>
			<if test="appServiceProvider != null and appServiceProvider !='' "> app_service_provider = #{appServiceProvider},</if>
			<if test="accessMode != null and accessMode !='' "> access_mode = #{accessMode},</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>
	<!-- 逻辑删除多条件 -->
	<update id="logicDelete_Multi_Condition" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		update sys_app 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="productId != null and productId !='' ">and  product_id = #{productId}</if>
			<if test="name != null and name !='' ">and  name = #{name}</if>
			<if test="code != null and code !='' ">and  code = #{code}</if>
			<if test="pcPath != null and pcPath !='' ">and  pc_path = #{pcPath}</if>
			<if test="phonePath != null and phonePath !='' ">and  phone_path = #{phonePath}</if>
			<if test="registeredProductCode != null and registeredProductCode !='' ">and  registered_product_code = #{registeredProductCode}</if>
			<if test="versionNumber != null and versionNumber !='' ">and  version_number = #{versionNumber}</if>
			<if test="versionDescription != null and versionDescription !='' ">and  version_description = #{versionDescription}</if>
			<if test="appDescription != null and appDescription !='' ">and  app_description = #{appDescription}</if>
			<if test="appLabel != null and appLabel !='' ">and  app_label = #{appLabel}</if>
			<if test="appServiceProvider != null and appServiceProvider !='' ">and  app_service_provider = #{appServiceProvider}</if>
			<if test="accessMode != null and accessMode !='' ">and  access_mode = #{accessMode}</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>
	<!-- 物理删除 -->
	<delete id="entity_delete" parameterType="com.hzya.frame.sys.app.entity.SysApp">
		delete from sys_app where id =#{id}
	</delete>
</mapper>
