package com.njzscloud.dispose.mfg.craft.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.craft.pojo.entity.CraftOperationEntity;
import com.njzscloud.dispose.mfg.craft.pojo.param.SearchCraftOperationParam;
import com.njzscloud.dispose.mfg.craft.service.CraftOperationService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工序
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/craft_operation")
@RequiredArgsConstructor
public class CraftOperationController {
    private final CraftOperationService craftOperationService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody CraftOperationEntity craftOperationEntity) {
        craftOperationService.add(craftOperationEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody CraftOperationEntity craftOperationEntity) {
        craftOperationService.modify(craftOperationEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<CraftOperationEntity>> paging(PageParam pageParam, SearchCraftOperationParam operationParam) {
        return R.success(craftOperationService.paging(pageParam, operationParam));
    }
}
