package com.fs.doctor.mapper;

import java.util.ArrayList;
import java.util.List;

import com.fs.company.domain.CompanyProduct;
import com.fs.doctor.domain.DoctorCompanyUser;
import com.fs.doctor.vo.CompanyProductOptionVO;
import com.fs.doctor.vo.DoctorAndCompanyUserInfoVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 讲者业务员绑定Mapper接口
 * 
 * @author fs
 * @date 2025-12-30
 */
public interface DoctorCompanyUserMapper 
{
    /**
     * 查询讲者业务员绑定
     * 
     * @param id 讲者业务员绑定主键
     * @return 讲者业务员绑定
     */
    public DoctorCompanyUser selectDoctorCompanyUserById(Long id);

    /**
     * 查询讲者业务员绑定列表
     * 
     * @param doctorCompanyUser 讲者业务员绑定
     * @return 讲者业务员绑定集合
     */
    public List<DoctorCompanyUser> selectDoctorCompanyUserList(DoctorCompanyUser doctorCompanyUser);

    /**
     * 新增讲者业务员绑定
     * 
     * @param doctorCompanyUser 讲者业务员绑定
     * @return 结果
     */
    public int insertDoctorCompanyUser(DoctorCompanyUser doctorCompanyUser);

    /**
     * 修改讲者业务员绑定
     * 
     * @param doctorCompanyUser 讲者业务员绑定
     * @return 结果
     */
    public int updateDoctorCompanyUser(DoctorCompanyUser doctorCompanyUser);

    /**
     * 删除讲者业务员绑定
     * 
     * @param id 讲者业务员绑定主键
     * @return 结果
     */
    public int deleteDoctorCompanyUserById(Long id);

    /**
     * 批量删除讲者业务员绑定
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteDoctorCompanyUserByIds(Long[] ids);

    List<DoctorCompanyUser> queryProductGroup(@Param("companyId") Long companyId, @Param("doctorId") String doctorId);

    List<CompanyProduct> selectCompanyProductByProductCodes(@Param("codes") ArrayList<String>  codes);

    @Select("select id, doctor_id, company_user_id, company_user_name, company_id, product, bindtime, create_time, update_time, deleted from doctor_company_user where  doctor_id = #{doctorId} AND deleted = 0 ")
    DoctorCompanyUser selectCompanyUserByDoctorId(String doctorId);

    /**
     * 根据医生ID和业务员ID查询绑定关系
     */
    @Select("select id, doctor_id, company_user_id, company_user_name, company_id, product, bindtime, create_time, update_time, deleted from doctor_company_user where doctor_id = #{doctorId} AND company_user_id = #{companyUserId} AND deleted = 0 LIMIT 1")
    DoctorCompanyUser selectByDoctorIdAndCompanyUserId(@Param("doctorId") String doctorId, @Param("companyUserId") String companyUserId);

    List<DoctorAndCompanyUserInfoVO> selectDoctorOptionsByCompanyUser(@Param("companyId") Long companyId, @Param("companyUserId") Long companyUserId,@Param("productCode") String productCode,@Param("keyword") String keyword);

    List<CompanyProductOptionVO> getProductOptionsByCompanyUser(@Param("companyId") Long companyId, @Param("companyUserId")Long companyUserId, @Param("keyword")String keyword);
}
