package com.fizz.business.controller;

import com.fizz.business.domain.CrmPdoExcoil;
import com.fizz.business.form.CrmPdoExcoilForm;
import com.fizz.business.service.CrmPdoExcoilService;
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/pdo")
@Tag(name ="实绩管理")
@Anonymous
public class CrmPdoExcoilController {

    @Resource
    private CrmPdoExcoilService crmPdoExcoilService;

    @GetMapping("/get/{excoilid}")
    @Operation(summary ="查询实绩")
    public R<CrmPdoExcoil> getByExcoilId(@PathVariable String excoilid) {
        return R.ok(crmPdoExcoilService.getByExcoilId(excoilid));
    }

    @PostMapping("/add")
    @Operation(summary ="新增实绩")
    public R<Boolean> add(@RequestBody CrmPdoExcoil crmPdoExcoil) {
        return R.ok(crmPdoExcoilService.addCrmPdoExcoil(crmPdoExcoil));
    }

    @PutMapping("/update")
    @Operation(summary ="修改")
    public R<Boolean> update(@RequestBody CrmPdoExcoil crmPdoExcoil) {
        return R.ok(crmPdoExcoilService.updateCrmPdoExcoil(crmPdoExcoil));
    }

    @DeleteMapping("/delete/{excoilid}/{planId}")
    @Operation(summary ="删除实绩")

    public R<Boolean> delete(@PathVariable String excoilid, @PathVariable String planId) {
        return R.ok(crmPdoExcoilService.deleteCrmPdoExcoil(excoilid, planId));
    }

    @PostMapping("/list")
    @Operation(summary ="查询实绩列表")
    public R<List<CrmPdoExcoil>> list(@RequestBody CrmPdoExcoilForm form) {
        return R.ok(crmPdoExcoilService.listAll(form));
    }
}
