package com.ruoyi.post.frequency.posshield.controller;

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.post.frequency.posshield.entity.PostShield;
import com.ruoyi.post.frequency.posshield.service.PostShieldService;
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 liwenlong
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/frequency/posshield")
public class PostShieldController extends BaseController
{
    @Autowired
    private PostShieldService postShieldService;

    /**
     * 查询论坛屏蔽列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:list')")
    @PostMapping("/list")
    public TableDataInfo<PostShield> list(@RequestBody  PostShield postShield)
    {
        startPage();
        List<PostShield> list = postShieldService.selectPostShieldList(postShield);
        return getDataTable(list);
    }

    /**
     * 导出论坛屏蔽列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:export')")
    @Log(title = "论坛屏蔽", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PostShield postShield)
    {
        List<PostShield> list = postShieldService.selectPostShieldList(postShield);
        ExcelUtil<PostShield> util = new ExcelUtil<PostShield>(PostShield.class);
        return util.exportExcel(list, "论坛屏蔽数据");
    }

    /**
     * 获取论坛屏蔽详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<PostShield> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(postShieldService.selectPostShieldById(id));
    }

    /**
     * 新增论坛屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:add')")
    @Log(title = "论坛屏蔽", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PostShield postShield)
    {
        return toAjax(postShieldService.insertPostShield(postShield));
    }

    /**
     * 修改论坛屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:edit')")
    @Log(title = "论坛屏蔽", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PostShield postShield)
    {
        return toAjax(postShieldService.updatePostShield(postShield));
    }

    /**
     * 删除论坛屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:posshield:remove')")
    @Log(title = "论坛屏蔽", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(postShieldService.deletePostShieldByIds(ids));
    }
}
