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.LiveAfterSalesItem;
import com.fs.live.service.ILiveAfterSalesItemService;
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/liveAfterSalesItem")
public class LiveAfterSalesItemController extends BaseController
{
    @Autowired
    private ILiveAfterSalesItemService liveAfterSalesItemService;

    /**
     * 查询售后子列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(LiveAfterSalesItem liveAfterSalesItem)
    {
        startPage();
        List<LiveAfterSalesItem> list = liveAfterSalesItemService.selectLiveAfterSalesItemList(liveAfterSalesItem);
        return getDataTable(list);
    }

    /**
     * 导出售后子列表
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:export')")
    @Log(title = "售后子", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LiveAfterSalesItem liveAfterSalesItem)
    {
        List<LiveAfterSalesItem> list = liveAfterSalesItemService.selectLiveAfterSalesItemList(liveAfterSalesItem);
        ExcelUtil<LiveAfterSalesItem> util = new ExcelUtil<LiveAfterSalesItem>(LiveAfterSalesItem.class);
        return util.exportExcel(list, "售后子数据");
    }

    /**
     * 获取售后子详细信息
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(liveAfterSalesItemService.selectLiveAfterSalesItemById(id));
    }

    /**
     * 新增售后子
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:add')")
    @Log(title = "售后子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LiveAfterSalesItem liveAfterSalesItem)
    {
        return toAjax(liveAfterSalesItemService.insertLiveAfterSalesItem(liveAfterSalesItem));
    }

    /**
     * 修改售后子
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:edit')")
    @Log(title = "售后子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LiveAfterSalesItem liveAfterSalesItem)
    {
        return toAjax(liveAfterSalesItemService.updateLiveAfterSalesItem(liveAfterSalesItem));
    }

    /**
     * 删除售后子
     */
    @PreAuthorize("@ss.hasPermi('live:liveAfterSalesItem:remove')")
    @Log(title = "售后子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(liveAfterSalesItemService.deleteLiveAfterSalesItemByIds(ids));
    }
}
