package thyyxxk.webserver.controller.inpatient;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import thyyxxk.webserver.config.auth.PassToken;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.CodeName;
import thyyxxk.webserver.entity.dictionary.SearchDataParam;
import thyyxxk.webserver.entity.medicalinsurance.inpatient.SpecialDiag;
import thyyxxk.webserver.service.inpatient.DictionaryService;

import java.util.List;

/**
 * @author dj
 */
@Slf4j
@RestController
@RequestMapping("/dictionary")
public class DictionaryController {
    private final DictionaryService service;

    @Autowired
    public DictionaryController(DictionaryService service) {
        this.service = service;
    }

    @PostMapping("/executeSearch")
    public ResultVo<List<CodeName>> executeSearch(@RequestBody @Validated SearchDataParam param) {
        return service.executeSearch(param);
    }

    @PostMapping("/increaseWeight")
    public ResultVo<String> increaseWeight(@RequestBody CodeName data) {
        return service.increaseWeight(data);
    }

    @GetMapping("/getAllSpecialDiags")
    public ResultVo<List<SpecialDiag>> getAllSpecialDiags(@RequestParam("medType") String medType) {
        return service.getAllSpecialDiags(medType);
    }

    /**
     * 这是给病案首页填医保诊断用的
     */
    @PassToken
    @PostMapping("/searchYbDiag")
    public ResultVo<List<CodeName>> searchYbDiag(@RequestBody SearchDataParam param) {
        return service.searchYbDiag(param);
    }
}
