package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.system.domain.WorkReview;
import com.ruoyi.system.service.IWorkReviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品评审意见Controller
 * 
 * @author haotian
 * @date 2024-12-11
 */
@RestController
@RequestMapping("/system/review")
public class WorkReviewController extends BaseController
{
    @Autowired
    private IWorkReviewService workReviewService;

    /**
     * 查询作品评审意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkReview workReview)
    {
        startPage();
        List<WorkReview> list = workReviewService.selectWorkReviewList(workReview);
        return getDataTable(list);
    }

    /**
     * 导出作品评审意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:review:export')")
    @Log(title = "作品评审意见", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkReview workReview)
    {
        List<WorkReview> list = workReviewService.selectWorkReviewList(workReview);
        ExcelUtil<WorkReview> util = new ExcelUtil<WorkReview>(WorkReview.class);
        util.exportExcel(response, list, "作品评审意见数据");
    }

    /**
     * 获取作品评审意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:review:query')")
    @GetMapping(value = "/{reviewId}")
    public AjaxResult getInfo(@PathVariable("reviewId") Long reviewId)
    {
        return success(workReviewService.selectWorkReviewByReviewId(reviewId));
    }

    /**
     * 新增作品评审意见
     */
    @PreAuthorize("@ss.hasPermi('system:review:add')")
    @Log(title = "作品评审意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkReview workReview)
    {
        return toAjax(workReviewService.insertWorkReview(workReview));
    }

    /**
     * 修改作品评审意见
     */
    @PreAuthorize("@ss.hasPermi('system:review:edit')")
    @Log(title = "作品评审意见", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkReview workReview)
    {
        return toAjax(workReviewService.updateWorkReview(workReview));
    }

    /**
     * 删除作品评审意见
     */
    @PreAuthorize("@ss.hasPermi('system:review:remove')")
    @Log(title = "作品评审意见", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reviewIds}")
    public AjaxResult remove(@PathVariable Long[] reviewIds)
    {
        return toAjax(workReviewService.deleteWorkReviewByReviewIds(reviewIds));
    }
}
