RosteringController.java 1.84 KB
package com.pipihelper.project.controller;

import com.alibaba.fastjson.JSONObject;
import com.pipihelper.project.core.Result;
import com.pipihelper.project.core.ResultGenerator;
import com.pipihelper.project.rostering.model.DateRuleModel;
import com.pipihelper.project.rostering.model.RosteringModel;
import com.pipihelper.project.rostering.model.ShiftRuleModel;
import com.pipihelper.project.rostering.model.StaffRuleModel;
import com.pipihelper.project.rostering.service.RosteringService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @author: zsw
 * @create: 2022-10-15 20:01
 **/
@RestController
@RequestMapping("/api/v1/rostering")
public class RosteringController {

    @Autowired
    private RosteringService rosteringService;

    @PostMapping(value = "gen")
    public Result genRostering(@RequestParam("month") int month,
                               @RequestParam("shiftRuleModel") String shiftRuleModelStr,
                               @RequestParam("staffRuleModel") String staffRuleModelStr,
                               @RequestParam("dateRuleModel") String dateRuleModelStr) {

        List<ShiftRuleModel> shiftRuleModels = JSONObject.parseArray(shiftRuleModelStr, ShiftRuleModel.class);
        List<StaffRuleModel> staffRuleModels = JSONObject.parseArray(staffRuleModelStr, StaffRuleModel.class);
        List<DateRuleModel> dateRuleModels = JSONObject.parseArray(dateRuleModelStr, DateRuleModel.class);
        return ResultGenerator.genSuccessResult(rosteringService.gen(month, shiftRuleModels, staffRuleModels, dateRuleModels));
    }

}