package org.dromara.erp.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.erp.domain.query.ErpSaleOrderMasterQuery;
import org.dromara.erp.domain.vo.ErpSaleOrderMasterVo;
import org.dromara.erp.service.IErpSaleOrderMasterService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * ERP 销售订单主表控制器
 *
 * @author Antigravity
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/erp/saleOrderMaster")
public class ErpSaleOrderMasterController {

    private final IErpSaleOrderMasterService erpSaleOrderMasterService;

    /**
     * 分页查询
     */
    @GetMapping("/list")
    public TableDataInfo<ErpSaleOrderMasterVo> list(ErpSaleOrderMasterQuery query, PageQuery pageQuery) {
        return erpSaleOrderMasterService.queryPageList(query, pageQuery);
    }

    /**
     * 查询列表（不分页）
     */
    @GetMapping("/all")
    public R<List<ErpSaleOrderMasterVo>> all(ErpSaleOrderMasterQuery query) {
        return R.ok(erpSaleOrderMasterService.queryList(query));
    }

    /**
     * 根据 ID 获取详情
     */
    @GetMapping("/{rowId}")
    public R<ErpSaleOrderMasterVo> getInfo(@PathVariable("rowId") String rowId) {
        return R.ok(erpSaleOrderMasterService.queryById(rowId));
    }

}
