<?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="cn.pluss.platform.mapper.DeviceOperateInfoMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.pluss.platform.entity.DeviceOperateInfo">
        <id column="id" property="id" />
        <result column="deviceNo" property="deviceNo" />
        <result column="type" property="type" />
        <result column="userId" property="userId" />
        <result column="createTime" property="createTime" />
        <result column="remark" property="remark" />
    </resultMap>

    <select id="selectListVo" resultType="cn.pluss.platform.vo.DeviceOperateInfoVO">
        SELECT doi.*,
               ua.userName,
               ui.phone,
               mbi.alias as 'merchantName'
        FROM tb_pluss_device_operate_info doi
        left join tb_pluss_user_app ua on doi.userId = ua.userId
        left join tb_pluss_user_info ui on  doi.userId = ui.id
        left join tb_pluss_merchant_base_info mbi on doi.userId = mbi.userId
        <where>
            <if test="snNo != null and snNo != ''">
                and deviceNo = #{snNo}
            </if>
        </where>
        order by doi.id desc
    </select>

    <select id="pageInfo" resultType="cn.pluss.platform.vo.DeviceOperateInfoVO">
        SELECT doi.*,
        ua.userName,
        ui.phone,
        mbi.alias as 'merchantName'
        FROM tb_pluss_device_operate_info doi
        left join tb_pluss_user_app ua on doi.userId = ua.userId
        left join tb_pluss_user_info ui on  doi.userId = ui.id
        left join tb_pluss_merchant_base_info mbi on doi.userId = mbi.userId
        <where>
            <if test="condition != null and condition.deviceNo != null and condition.deviceNo != ''">
                and doi.deviceNo = #{condition.deviceNo}
            </if>
        </where>
        order by doi.id desc
    </select>
</mapper>
