package com.hfkj.dao;

import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserCard;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * mapper扩展类
 */
public interface BsUserCardMapperExt {

    @Insert({
            "<script>",
            "insert into bs_user_card (user_id, `type`, ",
            "card_no, `status`, ",
            "create_time, ",
            "update_time, ext_1, ",
            "ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.userId,jdbcType=BIGINT}, " +
            "#{item.type,jdbcType=INTEGER}, ",
            "#{item.cardNo,jdbcType=VARCHAR}, " +
            "#{item.status,jdbcType=INTEGER}, ",
            "#{item.createTime,jdbcType=TIMESTAMP}, ",
            "#{item.updateTime,jdbcType=TIMESTAMP}, " +
            "#{item.ext1,jdbcType=VARCHAR}, ",
            "#{item.ext2,jdbcType=VARCHAR}," +
            "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertUserCardList(@Param(value = "list") List<BsUserCard> list);

    @Update({
            "<script>",
            "<foreach collection='list' item='item'  separator=';'>",
            "update bs_user_card set " +
                "user_id = #{item.userId}, ",
                "type = #{item.type}, " +
                "card_no = #{item.cardNo}, ",
                "status = #{item.status}, " +
                "create_time = #{item.createTime}, ",
                "update_time = #{item.updateTime}, " +
                "ext_1 = #{item.ext1}, ",
                "ext_2 = #{item.ext2}," +
                "ext_3 = #{item.ext3} where id=#{item.id}",
            "</foreach>",
            "</script>"
    })
    void updateUserCardList(@Param(value = "list") List<BsUserCard> list);
}