package thyyxxk.webserver.controller.outpatient.managedoctorinfo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.outpatient.mangedoctorinfo.DoctorInfo;
import thyyxxk.webserver.entity.outpatient.mangedoctorinfo.QueryParam;
import thyyxxk.webserver.service.outpatient.managedoctorinfo.ManageDoctorInfoService;

import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/manageDoctorInfo")
public class ManageDoctorInfoController {
    private final ManageDoctorInfoService service;

    @Autowired
    public ManageDoctorInfoController(ManageDoctorInfoService service) {
        this.service = service;
    }

    @GetMapping("/getAllMzDept")
    public ResultVo<List<CodeName>> getAllMzDept() {
        return service.getAllMzDept();
    }

    @PostMapping("/getAllDoctors")
    public ResultVo<Map<String, Object>> getAllDoctor(@RequestBody QueryParam param) {
        return service.getAllDoctors(param);
    }

    @GetMapping("/getAllTitles")
    public ResultVo<List<CodeName>> getAllTitles() {
        return service.getAllTitles();
    }

    @PassToken
    @GetMapping("/getDoctorInfo")
    public ResultVo<DoctorInfo> getDoctorInfo(@RequestParam("code") String code) {
        return service.getDoctorInfo(code);
    }

    @PostMapping("/uploadPortrait")
    public ResultVo<String> uploadPortrait(@RequestParam("code") String code, @RequestBody MultipartFile file) {
        return service.uploadDoctorImg(code, file);
    }

    @PostMapping("/saveDoctorInfo")
    public ResultVo<String> saveDoctorInfo(@RequestBody DoctorInfo param) {
        return service.saveDoctorInfo(param);
    }

    @GetMapping("/updateDoctorWxHomepageFlag")
    public ResultVo<String> updateDoctorWxHomepageFlag(@RequestParam("code") String code,
                                                       @RequestParam("flag") Integer flag) {
        return service.updateDoctorWxHomepageFlag(code, flag);
    }

    @GetMapping("/getAllRecommendDoctors")
    public ResultVo<List<DoctorInfo>> getAllRecommendDoctors() {
        return service.getAllRecommendDoctors();
    }

    @GetMapping("/updateWxHomepageOrder")
    public ResultVo<String> updateWxHomepageOrder(@RequestParam("code") String code,
                                                  @RequestParam("order") Integer order) {
        return service.updateWxHomepageOrder(code, order);
    }

    @GetMapping("/deleteDoctor")
    public ResultVo<String> deleteDoctor(@RequestParam("code") String code) {
        return service.deleteDoctor(code);
    }

    @GetMapping("/updateDoctorStatus")
    public ResultVo<String> updateDoctorStatus(@RequestParam("code") String code,
                                               @RequestParam("status") Integer status) {
        return service.updateDoctorStatus(code, status);
    }
}
