<?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.zehong.system.mapper.TRiskManagerMapper">

    <resultMap type="TRiskManager" id="TRiskManagerResult">
        <result property="id"    column="id"    />
        <result property="riskPart"    column="risk_part"    />
        <result property="riskContent"    column="risk_content"    />
        <result property="riskLevel"    column="risk_level"    />
        <result property="riskType"    column="risk_type"    />
        <result property="riskControl"    column="risk_control"    />
        <result property="riskDept"    column="risk_dept"    />
        <result property="riskPerson"    column="risk_person"    />
    </resultMap>

    <sql id="selectTRiskManagerVo">
        select id, risk_part, risk_content, risk_level, risk_type, risk_control, risk_dept, risk_person from t_risk_manager
    </sql>

    <select id="selectTRiskManagerList" parameterType="TRiskManager" resultMap="TRiskManagerResult">
        <include refid="selectTRiskManagerVo"/>
        <where>
            <if test="riskPart != null  and riskPart != ''"> and risk_part LIKE concat('%',#{riskPart},'%')</if>
            <if test="riskContent != null  and riskContent != ''"> and risk_content = #{riskContent}</if>
            <if test="riskLevel != null  and riskLevel != ''"> and risk_level = #{riskLevel}</if>
            <if test="riskType != null  and riskType != ''"> and risk_type = #{riskType}</if>
            <if test="riskControl != null  and riskControl != ''"> and risk_control = #{riskControl}</if>
            <if test="riskDept != null"> and risk_dept = #{riskDept}</if>
            <if test="riskPerson != null  and riskPerson != ''"> and risk_person = #{riskPerson}</if>
        </where>
    </select>

    <select id="selectTRiskManagerById" parameterType="Long" resultMap="TRiskManagerResult">
        <include refid="selectTRiskManagerVo"/>
        where id = #{id}
    </select>

    <insert id="insertTRiskManager" parameterType="TRiskManager" useGeneratedKeys="true" keyProperty="id">
        insert into t_risk_manager
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="riskPart != null">risk_part,</if>
            <if test="riskContent != null">risk_content,</if>
            <if test="riskLevel != null">risk_level,</if>
            <if test="riskType != null">risk_type,</if>
            <if test="riskControl != null">risk_control,</if>
            <if test="riskDept != null">risk_dept,</if>
            <if test="riskPerson != null">risk_person,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="riskPart != null">#{riskPart},</if>
            <if test="riskContent != null">#{riskContent},</if>
            <if test="riskLevel != null">#{riskLevel},</if>
            <if test="riskType != null">#{riskType},</if>
            <if test="riskControl != null">#{riskControl},</if>
            <if test="riskDept != null">#{riskDept},</if>
            <if test="riskPerson != null">#{riskPerson},</if>
         </trim>
    </insert>

    <update id="updateTRiskManager" parameterType="TRiskManager">
        update t_risk_manager
        <trim prefix="SET" suffixOverrides=",">
            <if test="riskPart != null">risk_part = #{riskPart},</if>
            <if test="riskContent != null">risk_content = #{riskContent},</if>
            <if test="riskLevel != null">risk_level = #{riskLevel},</if>
            <if test="riskType != null">risk_type = #{riskType},</if>
            <if test="riskControl != null">risk_control = #{riskControl},</if>
            <if test="riskDept != null">risk_dept = #{riskDept},</if>
            <if test="riskPerson != null">risk_person = #{riskPerson},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTRiskManagerById" parameterType="Long">
        delete from t_risk_manager where id = #{id}
    </delete>

    <delete id="deleteTRiskManagerByIds" parameterType="String">
        delete from t_risk_manager where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectNamesByid" parameterType="string" resultType="string">
        SELECT GROUP_CONCAT(risk_part) FROM t_risk_manager WHERE id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
</mapper>