<?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.crm.manager.dao.mapper.UserInfoAttachMapper">

    <insert id="batchSave" parameterType="java.util.List">
        INSERT INTO user_info_attach (
            user_id,
            attach_id,
            add_time
        )
        VALUES
        <foreach collection="list" item="item" separator=",">
            (
            #{item.userId},
            #{item.attachId},
            #{item.addTime})
        </foreach>
    </insert>

    <select id="getViewByUserId" parameterType="Long" resultType="com.crm.rely.backend.core.pojo.view.UserInfoAttachView">
        select au.id,au.`name`
        From user_info_attach uia
                 inner join user_info au on uia.attach_id=au.id
        where uia.user_id=#{userId}
    </select>

</mapper>