package com.trade.admin.salesorder;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;

import com.trade.common.core.domain.ResponseResult;
import com.trade.service.salesorder.service.ISalesOrderService;
import com.trade.service.salesorder.vo.SalesOrderSearch;

@Controller
@RequestMapping("/salesOrderB")
@Validated
public class SalesOrderBController {

    @Resource
    private ISalesOrderService salesOrderService;

    /**
     * 获取销售订单列表
     */
    @RequestMapping("/queryList")
    @PreAuthorize("@ss.hasPermi('sales:order:list')")
    public Object queryList(SalesOrderSearch search) {
        return ResponseResult.success(salesOrderService.queryListBySearch(search));
    }

    /**
     * 根据订单id获取销售订单详情
     */
    @RequestMapping("/getDetailById")
    @PreAuthorize("@ss.hasPermi('sales:order:detail')")
    public Object getByEntityId(@NotNull(message = "订单ID不能为空") Long id) {
        return ResponseResult.success(salesOrderService.getDetail(id, false));
    }
}
