package com.ruoyi.web.controller.review;

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

import com.ruoyi.system.domain.review.ReviewComments;
import com.ruoyi.system.service.review.IReviewCommentsService;
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.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.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务审核意见Controller
 *
 * @author boman
 * @date 2024-04-24
 */
@RestController
@RequestMapping("/comments")
public class ReviewCommentsController extends BaseController {
    @Autowired
    private IReviewCommentsService reviewCommentsService;

    /**
     * 查询业务审核意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:comments:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReviewComments reviewComments) {
        List<ReviewComments> list = reviewCommentsService.selectReviewCommentsList(reviewComments);
        return getDataTable(list);
    }

    /**
     * 导出业务审核意见列表
     */
    @PreAuthorize("@ss.hasPermi('system:comments:export')")
    @Log(title = "业务审核意见", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ReviewComments reviewComments) {
        List<ReviewComments> list = reviewCommentsService.selectReviewCommentsList(reviewComments);
        ExcelUtil<ReviewComments> util = new ExcelUtil<ReviewComments>(ReviewComments.class);
        util.exportExcel(response, list, "业务审核意见数据");
    }

    /**
     * 获取业务审核意见详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:comments:query')")
    @GetMapping(value = "/{reviewCommentsId}")
    public AjaxResult getInfo(@PathVariable("reviewCommentsId") Long reviewCommentsId) {
        return success(reviewCommentsService.selectReviewCommentsByReviewCommentsId(reviewCommentsId));
    }

    /**
     * 新增业务审核意见
     */
    @PreAuthorize("@ss.hasPermi('system:comments:add')")
    @Log(title = "业务审核意见", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReviewComments reviewComments) {
        return toAjax(reviewCommentsService.insertReviewComments(reviewComments));
    }

    /**
     * 修改业务审核意见
     */
    @PreAuthorize("@ss.hasPermi('system:comments:edit')")
    @Log(title = "业务审核意见", businessType = BusinessType.UPDATE)
    @PostMapping("/put")
    public AjaxResult edit(@RequestBody ReviewComments reviewComments) {
        return toAjax(reviewCommentsService.updateReviewComments(reviewComments));
    }

    /**
     * 删除业务审核意见
     */
    @PreAuthorize("@ss.hasPermi('system:comments:remove')")
    @Log(title = "业务审核意见", businessType = BusinessType.DELETE)
    @GetMapping("/delete/{reviewCommentsIds}")
    public AjaxResult remove(@PathVariable Long[] reviewCommentsIds) {
        return toAjax(reviewCommentsService.deleteReviewCommentsByReviewCommentsIds(reviewCommentsIds));
    }
}
