package com.fs.his.controller;

import java.util.List;

import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsStoreOrderScrmComment;
import com.fs.his.service.IFsStoreOrderScrmCommentService;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.common.core.page.TableDataInfo;

/**
 * 订单评价Controller
 * 
 * @author fs
 * @date 2025-10-15
 */
@RestController
@RequestMapping("/his/comment")
public class FsStoreOrderScrmCommentController extends BaseController
{
    @Autowired
    private IFsStoreOrderScrmCommentService fsStoreOrderScrmCommentService;

    /**
     * 查询订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('his:comment:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsStoreOrderScrmComment fsStoreOrderScrmComment)
    {
        startPage();
        List<FsStoreOrderScrmComment> list = fsStoreOrderScrmCommentService.selectFsStoreOrderScrmCommentList(fsStoreOrderScrmComment);
        return getDataTable(list);
    }

    /**
     * 导出订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('his:comment:export')")
    @Log(title = "订单评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsStoreOrderScrmComment fsStoreOrderScrmComment)
    {
        List<FsStoreOrderScrmComment> list = fsStoreOrderScrmCommentService.selectFsStoreOrderScrmCommentList(fsStoreOrderScrmComment);
        ExcelUtil<FsStoreOrderScrmComment> util = new ExcelUtil<FsStoreOrderScrmComment>(FsStoreOrderScrmComment.class);
        return util.exportExcel(list, "订单评价数据");
    }

    /**
     * 获取订单评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:comment:query')")
    @GetMapping(value = "/{commentId}")
    public AjaxResult getInfo(@PathVariable("commentId") Long commentId)
    {
        return AjaxResult.success(fsStoreOrderScrmCommentService.selectFsStoreOrderScrmCommentByCommentId(commentId));
    }

    /**
     * 新增订单评价
     */
    @PreAuthorize("@ss.hasPermi('his:comment:add')")
    @Log(title = "订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsStoreOrderScrmComment fsStoreOrderScrmComment)
    {
        return toAjax(fsStoreOrderScrmCommentService.insertFsStoreOrderScrmComment(fsStoreOrderScrmComment));
    }

    /**
     * 修改订单评价
     */
    @PreAuthorize("@ss.hasPermi('his:comment:edit')")
    @Log(title = "订单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsStoreOrderScrmComment fsStoreOrderScrmComment)
    {
        return toAjax(fsStoreOrderScrmCommentService.updateFsStoreOrderScrmComment(fsStoreOrderScrmComment));
    }

    /**
     * 删除订单评价
     */
    @PreAuthorize("@ss.hasPermi('his:comment:remove')")
    @Log(title = "订单评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{commentIds}")
    public AjaxResult remove(@PathVariable Long[] commentIds)
    {
        return toAjax(fsStoreOrderScrmCommentService.deleteFsStoreOrderScrmCommentByCommentIds(commentIds));
    }
}
