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

    <resultMap type="com.willalp.system.domain.DeviceRelation" id="DeviceRelationResult">
        <result property="relationId" column="relation_id"/>
        <result property="userNumber" column="user_number"/>
        <result property="deviceNumber" column="device_number"/>
        <result property="effectTime" column="effect_time"/>
        <result property="jgid" column="jgid"/>
        <result property="isDelete" column="is_delete"/>
    </resultMap>

    <sql id="selectDeviceRelationVo">
        select relation_id, user_number, device_number, effect_time, jgid, is_delete        from pns_device_relation
    </sql>

    <select id="selectDeviceRelationList" parameterType="DeviceRelation" resultMap="DeviceRelationResult">
        <include refid="selectDeviceRelationVo"/>
        <where>
            is_delete = 0
            <if test="userNumber != null  and userNumber != ''">
                and user_number = #{userNumber}
            </if>
            <if test="deviceNumber != null  and deviceNumber != ''">
                and device_number = #{deviceNumber}
            </if>
            <if test="jgid != null and jgid !=''">
                and jgid = #{jgid}
            </if>
        </where>
    </select>
</mapper>
