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.FsCourseRedPacketRetry;
import com.fs.course.service.IFsCourseRedPacketRetryService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 课程红包失败重试记录Controller
 * 
 * @author fs
 * @date 2025-03-18
 */
@RestController
@RequestMapping("/course/courseRedPacketRetry")
public class FsCourseRedPacketRetryController extends BaseController
{
    @Autowired
    private IFsCourseRedPacketRetryService fsCourseRedPacketRetryService;

    /**
     * 查询课程红包失败重试记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseRedPacketRetry fsCourseRedPacketRetry)
    {
        startPage();
        List<FsCourseRedPacketRetry> list = fsCourseRedPacketRetryService.selectFsCourseRedPacketRetryList(fsCourseRedPacketRetry);
        return getDataTable(list);
    }

    /**
     * 导出课程红包失败重试记录列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:export')")
    @Log(title = "课程红包失败重试记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseRedPacketRetry fsCourseRedPacketRetry)
    {
        List<FsCourseRedPacketRetry> list = fsCourseRedPacketRetryService.selectFsCourseRedPacketRetryList(fsCourseRedPacketRetry);
        ExcelUtil<FsCourseRedPacketRetry> util = new ExcelUtil<FsCourseRedPacketRetry>(FsCourseRedPacketRetry.class);
        return util.exportExcel(list, "课程红包失败重试记录数据");
    }

    /**
     * 获取课程红包失败重试记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:query')")
    @GetMapping(value = "/{logId}")
    public AjaxResult getInfo(@PathVariable("logId") Long logId)
    {
        return AjaxResult.success(fsCourseRedPacketRetryService.selectFsCourseRedPacketRetryByLogId(logId));
    }

    /**
     * 新增课程红包失败重试记录
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:add')")
    @Log(title = "课程红包失败重试记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseRedPacketRetry fsCourseRedPacketRetry)
    {
        return toAjax(fsCourseRedPacketRetryService.insertFsCourseRedPacketRetry(fsCourseRedPacketRetry));
    }

    /**
     * 修改课程红包失败重试记录
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:edit')")
    @Log(title = "课程红包失败重试记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseRedPacketRetry fsCourseRedPacketRetry)
    {
        return toAjax(fsCourseRedPacketRetryService.updateFsCourseRedPacketRetry(fsCourseRedPacketRetry));
    }

    /**
     * 删除课程红包失败重试记录
     */
    @PreAuthorize("@ss.hasPermi('course:courseRedPacketRetry:remove')")
    @Log(title = "课程红包失败重试记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logIds}")
    public AjaxResult remove(@PathVariable Long[] logIds)
    {
        return toAjax(fsCourseRedPacketRetryService.deleteFsCourseRedPacketRetryByLogIds(logIds));
    }
}
