<?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.kxs.product.biz.mapper.KxsMachineTransferMapper">

    <resultMap type="com.kxs.product.api.model.KxsMachineTransfer" id="KxsMachineTransferMap">
        <result column="id" property="id" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="del_flag" property="delFlag" />
        <result column="version" property="version" />
        <result column="machine_sn" property="machineSn" />
        <result column="machine_id" property="machineId" />
        <result column="send_user_id" property="sendUserId" />
        <result column="brand_id" property="brandId" />
        <result column="to_user_id" property="toUserId" />
        <result column="machine_type" property="machineType" />
        <result column="transfer_type" property="transferType" />
        <result column="to_user_name" property="toUserName" />
        <result column="to_user_code" property="toUserCode" />

    </resultMap>

    <select id="getByPage" resultType="com.kxs.product.api.vo.kxsapp.machine.MachineTransferListVO">
        select id, machine_sn, machine_type, to_user_name, to_user_code  from kxs_machine_transfer
        <where>
            and del_flag = 0
            and send_user_id = #{query.userId}
            and brand_id = #{query.brandId}
            <if test="query.keyword != null and query.keyword != ''">
                and (machine_sn like concat('%', #{query.keyword}, '%') or to_user_name like concat('%', #{query.keyword}, '%') or to_user_code like concat('%', #{query.keyword}, '%'))
            </if>
        </where>
    </select>

</mapper>
