package com.ruoyi.controller;

import java.util.List;
import javax.annotation.Resource;
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.cs.domain.CsEvaluate;
import com.ruoyi.cs.service.ICsEvaluateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务评价Controller
 *
 * @author ruoyi
 * @date 2024-05-28
 */
@RestController
@RequestMapping("/cs/csEvaluate")
public class CsEvaluateController extends BaseController
{
    @Resource
    private ICsEvaluateService csEvaluateService;

    /**
     * 查询服务评价列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:list')")
    @GetMapping("/list")
    public TableDataInfo list(CsEvaluate csEvaluate)
    {
        startPage();
        List<CsEvaluate> list = csEvaluateService.selectCsEvaluateList(csEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出服务评价列表
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:export')")
    @Log(title = "服务评价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CsEvaluate csEvaluate)
    {
        List<CsEvaluate> list = csEvaluateService.selectCsEvaluateList(csEvaluate);
        ExcelUtil<CsEvaluate> util = new ExcelUtil<CsEvaluate>(CsEvaluate.class);
        util.exportExcel(response, list, "服务评价数据");
    }

    /**
     * 获取服务评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:query')")
    @GetMapping(value = "/{evaluateId}")
    public AjaxResult getInfo(@PathVariable("evaluateId") String evaluateId)
    {
        return AjaxResult.success(csEvaluateService.selectCsEvaluateByEvaluateId(evaluateId));
    }

    /**
     * 新增服务评价
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:add')")
    @Log(title = "服务评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CsEvaluate csEvaluate)
    {
        return toAjax(csEvaluateService.insertCsEvaluate(csEvaluate));
    }

    /**
     * 修改服务评价
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:edit')")
    @Log(title = "服务评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CsEvaluate csEvaluate)
    {
        return toAjax(csEvaluateService.updateCsEvaluate(csEvaluate));
    }

    /**
     * 删除服务评价
     */
    @PreAuthorize("@ss.hasPermi('cs:csEvaluate:remove')")
    @Log(title = "服务评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaluateIds}")
    public AjaxResult remove(@PathVariable String[] evaluateIds)
    {
        return toAjax(csEvaluateService.deleteCsEvaluateByEvaluateIds(evaluateIds));
    }
}
