package com.fs.live.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.live.domain.LiveOrderItem;
import com.fs.live.service.ILiveOrderItemService;
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 2025-07-08
 */
@RestController
@RequestMapping("/live/liveOrderItem")
public class LiveOrderItemController extends BaseController
{
    @Autowired
    private ILiveOrderItemService liveOrderItemService;

    /**
     * 查询订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveOrderItem liveOrderItem)
    {
        startPage();
        List<LiveOrderItem> list = liveOrderItemService.selectLiveOrderItemList(liveOrderItem);
        return getDataTable(list);
    }

    /**
     * 导出订单详情列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:export')")
    @Log(title = "订单详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveOrderItem liveOrderItem)
    {
        List<LiveOrderItem> list = liveOrderItemService.selectLiveOrderItemList(liveOrderItem);
        ExcelUtil<LiveOrderItem> util = new ExcelUtil<LiveOrderItem>(LiveOrderItem.class);
        return util.exportExcel(list, "订单详情数据");
    }

    /**
     * 获取订单详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:query')")
    @GetMapping(value = "/{itemId}")
    public AjaxResult getInfo(@PathVariable("itemId") String itemId)
    {
        return AjaxResult.success(liveOrderItemService.selectLiveOrderItemByItemId(itemId));
    }

    /**
     * 新增订单详情
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:add')")
    @Log(title = "订单详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveOrderItem liveOrderItem)
    {
        return toAjax(liveOrderItemService.insertLiveOrderItem(liveOrderItem));
    }

    /**
     * 修改订单详情
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:edit')")
    @Log(title = "订单详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveOrderItem liveOrderItem)
    {
        return toAjax(liveOrderItemService.updateLiveOrderItem(liveOrderItem));
    }

    /**
     * 删除订单详情
     */
    @PreAuthorize("@ss.hasPermi('live:liveOrderItem:remove')")
    @Log(title = "订单详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{itemIds}")
    public AjaxResult remove(@PathVariable String[] itemIds)
    {
        return toAjax(liveOrderItemService.deleteLiveOrderItemByItemIds(itemIds));
    }
}
