package com.jwipc.order.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.order.dto.PurchaseOrderBomDTO;

import com.jwipc.order.logic.PurchaseOrderBomLogic;

import com.jwipc.order.model.query.PurchaseOrderBomQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.jwipc.order.constant.ModuleConst.MODULE_ROOT;


/**
 * <p> </p>
 *
 * @author ZhangJie
 * @version 1.0
 * @since JDK 1.8
 */
@RequestMapping(MODULE_ROOT + "/purchaseOrderBom/rest/")
@RequiredArgsConstructor
@RestController
public class PurchaseOrderBomRestController {

    private final PurchaseOrderBomLogic purchaseOrderBomLogic;
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(PurchaseOrderBomQuery query) {
        return purchaseOrderBomLogic.findByPage(query);
    }

    /**
     * 下拉列表
     *
     * @param query
     * @return
     */
//    @RequestMapping("/listAll")
//    public ResponseEntity<List<PurchaseOrgDTO>> listAll(PurchaseOrgQuery query) {
//        return ResponseEntity.ok(purchaseOrgLogic.listAll(query));
//    }

    /**
     * 保存更新
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(PurchaseOrderBomDTO param){
        purchaseOrderBomLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }

    /**
     * 删除
     *
     * @param id 参数
     */
    @PostMapping("/remove")
    public ResponseEntity remove(Long id) {
        purchaseOrderBomLogic.remove(id);
        return ResponseEntity.ok(true);
    }

}
