package com.njzscloud.supervisory.order.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.supervisory.order.pojo.entity.OrderGoodsEntity;
import com.njzscloud.supervisory.order.service.OrderGoodsService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单产品表
 */
@Slf4j
@RestController
@RequestMapping("/order_goods")
@RequiredArgsConstructor
public class OrderGoodsController {

    private final OrderGoodsService orderGoodsService;

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody OrderGoodsEntity orderGoodsEntity) {
        orderGoodsService.modify(orderGoodsEntity);
        return R.success();
    }

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

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

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

}
