移除与AI相关的接口、服务、实体类及Mapper文件,新增官网模块的相关实体类、控制器和服务接口。此次重构旨在清理不再使用的AI代码,并为官网模块提供基础支持。master
@ -1,13 +0,0 @@ | |||
package org.dromara.ai.constant; | |||
public interface AiMessageRoleConstant { | |||
// 系统 | |||
static final String SYSTEM = "system"; | |||
// 用户 | |||
static final String USER = "user"; | |||
// 智能体 | |||
static final String ASSISTANT = "assistant"; | |||
} |
@ -1,5 +0,0 @@ | |||
package org.dromara.ai.constant; | |||
public interface AiModelTypeConstant { | |||
String OPENAI = "openai"; | |||
} |
@ -1,105 +0,0 @@ | |||
package org.dromara.ai.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.ai.service.IAiAgentChatService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 智能体的对话 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/ai/agentChat") | |||
public class AiAgentChatController extends BaseController { | |||
private final IAiAgentChatService aiAgentChatService; | |||
/** | |||
* 查询智能体的对话列表 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<AiAgentChatVo> list(AiAgentChatBo bo, PageQuery pageQuery) { | |||
return aiAgentChatService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出智能体的对话列表 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:export") | |||
@Log(title = "智能体的对话", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(AiAgentChatBo bo, HttpServletResponse response) { | |||
List<AiAgentChatVo> list = aiAgentChatService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "智能体的对话", AiAgentChatVo.class, response); | |||
} | |||
/** | |||
* 获取智能体的对话详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:query") | |||
@GetMapping("/{id}") | |||
public R<AiAgentChatVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(aiAgentChatService.queryById(id)); | |||
} | |||
/** | |||
* 新增智能体的对话 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:add") | |||
@Log(title = "智能体的对话", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AiAgentChatBo bo) { | |||
return toAjax(aiAgentChatService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改智能体的对话 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:edit") | |||
@Log(title = "智能体的对话", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AiAgentChatBo bo) { | |||
return toAjax(aiAgentChatService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除智能体的对话 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("ai:agentChat:remove") | |||
@Log(title = "智能体的对话", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(aiAgentChatService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -1,105 +0,0 @@ | |||
package org.dromara.ai.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.bo.AiAgentChatHistoryBo; | |||
import org.dromara.ai.service.IAiAgentChatHistoryService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 聊天记录 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/ai/agentChatHistory") | |||
public class AiAgentChatHistoryController extends BaseController { | |||
private final IAiAgentChatHistoryService aiAgentChatHistoryService; | |||
/** | |||
* 查询聊天记录列表 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<AiAgentChatHistoryVo> list(AiAgentChatHistoryBo bo, PageQuery pageQuery) { | |||
return aiAgentChatHistoryService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出聊天记录列表 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:export") | |||
@Log(title = "聊天记录", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(AiAgentChatHistoryBo bo, HttpServletResponse response) { | |||
List<AiAgentChatHistoryVo> list = aiAgentChatHistoryService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "聊天记录", AiAgentChatHistoryVo.class, response); | |||
} | |||
/** | |||
* 获取聊天记录详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:query") | |||
@GetMapping("/{id}") | |||
public R<AiAgentChatHistoryVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(aiAgentChatHistoryService.queryById(id)); | |||
} | |||
/** | |||
* 新增聊天记录 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:add") | |||
@Log(title = "聊天记录", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AiAgentChatHistoryBo bo) { | |||
return toAjax(aiAgentChatHistoryService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改聊天记录 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:edit") | |||
@Log(title = "聊天记录", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AiAgentChatHistoryBo bo) { | |||
return toAjax(aiAgentChatHistoryService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除聊天记录 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("ai:agentChatHistory:remove") | |||
@Log(title = "聊天记录", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(aiAgentChatHistoryService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -1,105 +0,0 @@ | |||
package org.dromara.ai.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.ai.domain.vo.AiAgentVo; | |||
import org.dromara.ai.domain.bo.AiAgentBo; | |||
import org.dromara.ai.service.IAiAgentService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 智能体 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/ai/agent") | |||
public class AiAgentController extends BaseController { | |||
private final IAiAgentService aiAgentService; | |||
/** | |||
* 查询智能体列表 | |||
*/ | |||
@SaCheckPermission("ai:agent:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<AiAgentVo> list(AiAgentBo bo, PageQuery pageQuery) { | |||
return aiAgentService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出智能体列表 | |||
*/ | |||
@SaCheckPermission("ai:agent:export") | |||
@Log(title = "智能体", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(AiAgentBo bo, HttpServletResponse response) { | |||
List<AiAgentVo> list = aiAgentService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "智能体", AiAgentVo.class, response); | |||
} | |||
/** | |||
* 获取智能体详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("ai:agent:query") | |||
@GetMapping("/{id}") | |||
public R<AiAgentVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(aiAgentService.queryById(id)); | |||
} | |||
/** | |||
* 新增智能体 | |||
*/ | |||
@SaCheckPermission("ai:agent:add") | |||
@Log(title = "智能体", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody AiAgentBo bo) { | |||
return toAjax(aiAgentService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改智能体 | |||
*/ | |||
@SaCheckPermission("ai:agent:edit") | |||
@Log(title = "智能体", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody AiAgentBo bo) { | |||
return toAjax(aiAgentService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除智能体 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("ai:agent:remove") | |||
@Log(title = "智能体", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(aiAgentService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -1,69 +0,0 @@ | |||
package org.dromara.ai.controller; | |||
import cn.dev33.satoken.annotation.SaIgnore; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.ai.domain.bo.AiChatMessageBo; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.ai.service.IChatService; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import reactor.core.publisher.Flux; | |||
/*** | |||
* 聊天接口 | |||
*/ | |||
@SaIgnore | |||
@RestController | |||
@RequestMapping("/api/ai/chat") | |||
@RequiredArgsConstructor | |||
public class ChatController { | |||
private final IChatService chatService; | |||
/** | |||
* 获取我的对话 | |||
*/ | |||
@GetMapping("/listMyChats") | |||
public R<TableDataInfo<AiAgentChatVo>> queryPageList(AiAgentChatBo bo, PageQuery pageQuery){ | |||
return R.ok(chatService.listMyChats(bo, pageQuery)); | |||
} | |||
/** | |||
* 获取我的聊天记录 | |||
*/ | |||
@GetMapping("/getMyChatMessages/{chatId}") | |||
public R<TableDataInfo<AiAgentChatHistoryVo>> getMyChatMessages(@PathVariable("chatId") Long chatId, PageQuery pageQuery){ | |||
return R.ok(chatService.getMyChatMessages(chatId, pageQuery)); | |||
} | |||
/*** | |||
* 聊天,流式数据 | |||
* @param message 用户发给ai的消息 | |||
* @return Flux | |||
*/ | |||
@GetMapping(value = "/sendMessageFlux",produces = "text/event-stream;charset=utf-8") | |||
public Flux sendMessageFlux(@Validated(AddGroup.class) AiChatMessageBo message){ | |||
return chatService.sendMessageFlux(message); | |||
} | |||
/*** | |||
* 聊天 | |||
* @param message 用户发给ai的消息 | |||
* @return R<String> | |||
*/ | |||
@GetMapping(value = "/sendMessage") | |||
public R<String> sendMessage(@Validated(AddGroup.class) AiChatMessageBo message){ | |||
return R.ok(chatService.sendMessage(message)); | |||
} | |||
} |
@ -1,53 +0,0 @@ | |||
package org.dromara.ai.domain.bo; | |||
import org.dromara.ai.domain.AiAgent; | |||
import org.dromara.common.mybatis.core.domain.BaseEntity; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import io.github.linpeilie.annotations.AutoMapper; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import jakarta.validation.constraints.*; | |||
/** | |||
* 智能体业务对象 ai_agent | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@AutoMapper(target = AiAgent.class, reverseConvertGenerate = false) | |||
public class AiAgentBo extends BaseEntity { | |||
/** | |||
* 编号 | |||
*/ | |||
@NotNull(message = "编号不能为空", groups = { EditGroup.class }) | |||
private Long id; | |||
/** | |||
* 智能体名称 | |||
*/ | |||
@NotBlank(message = "智能体名称不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private String name; | |||
/** | |||
* 状态 | |||
*/ | |||
@NotNull(message = "状态不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long status; | |||
/** | |||
* 备注 | |||
*/ | |||
private String remark; | |||
/** | |||
* 排序 | |||
*/ | |||
@NotNull(message = "排序不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long aiSort; | |||
} |
@ -1,56 +0,0 @@ | |||
package org.dromara.ai.domain.bo; | |||
import lombok.*; | |||
import org.dromara.ai.domain.AiAgentChat; | |||
import org.dromara.common.mybatis.core.domain.BaseEntity; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import io.github.linpeilie.annotations.AutoMapper; | |||
import jakarta.validation.constraints.*; | |||
/** | |||
* 智能体的对话业务对象 ai_agent_chat | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@AutoMapper(target = AiAgentChat.class, reverseConvertGenerate = false) | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
public class AiAgentChatBo extends BaseEntity { | |||
/** | |||
* 编号 | |||
*/ | |||
@NotNull(message = "编号不能为空", groups = { EditGroup.class }) | |||
private Long id; | |||
/** | |||
* 智能体id | |||
*/ | |||
@NotNull(message = "智能体id不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long agentId; | |||
/** | |||
* 用户id | |||
*/ | |||
@NotNull(message = "用户id不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long uid; | |||
/** | |||
* 对话名称 | |||
*/ | |||
@NotBlank(message = "对话名称不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private String chatName; | |||
/** | |||
* 排序 | |||
*/ | |||
@NotNull(message = "排序不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long aiSort; | |||
} |
@ -1,60 +0,0 @@ | |||
package org.dromara.ai.domain.bo; | |||
import lombok.*; | |||
import org.dromara.ai.domain.AiAgentChatHistory; | |||
import org.dromara.common.mybatis.core.domain.BaseEntity; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import io.github.linpeilie.annotations.AutoMapper; | |||
import jakarta.validation.constraints.*; | |||
/** | |||
* 聊天记录业务对象 ai_agent_chat_history | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@AutoMapper(target = AiAgentChatHistory.class, reverseConvertGenerate = false) | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
public class AiAgentChatHistoryBo extends BaseEntity { | |||
/** | |||
* 编号 | |||
*/ | |||
@NotNull(message = "编号不能为空", groups = { EditGroup.class }) | |||
private Long id; | |||
/** | |||
* 对话id | |||
*/ | |||
private Long agentChatId; | |||
/** | |||
* 智能体id | |||
*/ | |||
private Long agentId; | |||
/** | |||
* 对话身份 | |||
*/ | |||
@NotBlank(message = "对话身份不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private String role; | |||
/** | |||
* 对话内容 | |||
*/ | |||
@NotBlank(message = "对话内容不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private String message; | |||
/** | |||
* 排序 | |||
*/ | |||
@NotNull(message = "排序不能为空", groups = { AddGroup.class, EditGroup.class }) | |||
private Long aiSort; | |||
} |
@ -1,32 +0,0 @@ | |||
package org.dromara.ai.domain.bo; | |||
import jakarta.validation.constraints.NotNull; | |||
import lombok.*; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
@Data | |||
@Builder | |||
@AllArgsConstructor | |||
@NoArgsConstructor | |||
public class AiChatMessageBo { | |||
// 模型类型 | |||
private String modelType; | |||
// 模型 | |||
private String model; | |||
// 智能体id | |||
@NotNull(message = "智能体id不能为空", groups = AddGroup.class) | |||
private Long agentId; | |||
// 消息 | |||
@NotNull(message = "消息不能为空", groups = AddGroup.class) | |||
private String message; | |||
// 对话id | |||
@NotNull(message = "对话id不能为空", groups = AddGroup.class) | |||
private Long chatId; | |||
} |
@ -1,69 +0,0 @@ | |||
package org.dromara.ai.domain.vo; | |||
import org.dromara.ai.domain.AiAgentChatHistory; | |||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import org.dromara.common.excel.annotation.ExcelDictFormat; | |||
import org.dromara.common.excel.convert.ExcelDictConvert; | |||
import io.github.linpeilie.annotations.AutoMapper; | |||
import lombok.Data; | |||
import java.io.Serial; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 聊天记录视图对象 ai_agent_chat_history | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Data | |||
@ExcelIgnoreUnannotated | |||
@AutoMapper(target = AiAgentChatHistory.class) | |||
public class AiAgentChatHistoryVo implements Serializable { | |||
@Serial | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 编号 | |||
*/ | |||
@ExcelProperty(value = "编号") | |||
private Long id; | |||
/** | |||
* 对话id | |||
*/ | |||
@ExcelProperty(value = "对话id") | |||
private Long agentChatId; | |||
/** | |||
* 智能体id | |||
*/ | |||
@ExcelProperty(value = "智能体id") | |||
private Long agentId; | |||
/** | |||
* 对话身份 | |||
*/ | |||
@ExcelProperty(value = "对话身份", converter = ExcelDictConvert.class) | |||
@ExcelDictFormat(dictType = "ai_agent_chat_history_role") | |||
private String role; | |||
/** | |||
* 对话内容 | |||
*/ | |||
@ExcelProperty(value = "对话内容") | |||
private String message; | |||
/** | |||
* 排序 | |||
*/ | |||
@ExcelProperty(value = "排序") | |||
private Long aiSort; | |||
} |
@ -1,74 +0,0 @@ | |||
package org.dromara.ai.domain.vo; | |||
import org.dromara.ai.domain.AiAgentChat; | |||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | |||
import com.alibaba.excel.annotation.ExcelProperty; | |||
import org.dromara.common.excel.annotation.ExcelDictFormat; | |||
import org.dromara.common.excel.convert.ExcelDictConvert; | |||
import io.github.linpeilie.annotations.AutoMapper; | |||
import lombok.Data; | |||
import java.io.Serial; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* 智能体的对话视图对象 ai_agent_chat | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@Data | |||
@ExcelIgnoreUnannotated | |||
@AutoMapper(target = AiAgentChat.class) | |||
public class AiAgentChatVo implements Serializable { | |||
@Serial | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 编号 | |||
*/ | |||
@ExcelProperty(value = "编号") | |||
private Long id; | |||
/** | |||
* 智能体id | |||
*/ | |||
@ExcelProperty(value = "智能体id") | |||
private Long agentId; | |||
/** | |||
* 智能体名称 | |||
*/ | |||
@ExcelProperty(value = "智能体名称") | |||
private String agentName; | |||
/** | |||
* 用户id | |||
*/ | |||
@ExcelProperty(value = "用户id") | |||
private Long uid; | |||
/** | |||
* 用户名称 | |||
*/ | |||
@ExcelProperty(value = "用户名称") | |||
private String nickName; | |||
/** | |||
* 对话名称 | |||
*/ | |||
@ExcelProperty(value = "对话名称") | |||
private String chatName; | |||
/** | |||
* 排序 | |||
*/ | |||
@ExcelProperty(value = "排序") | |||
private Long aiSort; | |||
} |
@ -1,15 +0,0 @@ | |||
package org.dromara.ai.mapper; | |||
import org.dromara.ai.domain.AiAgentChatHistory; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | |||
/** | |||
* 聊天记录Mapper接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface AiAgentChatHistoryMapper extends BaseMapperPlus<AiAgentChatHistory, AiAgentChatHistoryVo> { | |||
} |
@ -1,15 +0,0 @@ | |||
package org.dromara.ai.mapper; | |||
import org.dromara.ai.domain.AiAgentChat; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | |||
/** | |||
* 智能体的对话Mapper接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface AiAgentChatMapper extends BaseMapperPlus<AiAgentChat, AiAgentChatVo> { | |||
} |
@ -1,15 +0,0 @@ | |||
package org.dromara.ai.mapper; | |||
import org.dromara.ai.domain.AiAgent; | |||
import org.dromara.ai.domain.vo.AiAgentVo; | |||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; | |||
/** | |||
* 智能体Mapper接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface AiAgentMapper extends BaseMapperPlus<AiAgent, AiAgentVo> { | |||
} |
@ -1,76 +0,0 @@ | |||
package org.dromara.ai.service; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.bo.AiAgentChatHistoryBo; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* 聊天记录Service接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface IAiAgentChatHistoryService { | |||
/** | |||
* 查询聊天记录 | |||
* | |||
* @param id 主键 | |||
* @return 聊天记录 | |||
*/ | |||
AiAgentChatHistoryVo queryById(Long id); | |||
/** | |||
* 分页查询聊天记录列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 聊天记录分页列表 | |||
*/ | |||
TableDataInfo<AiAgentChatHistoryVo> queryPageList(AiAgentChatHistoryBo bo, PageQuery pageQuery); | |||
/** | |||
* 查询符合条件的聊天记录列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 聊天记录列表 | |||
*/ | |||
List<AiAgentChatHistoryVo> queryList(AiAgentChatHistoryBo bo); | |||
/** | |||
* 根据智能体id查询系统消息列表 | |||
* | |||
* @param agentId 智能体ID | |||
* @return 聊天记录列表 | |||
*/ | |||
List<AiAgentChatHistoryVo> querySystemOverallList(Long agentId); | |||
/** | |||
* 新增聊天记录 | |||
* | |||
* @param bo 聊天记录 | |||
* @return 是否新增成功 | |||
*/ | |||
Boolean insertByBo(AiAgentChatHistoryBo bo); | |||
/** | |||
* 修改聊天记录 | |||
* | |||
* @param bo 聊天记录 | |||
* @return 是否修改成功 | |||
*/ | |||
Boolean updateByBo(AiAgentChatHistoryBo bo); | |||
/** | |||
* 校验并批量删除聊天记录信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | |||
} |
@ -1,68 +0,0 @@ | |||
package org.dromara.ai.service; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* 智能体的对话Service接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface IAiAgentChatService { | |||
/** | |||
* 查询智能体的对话 | |||
* | |||
* @param id 主键 | |||
* @return 智能体的对话 | |||
*/ | |||
AiAgentChatVo queryById(Long id); | |||
/** | |||
* 分页查询智能体的对话列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 智能体的对话分页列表 | |||
*/ | |||
TableDataInfo<AiAgentChatVo> queryPageList(AiAgentChatBo bo, PageQuery pageQuery); | |||
/** | |||
* 查询符合条件的智能体的对话列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 智能体的对话列表 | |||
*/ | |||
List<AiAgentChatVo> queryList(AiAgentChatBo bo); | |||
/** | |||
* 新增智能体的对话 | |||
* | |||
* @param bo 智能体的对话 | |||
* @return 是否新增成功 | |||
*/ | |||
Boolean insertByBo(AiAgentChatBo bo); | |||
/** | |||
* 修改智能体的对话 | |||
* | |||
* @param bo 智能体的对话 | |||
* @return 是否修改成功 | |||
*/ | |||
Boolean updateByBo(AiAgentChatBo bo); | |||
/** | |||
* 校验并批量删除智能体的对话信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | |||
} |
@ -1,68 +0,0 @@ | |||
package org.dromara.ai.service; | |||
import org.dromara.ai.domain.vo.AiAgentVo; | |||
import org.dromara.ai.domain.bo.AiAgentBo; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import java.util.Collection; | |||
import java.util.List; | |||
/** | |||
* 智能体Service接口 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
public interface IAiAgentService { | |||
/** | |||
* 查询智能体 | |||
* | |||
* @param id 主键 | |||
* @return 智能体 | |||
*/ | |||
AiAgentVo queryById(Long id); | |||
/** | |||
* 分页查询智能体列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 智能体分页列表 | |||
*/ | |||
TableDataInfo<AiAgentVo> queryPageList(AiAgentBo bo, PageQuery pageQuery); | |||
/** | |||
* 查询符合条件的智能体列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 智能体列表 | |||
*/ | |||
List<AiAgentVo> queryList(AiAgentBo bo); | |||
/** | |||
* 新增智能体 | |||
* | |||
* @param bo 智能体 | |||
* @return 是否新增成功 | |||
*/ | |||
Boolean insertByBo(AiAgentBo bo); | |||
/** | |||
* 修改智能体 | |||
* | |||
* @param bo 智能体 | |||
* @return 是否修改成功 | |||
*/ | |||
Boolean updateByBo(AiAgentBo bo); | |||
/** | |||
* 校验并批量删除智能体信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); | |||
} |
@ -1,34 +0,0 @@ | |||
package org.dromara.ai.service; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.ai.domain.bo.AiChatMessageBo; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import reactor.core.publisher.Flux; | |||
import java.util.List; | |||
public interface IChatService { | |||
/** | |||
* 查询我的对话列表 | |||
*/ | |||
TableDataInfo<AiAgentChatVo> listMyChats(AiAgentChatBo bo, PageQuery pageQuery); | |||
/** | |||
* 获取我的聊天记录 | |||
*/ | |||
TableDataInfo<AiAgentChatHistoryVo> getMyChatMessages(Long chatId, PageQuery pageQuery); | |||
/*** | |||
* 发送消息给AI | |||
*/ | |||
String sendMessage(AiChatMessageBo message); | |||
/*** | |||
* 发送消息给AI,流式返回数据 | |||
*/ | |||
Flux sendMessageFlux(AiChatMessageBo message); | |||
} |
@ -1,4 +0,0 @@ | |||
package org.dromara.ai.service; | |||
public interface IChatServiceNew { | |||
} |
@ -1,148 +0,0 @@ | |||
package org.dromara.ai.service.impl; | |||
import org.dromara.ai.constant.AiMessageRoleConstant; | |||
import org.dromara.common.core.utils.MapstructUtils; | |||
import org.dromara.common.core.utils.StringUtils; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Service; | |||
import org.dromara.ai.domain.bo.AiAgentChatHistoryBo; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.AiAgentChatHistory; | |||
import org.dromara.ai.mapper.AiAgentChatHistoryMapper; | |||
import org.dromara.ai.service.IAiAgentChatHistoryService; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Collection; | |||
/** | |||
* 聊天记录Service业务层处理 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@RequiredArgsConstructor | |||
@Service | |||
public class AiAgentChatHistoryServiceImpl implements IAiAgentChatHistoryService { | |||
private final AiAgentChatHistoryMapper baseMapper; | |||
/** | |||
* 查询聊天记录 | |||
* | |||
* @param id 主键 | |||
* @return 聊天记录 | |||
*/ | |||
@Override | |||
public AiAgentChatHistoryVo queryById(Long id){ | |||
return baseMapper.selectVoById(id); | |||
} | |||
/** | |||
* 分页查询聊天记录列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 聊天记录分页列表 | |||
*/ | |||
@Override | |||
public TableDataInfo<AiAgentChatHistoryVo> queryPageList(AiAgentChatHistoryBo bo, PageQuery pageQuery) { | |||
LambdaQueryWrapper<AiAgentChatHistory> lqw = buildQueryWrapper(bo); | |||
Page<AiAgentChatHistoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | |||
return TableDataInfo.build(result); | |||
} | |||
/** | |||
* 查询符合条件的聊天记录列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 聊天记录列表 | |||
*/ | |||
@Override | |||
public List<AiAgentChatHistoryVo> queryList(AiAgentChatHistoryBo bo) { | |||
LambdaQueryWrapper<AiAgentChatHistory> lqw = buildQueryWrapper(bo); | |||
return baseMapper.selectVoList(lqw); | |||
} | |||
@Override | |||
public List<AiAgentChatHistoryVo> querySystemOverallList(Long agentId) { | |||
LambdaQueryWrapper<AiAgentChatHistory> lqw = Wrappers.<AiAgentChatHistory>lambdaQuery() | |||
.eq(AiAgentChatHistory::getRole, AiMessageRoleConstant.SYSTEM) | |||
.and(n -> { | |||
n.isNull(AiAgentChatHistory::getAgentChatId) | |||
.eq(AiAgentChatHistory::getAgentId, agentId) | |||
.or() | |||
.isNull(AiAgentChatHistory::getAgentId); | |||
}); | |||
return baseMapper.selectVoList(lqw); | |||
} | |||
private LambdaQueryWrapper<AiAgentChatHistory> buildQueryWrapper(AiAgentChatHistoryBo bo) { | |||
Map<String, Object> params = bo.getParams(); | |||
LambdaQueryWrapper<AiAgentChatHistory> lqw = Wrappers.lambdaQuery(); | |||
lqw.eq(bo.getAgentChatId() != null, AiAgentChatHistory::getAgentChatId, bo.getAgentChatId()); | |||
lqw.eq(StringUtils.isNotBlank(bo.getRole()), AiAgentChatHistory::getRole, bo.getRole()); | |||
lqw.eq(StringUtils.isNotBlank(bo.getMessage()), AiAgentChatHistory::getMessage, bo.getMessage()); | |||
lqw.eq(bo.getAiSort() != null, AiAgentChatHistory::getAiSort, bo.getAiSort()); | |||
return lqw; | |||
} | |||
/** | |||
* 新增聊天记录 | |||
* | |||
* @param bo 聊天记录 | |||
* @return 是否新增成功 | |||
*/ | |||
@Override | |||
public Boolean insertByBo(AiAgentChatHistoryBo bo) { | |||
AiAgentChatHistory add = MapstructUtils.convert(bo, AiAgentChatHistory.class); | |||
validEntityBeforeSave(add); | |||
boolean flag = baseMapper.insert(add) > 0; | |||
if (flag) { | |||
bo.setId(add.getId()); | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 修改聊天记录 | |||
* | |||
* @param bo 聊天记录 | |||
* @return 是否修改成功 | |||
*/ | |||
@Override | |||
public Boolean updateByBo(AiAgentChatHistoryBo bo) { | |||
AiAgentChatHistory update = MapstructUtils.convert(bo, AiAgentChatHistory.class); | |||
validEntityBeforeSave(update); | |||
return baseMapper.updateById(update) > 0; | |||
} | |||
/** | |||
* 保存前的数据校验 | |||
*/ | |||
private void validEntityBeforeSave(AiAgentChatHistory entity){ | |||
//TODO 做一些数据校验,如唯一约束 | |||
} | |||
/** | |||
* 校验并批量删除聊天记录信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
@Override | |||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | |||
if(isValid){ | |||
//TODO 做一些业务上的校验,判断是否需要校验 | |||
} | |||
return baseMapper.deleteByIds(ids) > 0; | |||
} | |||
} |
@ -1,168 +0,0 @@ | |||
package org.dromara.ai.service.impl; | |||
import org.dromara.ai.domain.AiAgent; | |||
import org.dromara.ai.mapper.AiAgentMapper; | |||
import org.dromara.common.core.domain.dto.UserDTO; | |||
import org.dromara.common.core.service.UserService; | |||
import org.dromara.common.core.utils.MapstructUtils; | |||
import org.dromara.common.core.utils.StringUtils; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.system.mapper.SysUserMapper; | |||
import org.springframework.stereotype.Service; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.ai.domain.AiAgentChat; | |||
import org.dromara.ai.mapper.AiAgentChatMapper; | |||
import org.dromara.ai.service.IAiAgentChatService; | |||
import java.util.*; | |||
import java.util.function.Function; | |||
import java.util.stream.Collectors; | |||
/** | |||
* 智能体的对话Service业务层处理 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@RequiredArgsConstructor | |||
@Service | |||
public class AiAgentChatServiceImpl implements IAiAgentChatService { | |||
private final AiAgentChatMapper baseMapper; | |||
private final AiAgentMapper aiAgentMapper; | |||
private final UserService userService; | |||
// private final SysUserMapper userMapper; | |||
/** | |||
* 查询智能体的对话 | |||
* | |||
* @param id 主键 | |||
* @return 智能体的对话 | |||
*/ | |||
@Override | |||
public AiAgentChatVo queryById(Long id){ | |||
return baseMapper.selectVoById(id); | |||
} | |||
/** | |||
* 分页查询智能体的对话列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 智能体的对话分页列表 | |||
*/ | |||
@Override | |||
public TableDataInfo<AiAgentChatVo> queryPageList(AiAgentChatBo bo, PageQuery pageQuery) { | |||
LambdaQueryWrapper<AiAgentChat> lqw = buildQueryWrapper(bo); | |||
Page<AiAgentChatVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | |||
if(bo.getParams().containsKey("extend")){ | |||
setExtendInfo(result.getRecords()); | |||
} | |||
return TableDataInfo.build(result); | |||
} | |||
/** | |||
* 查询符合条件的智能体的对话列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 智能体的对话列表 | |||
*/ | |||
@Override | |||
public List<AiAgentChatVo> queryList(AiAgentChatBo bo) { | |||
LambdaQueryWrapper<AiAgentChat> lqw = buildQueryWrapper(bo); | |||
return baseMapper.selectVoList(lqw); | |||
} | |||
private LambdaQueryWrapper<AiAgentChat> buildQueryWrapper(AiAgentChatBo bo) { | |||
Map<String, Object> params = bo.getParams(); | |||
LambdaQueryWrapper<AiAgentChat> lqw = Wrappers.lambdaQuery(); | |||
lqw.eq(bo.getAgentId() != null, AiAgentChat::getAgentId, bo.getAgentId()); | |||
lqw.eq(bo.getUid() != null, AiAgentChat::getUid, bo.getUid()); | |||
lqw.like(StringUtils.isNotBlank(bo.getChatName()), AiAgentChat::getChatName, bo.getChatName()); | |||
lqw.eq(bo.getAiSort() != null, AiAgentChat::getAiSort, bo.getAiSort()); | |||
return lqw; | |||
} | |||
/** | |||
* 新增智能体的对话 | |||
* | |||
* @param bo 智能体的对话 | |||
* @return 是否新增成功 | |||
*/ | |||
@Override | |||
public Boolean insertByBo(AiAgentChatBo bo) { | |||
AiAgentChat add = MapstructUtils.convert(bo, AiAgentChat.class); | |||
validEntityBeforeSave(add); | |||
boolean flag = baseMapper.insert(add) > 0; | |||
if (flag) { | |||
bo.setId(add.getId()); | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 修改智能体的对话 | |||
* | |||
* @param bo 智能体的对话 | |||
* @return 是否修改成功 | |||
*/ | |||
@Override | |||
public Boolean updateByBo(AiAgentChatBo bo) { | |||
AiAgentChat update = MapstructUtils.convert(bo, AiAgentChat.class); | |||
validEntityBeforeSave(update); | |||
return baseMapper.updateById(update) > 0; | |||
} | |||
/** | |||
* 保存前的数据校验 | |||
*/ | |||
private void validEntityBeforeSave(AiAgentChat entity){ | |||
//TODO 做一些数据校验,如唯一约束 | |||
} | |||
/** | |||
* 校验并批量删除智能体的对话信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
@Override | |||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | |||
if(isValid){ | |||
//TODO 做一些业务上的校验,判断是否需要校验 | |||
} | |||
return baseMapper.deleteByIds(ids) > 0; | |||
} | |||
public void setExtendInfo(List<AiAgentChatVo> list){ | |||
List<Long> uidList = list.stream().map(item -> item.getUid()).collect(Collectors.toList()); | |||
List<Long> agentIdList = list.stream().map(item -> item.getAgentId()).collect(Collectors.toList()); | |||
HashMap<Long, UserDTO> userDTOS = userService | |||
.selectListByIds(uidList).stream() | |||
.collect(Collectors.toMap(UserDTO::getUserId, | |||
Function.identity(), (k1, k2) -> k1, HashMap::new)); | |||
HashMap<Long, AiAgent> aiAgents = aiAgentMapper | |||
.selectList(Wrappers.<AiAgent>lambdaQuery() | |||
.in(AiAgent::getId, agentIdList) | |||
.select(AiAgent::getId, AiAgent::getName)) | |||
.stream() | |||
.collect(Collectors.toMap(AiAgent::getId, | |||
Function.identity(), (k1, k2) -> k1, HashMap::new)); | |||
list.forEach(item->{ | |||
item.setAgentName(aiAgents.get(item.getAgentId()).getName()); | |||
item.setNickName(userDTOS.get(item.getUid()).getNickName()); | |||
}); | |||
} | |||
} |
@ -1,131 +0,0 @@ | |||
package org.dromara.ai.service.impl; | |||
import org.dromara.common.core.utils.MapstructUtils; | |||
import org.dromara.common.core.utils.StringUtils; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
import lombok.RequiredArgsConstructor; | |||
import org.springframework.stereotype.Service; | |||
import org.dromara.ai.domain.bo.AiAgentBo; | |||
import org.dromara.ai.domain.vo.AiAgentVo; | |||
import org.dromara.ai.domain.AiAgent; | |||
import org.dromara.ai.mapper.AiAgentMapper; | |||
import org.dromara.ai.service.IAiAgentService; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Collection; | |||
/** | |||
* 智能体Service业务层处理 | |||
* | |||
* @author Lion Li | |||
* @date 2024-11-07 | |||
*/ | |||
@RequiredArgsConstructor | |||
@Service | |||
public class AiAgentServiceImpl implements IAiAgentService { | |||
private final AiAgentMapper baseMapper; | |||
/** | |||
* 查询智能体 | |||
* | |||
* @param id 主键 | |||
* @return 智能体 | |||
*/ | |||
@Override | |||
public AiAgentVo queryById(Long id){ | |||
return baseMapper.selectVoById(id); | |||
} | |||
/** | |||
* 分页查询智能体列表 | |||
* | |||
* @param bo 查询条件 | |||
* @param pageQuery 分页参数 | |||
* @return 智能体分页列表 | |||
*/ | |||
@Override | |||
public TableDataInfo<AiAgentVo> queryPageList(AiAgentBo bo, PageQuery pageQuery) { | |||
LambdaQueryWrapper<AiAgent> lqw = buildQueryWrapper(bo); | |||
Page<AiAgentVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); | |||
return TableDataInfo.build(result); | |||
} | |||
/** | |||
* 查询符合条件的智能体列表 | |||
* | |||
* @param bo 查询条件 | |||
* @return 智能体列表 | |||
*/ | |||
@Override | |||
public List<AiAgentVo> queryList(AiAgentBo bo) { | |||
LambdaQueryWrapper<AiAgent> lqw = buildQueryWrapper(bo); | |||
return baseMapper.selectVoList(lqw); | |||
} | |||
private LambdaQueryWrapper<AiAgent> buildQueryWrapper(AiAgentBo bo) { | |||
Map<String, Object> params = bo.getParams(); | |||
LambdaQueryWrapper<AiAgent> lqw = Wrappers.lambdaQuery(); | |||
lqw.like(StringUtils.isNotBlank(bo.getName()), AiAgent::getName, bo.getName()); | |||
lqw.eq(bo.getStatus() != null, AiAgent::getStatus, bo.getStatus()); | |||
lqw.eq(bo.getAiSort() != null, AiAgent::getAiSort, bo.getAiSort()); | |||
return lqw; | |||
} | |||
/** | |||
* 新增智能体 | |||
* | |||
* @param bo 智能体 | |||
* @return 是否新增成功 | |||
*/ | |||
@Override | |||
public Boolean insertByBo(AiAgentBo bo) { | |||
AiAgent add = MapstructUtils.convert(bo, AiAgent.class); | |||
validEntityBeforeSave(add); | |||
boolean flag = baseMapper.insert(add) > 0; | |||
if (flag) { | |||
bo.setId(add.getId()); | |||
} | |||
return flag; | |||
} | |||
/** | |||
* 修改智能体 | |||
* | |||
* @param bo 智能体 | |||
* @return 是否修改成功 | |||
*/ | |||
@Override | |||
public Boolean updateByBo(AiAgentBo bo) { | |||
AiAgent update = MapstructUtils.convert(bo, AiAgent.class); | |||
validEntityBeforeSave(update); | |||
return baseMapper.updateById(update) > 0; | |||
} | |||
/** | |||
* 保存前的数据校验 | |||
*/ | |||
private void validEntityBeforeSave(AiAgent entity){ | |||
//TODO 做一些数据校验,如唯一约束 | |||
} | |||
/** | |||
* 校验并批量删除智能体信息 | |||
* | |||
* @param ids 待删除的主键集合 | |||
* @param isValid 是否进行有效性校验 | |||
* @return 是否删除成功 | |||
*/ | |||
@Override | |||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { | |||
if(isValid){ | |||
//TODO 做一些业务上的校验,判断是否需要校验 | |||
} | |||
return baseMapper.deleteByIds(ids) > 0; | |||
} | |||
} |
@ -1,145 +0,0 @@ | |||
package org.dromara.ai.service.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.ai.constant.AiMessageRoleConstant; | |||
import org.dromara.ai.constant.AiModelTypeConstant; | |||
import org.dromara.ai.domain.bo.AiAgentChatBo; | |||
import org.dromara.ai.domain.bo.AiAgentChatHistoryBo; | |||
import org.dromara.ai.domain.bo.AiChatMessageBo; | |||
import org.dromara.ai.domain.vo.AiAgentChatHistoryVo; | |||
import org.dromara.ai.domain.vo.AiAgentChatVo; | |||
import org.dromara.ai.domain.vo.AiAgentVo; | |||
import org.dromara.ai.mapper.AiAgentChatHistoryMapper; | |||
import org.dromara.ai.service.IAiAgentChatHistoryService; | |||
import org.dromara.ai.service.IAiAgentChatService; | |||
import org.dromara.ai.service.IAiAgentService; | |||
import org.dromara.ai.service.IChatService; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.springframework.ai.chat.messages.AssistantMessage; | |||
import org.springframework.ai.chat.messages.Message; | |||
import org.springframework.ai.chat.messages.SystemMessage; | |||
import org.springframework.ai.chat.messages.UserMessage; | |||
import org.springframework.ai.chat.prompt.ChatOptions; | |||
import org.springframework.ai.chat.prompt.Prompt; | |||
import org.springframework.ai.ollama.OllamaChatClient; | |||
import org.springframework.ai.ollama.api.OllamaOptions; | |||
import org.springframework.ai.openai.OpenAiChatClient; | |||
import org.springframework.ai.openai.OpenAiChatOptions; | |||
import org.springframework.stereotype.Service; | |||
import reactor.core.publisher.Flux; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
@Service | |||
@RequiredArgsConstructor | |||
public class ChatServiceImpl implements IChatService { | |||
private final OpenAiChatClient openAiChatClient; | |||
private final OllamaChatClient ollamaChatClient; | |||
private final IAiAgentService aiAgentService; | |||
private final IAiAgentChatService aiAgentChatService; | |||
private final IAiAgentChatHistoryService aiAgentChatHistoryService; | |||
@Override | |||
public TableDataInfo<AiAgentChatVo> listMyChats(AiAgentChatBo bo, PageQuery pageQuery) { | |||
return aiAgentChatService.queryPageList(bo, pageQuery); | |||
} | |||
@Override | |||
public TableDataInfo<AiAgentChatHistoryVo> getMyChatMessages(Long chatId, PageQuery pageQuery) { | |||
return aiAgentChatHistoryService | |||
.queryPageList(AiAgentChatHistoryBo.builder() | |||
.agentChatId(chatId) | |||
.build(), pageQuery); | |||
} | |||
@Override | |||
public String sendMessage(AiChatMessageBo message) { | |||
String content = ollamaChatClient.call(buildPrompt(message)).getResult().getOutput().getContent(); | |||
//插入对话智能体的历史记录 | |||
aiAgentChatHistoryService.insertByBo(AiAgentChatHistoryBo.builder() | |||
.agentChatId(message.getChatId()) | |||
.message(content) | |||
.agentId(message.getAgentId()) | |||
.role(AiMessageRoleConstant.ASSISTANT) | |||
.build()); | |||
return content; | |||
} | |||
@Override | |||
public Flux sendMessageFlux(AiChatMessageBo message) { | |||
return ollamaChatClient.stream(buildPrompt(message)) | |||
.map((response -> response.getResult().getOutput().getContent())); | |||
} | |||
/** | |||
* 构建提示 | |||
* @param message | |||
* @return | |||
*/ | |||
private Prompt buildPrompt(AiChatMessageBo message) { | |||
//查询智能体 | |||
// AiAgentVo aiAgentVo = aiAgentService.queryById(message.getAgentId()); | |||
//插入对话用户的历史记录 | |||
aiAgentChatHistoryService.insertByBo(AiAgentChatHistoryBo.builder() | |||
.agentChatId(message.getChatId()) | |||
.message(message.getMessage()) | |||
.agentId(message.getAgentId()) | |||
.role(AiMessageRoleConstant.USER) | |||
.build()); | |||
ChatOptions chatOptions = null; | |||
if (AiModelTypeConstant.OPENAI.equals(message.getModelType())) { | |||
chatOptions = OpenAiChatOptions.builder().build(); | |||
}else{ | |||
chatOptions = OllamaOptions.create(); | |||
} | |||
return new Prompt(buildMessage(message), chatOptions); | |||
} | |||
/** | |||
* 构建消息 | |||
* @param message | |||
* @return | |||
*/ | |||
private List<Message> buildMessage(AiChatMessageBo message) { | |||
// 根据智能体id查询智能体全局system消息 | |||
List<AiAgentChatHistoryVo> listSystem = aiAgentChatHistoryService.querySystemOverallList(message.getAgentId()); | |||
// 根据id查询对话历史记录 | |||
List<AiAgentChatHistoryVo> list = aiAgentChatHistoryService | |||
.queryList(AiAgentChatHistoryBo.builder() | |||
.agentChatId(message.getChatId()) | |||
.build()); | |||
// list.addAll(list2); | |||
ArrayList<Message> messages = new ArrayList<>(); | |||
// 根据角色添加消息 | |||
for (AiAgentChatHistoryVo vo : list) { | |||
if (AiMessageRoleConstant.ASSISTANT.equals(vo.getRole())) { | |||
messages.add(new AssistantMessage(vo.getMessage())); | |||
}else if (AiMessageRoleConstant.USER.equals(vo.getRole())){ | |||
messages.add(new UserMessage(vo.getMessage())); | |||
}else{ | |||
messages.add(new SystemMessage(vo.getMessage())); | |||
} | |||
} | |||
return messages; | |||
} | |||
} |
@ -1,10 +0,0 @@ | |||
package org.dromara.ai.service.impl; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.ai.service.IChatServiceNew; | |||
import org.springframework.stereotype.Service; | |||
@Service | |||
@RequiredArgsConstructor | |||
public class IChatServiceNewImpl implements IChatServiceNew { | |||
} |
@ -0,0 +1,93 @@ | |||
package org.dromara.officialWebsite.domain; | |||
import org.dromara.common.mybatis.core.domain.BaseEntity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import org.dromara.common.translation.annotation.Translation; | |||
import org.dromara.common.translation.constant.TransConstant; | |||
import java.io.Serial; | |||
/** | |||
* 项目案例对象 ow_cases | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-13 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = true) | |||
@TableName("ow_cases") | |||
public class OwCases extends BaseEntity { | |||
@Serial | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 编号 | |||
*/ | |||
@TableId(value = "id") | |||
private Long id; | |||
/** | |||
* 标题 | |||
*/ | |||
private String title; | |||
/** | |||
* 简介 | |||
*/ | |||
private String description; | |||
/** | |||
* 主图 | |||
*/ | |||
private String image; | |||
/** | |||
* 分类 | |||
*/ | |||
private Long categoryId; | |||
/** | |||
* 客户名称 | |||
*/ | |||
private String client; | |||
/** | |||
* 完成日期 | |||
*/ | |||
private String completionDate; | |||
/** | |||
* 客户面临的挑战 | |||
*/ | |||
private String challenge; | |||
/** | |||
* 提供的解决方案 | |||
*/ | |||
private String solution; | |||
/** | |||
* 项目成果 | |||
*/ | |||
private String results; | |||
/** | |||
* 详情 | |||
*/ | |||
private String content; | |||
/** | |||
* 客户评价 | |||
*/ | |||
private String testimonial; | |||
/** | |||
* 评价人及职位 | |||
*/ | |||
private String testimonialAuthor; | |||
} |
@ -0,0 +1,34 @@ | |||
package org.dromara.officialWebsite.front.controller; | |||
import cn.dev33.satoken.annotation.SaIgnore; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.officialWebsite.domain.bo.OwCaseCategoryBo; | |||
import org.dromara.officialWebsite.domain.vo.OwCaseCategoryVo; | |||
import org.dromara.officialWebsite.service.IOwCaseCategoryService; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
* 案例分类 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-13 | |||
*/ | |||
@SaIgnore | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/api/officialWebsite/caseCategory") | |||
public class OwCaseCategoryController extends BaseController { | |||
private final IOwCaseCategoryService owCaseCategoryService; | |||
/** | |||
* 查询案例分类列表 | |||
*/ | |||
@GetMapping("/list") | |||
public List<OwCaseCategoryVo> list() { | |||
return owCaseCategoryService.queryList(OwCaseCategoryBo.builder().build()); | |||
} | |||
} |
@ -0,0 +1,105 @@ | |||
package org.dromara.officialWebsite.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.officialWebsite.domain.vo.OwCasesVo; | |||
import org.dromara.officialWebsite.domain.bo.OwCasesBo; | |||
import org.dromara.officialWebsite.service.IOwCasesService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 项目案例 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-13 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/officialWebsite/cases") | |||
public class OwCasesController extends BaseController { | |||
private final IOwCasesService owCasesService; | |||
/** | |||
* 查询项目案例列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<OwCasesVo> list(OwCasesBo bo, PageQuery pageQuery) { | |||
return owCasesService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出项目案例列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:export") | |||
@Log(title = "项目案例", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(OwCasesBo bo, HttpServletResponse response) { | |||
List<OwCasesVo> list = owCasesService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "项目案例", OwCasesVo.class, response); | |||
} | |||
/** | |||
* 获取项目案例详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:query") | |||
@GetMapping("/{id}") | |||
public R<OwCasesVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(owCasesService.queryById(id)); | |||
} | |||
/** | |||
* 新增项目案例 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:add") | |||
@Log(title = "项目案例", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OwCasesBo bo) { | |||
return toAjax(owCasesService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改项目案例 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:edit") | |||
@Log(title = "项目案例", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OwCasesBo bo) { | |||
return toAjax(owCasesService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除项目案例 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("officialWebsite:cases:remove") | |||
@Log(title = "项目案例", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(owCasesService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -0,0 +1,49 @@ | |||
package org.dromara.officialWebsite.front.controller; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import cn.dev33.satoken.annotation.SaIgnore; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.NotEmpty; | |||
import jakarta.validation.constraints.NotNull; | |||
import lombok.RequiredArgsConstructor; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.officialWebsite.domain.bo.OwConfigParamsBo; | |||
import org.dromara.officialWebsite.domain.vo.OwConfigParamsVo; | |||
import org.dromara.officialWebsite.service.IOwConfigParamsService; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.springframework.web.bind.annotation.*; | |||
import java.util.List; | |||
/** | |||
* 配置参数 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-13 | |||
*/ | |||
@SaIgnore | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/api/officialWebsite/configParams") | |||
public class OwConfigParamsController extends BaseController { | |||
private final IOwConfigParamsService owConfigParamsService; | |||
/** | |||
* 查询配置参数列表 | |||
*/ | |||
@GetMapping("/list") | |||
public List<OwConfigParamsVo> list() { | |||
return owConfigParamsService.queryList(OwConfigParamsBo.builder().build()); | |||
} | |||
} |
@ -0,0 +1,105 @@ | |||
package org.dromara.officialWebsite.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.officialWebsite.domain.vo.OwDevelopmentHistoryVo; | |||
import org.dromara.officialWebsite.domain.bo.OwDevelopmentHistoryBo; | |||
import org.dromara.officialWebsite.service.IOwDevelopmentHistoryService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* OW发展历程 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-15 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/officialWebsite/developmentHistory") | |||
public class OwDevelopmentHistoryController extends BaseController { | |||
private final IOwDevelopmentHistoryService owDevelopmentHistoryService; | |||
/** | |||
* 查询OW发展历程列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<OwDevelopmentHistoryVo> list(OwDevelopmentHistoryBo bo, PageQuery pageQuery) { | |||
return owDevelopmentHistoryService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出OW发展历程列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:export") | |||
@Log(title = "OW发展历程", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(OwDevelopmentHistoryBo bo, HttpServletResponse response) { | |||
List<OwDevelopmentHistoryVo> list = owDevelopmentHistoryService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "OW发展历程", OwDevelopmentHistoryVo.class, response); | |||
} | |||
/** | |||
* 获取OW发展历程详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:query") | |||
@GetMapping("/{id}") | |||
public R<OwDevelopmentHistoryVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(owDevelopmentHistoryService.queryById(id)); | |||
} | |||
/** | |||
* 新增OW发展历程 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:add") | |||
@Log(title = "OW发展历程", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OwDevelopmentHistoryBo bo) { | |||
return toAjax(owDevelopmentHistoryService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改OW发展历程 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:edit") | |||
@Log(title = "OW发展历程", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OwDevelopmentHistoryBo bo) { | |||
return toAjax(owDevelopmentHistoryService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除OW发展历程 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("officialWebsite:developmentHistory:remove") | |||
@Log(title = "OW发展历程", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(owDevelopmentHistoryService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -0,0 +1,105 @@ | |||
package org.dromara.officialWebsite.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.officialWebsite.domain.vo.OwLeaveMessageVo; | |||
import org.dromara.officialWebsite.domain.bo.OwLeaveMessageBo; | |||
import org.dromara.officialWebsite.service.IOwLeaveMessageService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 留言 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-15 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/officialWebsite/leaveMessage") | |||
public class OwLeaveMessageController extends BaseController { | |||
private final IOwLeaveMessageService owLeaveMessageService; | |||
/** | |||
* 查询留言列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<OwLeaveMessageVo> list(OwLeaveMessageBo bo, PageQuery pageQuery) { | |||
return owLeaveMessageService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出留言列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:export") | |||
@Log(title = "留言", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(OwLeaveMessageBo bo, HttpServletResponse response) { | |||
List<OwLeaveMessageVo> list = owLeaveMessageService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "留言", OwLeaveMessageVo.class, response); | |||
} | |||
/** | |||
* 获取留言详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:query") | |||
@GetMapping("/{id}") | |||
public R<OwLeaveMessageVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(owLeaveMessageService.queryById(id)); | |||
} | |||
/** | |||
* 新增留言 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:add") | |||
@Log(title = "留言", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OwLeaveMessageBo bo) { | |||
return toAjax(owLeaveMessageService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改留言 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:edit") | |||
@Log(title = "留言", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OwLeaveMessageBo bo) { | |||
return toAjax(owLeaveMessageService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除留言 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("officialWebsite:leaveMessage:remove") | |||
@Log(title = "留言", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(owLeaveMessageService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -0,0 +1,105 @@ | |||
package org.dromara.officialWebsite.controller; | |||
import java.util.List; | |||
import lombok.RequiredArgsConstructor; | |||
import jakarta.servlet.http.HttpServletResponse; | |||
import jakarta.validation.constraints.*; | |||
import cn.dev33.satoken.annotation.SaCheckPermission; | |||
import org.springframework.web.bind.annotation.*; | |||
import org.springframework.validation.annotation.Validated; | |||
import org.dromara.common.idempotent.annotation.RepeatSubmit; | |||
import org.dromara.common.log.annotation.Log; | |||
import org.dromara.common.web.core.BaseController; | |||
import org.dromara.common.mybatis.core.page.PageQuery; | |||
import org.dromara.common.core.domain.R; | |||
import org.dromara.common.core.validate.AddGroup; | |||
import org.dromara.common.core.validate.EditGroup; | |||
import org.dromara.common.log.enums.BusinessType; | |||
import org.dromara.common.excel.utils.ExcelUtil; | |||
import org.dromara.officialWebsite.domain.vo.OwServiceProcessVo; | |||
import org.dromara.officialWebsite.domain.bo.OwServiceProcessBo; | |||
import org.dromara.officialWebsite.service.IOwServiceProcessService; | |||
import org.dromara.common.mybatis.core.page.TableDataInfo; | |||
/** | |||
* 服务流程 | |||
* | |||
* @author Lion Li | |||
* @date 2025-05-15 | |||
*/ | |||
@Validated | |||
@RequiredArgsConstructor | |||
@RestController | |||
@RequestMapping("/officialWebsite/serviceProcess") | |||
public class OwServiceProcessController extends BaseController { | |||
private final IOwServiceProcessService owServiceProcessService; | |||
/** | |||
* 查询服务流程列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:list") | |||
@GetMapping("/list") | |||
public TableDataInfo<OwServiceProcessVo> list(OwServiceProcessBo bo, PageQuery pageQuery) { | |||
return owServiceProcessService.queryPageList(bo, pageQuery); | |||
} | |||
/** | |||
* 导出服务流程列表 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:export") | |||
@Log(title = "服务流程", businessType = BusinessType.EXPORT) | |||
@PostMapping("/export") | |||
public void export(OwServiceProcessBo bo, HttpServletResponse response) { | |||
List<OwServiceProcessVo> list = owServiceProcessService.queryList(bo); | |||
ExcelUtil.exportExcel(list, "服务流程", OwServiceProcessVo.class, response); | |||
} | |||
/** | |||
* 获取服务流程详细信息 | |||
* | |||
* @param id 主键 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:query") | |||
@GetMapping("/{id}") | |||
public R<OwServiceProcessVo> getInfo(@NotNull(message = "主键不能为空") | |||
@PathVariable Long id) { | |||
return R.ok(owServiceProcessService.queryById(id)); | |||
} | |||
/** | |||
* 新增服务流程 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:add") | |||
@Log(title = "服务流程", businessType = BusinessType.INSERT) | |||
@RepeatSubmit() | |||
@PostMapping() | |||
public R<Void> add(@Validated(AddGroup.class) @RequestBody OwServiceProcessBo bo) { | |||
return toAjax(owServiceProcessService.insertByBo(bo)); | |||
} | |||
/** | |||
* 修改服务流程 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:edit") | |||
@Log(title = "服务流程", businessType = BusinessType.UPDATE) | |||
@RepeatSubmit() | |||
@PutMapping() | |||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody OwServiceProcessBo bo) { | |||
return toAjax(owServiceProcessService.updateByBo(bo)); | |||
} | |||
/** | |||
* 删除服务流程 | |||
* | |||
* @param ids 主键串 | |||
*/ | |||
@SaCheckPermission("officialWebsite:serviceProcess:remove") | |||
@Log(title = "服务流程", businessType = BusinessType.DELETE) | |||
@DeleteMapping("/{ids}") | |||
public R<Void> remove(@NotEmpty(message = "主键不能为空") | |||
@PathVariable Long[] ids) { | |||
return toAjax(owServiceProcessService.deleteWithValidByIds(List.of(ids), true)); | |||
} | |||
} |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.ai.mapper.AiAgentChatHistoryMapper"> | |||
</mapper> |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.ai.mapper.AiAgentChatMapper"> | |||
</mapper> |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.ai.mapper.AiAgentMapper"> | |||
</mapper> |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.project.mapper.PmAmountRecordMapper"> | |||
</mapper> |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.project.mapper.PmProjectMapper"> | |||
</mapper> |
@ -1,7 +0,0 @@ | |||
<?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="org.dromara.project.mapper.PmProjectMemberMapper"> | |||
</mapper> |