package com.fs.course.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.course.domain.FsCourseFinishTempParent;
import com.fs.course.service.IFsCourseFinishTempParentService;
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 吴树波
 * @date 2025-05-22
 */
@RestController
@RequestMapping("/course/courseFinishTempParent")
public class FsCourseFinishTempParentController extends BaseController
{
    @Autowired
    private IFsCourseFinishTempParentService fsCourseFinishTempParentService;

    /**
     * 查询完课模板列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseFinishTempParent fsCourseFinishTempParent)
    {
        startPage();
        List<FsCourseFinishTempParent> list = fsCourseFinishTempParentService.selectFsCourseFinishTempParentList(fsCourseFinishTempParent);
        return getDataTable(list);
    }

    /**
     * 导出完课模板列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:export')")
    @Log(title = "完课模板", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseFinishTempParent fsCourseFinishTempParent)
    {
        List<FsCourseFinishTempParent> list = fsCourseFinishTempParentService.selectFsCourseFinishTempParentList(fsCourseFinishTempParent);
        ExcelUtil<FsCourseFinishTempParent> util = new ExcelUtil<FsCourseFinishTempParent>(FsCourseFinishTempParent.class);
        return util.exportExcel(list, "完课模板数据");
    }

    /**
     * 获取完课模板详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsCourseFinishTempParentService.selectFsCourseFinishTempParentById(id));
    }

    /**
     * 新增完课模板
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:add')")
    @Log(title = "完课模板", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseFinishTempParent fsCourseFinishTempParent){

        return toAjax(fsCourseFinishTempParentService.insertFsCourseFinishTempParent(fsCourseFinishTempParent));
    }

    /**
     * 修改完课模板
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:edit')")
    @Log(title = "完课模板", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseFinishTempParent fsCourseFinishTempParent)
    {
        return toAjax(fsCourseFinishTempParentService.updateFsCourseFinishTempParent(fsCourseFinishTempParent));
    }

    /**
     * 删除完课模板
     */
    @PreAuthorize("@ss.hasPermi('course:courseFinishTempParent:remove')")
    @Log(title = "完课模板", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsCourseFinishTempParentService.deleteFsCourseFinishTempParentByIds(ids));
    }
}
