package com.fs.doctor.mapper;

import com.fs.doctor.domain.Doctor;
import com.fs.doctor.vo.DoctorOptionReqVO;
import com.fs.doctor.vo.DoctorOptionRespVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;
import java.util.List;

/**
 * 讲者主Mapper接口
 *
 * @author fs
 * @date 2025-12-30
 */
public interface DoctorMapper {
    /**
     * 查询讲者主
     *
     * @param id 讲者主主键
     * @return 讲者主
     */
    public Doctor selectDoctorById(Long id);


    /**
     * 查询讲者主列表
     *
     * @param doctor 讲者主
     * @return 讲者主集合
     */
    public List<Doctor> selectDoctorList(Doctor doctor);

    /**
     * 新增讲者主
     *
     * @param doctor 讲者主
     * @return 结果
     */
    public int insertDoctor(Doctor doctor);

    /**
     * 修改讲者主
     *
     * @param doctor 讲者主
     * @return 结果
     */
    public int updateDoctor(Doctor doctor);

    /**
     * 删除讲者主
     *
     * @param id 讲者主主键
     * @return 结果
     */
    public int deleteDoctorById(Long id);

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

    /**
     * 前端获取医生下拉列表
     *
     * @param doctorOptionReqVO
     * @return
     */
    List<DoctorOptionRespVO> getDoctorOptionVOList(DoctorOptionReqVO doctorOptionReqVO);



    @Update("UPDATE doctor SET audit_instance_id = #{auditInstanceId} WHERE id = #{id} and deleted = 0")
    int updateAuditInstanceIdById(@Param("id") Long id,@Param("auditInstanceId") Long auditInstanceId);

    int updateDoctorPwd(Doctor update);

    Doctor selectDoctorByDoctorId(String doctorId);

    void addPoints(@Param("doctorId")Long doctorId,@Param("points") BigDecimal points);

    @Select("SELECT COUNT(1) FROM doctor WHERE mobile = #{mobile}    and deleted = 0 ")
    int countByMobile(@Param("mobile") String mobile);

    @Select("SELECT * FROM doctor WHERE mobile = #{mobile} and deleted = 0 ")
    Doctor selectDoctorByPhone(String mobile);

    @Select("select concat(doctor_name) from doctor where id=#{id}")
    String selectDoctorNameById(@Param("id") Long id);

    List<Doctor> selectDoctorListByIds(@Param("doctorIds") List<Long> doctorIds);

}
