package com.njzscloud.dispose.wh.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.wh.pojo.entity.SalesOrderEntity;
import com.njzscloud.dispose.wh.pojo.param.AddSalesOrderParam;
import com.njzscloud.dispose.wh.service.SalesOrderService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 销售单
 *
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/sales_order")
@RequiredArgsConstructor
public class SalesOrderController {
    private final SalesOrderService salesOrderService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody AddSalesOrderParam addSalesOrderParam) {
        salesOrderService.add(addSalesOrderParam);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody SalesOrderEntity salesOrderEntity) {
        salesOrderService.modify(salesOrderEntity);
        return R.success();
    }

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

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

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