package com.crm.manager.dao.mapper;

import com.crm.rely.backend.core.pojo.table.UserInfoAttachTable;
import com.crm.rely.backend.core.pojo.view.UserInfoAttachView;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Mapper
public interface UserInfoAttachMapper {


    @Select("select count(id) from user_info_attach where user_id=#{userId}")
    Integer countByUserId(@Param("userId") Long userId);

    @Select("select count(id) from user_info_attach where attach_id=#{attachId}")
    Integer countByAttachId(@Param("attachId") Long attachId);

    @Delete("delete from user_info_attach where user_id=#{userId}")
    void removeByUserId(@Param("userId") Long userId);

    @Delete("delete from user_info_attach where attach_id=#{attachId}")
    void removeByAttachId(@Param("attachId") Long attachId);

    void batchSave(@Param("list") List<UserInfoAttachTable> tables);

    List<UserInfoAttachView> getViewByUserId(@Param("userId") Long userId);

}
