260720
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.gxwebsoft.ai.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class WebSocketConfig
|
||||
{
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter()
|
||||
{
|
||||
ServerEndpointExporter exporter = new ServerEndpointExporter();
|
||||
|
||||
// 手动注册 WebSocket 端点
|
||||
exporter.setAnnotatedEndpointClasses(WebSocketServer.class);
|
||||
|
||||
|
||||
return exporter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.gxwebsoft.ai.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
||||
@ServerEndpoint(value = "/chat/{userId}")
|
||||
@Component
|
||||
public class WebSocketServer {
|
||||
|
||||
/**
|
||||
* concurrent包的线程安全Set,用来存放每个客户端对应的MyWebSocket对象。
|
||||
*/
|
||||
private static ConcurrentHashMap<String, WebSocketServer> webSocketMap = new ConcurrentHashMap<>();
|
||||
/**
|
||||
* 与某个客户端的连接会话,需要通过它来给客户端发送数据
|
||||
*/
|
||||
private Session session;
|
||||
/**
|
||||
* 接收userId
|
||||
*/
|
||||
private String userId = "";
|
||||
|
||||
/**
|
||||
* 连接建立成功调用的方法
|
||||
*/
|
||||
@OnOpen
|
||||
public void onOpen(Session session, @PathParam("userId") String userId) {
|
||||
this.session = session;
|
||||
this.userId = userId;
|
||||
if (webSocketMap.containsKey(userId)) {
|
||||
webSocketMap.remove(userId);
|
||||
webSocketMap.put(userId, this);
|
||||
//加入set中
|
||||
} else {
|
||||
webSocketMap.put(userId, this);
|
||||
}
|
||||
|
||||
try {
|
||||
sendMessage(userId, "连接成功");
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 连接关闭调用的方法
|
||||
*/
|
||||
@OnClose
|
||||
public void onClose() {
|
||||
if (webSocketMap.containsKey(userId)) {
|
||||
webSocketMap.remove(userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实现服务器主动推送
|
||||
*/
|
||||
public void sendMessage(String userId, String message) throws IOException {
|
||||
System.out.println("userId:" + userId);
|
||||
if (webSocketMap.containsKey(userId)) {
|
||||
Session session1 = webSocketMap.get(userId).session;
|
||||
System.out.println("session1:" + session1);
|
||||
if (session1 != null) session1.getBasicRemote().sendText(message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 实现服务器主动推送
|
||||
*/
|
||||
public void sendAllMessage(String message) throws IOException {
|
||||
ConcurrentHashMap.KeySetView<String, WebSocketServer> userIds = webSocketMap.keySet();
|
||||
for (String userId : userIds) {
|
||||
WebSocketServer webSocketServer = webSocketMap.get(userId);
|
||||
webSocketServer.session.getBasicRemote().sendText(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.gxwebsoft.ai.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.ai.service.AiChatHistoryService;
|
||||
import com.gxwebsoft.ai.entity.AiChatHistory;
|
||||
import com.gxwebsoft.ai.param.AiChatHistoryParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Api(tags = "管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/ai/ai-chat-history")
|
||||
public class AiChatHistoryController extends BaseController {
|
||||
@Resource
|
||||
private AiChatHistoryService aiChatHistoryService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AiChatHistory>> page(AiChatHistoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(aiChatHistoryService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AiChatHistory>> list(AiChatHistoryParam param) {
|
||||
// 使用关联查询
|
||||
return success(aiChatHistoryService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('ai:aiChatHistory:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AiChatHistory> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(aiChatHistoryService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AiChatHistory aiChatHistory) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
aiChatHistory.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (aiChatHistoryService.save(aiChatHistory)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AiChatHistory aiChatHistory) {
|
||||
if (aiChatHistoryService.updateById(aiChatHistory)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (aiChatHistoryService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AiChatHistory> list) {
|
||||
if (aiChatHistoryService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<AiChatHistory> batchParam) {
|
||||
if (batchParam.update(aiChatHistoryService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (aiChatHistoryService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.gxwebsoft.ai.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.ai.service.AiChatListService;
|
||||
import com.gxwebsoft.ai.entity.AiChatList;
|
||||
import com.gxwebsoft.ai.param.AiChatListParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.BatchParam;
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Api(tags = "管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/ai/ai-chat-list")
|
||||
public class AiChatListController extends BaseController {
|
||||
@Resource
|
||||
private AiChatListService aiChatListService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<AiChatList>> page(AiChatListParam param) {
|
||||
// 使用关联查询
|
||||
return success(aiChatListService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<AiChatList>> list(AiChatListParam param) {
|
||||
// 使用关联查询
|
||||
return success(aiChatListService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('ai:aiChatList:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<AiChatList> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(aiChatListService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody AiChatList aiChatList) {
|
||||
// 记录当前登录用户id
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
aiChatList.setUserId(loginUser.getUserId());
|
||||
}
|
||||
if (aiChatListService.save(aiChatList)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody AiChatList aiChatList) {
|
||||
if (aiChatListService.updateById(aiChatList)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (aiChatListService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量添加")
|
||||
@PostMapping("/batch")
|
||||
public ApiResult<?> saveBatch(@RequestBody List<AiChatList> list) {
|
||||
if (aiChatListService.saveBatch(list)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改")
|
||||
@PutMapping("/batch")
|
||||
public ApiResult<?> updateBatch(@RequestBody BatchParam<AiChatList> batchParam) {
|
||||
if (batchParam.update(aiChatListService, "id")) {
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除")
|
||||
@DeleteMapping("/batch")
|
||||
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
|
||||
if (aiChatListService.removeByIds(ids)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,131 @@
|
||||
package com.gxwebsoft.ai.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Api(tags = "知识库")
|
||||
@RestController
|
||||
@RequestMapping("/api/ai/knowledge-base")
|
||||
public class KnowledgeBaseController extends BaseController {
|
||||
|
||||
private static final String DATASET_API_URL = "http://82.156.98.71/v1/datasets";
|
||||
private static final String CHALLENGE_CUP_DATASET_ID = "b342f096-98b1-4a83-a296-f4ab60a6db0e";
|
||||
private static final String DATASET_API_KEY = "dataset-1n6MECRtQvEVGOL1o7SrSGfe";
|
||||
|
||||
@ApiOperation("知识库列表")
|
||||
@GetMapping("/list")
|
||||
public ApiResult<?> list(
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", defaultValue = "20") Integer limit,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
try {
|
||||
StringBuilder urlBuilder = new StringBuilder(DATASET_API_URL);
|
||||
urlBuilder.append("?page=").append(page);
|
||||
urlBuilder.append("&limit=").append(limit);
|
||||
if (keyword != null && !keyword.trim().isEmpty()) {
|
||||
urlBuilder.append("&keyword=").append(java.net.URLEncoder.encode(keyword.trim(), "UTF-8"));
|
||||
}
|
||||
|
||||
URL url = new URL(urlBuilder.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + DATASET_API_KEY);
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode < 200 || responseCode >= 300) {
|
||||
StringBuilder errorBody = new StringBuilder();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
errorBody.append(line);
|
||||
}
|
||||
}
|
||||
return fail("获取知识库列表失败", errorBody.toString());
|
||||
}
|
||||
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
responseBody.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
com.alibaba.fastjson.JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(responseBody.toString());
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
return fail("获取知识库列表失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation("挑战杯历史案例知识库文档列表")
|
||||
@GetMapping("/challenge-cup/documents")
|
||||
public ApiResult<?> challengeCupDocuments(
|
||||
@RequestParam(value = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(value = "limit", defaultValue = "20") Integer limit,
|
||||
@RequestParam(value = "keyword", required = false) String keyword) {
|
||||
try {
|
||||
int safePage = page == null || page < 1 ? 1 : page;
|
||||
int safeLimit = limit == null || limit < 1 ? 20 : Math.min(limit, 100);
|
||||
StringBuilder urlBuilder = new StringBuilder(DATASET_API_URL);
|
||||
urlBuilder.append("/").append(CHALLENGE_CUP_DATASET_ID).append("/documents");
|
||||
urlBuilder.append("?page=").append(safePage);
|
||||
urlBuilder.append("&limit=").append(safeLimit);
|
||||
if (keyword != null && !keyword.trim().isEmpty()) {
|
||||
urlBuilder.append("&keyword=").append(java.net.URLEncoder.encode(keyword.trim(), "UTF-8"));
|
||||
}
|
||||
|
||||
URL url = new URL(urlBuilder.toString());
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
connection.setRequestProperty("Authorization", "Bearer " + DATASET_API_KEY);
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setConnectTimeout(30000);
|
||||
connection.setReadTimeout(30000);
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode < 200 || responseCode >= 300) {
|
||||
StringBuilder errorBody = new StringBuilder();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(connection.getErrorStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
errorBody.append(line);
|
||||
}
|
||||
}
|
||||
return fail("获取挑战杯历史案例知识库失败", errorBody.toString());
|
||||
}
|
||||
|
||||
StringBuilder responseBody = new StringBuilder();
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
responseBody.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
com.alibaba.fastjson.JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(responseBody.toString());
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
return fail("获取挑战杯历史案例知识库失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.fasterxml.jackson.annotation.JsonAlias;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "活动策划大纲生成对象")
|
||||
public class ActivityOutlineInputs implements Serializable {
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_theme")
|
||||
@JsonAlias("eventTheme")
|
||||
private String eventTheme;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("people")
|
||||
private String people;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_time")
|
||||
@JsonAlias("eventTime")
|
||||
private String eventTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_funding")
|
||||
@JsonAlias("eventFunding")
|
||||
private String eventFunding;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_type")
|
||||
@JsonAlias("eventType")
|
||||
private String eventType;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_location")
|
||||
@JsonAlias("eventLocation")
|
||||
private String eventLocation;
|
||||
|
||||
@TableField(exist = false)
|
||||
@JsonProperty("event_meme")
|
||||
@JsonAlias("eventMeme")
|
||||
private String eventMeme;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "AiChatHistory对象", description = "")
|
||||
@TableName("ai_chat_history")
|
||||
public class AiChatHistory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private Integer chatId;
|
||||
|
||||
private String conversationId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private String content;
|
||||
|
||||
private String reply;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "AiChatList对象", description = "")
|
||||
@TableName("ai_chat_list")
|
||||
public class AiChatList implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
private String conversationId;
|
||||
|
||||
private Integer userId;
|
||||
|
||||
private Integer roleId;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleDesc;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@TableLogic
|
||||
private Integer deleted;
|
||||
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
|
||||
@ApiModelProperty(value = "注册时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty(value = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
private String title;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 机构
|
||||
*
|
||||
* @author LX
|
||||
* @since 2025-04-14 00:35:34
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "聊天对象")
|
||||
public class ChatMessage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String query;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String inputs;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String responseMode;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String user;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String conversationId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String type;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer requestType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer chatId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String roleName;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String roleDesc;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Map<String, Object> files;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 机构
|
||||
*
|
||||
* @author LX
|
||||
* @since 2025-04-14 00:35:34
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "LawOrg对象", description = "机构")
|
||||
@TableName("law_org")
|
||||
public class ChatResponse implements Serializable {
|
||||
private String event;
|
||||
|
||||
private String conversation_id;
|
||||
private String message_id;
|
||||
private long created_at;
|
||||
private String task_id;
|
||||
private String workflow_run_id;
|
||||
private String id;
|
||||
private String answer;
|
||||
private Metadata metadata;
|
||||
private Data data;
|
||||
private Object[] files;
|
||||
|
||||
public static class Data {
|
||||
private Usage usage;
|
||||
}
|
||||
|
||||
public static class Metadata {
|
||||
private String id;
|
||||
private String node_id;
|
||||
private String node_type;
|
||||
private String title;
|
||||
private String index;
|
||||
private String predecessor_node_id;
|
||||
private String inputs;
|
||||
private String created_at;
|
||||
private String extras;
|
||||
}
|
||||
|
||||
public static class Usage {
|
||||
private int prompt_tokens;
|
||||
private String prompt_unit_price;
|
||||
private String prompt_price_unit;
|
||||
private String prompt_price;
|
||||
private int completion_tokens;
|
||||
private String completion_unit_price;
|
||||
private String completion_price_unit;
|
||||
private String completion_price;
|
||||
private int total_tokens;
|
||||
private String total_price;
|
||||
private String currency;
|
||||
private double latency;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.gxwebsoft.ai.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value = "稿件生成对象")
|
||||
public class ManuscriptGenInputs implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String docType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String eventType;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String theme;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String time;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String location;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String participants;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String highlights;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer number;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<File> files;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.ai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.ai.entity.AiChatHistory;
|
||||
import com.gxwebsoft.ai.param.AiChatHistoryParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
public interface AiChatHistoryMapper extends BaseMapper<AiChatHistory> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AiChatHistory>
|
||||
*/
|
||||
List<AiChatHistory> selectPageRel(@Param("page") IPage<AiChatHistory> page,
|
||||
@Param("param") AiChatHistoryParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AiChatHistory> selectListRel(@Param("param") AiChatHistoryParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.ai.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.ai.entity.AiChatList;
|
||||
import com.gxwebsoft.ai.param.AiChatListParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Mapper
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
public interface AiChatListMapper extends BaseMapper<AiChatList> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<AiChatList>
|
||||
*/
|
||||
List<AiChatList> selectPageRel(@Param("page") IPage<AiChatList> page,
|
||||
@Param("param") AiChatListParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<AiChatList> selectListRel(@Param("param") AiChatListParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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.gxwebsoft.ai.mapper.AiChatHistoryMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM ai_chat_history a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.chatId != null">
|
||||
AND a.chat_id = #{param.chatId}
|
||||
</if>
|
||||
<if test="param.conversationId != null">
|
||||
AND a.conversation_id LIKE CONCAT('%', #{param.conversationId}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.content != null">
|
||||
AND a.content LIKE CONCAT('%', #{param.content}, '%')
|
||||
</if>
|
||||
<if test="param.reply != null">
|
||||
AND a.reply LIKE CONCAT('%', #{param.reply}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.ai.entity.AiChatHistory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.ai.entity.AiChatHistory">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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.gxwebsoft.ai.mapper.AiChatListMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM ai_chat_list a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.conversationId != null">
|
||||
AND a.conversation_id LIKE CONCAT('%', #{param.conversationId}, '%')
|
||||
</if>
|
||||
<if test="param.userId != null">
|
||||
AND a.user_id = #{param.userId}
|
||||
</if>
|
||||
<if test="param.roleId != null">
|
||||
AND a.role_id = #{param.roleId}
|
||||
</if>
|
||||
<if test="param.roleName != null">
|
||||
AND a.role_name LIKE CONCAT('%', #{param.roleName}, '%')
|
||||
</if>
|
||||
<if test="param.roleDesc != null">
|
||||
AND a.role_desc LIKE CONCAT('%', #{param.roleDesc}, '%')
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.title != null">
|
||||
AND a.title LIKE CONCAT('%', #{param.title}, '%')
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.ai.entity.AiChatList">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.ai.entity.AiChatList">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.gxwebsoft.ai.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "AiChatHistoryParam对象", description = "查询参数")
|
||||
public class AiChatHistoryParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer chatId;
|
||||
|
||||
private String conversationId;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
private String content;
|
||||
|
||||
private String reply;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.gxwebsoft.ai.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(value = "AiChatListParam对象", description = "查询参数")
|
||||
public class AiChatListParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
private String conversationId;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer userId;
|
||||
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer roleId;
|
||||
|
||||
private String roleName;
|
||||
|
||||
private String roleDesc;
|
||||
|
||||
@ApiModelProperty(value = "状态, 0正常, 1冻结")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer deleted;
|
||||
|
||||
private String title;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.gxwebsoft.ai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.ai.entity.AiChatHistory;
|
||||
import com.gxwebsoft.ai.param.AiChatHistoryParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
public interface AiChatHistoryService extends IService<AiChatHistory> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<AiChatHistory>
|
||||
*/
|
||||
PageResult<AiChatHistory> pageRel(AiChatHistoryParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<AiChatHistory>
|
||||
*/
|
||||
List<AiChatHistory> listRel(AiChatHistoryParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return AiChatHistory
|
||||
*/
|
||||
AiChatHistory getByIdRel(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.gxwebsoft.ai.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.ai.entity.AiChatList;
|
||||
import com.gxwebsoft.ai.param.AiChatListParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
public interface AiChatListService extends IService<AiChatList> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<AiChatList>
|
||||
*/
|
||||
PageResult<AiChatList> pageRel(AiChatListParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<AiChatList>
|
||||
*/
|
||||
List<AiChatList> listRel(AiChatListParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id
|
||||
* @return AiChatList
|
||||
*/
|
||||
AiChatList getByIdRel(Integer id);
|
||||
|
||||
void updateConversationId(Integer chatId, String conversationId);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.gxwebsoft.ai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.ai.mapper.AiChatHistoryMapper;
|
||||
import com.gxwebsoft.ai.service.AiChatHistoryService;
|
||||
import com.gxwebsoft.ai.entity.AiChatHistory;
|
||||
import com.gxwebsoft.ai.param.AiChatHistoryParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service实现
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Service
|
||||
public class AiChatHistoryServiceImpl extends ServiceImpl<AiChatHistoryMapper, AiChatHistory> implements AiChatHistoryService {
|
||||
|
||||
@Override
|
||||
public PageResult<AiChatHistory> pageRel(AiChatHistoryParam param) {
|
||||
PageParam<AiChatHistory, AiChatHistoryParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<AiChatHistory> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AiChatHistory> listRel(AiChatHistoryParam param) {
|
||||
List<AiChatHistory> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<AiChatHistory, AiChatHistoryParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiChatHistory getByIdRel(Integer id) {
|
||||
AiChatHistoryParam param = new AiChatHistoryParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gxwebsoft.ai.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.ai.mapper.AiChatListMapper;
|
||||
import com.gxwebsoft.ai.service.AiChatListService;
|
||||
import com.gxwebsoft.ai.entity.AiChatList;
|
||||
import com.gxwebsoft.ai.param.AiChatListParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Service实现
|
||||
*
|
||||
* @author LX
|
||||
* @since 2026-03-28 17:34:18
|
||||
*/
|
||||
@Service
|
||||
public class AiChatListServiceImpl extends ServiceImpl<AiChatListMapper, AiChatList> implements AiChatListService {
|
||||
|
||||
@Override
|
||||
public PageResult<AiChatList> pageRel(AiChatListParam param) {
|
||||
PageParam<AiChatList, AiChatListParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("create_time desc");
|
||||
List<AiChatList> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AiChatList> listRel(AiChatListParam param) {
|
||||
List<AiChatList> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<AiChatList, AiChatListParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AiChatList getByIdRel(Integer id) {
|
||||
AiChatListParam param = new AiChatListParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateConversationId(Integer chatId, String conversationId) {
|
||||
update(
|
||||
new LambdaUpdateWrapper<AiChatList>()
|
||||
.eq(AiChatList::getId, chatId)
|
||||
.set(AiChatList::getConversationId, conversationId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user