<?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.ruoyi.predict.mapper.FormulaParaMapper">

    <resultMap type="FormulaPara" id="FormulaParaResult">
        <result property="formulaNo" column="formula_no"/>
        <result property="formulaParaNo" column="formula_para_no"/>
        <result property="formulaParaName" column="formula_para_name"/>
        <result property="formulaParaDesc" column="formula_para_desc"/>
        <result property="formulaParaType" column="formula_para_type"/>
        <result property="formulaParaIsnormal" column="formula_para_isnormal"/>
        <result property="formulaParaIslock" column="formula_para_islock"/>
    </resultMap>

    <sql id="selectFormulaParaVo">
        select formula_no, formula_para_no, formula_para_name, formula_para_desc, formula_para_type, formula_para_isnormal, formula_para_islock from formula_para
    </sql>

    <select id="selectFormulaParaList" parameterType="FormulaPara" resultMap="FormulaParaResult">
        select
        fp.*,
        f.formula_name as "formulaName",
        emi1.item_name as "formulaParaTypeName",
        emi2.item_name as "formulaParaIslockName"
        from
        formula_para fp
        left join formula f on f.formula_no = fp.formula_no
        left join enum_menu_item emi1 on emi1.item_val = fp.formula_para_type and emi1.menu_no = 190
        left join enum_menu_item emi2 on emi2.item_val = fp.formula_para_islock and emi2.menu_no = 121
        <where>
            <if test="formulaNo != null ">and fp.formula_no = #{formulaNo}</if>
            <if test="formulaParaNo != null ">and fp.formula_para_no = #{formulaParaNo}</if>
            <if test="formulaParaName != null  and formulaParaName != ''">and fp.formula_para_name like concat(concat('%',
                #{formulaParaName}), '%')
            </if>
            <if test="formulaParaDesc != null  and formulaParaDesc != ''">and fp.formula_para_desc = #{formulaParaDesc}
            </if>
            <if test="formulaParaType != null ">and fp.formula_para_type = #{formulaParaType}</if>
            <if test="formulaParaIsnormal != null ">and fp.formula_para_isnormal = #{formulaParaIsnormal}</if>
            <if test="formulaParaIslock != null ">and fp.formula_para_islock = #{formulaParaIslock}</if>
            <if test="formulaName != null  and formulaName != ''">and f.formula_name like concat(concat('%',
                #{formulaName}), '%')
            </if>
        </where>
    </select>

    <select id="selectFormulaParaById" parameterType="Long" resultMap="FormulaParaResult">
        <include refid="selectFormulaParaVo"/>
        where formula_no = #{formulaNo}
    </select>

</mapper>