<?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.persagy.adm.diagram.dao.IconMapper">

    <resultMap id="iconBaseMap" type="com.persagy.adm.diagram.entity.IconEntity">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="icon_name" property="iconName" jdbcType="VARCHAR"/>
        <result column="icon_type" property="iconType" jdbcType="VARCHAR"/>
        <result column="system_type" property="systemType" jdbcType="VARCHAR"/>
        <result column="icon_size" property="iconSize" jdbcType="VARCHAR"/>
        <result column="icon_file_id" property="iconFileId" jdbcType="VARCHAR"/>
        <result column="icon_skin" property="iconSkin" jdbcType="VARCHAR"/>
        <result column="legend_id" property="legendId" jdbcType="VARCHAR"/>
        <result column="creator" property="creator" jdbcType="VARCHAR"/>
        <result column="creation_time" property="creationTime" jdbcType="CHAR"/>
        <result column="modifier" property="modifier" jdbcType="VARCHAR"/>
        <result column="modified_time" property="modifiedTime" jdbcType="CHAR"/>
        <result column="valid" property="valid" jdbcType="TINYINT"/>
        <result column="ts" property="ts" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="baseSql">
        id,icon_name,icon_type,system_type,icon_size,icon_file_id,icon_skin,legend_id,
        creator,creation_time,modifier,modified_time,valid,ts
    </sql>

    <select id="getIconsByLegendId" resultMap="iconBaseMap">
        SELECT
        <include refid="baseSql"/>
        FROM diagram_icon
        WHERE valid = 1 AND legend_id=#{legendId}
        <if test="null != skin and skin.length > 0">
            AND icon_skin=#{skin}
        </if>
    </select>

    <select id="getIcons" resultMap="iconBaseMap">
        SELECT
        <include refid="baseSql"/>
        FROM diagram_icon
        WHERE valid = 1
    </select>
    <select id="getIconsBySystemType" resultMap="iconBaseMap">
        SELECT
        <include refid="baseSql"/>
        FROM diagram_icon
        WHERE valid = 1 AND system_type=#{systemType}
    </select>
</mapper>


