package com.ruoyi.web.controller.blackManage;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.blackManage.BlackManage;
import com.ruoyi.system.service.IBlackManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 黑名单管理Controller
 *
 * @author boman
 * @date 2025-02-17
 */
@RestController
@RequestMapping("/wuYe/blackManage")
public class BlackManageController extends BaseController
{
    @Autowired
    private IBlackManageService blackManageService;

/**
 * 查询黑名单管理列表
 */
@PreAuthorize("@ss.hasPermi('wuYe:blackManage:list')")
@GetMapping("/list")
    public TableDataInfo list(BlackManage blackManage)
    {
        startPage();
        List<BlackManage> list = blackManageService.selectBlackManageList(blackManage);
        return getDataTable(list);
    }

    /**
     * 导出黑名单管理列表
     */
    @PreAuthorize("@ss.hasPermi('wuYe:blackManage:export')")
    @Log(title = "黑名单管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlackManage blackManage)
    {
        List<BlackManage> list = blackManageService.selectBlackManageList(blackManage);
        ExcelUtil<BlackManage> util = new ExcelUtil<BlackManage>(BlackManage.class);
        util.exportExcel(response, list, "黑名单管理数据");
    }

    /**
     * 获取黑名单管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('wuYe:blackManage:query')")
    @GetMapping(value = "/{blackManageId}")
    public AjaxResult getInfo(@PathVariable("blackManageId") Long blackManageId)
    {
        return success(blackManageService.selectBlackManageByBlackManageId(blackManageId));
    }

    /**
     * 新增黑名单管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:blackManage:add')")
    @Log(title = "黑名单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlackManage blackManage)
    {
        return toAjax(blackManageService.insertBlackManage(blackManage));
    }

    /**
     * 修改黑名单管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:blackManage:edit')")
    @Log(title = "黑名单管理", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody BlackManage blackManage)
    {
        return toAjax(blackManageService.updateBlackManage(blackManage));
    }

    /**
     * 删除黑名单管理
     */
    @PreAuthorize("@ss.hasPermi('wuYe:blackManage:remove')")
    @Log(title = "黑名单管理", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{blackManageIds}")
    public AjaxResult remove(@PathVariable Long[] blackManageIds)
    {
        return toAjax(blackManageService.deleteBlackManageByBlackManageIds(blackManageIds));
    }
}
