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 BsUserMapperExt {

    @Insert({
            "<script>",
            "insert into bs_user (head_img, `name`, ",
            "phone, `password`, ",
            "integral, `status`, ",
            "wx_mp_openid, wx_ma_openid, ",
            "outside_openid, create_time, ",
            "update_time, ext_1, ",
            "ext_2, ext_3)",
            "values ",
            "<foreach collection='list' item='item' index='index' separator=','>",
            "(#{item.headImg,jdbcType=VARCHAR}, " +
                "#{item.name,jdbcType=VARCHAR}, ",
                "#{item.phone,jdbcType=VARCHAR}, " +
                "#{item.password,jdbcType=VARCHAR}, ",
                "#{item.integral,jdbcType=BIGINT}, " +
                "#{item.status,jdbcType=INTEGER}, ",
                "#{item.wxMpOpenid,jdbcType=VARCHAR}, " +
                "#{item.wxMaOpenid,jdbcType=VARCHAR}, ",
                "#{item.outsideOpenid,jdbcType=VARCHAR}, " +
                "#{item.createTime,jdbcType=TIMESTAMP}, ",
                "#{item.updateTime,jdbcType=TIMESTAMP}, " +
                "#{item.ext1,jdbcType=VARCHAR}, ",
                "#{item.ext2,jdbcType=VARCHAR}," +
                "#{item.ext3,jdbcType=VARCHAR})",
            "</foreach>",
            "</script>"
    })
    void insertUserList(@Param(value = "list") List<BsUser> list);


    @Update({
            "<script>",
            "<foreach collection='list' item='item'  separator=';'>",
            "update bs_user set " +
                "head_img = #{item.headImg}, " +
                "name = #{item.name}, ",
                "phone = #{item.phone}, " +
                "password = #{item.password}, ",
                "integral = #{item.integral}, ",
                "status = #{item.status}, " +
                "wx_mp_openid = #{item.wxMpOpenid}, " +
                "wx_ma_openid = #{item.wxMaOpenid}, " +
                "outside_openid = #{item.outsideOpenid}, " +
                "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 updateUserList(@Param(value = "list") List<BsUser> list);

}