package thyyxxk.webserver.controller.settings;

import cn.hutool.json.JSONObject;
import lombok.RequiredArgsConstructor;
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.schedulingClass.data.SchedulingClass;
import thyyxxk.webserver.service.settings.SchedulingClass.SchedulingClassService;
import thyyxxk.webserver.utils.R;

import java.util.List;

@RequestMapping("/schedulingClass")
@RestController
@RequiredArgsConstructor
public class SchedulingClassController {
    private final SchedulingClassService service;

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

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

    @PostMapping("/saveSort")
    public ResultVo<String> saveSort(@RequestBody JSONObject value) {
        return service.saveSort(value);
    }

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

    @GetMapping("/getByMonth")
    public ResultVo<List<SchedulingClass.SchedulingClassVo>> getByMonth(@RequestParam("month") String month) {
        return R.ok(service.getByMonth(month));
    }

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


    @GetMapping("/taskCreateClass")
    @PassToken
    public void taskCreateClass() {
        service.create();
    }

    @GetMapping("/taskSendMsg")
    @PassToken
    public void taskSendMsg() {
        service.sendMessageData();
    }

}
