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.CraftWayEntity;
import com.njzscloud.dispose.mfg.craft.pojo.param.AddAllCraftWayParam;
import com.njzscloud.dispose.mfg.craft.pojo.result.SearchCraftWayResult;
import com.njzscloud.dispose.mfg.craft.service.CraftWayService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工艺路线
 */
@Slf4j
@RestController
@RequestMapping("/craft_way")
@RequiredArgsConstructor
public class CraftWayController {
    private final CraftWayService craftWayService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody CraftWayEntity craftWayEntity) {
        craftWayService.add(craftWayEntity);
        return R.success();
    }

    /**
     * 新增
     */
    @PostMapping("/add_all")
    public R<?> addAll(@RequestBody AddAllCraftWayParam addAllCraftWayParam) {
        craftWayService.addAll(addAllCraftWayParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody CraftWayEntity craftWayEntity) {
        craftWayService.modify(craftWayEntity);
        return R.success();
    }

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

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

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


    /**
     * 查询工艺路线列表
     */
    @GetMapping("/list_all")
    public R<List<SearchCraftWayResult>> listAll(Long craftId) {
        return R.success(craftWayService.listAll(craftId));
    }

}
