Jelajahi Sumber

新增对话日志

zmj 5 hari lalu
induk
melakukan
312a0f8031

+ 104 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/base/DialogueLogController.java

@@ -0,0 +1,104 @@
+package com.ruoyi.web.controller.base;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+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.base.domain.DialogueLog;
+import com.ruoyi.base.service.IDialogueLogService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 对话日志Controller
+ *
+ * @author ruoyi
+ * @date 2026-05-19
+ */
+@RestController
+@RequestMapping("/base/dialogueLog")
+public class DialogueLogController extends BaseController
+{
+    @Autowired
+    private IDialogueLogService dialogueLogService;
+
+    /**
+     * 查询对话日志列表
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(DialogueLog dialogueLog)
+    {
+        startPage();
+        List<DialogueLog> list = dialogueLogService.selectDialogueLogList(dialogueLog);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出对话日志列表
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:export')")
+    @Log(title = "对话日志", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, DialogueLog dialogueLog)
+    {
+        List<DialogueLog> list = dialogueLogService.selectDialogueLogList(dialogueLog);
+        ExcelUtil<DialogueLog> util = new ExcelUtil<DialogueLog>(DialogueLog.class);
+        util.exportExcel(response, list, "对话日志数据");
+    }
+
+    /**
+     * 获取对话日志详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(dialogueLogService.selectDialogueLogById(id));
+    }
+
+    /**
+     * 新增对话日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:add')")
+    @Log(title = "对话日志", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody DialogueLog dialogueLog)
+    {
+        return toAjax(dialogueLogService.insertDialogueLog(dialogueLog));
+    }
+
+    /**
+     * 修改对话日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:edit')")
+    @Log(title = "对话日志", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody DialogueLog dialogueLog)
+    {
+        return toAjax(dialogueLogService.updateDialogueLog(dialogueLog));
+    }
+
+    /**
+     * 删除对话日志
+     */
+    @PreAuthorize("@ss.hasPermi('base:dialogueLog:remove')")
+    @Log(title = "对话日志", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(dialogueLogService.deleteDialogueLogByIds(ids));
+    }
+}

+ 218 - 0
ruoyi-system/src/main/java/com/ruoyi/base/domain/DialogueLog.java

@@ -0,0 +1,218 @@
+package com.ruoyi.base.domain;
+
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+
+/**
+ * 对话日志对象 robot_ops_dialogue_log
+ * 
+ * @author ruoyi
+ * @date 2026-05-19
+ */
+public class DialogueLog extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 主键ID */
+    private Long id;
+
+    /** 机器人编号,用于后续上传上位平台或多机器人汇聚识别 */
+    @Excel(name = "机器人编号,用于后续上传上位平台或多机器人汇聚识别")
+    private String robotCode;
+
+    /** 会话ID */
+    @Excel(name = "会话ID")
+    private String sessionId;
+
+    /** 提问时间 */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @Excel(name = "提问时间", width = 30, dateFormat = "yyyy-MM-dd")
+    private Date askTime;
+
+    /** 用户问题 */
+    @Excel(name = "用户问题")
+    private String question;
+
+    /** 机器人回答 */
+    private String answer;
+
+    /** 回答摘要 */
+    @Excel(name = "回答摘要")
+    private String answerSummary;
+
+    /** 命中方式 */
+    @Excel(name = "命中方式")
+    private String hitType;
+
+    /** 来源场景 */
+    @Excel(name = "来源场景")
+    private String sceneType;
+
+    /** 结果状态 */
+    @Excel(name = "结果状态")
+    private String resultStatus;
+
+    /** 失败原因或错误信息 */
+    @Excel(name = "失败原因或错误信息")
+    private String errorMsg;
+
+    /** 原始请求 */
+    private String rawRequest;
+
+    /** 原始响应 */
+    private String rawResponse;
+
+    public void setId(Long id) 
+    {
+        this.id = id;
+    }
+
+    public Long getId() 
+    {
+        return id;
+    }
+
+    public void setRobotCode(String robotCode) 
+    {
+        this.robotCode = robotCode;
+    }
+
+    public String getRobotCode() 
+    {
+        return robotCode;
+    }
+
+    public void setSessionId(String sessionId) 
+    {
+        this.sessionId = sessionId;
+    }
+
+    public String getSessionId() 
+    {
+        return sessionId;
+    }
+
+    public void setAskTime(Date askTime) 
+    {
+        this.askTime = askTime;
+    }
+
+    public Date getAskTime() 
+    {
+        return askTime;
+    }
+
+    public void setQuestion(String question) 
+    {
+        this.question = question;
+    }
+
+    public String getQuestion() 
+    {
+        return question;
+    }
+
+    public void setAnswer(String answer) 
+    {
+        this.answer = answer;
+    }
+
+    public String getAnswer() 
+    {
+        return answer;
+    }
+
+    public void setAnswerSummary(String answerSummary) 
+    {
+        this.answerSummary = answerSummary;
+    }
+
+    public String getAnswerSummary() 
+    {
+        return answerSummary;
+    }
+
+    public void setHitType(String hitType) 
+    {
+        this.hitType = hitType;
+    }
+
+    public String getHitType() 
+    {
+        return hitType;
+    }
+
+    public void setSceneType(String sceneType) 
+    {
+        this.sceneType = sceneType;
+    }
+
+    public String getSceneType() 
+    {
+        return sceneType;
+    }
+
+    public void setResultStatus(String resultStatus) 
+    {
+        this.resultStatus = resultStatus;
+    }
+
+    public String getResultStatus() 
+    {
+        return resultStatus;
+    }
+
+    public void setErrorMsg(String errorMsg) 
+    {
+        this.errorMsg = errorMsg;
+    }
+
+    public String getErrorMsg() 
+    {
+        return errorMsg;
+    }
+
+    public void setRawRequest(String rawRequest) 
+    {
+        this.rawRequest = rawRequest;
+    }
+
+    public String getRawRequest() 
+    {
+        return rawRequest;
+    }
+
+    public void setRawResponse(String rawResponse) 
+    {
+        this.rawResponse = rawResponse;
+    }
+
+    public String getRawResponse() 
+    {
+        return rawResponse;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("id", getId())
+            .append("robotCode", getRobotCode())
+            .append("sessionId", getSessionId())
+            .append("askTime", getAskTime())
+            .append("question", getQuestion())
+            .append("answer", getAnswer())
+            .append("answerSummary", getAnswerSummary())
+            .append("hitType", getHitType())
+            .append("sceneType", getSceneType())
+            .append("resultStatus", getResultStatus())
+            .append("errorMsg", getErrorMsg())
+            .append("rawRequest", getRawRequest())
+            .append("rawResponse", getRawResponse())
+            .append("createTime", getCreateTime())
+            .toString();
+    }
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/base/mapper/DialogueLogMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.base.mapper;
+
+import java.util.List;
+import com.ruoyi.base.domain.DialogueLog;
+
+/**
+ * 对话日志Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2026-05-19
+ */
+public interface DialogueLogMapper 
+{
+    /**
+     * 查询对话日志
+     * 
+     * @param id 对话日志主键
+     * @return 对话日志
+     */
+    public DialogueLog selectDialogueLogById(Long id);
+
+    /**
+     * 查询对话日志列表
+     * 
+     * @param dialogueLog 对话日志
+     * @return 对话日志集合
+     */
+    public List<DialogueLog> selectDialogueLogList(DialogueLog dialogueLog);
+
+    /**
+     * 新增对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    public int insertDialogueLog(DialogueLog dialogueLog);
+
+    /**
+     * 修改对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    public int updateDialogueLog(DialogueLog dialogueLog);
+
+    /**
+     * 删除对话日志
+     * 
+     * @param id 对话日志主键
+     * @return 结果
+     */
+    public int deleteDialogueLogById(Long id);
+
+    /**
+     * 批量删除对话日志
+     * 
+     * @param ids 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteDialogueLogByIds(Long[] ids);
+}

+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/base/service/IDialogueLogService.java

@@ -0,0 +1,61 @@
+package com.ruoyi.base.service;
+
+import java.util.List;
+import com.ruoyi.base.domain.DialogueLog;
+
+/**
+ * 对话日志Service接口
+ * 
+ * @author ruoyi
+ * @date 2026-05-19
+ */
+public interface IDialogueLogService 
+{
+    /**
+     * 查询对话日志
+     * 
+     * @param id 对话日志主键
+     * @return 对话日志
+     */
+    public DialogueLog selectDialogueLogById(Long id);
+
+    /**
+     * 查询对话日志列表
+     * 
+     * @param dialogueLog 对话日志
+     * @return 对话日志集合
+     */
+    public List<DialogueLog> selectDialogueLogList(DialogueLog dialogueLog);
+
+    /**
+     * 新增对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    public int insertDialogueLog(DialogueLog dialogueLog);
+
+    /**
+     * 修改对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    public int updateDialogueLog(DialogueLog dialogueLog);
+
+    /**
+     * 批量删除对话日志
+     * 
+     * @param ids 需要删除的对话日志主键集合
+     * @return 结果
+     */
+    public int deleteDialogueLogByIds(Long[] ids);
+
+    /**
+     * 删除对话日志信息
+     * 
+     * @param id 对话日志主键
+     * @return 结果
+     */
+    public int deleteDialogueLogById(Long id);
+}

+ 95 - 0
ruoyi-system/src/main/java/com/ruoyi/base/service/impl/DialogueLogServiceImpl.java

@@ -0,0 +1,95 @@
+package com.ruoyi.base.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.base.mapper.DialogueLogMapper;
+import com.ruoyi.base.domain.DialogueLog;
+import com.ruoyi.base.service.IDialogueLogService;
+
+/**
+ * 对话日志Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2026-05-19
+ */
+@Service
+public class DialogueLogServiceImpl implements IDialogueLogService 
+{
+    @Autowired
+    private DialogueLogMapper dialogueLogMapper;
+
+    /**
+     * 查询对话日志
+     * 
+     * @param id 对话日志主键
+     * @return 对话日志
+     */
+    @Override
+    public DialogueLog selectDialogueLogById(Long id)
+    {
+        return dialogueLogMapper.selectDialogueLogById(id);
+    }
+
+    /**
+     * 查询对话日志列表
+     * 
+     * @param dialogueLog 对话日志
+     * @return 对话日志
+     */
+    @Override
+    public List<DialogueLog> selectDialogueLogList(DialogueLog dialogueLog)
+    {
+        return dialogueLogMapper.selectDialogueLogList(dialogueLog);
+    }
+
+    /**
+     * 新增对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    @Override
+    public int insertDialogueLog(DialogueLog dialogueLog)
+    {
+        dialogueLog.setCreateTime(DateUtils.getNowDate());
+        return dialogueLogMapper.insertDialogueLog(dialogueLog);
+    }
+
+    /**
+     * 修改对话日志
+     * 
+     * @param dialogueLog 对话日志
+     * @return 结果
+     */
+    @Override
+    public int updateDialogueLog(DialogueLog dialogueLog)
+    {
+        return dialogueLogMapper.updateDialogueLog(dialogueLog);
+    }
+
+    /**
+     * 批量删除对话日志
+     * 
+     * @param ids 需要删除的对话日志主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDialogueLogByIds(Long[] ids)
+    {
+        return dialogueLogMapper.deleteDialogueLogByIds(ids);
+    }
+
+    /**
+     * 删除对话日志信息
+     * 
+     * @param id 对话日志主键
+     * @return 结果
+     */
+    @Override
+    public int deleteDialogueLogById(Long id)
+    {
+        return dialogueLogMapper.deleteDialogueLogById(id);
+    }
+}

+ 115 - 0
ruoyi-system/src/main/resources/mapper/base/DialogueLogMapper.xml

@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ruoyi.base.mapper.DialogueLogMapper">
+    
+    <resultMap type="DialogueLog" id="DialogueLogResult">
+        <result property="id"    column="id"    />
+        <result property="robotCode"    column="robot_code"    />
+        <result property="sessionId"    column="session_id"    />
+        <result property="askTime"    column="ask_time"    />
+        <result property="question"    column="question"    />
+        <result property="answer"    column="answer"    />
+        <result property="answerSummary"    column="answer_summary"    />
+        <result property="hitType"    column="hit_type"    />
+        <result property="sceneType"    column="scene_type"    />
+        <result property="resultStatus"    column="result_status"    />
+        <result property="errorMsg"    column="error_msg"    />
+        <result property="rawRequest"    column="raw_request"    />
+        <result property="rawResponse"    column="raw_response"    />
+        <result property="createTime"    column="create_time"    />
+    </resultMap>
+
+    <sql id="selectDialogueLogVo">
+        select id, robot_code, session_id, ask_time, question, answer, answer_summary, hit_type, scene_type, result_status, error_msg, raw_request, raw_response, create_time from robot_ops_dialogue_log
+    </sql>
+
+    <select id="selectDialogueLogList" parameterType="DialogueLog" resultMap="DialogueLogResult">
+        <include refid="selectDialogueLogVo"/>
+        <where>  
+            <if test="robotCode != null  and robotCode != ''"> and robot_code = #{robotCode}</if>
+            <if test="sessionId != null  and sessionId != ''"> and session_id = #{sessionId}</if>
+            <if test="askTime != null "> and ask_time = #{askTime}</if>
+            <if test="question != null  and question != ''"> and question = #{question}</if>
+            <if test="answer != null  and answer != ''"> and answer = #{answer}</if>
+            <if test="answerSummary != null  and answerSummary != ''"> and answer_summary = #{answerSummary}</if>
+            <if test="hitType != null  and hitType != ''"> and hit_type = #{hitType}</if>
+            <if test="sceneType != null  and sceneType != ''"> and scene_type = #{sceneType}</if>
+            <if test="resultStatus != null  and resultStatus != ''"> and result_status = #{resultStatus}</if>
+            <if test="errorMsg != null  and errorMsg != ''"> and error_msg = #{errorMsg}</if>
+            <if test="rawRequest != null  and rawRequest != ''"> and raw_request = #{rawRequest}</if>
+            <if test="rawResponse != null  and rawResponse != ''"> and raw_response = #{rawResponse}</if>
+        </where>
+    </select>
+    
+    <select id="selectDialogueLogById" parameterType="Long" resultMap="DialogueLogResult">
+        <include refid="selectDialogueLogVo"/>
+        where id = #{id}
+    </select>
+
+    <insert id="insertDialogueLog" parameterType="DialogueLog" useGeneratedKeys="true" keyProperty="id">
+        insert into robot_ops_dialogue_log
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="robotCode != null">robot_code,</if>
+            <if test="sessionId != null">session_id,</if>
+            <if test="askTime != null">ask_time,</if>
+            <if test="question != null">question,</if>
+            <if test="answer != null">answer,</if>
+            <if test="answerSummary != null">answer_summary,</if>
+            <if test="hitType != null">hit_type,</if>
+            <if test="sceneType != null">scene_type,</if>
+            <if test="resultStatus != null">result_status,</if>
+            <if test="errorMsg != null">error_msg,</if>
+            <if test="rawRequest != null">raw_request,</if>
+            <if test="rawResponse != null">raw_response,</if>
+            <if test="createTime != null">create_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="robotCode != null">#{robotCode},</if>
+            <if test="sessionId != null">#{sessionId},</if>
+            <if test="askTime != null">#{askTime},</if>
+            <if test="question != null">#{question},</if>
+            <if test="answer != null">#{answer},</if>
+            <if test="answerSummary != null">#{answerSummary},</if>
+            <if test="hitType != null">#{hitType},</if>
+            <if test="sceneType != null">#{sceneType},</if>
+            <if test="resultStatus != null">#{resultStatus},</if>
+            <if test="errorMsg != null">#{errorMsg},</if>
+            <if test="rawRequest != null">#{rawRequest},</if>
+            <if test="rawResponse != null">#{rawResponse},</if>
+            <if test="createTime != null">#{createTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateDialogueLog" parameterType="DialogueLog">
+        update robot_ops_dialogue_log
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="robotCode != null">robot_code = #{robotCode},</if>
+            <if test="sessionId != null">session_id = #{sessionId},</if>
+            <if test="askTime != null">ask_time = #{askTime},</if>
+            <if test="question != null">question = #{question},</if>
+            <if test="answer != null">answer = #{answer},</if>
+            <if test="answerSummary != null">answer_summary = #{answerSummary},</if>
+            <if test="hitType != null">hit_type = #{hitType},</if>
+            <if test="sceneType != null">scene_type = #{sceneType},</if>
+            <if test="resultStatus != null">result_status = #{resultStatus},</if>
+            <if test="errorMsg != null">error_msg = #{errorMsg},</if>
+            <if test="rawRequest != null">raw_request = #{rawRequest},</if>
+            <if test="rawResponse != null">raw_response = #{rawResponse},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+    <delete id="deleteDialogueLogById" parameterType="Long">
+        delete from robot_ops_dialogue_log where id = #{id}
+    </delete>
+
+    <delete id="deleteDialogueLogByIds" parameterType="String">
+        delete from robot_ops_dialogue_log where id in 
+        <foreach item="id" collection="array" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
+</mapper>