package com.ruoyi.message.frequency.interactionmessagerecord.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.interactionmessagerecord.entity.InteractionMessageRecord;
import com.ruoyi.message.frequency.interactionmessagerecord.service.InteractionMessageRecordService;
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 2023-10-17
 */
@RestController
@RequestMapping("/frequency/interactionmessagerecord")
public class InteractionMessageRecordController extends BaseController
{
    @Autowired
    private InteractionMessageRecordService interactionMessageRecordService;

    /**
     * 查询互动消息记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:list')")
    @GetMapping("/list")
    public TableDataInfo<InteractionMessageRecord> list(InteractionMessageRecord interactionMessageRecord)
    {
        startPage();
        List<InteractionMessageRecord> list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord);
        return getDataTable(list);
    }

    /**
     * 导出互动消息记录列表
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:export')")
    @Log(title = "互动消息记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(InteractionMessageRecord interactionMessageRecord)
    {
        List<InteractionMessageRecord> list = interactionMessageRecordService.selectInteractionMessageRecordList(interactionMessageRecord);
        ExcelUtil<InteractionMessageRecord> util = new ExcelUtil<InteractionMessageRecord>(InteractionMessageRecord.class);
        return util.exportExcel(list, "互动消息记录数据");
    }

    /**
     * 获取互动消息记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult<InteractionMessageRecord> getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(interactionMessageRecordService.selectInteractionMessageRecordById(id));
    }

    /**
     * 新增互动消息记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:add')")
    @Log(title = "互动消息记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InteractionMessageRecord interactionMessageRecord)
    {
        return toAjax(interactionMessageRecordService.insertInteractionMessageRecord(interactionMessageRecord));
    }

    /**
     * 修改互动消息记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:edit')")
    @Log(title = "互动消息记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InteractionMessageRecord interactionMessageRecord)
    {
        return toAjax(interactionMessageRecordService.updateInteractionMessageRecord(interactionMessageRecord));
    }

    /**
     * 删除互动消息记录
     */
    @PreAuthorize("@ss.hasPermi('frequency:interactionmessagerecord:remove')")
    @Log(title = "互动消息记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(interactionMessageRecordService.deleteInteractionMessageRecordByIds(ids));
    }
}
