<?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.willalp.device.mapper.HsDeviceRepairsMapper">

    <resultMap type="com.willalp.device.domain.HsDeviceRepairs" id="HsDeviceRepairsResult">
        <result property="id" column="id"/>
        <result property="title" column="title"/>
        <result property="deviceLoca" column="device_loca"/>
        <result property="urgencyLevel" column="urgency_level"/>
        <result property="photos" column="photos"/>
        <result property="deptId" column="dept_id"/>
        <result property="applyUserName" column="apply_user_name"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>

    <sql id="selectHsDeviceRepairsVo">
        select id,
               title,
               device_loca,
               urgency_level,
               photos,
               dept_id,
               apply_user_name,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time,
               remark
        from hs_device_repairs
    </sql>

    <select id="selectHsDeviceRepairsList" parameterType="HsDeviceRepairs" resultMap="HsDeviceRepairsResult">
        <include refid="selectHsDeviceRepairsVo"/>
        <where>
            is_delete = 0
            <if test="title != null  and title != ''">
                and title = #{title}
            </if>
            <if test="deviceLoca != null  and deviceLoca != ''">
                and device_loca = #{deviceLoca}
            </if>
            <if test="urgencyLevel != null  and urgencyLevel != ''">
                and urgency_level = #{urgencyLevel}
            </if>
            <if test="deptId != null  and deptId != ''">
                and dept_id = #{deptId}
            </if>
            <if test="applyUserName != null  and applyUserName != ''">
                and apply_user_name like concat('%', #{applyUserName}, '%')
            </if>
        </where>
    </select>
</mapper>
