package com.fizz.business.controller;

import com.fizz.business.domain.CrmPdiPlan;
import com.fizz.business.form.CalcPdiPlanForm;
import com.fizz.business.form.CrmPdiPlanForm;
import com.fizz.business.form.PlanQueryForm;
import com.fizz.business.service.CrmPdiPlanService;
import com.fizz.business.vo.CrmPdiPlanVO;
import com.fizz.business.vo.PdiPlanSetupInfoVO;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/pdi")
@Tag(name="计划管理")
@Anonymous
public class CrmPdiPlanController {

    @Resource
    private CrmPdiPlanService crmPdiPlanService;

    @PostMapping("/add")
    @Operation(summary ="新增计划")
    public R<Boolean> add(@RequestBody CrmPdiPlan crmPdiPlan) {
        return R.ok(crmPdiPlanService.addCrmPdiPlan(crmPdiPlan));
    }

    @GetMapping("/getByCoilId")
    @Operation(summary ="新增计划")
    public R<CrmPdiPlanVO> add(@RequestParam String coilId) {
        return R.ok(crmPdiPlanService.getByCoilIdAndOperId(coilId));
    }

    @PutMapping("/update")
    @Operation(summary ="修改计划")
    public R<Boolean> update(@RequestBody CrmPdiPlan crmPdiPlan) {
        return R.ok(crmPdiPlanService.updateCrmPdiPlan(crmPdiPlan));
    }

    @PostMapping("/delete")
    @Operation(summary ="计划删除")
    public R<Boolean> delete(@RequestBody List<Long> coilid) {
        return R.ok(crmPdiPlanService.deleteCrmPdiPlan(coilid));
    }

    @PostMapping("/list")
    @Operation(summary ="查询计划列表")
    public R<List<CrmPdiPlanVO>> list(@RequestBody PlanQueryForm form) {
        return R.ok(crmPdiPlanService.listAll(form));
    }

}
