package com.fs.hisStore.controller;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.hisStore.domain.FsStoreOrderItemScrm;
import com.fs.hisStore.service.IFsStoreOrderItemScrmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 订单详情Controller
 *
 * @author fs
 * @date 2022-03-21
 */
@RestController
@RequestMapping("/store/store/storeOrderItem")
public class FsStoreOrderItemScrmController extends BaseController
{
    @Autowired
    private IFsStoreOrderItemScrmService fsStoreOrderItemService;

    /**
     * 查询订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreOrderItemScrm fsStoreOrderItem)
    {
        startPage();
        List<FsStoreOrderItemScrm> list = fsStoreOrderItemService.selectFsStoreOrderItemList(fsStoreOrderItem);
        return getDataTable(list);
    }

    /**
     * 导出订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:export')")
    @Log(title = "订单详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreOrderItemScrm fsStoreOrderItem)
    {
        List<FsStoreOrderItemScrm> list = fsStoreOrderItemService.selectFsStoreOrderItemList(fsStoreOrderItem);
        ExcelUtil<FsStoreOrderItemScrm> util = new ExcelUtil<FsStoreOrderItemScrm>(FsStoreOrderItemScrm.class);
        return util.exportExcel(list, "storeOrderItem");
    }

    /**
     * 获取订单详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") Long itemId)
    {
        return AjaxResult.success(fsStoreOrderItemService.selectFsStoreOrderItemById(itemId));
    }

    /**
     * 新增订单详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:add')")
    @Log(title = "订单详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreOrderItemScrm fsStoreOrderItem)
    {
        return toAjax(fsStoreOrderItemService.insertFsStoreOrderItem(fsStoreOrderItem));
    }

    /**
     * 修改订单详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:edit')")
    @Log(title = "订单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreOrderItemScrm fsStoreOrderItem)
    {
        return toAjax(fsStoreOrderItemService.updateFsStoreOrderItem(fsStoreOrderItem));
    }

    /**
     * 删除订单详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:remove')")
    @Log(title = "订单详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable Long[] itemIds)
    {
        return toAjax(fsStoreOrderItemService.deleteFsStoreOrderItemByIds(itemIds));
    }
}
