<?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.opinion" name="超期预警处置意见">

    <select id="selectOpinionList" parameterType="com.scpyun.platform.jilinsscgsdp.bean.vo.ReqEventOpinionFindVo" resultType="com.scpyun.platform.jilinsscgsdp.bean.vo.ResEventOpinionVo">
        SELECT
            jeo.id,
            jeo.event_id AS eventId,
            jeo.opinion,
            jeo.del_flag AS delFlag,
            jeo.create_company_id AS createCompanyId,
            jeo.create_by AS createBy,
            sc.name AS createCompanyName,
            su.name AS createByName,
            DATE_FORMAT(jeo.create_time,'%Y-%m-%d') createTime
        FROM
        jl_event_opinion jeo
        LEFT JOIN sys_office sc ON jeo.update_company_id = sc.id
        LEFT JOIN sys_user su ON jeo.update_by = su.id
        WHERE
        event_id = #{eventId}
        AND jeo.del_flag = '0'
        ORDER BY jeo.create_time DESC
    </select>

    <insert id="insertEventOpinion" parameterType="com.scpyun.platform.jilinsscgsdp.bean.vo.ReqEventOpinionInsertVo">
        INSERT INTO jl_event_opinion (
            id,
            event_id,
            opinion,
            create_company_id,
            create_by,
            create_time,
            update_company_id,
            update_by,
            update_time
        ) VALUES (
            UUID(),
            #{eventId},
            #{opinion},
            #{_user.company_id},
            #{_user.id},
            NOW(),
            #{_user.company_id},
            #{_user.id},
            NOW()
        )
    </insert>

    <update id="updateEventOpinion" parameterType="com.scpyun.platform.jilinsscgsdp.bean.vo.ReqEventOpinionUpdateVo">
        UPDATE
            jl_event_opinion
        SET
            opinion = #{opinion},
            <if test="delFlag != null and delFlag != ''">
                del_flag = #{delFlag},
            </if>
            update_company_id = #{_user.company_id},
            update_by = #{_user.id},
            update_time = NOW()
        WHERE
            id = #{id}
    </update>

</mapper>
