package com.ruoyi.frequency.mallevaluate.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.frequency.mallevaluate.entity.MallEvaluate;
import com.ruoyi.frequency.mallevaluate.service.MallEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商城订单评价Controller
 *
 * @author liwenlong
 * @date 2024-01-25
 */
@RestController
@RequestMapping("/frequency/mallevaluate")
public class MallEvaluateController extends BaseController
{
    @Autowired
    private MallEvaluateService mallEvaluateService;

    /**
     * 查询商城订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:list')")
    @GetMapping("/list")
    public TableDataInfo<MallEvaluate> list(MallEvaluate mallEvaluate)
    {
        startPage();
        List<MallEvaluate> list = mallEvaluateService.selectMallEvaluateList(mallEvaluate);
        return getDataTable(list);
    }

    /**
     * 导出商城订单评价列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:export')")
    @Log(title = "商城订单评价", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallEvaluate mallEvaluate)
    {
        List<MallEvaluate> list = mallEvaluateService.selectMallEvaluateList(mallEvaluate);
        ExcelUtil<MallEvaluate> util = new ExcelUtil<MallEvaluate>(MallEvaluate.class);
        return util.exportExcel(list, "商城订单评价数据");
    }

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

    /**
     * 新增商城订单评价
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:add')")
    @Log(title = "商城订单评价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallEvaluate mallEvaluate)
    {
        return toAjax(mallEvaluateService.insertMallEvaluate(mallEvaluate));
    }

    /**
     * 修改商城订单评价
     */
    @PreAuthorize("@ss.hasPermi('frequency:mallevaluate:edit')")
    @Log(title = "商城订单评价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallEvaluate mallEvaluate)
    {
        return toAjax(mallEvaluateService.updateMallEvaluate(mallEvaluate));
    }

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