package com.fs.store.controller;

import java.util.List;
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.store.domain.FsStoreOrderItem;
import com.fs.store.service.IFsStoreOrderItemService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

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

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

    /**
     * 导出订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:export')")
    @Log(title = "订单详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreOrderItem fsStoreOrderItem)
    {
        List<FsStoreOrderItem> list = fsStoreOrderItemService.selectFsStoreOrderItemList(fsStoreOrderItem);
        ExcelUtil<FsStoreOrderItem> util = new ExcelUtil<FsStoreOrderItem>(FsStoreOrderItem.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 FsStoreOrderItem fsStoreOrderItem)
    {
        return toAjax(fsStoreOrderItemService.insertFsStoreOrderItem(fsStoreOrderItem));
    }

    /**
     * 修改订单详情
     */
    @PreAuthorize("@ss.hasPermi('store:storeOrderItem:edit')")
    @Log(title = "订单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreOrderItem 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));
    }
}
