<?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.energy.manage.service.mappers.analysis.AnalysisTypeMapper">
    <resultMap id="BaseResultMap" type="com.energy.manage.common.po.analysis.AnalysisTypePo">
        <id column="id" property="id" jdbcType="BIGINT"/>
        <result column="parent_id" property="parentId" jdbcType="INTEGER"/>
        <result column="type_code" property="typeCode" jdbcType="VARCHAR"/>
        <result column="type_name" property="typeName" jdbcType="VARCHAR"/>
        <result column="create_by" property="createBy" jdbcType="INTEGER"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
    </resultMap>

    <select id="selectAllVo" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisTypeVo">
        select id,
               parent_id,
               type_code,
               type_flag,
               type_name
        from analysis_type
        where parent_id != 0
    </select>

    <select id="selectAllByOrderNum" resultMap="BaseResultMap">
        select id,parent_id,type_code,type_name
        from analysis_type
        order by order_num
    </select>

    <select id="selectByTypeCode" parameterType="java.lang.String" resultType="com.energy.manage.service.domain.vo.analysis.AnalysisTypeVo">
        select parent_id,
               type_code,
               type_name
        from analysis_type
        where 1 = 1
        <if test="typeCode != null and typeCode != ''">
            and type_code = #{typeCode,jdbcType=VARCHAR}
        </if>
    </select>
    <select id="selecFlagtByCodes" parameterType="java.lang.String" resultType="java.lang.String">
        select
        type_flag
        from analysis_type
        where 1 = 1
        <if test="typeCodes != null and typeCodes.size() > 0">
            and type_code in
                <foreach collection="typeCodes" open="(" close=")" separator="," item="typeCode">
                    #{typeCode,jdbcType=VARCHAR}
                </foreach>
        </if>
    </select>

    <select id="selecFlagByCode" parameterType="java.lang.String" resultType="java.lang.String">
        select
        type_flag
        from analysis_type
        where  type_code = #{typeCode,jdbcType=VARCHAR}
        limit 1
    </select>
</mapper>
