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.CompanyVoiceBlacklist;
import com.fs.company.service.ICompanyVoiceBlacklistService;
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/companyVoiceBlacklist")
public class CompanyVoiceBlacklistController extends BaseController
{
    @Autowired
    private ICompanyVoiceBlacklistService companyVoiceBlacklistService;

    /**
     * 查询黑名单列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:list')")
    @GetMapping("/list")
    public TableDataInfo list(CompanyVoiceBlacklist companyVoiceBlacklist)
    {
        startPage();
        List<CompanyVoiceBlacklist> list = companyVoiceBlacklistService.selectCompanyVoiceBlacklistList(companyVoiceBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出黑名单列表
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:export')")
    @Log(title = "黑名单", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(CompanyVoiceBlacklist companyVoiceBlacklist)
    {
        List<CompanyVoiceBlacklist> list = companyVoiceBlacklistService.selectCompanyVoiceBlacklistList(companyVoiceBlacklist);
        ExcelUtil<CompanyVoiceBlacklist> util = new ExcelUtil<CompanyVoiceBlacklist>(CompanyVoiceBlacklist.class);
        return util.exportExcel(list, "companyVoiceBlacklist");
    }

    /**
     * 获取黑名单详细信息
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:query')")
    @GetMapping(value = "/{blacklistId}")
    public AjaxResult getInfo(@PathVariable("blacklistId") Long blacklistId)
    {
        return AjaxResult.success(companyVoiceBlacklistService.selectCompanyVoiceBlacklistById(blacklistId));
    }

    /**
     * 新增黑名单
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:add')")
    @Log(title = "黑名单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CompanyVoiceBlacklist companyVoiceBlacklist)
    {
        return toAjax(companyVoiceBlacklistService.insertCompanyVoiceBlacklist(companyVoiceBlacklist));
    }

    /**
     * 修改黑名单
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:edit')")
    @Log(title = "黑名单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CompanyVoiceBlacklist companyVoiceBlacklist)
    {
        return toAjax(companyVoiceBlacklistService.updateCompanyVoiceBlacklist(companyVoiceBlacklist));
    }

    /**
     * 删除黑名单
     */
    @PreAuthorize("@ss.hasPermi('company:companyVoiceBlacklist:remove')")
    @Log(title = "黑名单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{blacklistIds}")
    public AjaxResult remove(@PathVariable Long[] blacklistIds)
    {
        return toAjax(companyVoiceBlacklistService.deleteCompanyVoiceBlacklistByIds(blacklistIds));
    }
}
