package com.fs.company.mapper;

import java.util.List;
import com.fs.company.domain.CompanyUserCard;
import com.fs.company.param.CompanyUserCardQueryParam;
import com.fs.crm.param.CrmEventListQueryParam;
import com.fs.crm.vo.CrmEventListQueryVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author fs
 * @date 2023-04-25
 */
public interface CompanyUserCardMapper
{
    /**
     * 查询【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 【请填写功能名称】
     */
    public CompanyUserCard selectCompanyUserCardById(Long id);

    /**
     * 查询【请填写功能名称】列表
     *
     * @param companyUserCard 【请填写功能名称】
     * @return 【请填写功能名称】集合
     */
    public List<CompanyUserCard> selectCompanyUserCardList(CompanyUserCard companyUserCard);

    /**
     * 新增【请填写功能名称】
     *
     * @param companyUserCard 【请填写功能名称】
     * @return 结果
     */
    public int insertCompanyUserCard(CompanyUserCard companyUserCard);

    /**
     * 修改【请填写功能名称】
     *
     * @param companyUserCard 【请填写功能名称】
     * @return 结果
     */
    public int updateCompanyUserCard(CompanyUserCard companyUserCard);

    /**
     * 删除【请填写功能名称】
     *
     * @param id 【请填写功能名称】ID
     * @return 结果
     */
    public int deleteCompanyUserCardById(Long id);

    /**
     * 批量删除【请填写功能名称】
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyUserCardByIds(Long[] ids);


    @Select({"<script> " +
            " SELECT * FROM company_user_card " +
            "where 1=1 " +
            "<if test = 'maps.companyId != null     '> " +
            "and company_id =#{maps.companyId} " +
            "</if>" +
            "<if test = 'maps.userId != null     '> " +
            "and user_id =#{maps.companyUserId} " +
            "</if>" +
            "<if test = 'maps.type != null   '> " +
            "and type =#{maps.type} " +
            "</if>" +

            "<if test = 'maps.isVisit != null and maps.isVisit !=\"\"     '> " +
            "and is_visit =#{maps.isVisit} " +
            "</if>" +

            " order by create_time desc "+
            "</script>"})
    List<CompanyUserCard> selectMyCardListQuery(@Param("maps") CompanyUserCardQueryParam param);

    @Update(" update company_user_card set short_url=#{shortUrl} where id=#{cardId} ")
    int updateUserCardShortUrlById(@Param("cardId")Long cardId,@Param("shortUrl")String shortUrl);

}
