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

/**
 * 会员套餐Controller
 * 
 * @author fs
 * @date 2024-06-27
 */
@RestController
@RequestMapping("/course/userVipPackage")
public class FsUserVipPackageController extends BaseController
{
    @Autowired
    private IFsUserVipPackageService fsUserVipPackageService;

    /**
     * 查询会员套餐列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserVipPackage fsUserVipPackage)
    {
        startPage();
        List<FsUserVipPackage> list = fsUserVipPackageService.selectFsUserVipPackageList(fsUserVipPackage);
        return getDataTable(list);
    }

    /**
     * 导出会员套餐列表
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:export')")
    @Log(title = "会员套餐", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserVipPackage fsUserVipPackage)
    {
        List<FsUserVipPackage> list = fsUserVipPackageService.selectFsUserVipPackageList(fsUserVipPackage);
        ExcelUtil<FsUserVipPackage> util = new ExcelUtil<FsUserVipPackage>(FsUserVipPackage.class);
        return util.exportExcel(list, "会员套餐数据");
    }

    /**
     * 获取会员套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:query')")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return AjaxResult.success(fsUserVipPackageService.selectFsUserVipPackageByPackageId(packageId));
    }

    /**
     * 新增会员套餐
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:add')")
    @Log(title = "会员套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserVipPackage fsUserVipPackage)
    {
        return toAjax(fsUserVipPackageService.insertFsUserVipPackage(fsUserVipPackage));
    }

    /**
     * 修改会员套餐
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:edit')")
    @Log(title = "会员套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserVipPackage fsUserVipPackage)
    {
        return toAjax(fsUserVipPackageService.updateFsUserVipPackage(fsUserVipPackage));
    }

    /**
     * 删除会员套餐
     */
    @PreAuthorize("@ss.hasPermi('course:userVipPackage:remove')")
    @Log(title = "会员套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(fsUserVipPackageService.deleteFsUserVipPackageByPackageIds(packageIds));
    }
}
