package thyyxxk.webserver.controller.dictionary;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import thyyxxk.webserver.entity.ResultVo;
import thyyxxk.webserver.entity.dictionary.ZdUnitCode;
import thyyxxk.webserver.service.dictionary.PersonnelDictService;

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

/**
 * @Description: 人事字典
 * @Author: hsh
 * @CreateTime: 2023-10-16  16:30
 * @Version: 1.0
 */
@RestController
@RequestMapping("/personnel")
public class PersonnelDictController {

    private final PersonnelDictService service;

    @Autowired
    public PersonnelDictController(PersonnelDictService service) {
        this.service = service;
    }

    @GetMapping("/selectDeptDict")
    public ResultVo<List<ZdUnitCode>> selectDeptDict(@RequestParam("text") String text){
        return service.selectDeptDict(text);
    }

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

    @GetMapping("/selectUnitClass")
    public ResultVo<List<Map<String, Object>>> selectUnitClass(){
        return service.selectUnitClass();
    }

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


    @PostMapping("/saveDeptDict")
    public ResultVo<Map<String, Object>> saveDeptDict(@RequestBody @Validated ZdUnitCode zdUnitCode){
        return service.saveDeptDict(zdUnitCode);
    }

}
