<?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.WarningRecordMapper">
    
    <resultMap type="com.tuoheng.admin.entity.domain.WarningRecord" id="WarningRecordResult">
        <result property="id"    column="id"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="warningId"    column="warning_id"    />
        <result property="missionId"    column="mission_id"    />
        <result property="emergencyMissionId"    column="emergency_mission_id"    />
        <result property="name"    column="name"    />
        <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="mark"    column="mark"    />
    </resultMap>

    <sql id="selectWarningRecordVo">
        select id, tenant_id, warning_id, name, mission_id, create_user, create_time, update_user, update_time, mark from th_warning_record
    </sql>

    <select id="getList" parameterType="com.tuoheng.admin.entity.request.warningrecord.QueryWarningRecordListByWarningIdRequest" resultMap="WarningRecordResult">
        <include refid="selectWarningRecordVo"/>
        <where>
            <if test="1 == 1"> and mark = 1 </if>
            <if test="tenantId != null "> and tenant_id = #{tenantId}</if>
            <if test="warningId != null "> and warning_id = #{warningId}</if>
        </where>
        order by create_time desc
    </select>
    
    <select id="getOneById" parameterType="Integer" resultMap="WarningRecordResult">
        <include refid="selectWarningRecordVo"/>
        where mark = 1 and id = #{id}
    </select>

</mapper>