<?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.artfess.sysConfig.persistence.dao.SysTagDao">
	<resultMap id="SysTag" type="com.artfess.sysConfig.persistence.model.SysTag">
		<id property="id" column="ID_" jdbcType="VARCHAR"/>
		<result property="typeId" column="TYPE_ID_" jdbcType="VARCHAR"/>
		<result property="key" column="KEY_" jdbcType="VARCHAR"/>
		<result property="name" column="NAME_" jdbcType="VARCHAR"/>
		<result property="sn" column="SN_" jdbcType="NUMERIC"/>
		<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
		<result property="typeKey" column="TYPE_KEY_" jdbcType="VARCHAR"/>
	</resultMap>

	<select id="selectPage" parameterType="java.util.Map" resultMap="SysTag">
		select * from (
			select tag.*,t.type_key_ from portal_sys_tag tag
			left join portal_sys_type t on t.id_ = tag.type_id_
		) temp
		${ew.customSqlSegment}
	</select>

	<select id="getSysTagsByAppId" parameterType="java.lang.String" resultMap="SysTag">
		SELECT
			tg.*,
			t.TYPE_KEY_
		FROM
			portal_app_tags_relation r
			JOIN portal_sys_app a ON r.APP_ID_ = a.ID_
			JOIN portal_sys_tag tg ON r.TAG_ID_ = tg.ID_
			JOIN portal_sys_type t ON t.ID_ = tg.TYPE_ID_
		WHERE a.ID_ = #{appId}
	</select>
</mapper>