package com.fs.company.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.company.domain.CompanySmsPackage;
import com.fs.company.service.ICompanySmsPackageService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 短信套餐包Controller
 *
 * @author fs
 * @date 2023-01-09
 */
@RestController
@RequestMapping("/company/companySmsPackage")
public class CompanySmsPackageController extends BaseController
{
    @Autowired
    private ICompanySmsPackageService companySmsPackageService;

    /**
     * 查询短信套餐包列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:list')")
    @GetMapping("/listAll")
    public AjaxResult listAll(CompanySmsPackage companySmsPackage)
    {
        List<CompanySmsPackage> list = companySmsPackageService.selectCompanySmsPackageList(companySmsPackage);
        return AjaxResult.success(list);
    }

    /**
     * 查询短信套餐包列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanySmsPackage companySmsPackage)
    {
        startPage();
        List<CompanySmsPackage> list = companySmsPackageService.selectCompanySmsPackageList(companySmsPackage);
        return getDataTable(list);
    }

    /**
     * 导出短信套餐包列表
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:export')")
    @Log(title = "短信套餐包", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanySmsPackage companySmsPackage)
    {
        List<CompanySmsPackage> list = companySmsPackageService.selectCompanySmsPackageList(companySmsPackage);
        ExcelUtil<CompanySmsPackage> util = new ExcelUtil<CompanySmsPackage>(CompanySmsPackage.class);
        return util.exportExcel(list, "companySmsPackage");
    }

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

    /**
     * 新增短信套餐包
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:add')")
    @Log(title = "短信套餐包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanySmsPackage companySmsPackage)
    {
        return toAjax(companySmsPackageService.insertCompanySmsPackage(companySmsPackage));
    }

    /**
     * 修改短信套餐包
     */
    @PreAuthorize("@ss.hasPermi('company:companySmsPackage:edit')")
    @Log(title = "短信套餐包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanySmsPackage companySmsPackage)
    {
        return toAjax(companySmsPackageService.updateCompanySmsPackage(companySmsPackage));
    }

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