package com.fs.company.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.company.domain.CompanyVoicePackage;
import com.fs.company.service.ICompanyVoicePackageService;
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 2023-02-23
 */
@RestController
@RequestMapping("/company/companyVoicePackage")
public class CompanyVoicePackageController extends BaseController
{
    @Autowired
    private ICompanyVoicePackageService companyVoicePackageService;

    /**
     * 查询套餐列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyVoicePackage companyVoicePackage)
    {
        startPage();
        List<CompanyVoicePackage> list = companyVoicePackageService.selectCompanyVoicePackageList(companyVoicePackage);
        return getDataTable(list);
    }

    /**
     * 导出套餐列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:export')")
    @Log(title = "套餐", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyVoicePackage companyVoicePackage)
    {
        List<CompanyVoicePackage> list = companyVoicePackageService.selectCompanyVoicePackageList(companyVoicePackage);
        ExcelUtil<CompanyVoicePackage> util = new ExcelUtil<CompanyVoicePackage>(CompanyVoicePackage.class);
        return util.exportExcel(list, "companyVoicePackage");
    }

    /**
     * 获取套餐详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:query')")
    @GetMapping(value = "/{packageId}")
    public AjaxResult getInfo(@PathVariable("packageId") Long packageId)
    {
        return AjaxResult.success(companyVoicePackageService.selectCompanyVoicePackageById(packageId));
    }

    /**
     * 新增套餐
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:add')")
    @Log(title = "套餐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyVoicePackage companyVoicePackage)
    {
        return toAjax(companyVoicePackageService.insertCompanyVoicePackage(companyVoicePackage));
    }

    /**
     * 修改套餐
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:edit')")
    @Log(title = "套餐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyVoicePackage companyVoicePackage)
    {
        return toAjax(companyVoicePackageService.updateCompanyVoicePackage(companyVoicePackage));
    }

    /**
     * 删除套餐
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoicePackage:remove')")
    @Log(title = "套餐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{packageIds}")
    public AjaxResult remove(@PathVariable Long[] packageIds)
    {
        return toAjax(companyVoicePackageService.deleteCompanyVoicePackageByIds(packageIds));
    }
}
