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

/**
 * 订单评价Controller
 * 
 * @author zj
 * @date 2023-10-13
 */
@RestController
@RequestMapping("/frequency/orderevaluate")
public class OrderEvaluateController extends BaseController
{
    @Autowired
    private OrderEvaluateService orderEvaluateService;

    /**
     * 查询订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:list')")
    @PostMapping("/list")
    public TableDataInfo<OrderEvaluate> list(@RequestBody OrderEvaluate orderEvaluate)
    {
        startPage();
        List<OrderEvaluate> list = orderEvaluateService.selectOrderEvaluateList(orderEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:export')")
    @Log(title = "订单评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(OrderEvaluate orderEvaluate)
    {
        List<OrderEvaluate> list = orderEvaluateService.selectOrderEvaluateList(orderEvaluate);
        ExcelUtil<OrderEvaluate> util = new ExcelUtil<OrderEvaluate>(OrderEvaluate.class);
        return util.exportExcel(list, "订单评价数据");
    }

    /**
     * 获取订单评价详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<OrderEvaluate> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(orderEvaluateService.selectOrderEvaluateById(id));
    }

    /**
     * 新增订单评价
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:add')")
    @Log(title = "订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderEvaluate orderEvaluate)
    {
        return toAjax(orderEvaluateService.insertOrderEvaluate(orderEvaluate));
    }

    /**
     * 修改订单评价
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:edit')")
    @Log(title = "订单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderEvaluate orderEvaluate)
    {
        return toAjax(orderEvaluateService.updateOrderEvaluate(orderEvaluate));
    }

    /**
     * 删除订单评价
     */
    @PreAuthorize("@ss.hasPermi('frequency:orderevaluate:remove')")
    @Log(title = "订单评价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(orderEvaluateService.deleteOrderEvaluateByIds(ids));
    }
}
