<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.riiskfactor" name="风险因子管理">

    <select id="selectARiskFactorList" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor"
            resultType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor">
        select id, factor_name as factorName, risk_weight as riskWeight ,
        create_time as createTime,
        update_time as updateTime,
        update_user as updateUser,
        create_user as createUser,
        del_flag as delFlag,
        sort
        from jl_risk_factor
        where del_flag='0'
        <if test="factorName != null and factorName != ''">
            and factor_name LIKE CONCAT('%',#{factorName},'%')
        </if>
        <if test="riskWeight != null and riskWeight != ''">
            and risk_weight = #{riskWeight}
        </if>
        <if test="is_custom != null and is_custom != ''">
            and is_custom = #{is_custom}
        </if>
        <if test="is_show != null and is_show != ''">
            and is_show = #{is_show}
        </if>
        ORDER BY create_time DESC
    </select>

    <delete id="deleteRiskFactorById" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor">
        DELETE
        FROM
        jl_risk_factor
        WHERE
        id = #{id}
    </delete>

    <!--<insert id="insertRiskFactor" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor">
        insert into jl_risk_factor
        (id, factor_name, create_user, create_time,del_flag, update_user)
        values
        (#{id}, #{factorName}, #{_user.id}, now(),0, #{_user.id})
    </insert>-->
    <insert id="insertRiskFactor" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor">
        insert into jl_risk_factor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">id,</if>
            <if test="factorName != null and factorName != ''">factor_name,</if>
            <if test="is_custom != null and is_custom != ''">is_custom,</if>
            <if test="sort != null and sort != ''">sort,</if>
            create_user,
            update_user,
            create_time,
            del_flag
        </trim>
        values
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null and id != ''">#{id},</if>
            <if test="factorName != null and factorName != ''">#{factorName},</if>
            <if test="is_custom != null and is_custom != ''">#{is_custom},</if>
            <if test="sort != null and sort != ''">#{sort},</if>
            #{_user.id},
            #{_user.id},
            now(),
            '0'
        </trim>
    </insert>

    <update id="updateRiskFactor" parameterType="com.scpyun.platform.jilinsscgsdp.bean.entity.RiskFactor">
        update jl_risk_factor
        <set>
            <if test="factorName != null and factorName != ''">
                factor_name = #{factorName},
            </if>
            <if test="is_show != null and is_show != ''">
                is_show = #{is_show},
            </if>
            <if test="sort != null and sort != ''">
                sort = #{sort},
            </if>
            update_user = #{_user.id},
            update_time = now()
        </set>
        where
        id = #{id}
    </update>





</mapper>
