package com.ruoyi.message.frequency.goeasymessagenew.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.message.frequency.goeasymessagenew.entity.GoeasyMessageNew;
import com.ruoyi.message.frequency.goeasymessagenew.service.GoeasyMessageNewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * goeasy最新消息Controller
 *
 * @author liwenlong
 * @date 2024-04-20
 */
@RestController
@RequestMapping("/frequency/goeasymessagenew")
public class GoeasyMessageNewController extends BaseController {
    @Autowired
    private GoeasyMessageNewService goeasyMessageNewService;

    /**
     * 查询goeasy最新消息列表
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:list')")
    @PostMapping("/list")
    public TableDataInfo<GoeasyMessageNew> list(@RequestBody GoeasyMessageNew goeasyMessageNew) {
        startPage();
        List<GoeasyMessageNew> list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew);
        return getDataTable(list);
    }

    /**
     * 导出goeasy最新消息列表
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:export')")
    @Log(title = "goeasy最新消息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GoeasyMessageNew goeasyMessageNew) {
        List<GoeasyMessageNew> list = goeasyMessageNewService.selectGoeasyMessageNewList(goeasyMessageNew);
        ExcelUtil<GoeasyMessageNew> util = new ExcelUtil<GoeasyMessageNew>(GoeasyMessageNew.class);
        return util.exportExcel(list, "goeasy最新消息数据");
    }

    /**
     * 获取goeasy最新消息详细信息
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<GoeasyMessageNew> getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(goeasyMessageNewService.selectGoeasyMessageNewById(id));
    }

    /**
     * 新增goeasy最新消息
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:add')")
    @Log(title = "goeasy最新消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GoeasyMessageNew goeasyMessageNew) {
        return toAjax(goeasyMessageNewService.insertGoeasyMessageNew(goeasyMessageNew));
    }

    /**
     * 修改goeasy最新消息
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:edit')")
    @Log(title = "goeasy最新消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GoeasyMessageNew goeasyMessageNew) {
        return toAjax(goeasyMessageNewService.updateGoeasyMessageNew(goeasyMessageNew));
    }

    /**
     * 删除goeasy最新消息
     */
//    @PreAuthorize("@ss.hasPermi('frequency:goeasymessagenew:remove')")
    @Log(title = "goeasy最新消息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}/{delFlag}")
    public AjaxResult remove(@PathVariable("ids") Long[] ids, @PathVariable("delFlag") Integer delFlag) {
        return toAjax(goeasyMessageNewService.deleteGoeasyMessageNewByIds(ids, delFlag));
    }
}
