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.dto.BomAddDto;
import com.njzscloud.dispose.mfg.bom.pojo.dto.BomQueryDto;
import com.njzscloud.dispose.mfg.bom.pojo.entity.BomEntity;
import com.njzscloud.dispose.mfg.bom.service.BomService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 物料清单
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/bom")
@RequiredArgsConstructor
public class BomController {
    private final BomService bomService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody BomAddDto bomAddDTO) {
        bomService.add(bomAddDTO);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody BomEntity bomEntity) {
        bomService.modify(bomEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<BomEntity>> paging(PageParam pageParam, BomQueryDto queryDto) {
        return R.success(bomService.paging(pageParam, queryDto));
    }
}
