package com.ruoyi.mall.controller;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
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.mall.domain.MallFeedback;
import com.ruoyi.mall.service.IMallFeedbackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 意见反馈Controller
 * 
 * @author chang
 * @date 2021-11-25
 */
@RestController
@RequestMapping("/mall/mallFeedback")
public class MallFeedbackController extends BaseController
{
    @Autowired
    private IMallFeedbackService mallFeedbackService;

    /**
     * 查询意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:list')")
    @GetMapping("/list")
    public TableDataInfo list(MallFeedback mallFeedback)
    {
        startPage();
        List<MallFeedback> list = mallFeedbackService.selectMallFeedbackList(mallFeedback);
        return getDataTable(list);
    }

    /**
     * 导出意见反馈列表
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:export')")
    @Log(title = "意见反馈", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MallFeedback mallFeedback)
    {
        List<MallFeedback> list = mallFeedbackService.selectMallFeedbackList(mallFeedback);
        ExcelUtil<MallFeedback> util = new ExcelUtil<MallFeedback>(MallFeedback.class);
        return util.exportExcel(list, "意见反馈数据");
    }

    /**
     * 获取意见反馈详细信息
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(mallFeedbackService.selectMallFeedbackById(id));
    }

    /**
     * 新增意见反馈
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:add')")
    @Log(title = "意见反馈", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MallFeedback mallFeedback)
    {
        return toAjax(mallFeedbackService.insertMallFeedback(mallFeedback));
    }

    /**
     * 修改意见反馈
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:edit')")
    @Log(title = "意见反馈", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MallFeedback mallFeedback)
    {
        mallFeedback.setUpdateAt(DateUtils.getTime());
        return toAjax(mallFeedbackService.updateMallFeedback(mallFeedback));
    }

    /**
     * 删除意见反馈
     */
    @PreAuthorize("@ss.hasPermi('mall:mallFeedback:remove')")
    @Log(title = "意见反馈", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(mallFeedbackService.deleteMallFeedbackByIds(ids));
    }
}
