<?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.tuoheng.admin.mapper.WarningMapper">
    
    <resultMap type="com.tuoheng.admin.entity.domain.Warning" id="WarningResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="missionId"    column="mission_id"    />
        <result property="discoveryWay"    column="discovery_way"    />
        <result property="location"    column="location"    />
        <result property="status"    column="status"    />
        <result property="questionId"    column="question_id"    />
        <result property="createUser"    column="create_user"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateUser"    column="update_user"    />
        <result property="updateTime"    column="update_time"    />
        <result property="checkUser"    column="check_user"    />
        <result property="checkTime"    column="check_time"    />
        <result property="checkResult"    column="check_result"    />
        <result property="mark"    column="mark"    />
    </resultMap>

    <sql id="selectWarningVo">
        select id, tenant_id, mission_id, discovery_way, location, status, question_id, create_user, create_time, update_user, update_time, check_user, check_time, check_result, mark from th_warning
    </sql>

    <select id="getList" parameterType="com.tuoheng.admin.entity.request.warning.QueryWarningListRequest" resultMap="WarningResult">
        <include refid="selectWarningVo"/>
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="tenantId != null "> and tenant_id = #{tenantId} </if>
            <if test="status != null and status != 0 "> and status = #{status}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="getOneById" parameterType="Integer" resultMap="WarningResult">
        <include refid="selectWarningVo"/>
        where mark = 1 and id = #{id}
    </select>

    <update id="confirm" parameterType="hashmap">
        update th_inspection_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null"> status = #{status}, </if>
            <if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
            <if test="updateTime != null"> update_time = #{updateTime}, </if>
            <if test="checkUser != null and checkUser != ''"> check_user = #{checkUser}, </if>
            <if test="checkTime != null"> check_time = #{checkTime}, </if>
            <if test="checkResult != null and checkResult != ''"> check_result = #{checkResult}, </if>
        </trim>
        where id = #{id}
    </update>

    <update id="ignore" parameterType="hashmap">
        update th_inspection_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="status != null"> status = #{status}, </if>
            <if test="updateUser != null and updateUser != ''"> update_user = #{updateUser}, </if>
            <if test="updateTime != null"> update_time = #{updateTime}, </if>
            <if test="checkUser != null and checkUser != ''"> check_user = #{checkUser}, </if>
            <if test="checkTime != null"> check_time = #{checkTime}, </if>
        </trim>
        where id = #{id}
    </update>
</mapper>