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.FsCourseDomainName;
import com.fs.course.service.IFsCourseDomainNameService;
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 2024-10-09
 */
@RestController
@RequestMapping("/course/courseDomainName")
public class FsCourseDomainNameController extends BaseController
{
    @Autowired
    private IFsCourseDomainNameService fsCourseDomainNameService;

    /**
     * 查询课程短链域名列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsCourseDomainName fsCourseDomainName)
    {
        startPage();
        List<FsCourseDomainName> list = fsCourseDomainNameService.selectFsCourseDomainNameList(fsCourseDomainName);
        return getDataTable(list);
    }

    /**
     * 导出课程短链域名列表
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:export')")
    @Log(title = "课程短链域名", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsCourseDomainName fsCourseDomainName)
    {
        List<FsCourseDomainName> list = fsCourseDomainNameService.selectFsCourseDomainNameList(fsCourseDomainName);
        ExcelUtil<FsCourseDomainName> util = new ExcelUtil<FsCourseDomainName>(FsCourseDomainName.class);
        return util.exportExcel(list, "课程短链域名数据");
    }

    /**
     * 获取课程短链域名详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsCourseDomainNameService.selectFsCourseDomainNameById(id));
    }

    /**
     * 新增课程短链域名
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:add')")
    @Log(title = "课程短链域名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsCourseDomainName fsCourseDomainName)
    {
        return toAjax(fsCourseDomainNameService.insertFsCourseDomainName(fsCourseDomainName));
    }

    /**
     * 修改课程短链域名
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:edit')")
    @Log(title = "课程短链域名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsCourseDomainName fsCourseDomainName)
    {
        return toAjax(fsCourseDomainNameService.updateFsCourseDomainName(fsCourseDomainName));
    }

    /**
     * 删除课程短链域名
     */
    @PreAuthorize("@ss.hasPermi('course:courseDomainName:remove')")
    @Log(title = "课程短链域名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsCourseDomainNameService.deleteFsCourseDomainNameByIds(ids));
    }
}
