package com.fjhx.controller.production;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.production.ProductionWorkshop;
import com.fjhx.params.production.ProductionWorkshopEx;
import com.fjhx.params.production.ProductionWorkshopVo;
import com.fjhx.service.production.ProductionWorkshopService;
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-13
 */
@RestController
@RequestMapping("/productionWorkshop")
public class ProductionWorkshopController {

    @Autowired
    private ProductionWorkshopService productionWorkshopService;

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

    @PostMapping("/add")
    public R add(@RequestBody ProductionWorkshopVo productionWorkshopVo) {
        productionWorkshopService.add(productionWorkshopVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ProductionWorkshopVo productionWorkshopVo) {
        productionWorkshopService.edit(productionWorkshopVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ProductionWorkshopVo productionWorkshopVo) {
        productionWorkshopService.delete(productionWorkshopVo);
        return R.success();
    }

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


}

