package com.fs.fastGpt;

import com.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.enums.BusinessType;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.fastGpt.domain.FastGptChatMsgLogs;
import com.fs.fastGpt.param.FastGptChatMsgLogsListParam;
import com.fs.fastGpt.service.IFastGptChatMsgLogsService;
import com.fs.fastGpt.vo.FastGptChatMsgLogsListCVO;
import com.fs.fastGpt.vo.FastGptChatMsgLogsVO;
//import com.fs.framework.security.LoginUser;
//import com.fs.framework.service.TokenService;
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 fs
 * @date 2024-10-10
 */
@RestController
@RequestMapping("/fastGpt/fastGptChatMsgLogs")
public class FastGptChatMsgLogsController extends BaseController
{
    @Autowired
    private IFastGptChatMsgLogsService fastGptChatMsgLogsService;

//    @Autowired
//    private TokenService tokenService;

    /**
     * 查询聊天记录日志列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:list')")
    @GetMapping("/list")
    public TableDataInfo list(FastGptChatMsgLogs fastGptChatMsgLogs)
    {
        startPage();
        List<FastGptChatMsgLogsVO> list = fastGptChatMsgLogsService.selectFastGptChatMsgLogsListVO(fastGptChatMsgLogs);
        return getDataTable(list);
    }

//    @GetMapping("/logsList")
//    public R list(FastGptChatMsgLogsListParam param)
//    {
//        PageHelper.startPage(param.getPageNum(), param.getPageSize());
//        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
//        param.setCompanyId(loginUser.getCompany().getCompanyId());
//
//        List<FastGptChatMsgLogsListCVO> list= fastGptChatMsgLogsService.selectFastGptChatMsgLogsListCVO(param);
//        PageInfo<FastGptChatMsgLogsListCVO> listPageInfo=new PageInfo<>(list);
//        return R.ok().put("data",listPageInfo);
//    }
    /**
     * 导出聊天记录日志列表
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:export')")
    @Log(title = "聊天记录日志", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FastGptChatMsgLogsListParam param)
    {
        List<FastGptChatMsgLogsListCVO> list = fastGptChatMsgLogsService.selectFastGptChatMsgLogsListCVO(param);
        ExcelUtil<FastGptChatMsgLogsListCVO> util = new ExcelUtil<FastGptChatMsgLogsListCVO>(FastGptChatMsgLogsListCVO.class);
        return util.exportExcel(list, "聊天记录日志数据");
    }

    /**
     * 获取聊天记录日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return AjaxResult.success(fastGptChatMsgLogsService.selectFastGptChatMsgLogsByLogsId(logsId));
    }

    /**
     * 新增聊天记录日志
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:add')")
    @Log(title = "聊天记录日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FastGptChatMsgLogs fastGptChatMsgLogs)
    {
        return toAjax(fastGptChatMsgLogsService.insertFastGptChatMsgLogs(fastGptChatMsgLogs));
    }

    /**
     * 修改聊天记录日志
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:edit')")
    @Log(title = "聊天记录日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FastGptChatMsgLogs fastGptChatMsgLogs)
    {
        return toAjax(fastGptChatMsgLogsService.updateFastGptChatMsgLogs(fastGptChatMsgLogs));
    }

    /**
     * 删除聊天记录日志
     */
    @PreAuthorize("@ss.hasPermi('fastGpt:fastGptChatMsgLogs:remove')")
    @Log(title = "聊天记录日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(fastGptChatMsgLogsService.deleteFastGptChatMsgLogsByLogsIds(logsIds));
    }
}
