package com.gxwebsoft.clinic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.clinic.mapper.ClinicDoctorApplyMapper;
import com.gxwebsoft.clinic.service.ClinicDoctorApplyService;
import com.gxwebsoft.clinic.entity.ClinicDoctorApply;
import com.gxwebsoft.clinic.param.ClinicDoctorApplyParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 医生入驻申请Service实现
 *
 * @author 科技小王子
 * @since 2025-10-19 09:27:04
 */
@Service
public class ClinicDoctorApplyServiceImpl extends ServiceImpl<ClinicDoctorApplyMapper, ClinicDoctorApply> implements ClinicDoctorApplyService {

    @Override
    public PageResult<ClinicDoctorApply> pageRel(ClinicDoctorApplyParam param) {
        PageParam<ClinicDoctorApply, ClinicDoctorApplyParam> page = new PageParam<>(param);
        page.setDefaultOrder("sort_number asc, create_time desc");
        List<ClinicDoctorApply> list = baseMapper.selectPageRel(page, param);
        return new PageResult<>(list, page.getTotal());
    }

    @Override
    public List<ClinicDoctorApply> listRel(ClinicDoctorApplyParam param) {
        List<ClinicDoctorApply> list = baseMapper.selectListRel(param);
        // 排序
        PageParam<ClinicDoctorApply, ClinicDoctorApplyParam> page = new PageParam<>();
        page.setDefaultOrder("sort_number asc, create_time desc");
        return page.sortRecords(list);
    }

    @Override
    public ClinicDoctorApply getByIdRel(Integer applyId) {
        ClinicDoctorApplyParam param = new ClinicDoctorApplyParam();
        param.setApplyId(applyId);
        return param.getOne(baseMapper.selectListRel(param));
    }

}
