package com.fs.his.controller;

import java.util.List;

import com.fs.aiChat.domain.DoctorAiChatMsg;
import com.fs.his.service.IHisDoctorAiChatMsgService;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;

import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 聊天记录Controller
 *
 * @author fs
 * @date 2024-12-30
 */
@RestController
@RequestMapping("doctorChat/msg")
public class HisDoctorAiChatMsgController extends BaseController
{
    @Autowired
    private IHisDoctorAiChatMsgService doctorAiChatMsgService;

    /**
     * 查询聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:list')")
    @GetMapping("/list")
    public TableDataInfo list(DoctorAiChatMsg doctorAiChatMsg)
    {
        startPage();
        List<DoctorAiChatMsg> list = doctorAiChatMsgService.selectDoctorAiChatMsgList(doctorAiChatMsg);
        return getDataTable(list);
    }

    /**
     * 导出聊天记录列表
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:export')")
    @Log(title = "聊天记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DoctorAiChatMsg doctorAiChatMsg)
    {
        List<DoctorAiChatMsg> list = doctorAiChatMsgService.selectDoctorAiChatMsgList(doctorAiChatMsg);
        ExcelUtil<DoctorAiChatMsg> util = new ExcelUtil<DoctorAiChatMsg>(DoctorAiChatMsg.class);
        return util.exportExcel(list, "聊天记录数据");
    }

    /**
     * 获取聊天记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:query')")
    @GetMapping(value = "/{msgId}")
    public AjaxResult getInfo(@PathVariable("msgId") Long msgId)
    {
        return AjaxResult.success(doctorAiChatMsgService.selectDoctorAiChatMsgByMsgId(msgId));
    }

    /**
     * 新增聊天记录
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:add')")
    @Log(title = "聊天记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DoctorAiChatMsg doctorAiChatMsg)
    {
        return toAjax(doctorAiChatMsgService.insertDoctorAiChatMsg(doctorAiChatMsg));
    }

    /**
     * 修改聊天记录
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:edit')")
    @Log(title = "聊天记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DoctorAiChatMsg doctorAiChatMsg)
    {
        return toAjax(doctorAiChatMsgService.updateDoctorAiChatMsg(doctorAiChatMsg));
    }

    /**
     * 删除聊天记录
     */
    @PreAuthorize("@ss.hasPermi('shop:msg:remove')")
    @Log(title = "聊天记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{msgIds}")
    public AjaxResult remove(@PathVariable Long[] msgIds)
    {
        return toAjax(doctorAiChatMsgService.deleteDoctorAiChatMsgByMsgIds(msgIds));
    }
}
