package com.njzscloud.dispose.mfg.bom.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.mfg.bom.pojo.entity.BomDetailEntity;
import com.njzscloud.dispose.mfg.bom.service.BomDetailService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物料清单明细
 */
@Slf4j
@RestController
@RequestMapping("/bom_detail")
@RequiredArgsConstructor
public class BomDetailController {
    private final BomDetailService bomDetailService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody BomDetailEntity bomDetailEntity) {
        bomDetailService.add(bomDetailEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody BomDetailEntity bomDetailEntity) {
        bomDetailService.modify(bomDetailEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        bomDetailService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<BomDetailEntity> detail(@RequestParam("id") Long id) {
        return R.success(bomDetailService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<BomDetailEntity>> paging(PageParam pageParam, BomDetailEntity bomDetailEntity) {
        return R.success(bomDetailService.paging(pageParam, bomDetailEntity));
    }
}
