package com.ruoyi.frequency.worksshield.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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.frequency.worksshield.entity.WorksShield;
import com.ruoyi.frequency.worksshield.service.WorksShieldService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品屏蔽Controller
 * 
 * @author liwenlong
 * @date 2023-11-30
 */
@RestController
@RequestMapping("/frequency/worksshield")
public class WorksShieldController extends BaseController
{
    @Autowired
    private WorksShieldService worksShieldService;

    /**
     * 查询作品屏蔽列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:list')")
    @PostMapping("/list")
    public TableDataInfo<WorksShield> list(@RequestBody WorksShield worksShield)
    {
        startPage();
        List<WorksShield> list = worksShieldService.selectWorksShieldList(worksShield);
        return getDataTable(list);
    }

    /**
     * 导出作品屏蔽列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:export')")
    @Log(title = "作品屏蔽", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorksShield worksShield)
    {
        List<WorksShield> list = worksShieldService.selectWorksShieldList(worksShield);
        ExcelUtil<WorksShield> util = new ExcelUtil<WorksShield>(WorksShield.class);
        return util.exportExcel(list, "作品屏蔽数据");
    }

    /**
     * 获取作品屏蔽详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<WorksShield> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(worksShieldService.selectWorksShieldById(id));
    }

    /**
     * 新增作品屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:add')")
    @Log(title = "作品屏蔽", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorksShield worksShield)
    {
        return toAjax(worksShieldService.insertWorksShield(worksShield));
    }

    /**
     * 修改作品屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:edit')")
    @Log(title = "作品屏蔽", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorksShield worksShield)
    {
        return toAjax(worksShieldService.updateWorksShield(worksShield));
    }

    /**
     * 删除作品屏蔽
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksshield:remove')")
    @Log(title = "作品屏蔽", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids,@PathVariable("delFlag") Integer delFlag)
    {
        return toAjax(worksShieldService.deleteWorksShieldByIds(ids,delFlag));
    }
}
