package com.fjhx.controller.working;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.working.WorkingProcedure;
import com.fjhx.params.working.WorkingProcedureVo;
import com.fjhx.service.working.WorkingProcedureService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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.RestController;

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

/**
 * <p>
 * 工序 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-07-14
 */
@RestController
@RequestMapping("/workingProcedure")
public class WorkingProcedureController {

    @Autowired
    private WorkingProcedureService workingProcedureService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, String> condition) {
        Page<WorkingProcedure> result = workingProcedureService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody WorkingProcedureVo workingProcedureVo) {
        workingProcedureService.add(workingProcedureVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody WorkingProcedureVo workingProcedureVo) {
        workingProcedureService.edit(workingProcedureVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody WorkingProcedureVo workingProcedureVo) {
        workingProcedureService.delete(workingProcedureVo);
        return R.success();
    }

    @PostMapping("/list")
    public R list() {
        List<WorkingProcedure> result = workingProcedureService.getList();
        return R.success(result);
    }

}

