package com.fs.oms.controller;

import java.util.List;

import com.fs.oms.param.OmsInnerOrderParam;
import com.fs.oms.vo.OmsInnerOrderVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.oms.domain.OmsOrder;
import com.fs.oms.service.IOmsOrderService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * oms销售订单Controller
 *
 * @author fs
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/oms/orderInternal")
public class OmsOrderInternalController extends BaseController
{
    @Autowired
    private IOmsOrderService omsOrderService;

    /**
     * 查询oms销售订单列表
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:list')")
    @GetMapping("/list")
    public TableDataInfo list(OmsInnerOrderParam omsOrder)
    {
        startPage();
        List<OmsInnerOrderVO> list = omsOrderService.selectOmsInnerOrderListVO(omsOrder);
        return getDataTable(list);
    }

    /**
     * 导出oms销售订单列表
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:export')")
    @Log(title = "oms销售订单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OmsOrder omsOrder)
    {
        List<OmsOrder> list = omsOrderService.selectOmsOrderList(omsOrder);
        ExcelUtil<OmsOrder> util = new ExcelUtil<OmsOrder>(OmsOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取oms销售订单详细信息
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(omsOrderService.selectOmsOrderById(id));
    }

    /**
     * 新增oms销售订单
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:add')")
    @Log(title = "oms销售订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OmsOrder omsOrder)
    {
        return toAjax(omsOrderService.insertOmsOrder(omsOrder));
    }

    /**
     * 修改oms销售订单
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:edit')")
    @Log(title = "oms销售订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OmsOrder omsOrder)
    {
        return toAjax(omsOrderService.updateOmsOrder(omsOrder));
    }

    /**
     * 删除oms销售订单
     */
    @PreAuthorize("@ss.hasPermi('oms:orderInternal:remove')")
    @Log(title = "oms销售订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(omsOrderService.deleteOmsOrderByIds(ids));
    }

}
