<?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="me.zhengjie.modules.system.mapper.BusUserDeviceMapper">
    <resultMap id="BaseResultMap" type="me.zhengjie.modules.system.domain.BusUserDevice">
        <id column="id" property="id"/>
        <result column="user_id" property="userId"/>
        <result column="device_id" property="deviceId"/>
        <result column="is_primary" property="isPrimary"/>
        <result column="status" property="status"/>
        <result column="create_by" property="createBy"/>
        <result column="update_by" property="updateBy"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>

    <insert id="bindingDevice">
        insert into bus_user_device (user_id, device_id) values
        <foreach collection="deviceIds" item="id" index="index" separator=",">
            (#{userId}, #{id})
        </foreach>
    </insert>

    <sql id="Base_Column_List">
        id, user_id, device_id, is_primary, status, create_by, update_by, create_time, update_time
    </sql>

    <select id="findAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from bus_user_device
        <where>
        </where>
        order by id desc
    </select>
</mapper>