package com.fs.course.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.course.domain.FsCourseProduct;
import com.fs.course.service.IFsCourseProductService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 拍单商品Controller
 * 
 * @author fs
 * @date 2025-07-28
 */
@RestController
@RequestMapping("/course/fsCourseProduct")
public class FsCourseProductController extends BaseController
{
    @Autowired
    private IFsCourseProductService fsCourseProductService;

    /**
     * 查询拍单商品列表
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseProduct fsCourseProduct)
    {
        startPage();
        List<FsCourseProduct> list = fsCourseProductService.selectFsCourseProductList(fsCourseProduct);
        return getDataTable(list);
    }

    /**
     * 导出拍单商品列表
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:export')")
    @Log(title = "拍单商品", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseProduct fsCourseProduct)
    {
        List<FsCourseProduct> list = fsCourseProductService.selectFsCourseProductList(fsCourseProduct);
        ExcelUtil<FsCourseProduct> util = new ExcelUtil<FsCourseProduct>(FsCourseProduct.class);
        return util.exportExcel(list, "拍单商品数据");
    }

    /**
     * 获取拍单商品详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsCourseProductService.selectFsCourseProductById(id));
    }

    /**
     * 新增拍单商品
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:add')")
    @Log(title = "拍单商品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseProduct fsCourseProduct)
    {
        return toAjax(fsCourseProductService.insertFsCourseProduct(fsCourseProduct));
    }

    /**
     * 修改拍单商品
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:edit')")
    @Log(title = "拍单商品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseProduct fsCourseProduct)
    {
        return toAjax(fsCourseProductService.updateFsCourseProduct(fsCourseProduct));
    }

    /**
     * 删除拍单商品
     */
    @PreAuthorize("@ss.hasPermi('course:fsCourseProduct:remove')")
    @Log(title = "拍单商品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsCourseProductService.deleteFsCourseProductByIds(ids));
    }
}
