package com.ruoyi.frequency.worksreport.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.worksreport.entity.WorksReport;
import com.ruoyi.frequency.worksreport.service.WorksReportService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品举报Controller
 * 
 * @author liwenlong
 * @date 2023-11-30
 */
@RestController
@RequestMapping("/frequency/worksreport")
public class WorksReportController extends BaseController
{
    @Autowired
    private WorksReportService worksReportService;

    /**
     * 查询作品举报列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksreport:list')")
    @PostMapping("/list")
    public TableDataInfo<WorksReport> list(@RequestBody WorksReport worksReport)
    {
        startPage();
        List<WorksReport> list = worksReportService.selectWorksReportList(worksReport);
        return getDataTable(list);
    }

    /**
     * 导出作品举报列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksreport:export')")
    @Log(title = "作品举报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(WorksReport worksReport)
    {
        List<WorksReport> list = worksReportService.selectWorksReportList(worksReport);
        ExcelUtil<WorksReport> util = new ExcelUtil<WorksReport>(WorksReport.class);
        return util.exportExcel(list, "作品举报数据");
    }

    /**
     * 获取作品举报详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksreport:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<WorksReport> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(worksReportService.selectWorksReportById(id));
    }

    /**
     * 新增作品举报
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksreport:add')")
    @Log(title = "作品举报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorksReport worksReport)
    {
        return toAjax(worksReportService.insertWorksReport(worksReport));
    }

    /**
     * 修改作品举报
     */
    @PreAuthorize("@ss.hasPermi('frequency:worksreport:edit')")
    @Log(title = "作品举报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorksReport worksReport)
    {
        return toAjax(worksReportService.updateWorksReport(worksReport));
    }

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