|
@@ -1,7 +1,20 @@
|
|
|
package cn.iocoder.byzs.module.web.controller.admin.ai;
|
|
package cn.iocoder.byzs.module.web.controller.admin.ai;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.util.ObjUtil;
|
|
|
import cn.iocoder.byzs.framework.common.pojo.CommonResult;
|
|
import cn.iocoder.byzs.framework.common.pojo.CommonResult;
|
|
|
import cn.iocoder.byzs.framework.common.util.object.BeanUtils;
|
|
import cn.iocoder.byzs.framework.common.util.object.BeanUtils;
|
|
|
|
|
+import cn.iocoder.byzs.framework.tenant.core.aop.TenantIgnore;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.chat.vo.conversation.AiChatConversationCreateMyReqVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.chat.vo.conversation.AiChatConversationRespVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.chat.vo.message.AiChatMessageSendReqVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.chat.vo.message.AiChatMessageSendRespVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.image.vo.AiImageDrawReqVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.controller.admin.image.vo.AiImageRespVO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.dal.dataobject.chat.AiChatConversationDO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.dal.dataobject.image.AiImageDO;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.service.chat.AiChatConversationService;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.service.chat.AiChatMessageService;
|
|
|
|
|
+import cn.iocoder.byzs.module.ai.service.image.AiImageService;
|
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO;
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.course.vo.CoursePageReqVO;
|
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.coursetype.vo.CourseTypeListReqVO;
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.coursetype.vo.CourseTypeListReqVO;
|
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.coursetype.vo.CourseTypeRespVO;
|
|
import cn.iocoder.byzs.module.bjdx.controller.admin.coursetype.vo.CourseTypeRespVO;
|
|
@@ -13,54 +26,77 @@ import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
import jakarta.annotation.security.PermitAll;
|
|
import jakarta.annotation.security.PermitAll;
|
|
|
|
|
+import jakarta.validation.Valid;
|
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-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 org.springframework.web.bind.annotation.*;
|
|
|
|
|
+import reactor.core.publisher.Flux;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static cn.iocoder.byzs.framework.common.pojo.CommonResult.success;
|
|
import static cn.iocoder.byzs.framework.common.pojo.CommonResult.success;
|
|
|
|
|
+import static cn.iocoder.byzs.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
|
|
|
|
|
@Tag(name = "Web-前端接口")
|
|
@Tag(name = "Web-前端接口")
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/bjdxWeb/ai")
|
|
@RequestMapping("/bjdxWeb/ai")
|
|
|
@Validated
|
|
@Validated
|
|
|
|
|
+@PermitAll
|
|
|
|
|
+@TenantIgnore
|
|
|
public class WebAiController {
|
|
public class WebAiController {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private CourseService courseService;
|
|
|
|
|
|
|
+ private AiChatConversationService chatConversationService;
|
|
|
@Resource
|
|
@Resource
|
|
|
- private CourseTypeService courseTypeService;
|
|
|
|
|
|
|
+ private AiChatMessageService chatMessageService;
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private AiImageService imageService;
|
|
|
|
|
+
|
|
|
|
|
+ private Long userId = 1L;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
+ // ================ 智能问答 ================
|
|
|
|
|
|
|
|
@PermitAll
|
|
@PermitAll
|
|
|
- @GetMapping("/getCourseByTypeId")
|
|
|
|
|
- @Operation(summary = "根据类型获得课程列表")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
- public CommonResult<List<CoursePageReqVO>> getCourseByTypeId(@RequestParam("typeId") String typeId) {
|
|
|
|
|
- List<CoursePageReqVO> courseList = courseService.getCourseList(new CoursePageReqVO().setCourseType(typeId));
|
|
|
|
|
- return success(courseList);
|
|
|
|
|
|
|
+ @TenantIgnore
|
|
|
|
|
+ @Operation(summary = "创建智能问答")
|
|
|
|
|
+ @PostMapping("/create-dialogue")
|
|
|
|
|
+ public CommonResult<Long> createChatConversationMy(@RequestBody @Valid AiChatConversationCreateMyReqVO createReqVO) {
|
|
|
|
|
+ return success(chatConversationService.createChatConversationMy(createReqVO, userId));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// @PermitAll
|
|
|
|
|
+// @TenantIgnore
|
|
|
|
|
+// @Operation(summary = "智能问答-获得智能问答列表")
|
|
|
|
|
+// @GetMapping("/dialogue-list")
|
|
|
|
|
+// public CommonResult<List<AiChatConversationRespVO>> getChatConversationMyList() {
|
|
|
|
|
+// List<AiChatConversationDO> list = chatConversationService.getChatConversationListByUserId(getLoginUserId());
|
|
|
|
|
+// return success(BeanUtils.toBean(list, AiChatConversationRespVO.class));
|
|
|
|
|
+// }
|
|
|
|
|
+
|
|
|
@PermitAll
|
|
@PermitAll
|
|
|
- @GetMapping("/getTypeGrade")
|
|
|
|
|
- @Operation(summary = "获得课程-年级")
|
|
|
|
|
- public CommonResult<List<CourseTypeRespVO>> getTypeGrade() {
|
|
|
|
|
- CourseTypeListReqVO listReqVO = new CourseTypeListReqVO().setCtTypeNode("0");
|
|
|
|
|
- List<CourseTypeDO> list = courseTypeService.getCourseTypeList(listReqVO);
|
|
|
|
|
- List<CourseTypeRespVO> listVo = BeanUtils.toBean(list, CourseTypeRespVO.class);
|
|
|
|
|
- return success(listVo);
|
|
|
|
|
|
|
+ @TenantIgnore
|
|
|
|
|
+ @Operation(summary = "智能问答-发送消息(流式)", description = "流式返回,响应较快")
|
|
|
|
|
+ @PostMapping(value = "/dialogue-send-stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
|
|
|
|
+ public Flux<CommonResult<AiChatMessageSendRespVO>> sendChatMessageStream(@Valid @RequestBody AiChatMessageSendReqVO sendReqVO) {
|
|
|
|
|
+ return chatMessageService.sendChatMessageStream(sendReqVO, userId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- @PermitAll
|
|
|
|
|
- @GetMapping("/getTypeByGradeId")
|
|
|
|
|
- @Operation(summary = "获得课程-年级大纲")
|
|
|
|
|
- public CommonResult<List<CourseTypeRespVO>> getTypeByGradeId(@RequestParam("id") Integer id) {
|
|
|
|
|
- CourseTypeListReqVO listReqVO = new CourseTypeListReqVO().setCtParentId(id).setCtTypeNode("1");
|
|
|
|
|
- List<CourseTypeDO> list = courseTypeService.getCourseTypeList(listReqVO);
|
|
|
|
|
- List<CourseTypeRespVO> listVo = BeanUtils.toBean(list, CourseTypeRespVO.class);
|
|
|
|
|
- return success(listVo);
|
|
|
|
|
|
|
+ // ================ 绘图管理 ================
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "生成图片")
|
|
|
|
|
+ @PostMapping("/create-painting")
|
|
|
|
|
+ public CommonResult<Long> drawImage(@Valid @RequestBody AiImageDrawReqVO drawReqVO) {
|
|
|
|
|
+ return success(imageService.drawImage(userId, drawReqVO));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/painting-get-my")
|
|
|
|
|
+ @Operation(summary = "绘画-获取绘图记录")
|
|
|
|
|
+ public CommonResult<AiImageRespVO> getImageMy(@RequestParam("id") Long id) {
|
|
|
|
|
+ AiImageDO image = imageService.getImage(id);
|
|
|
|
|
+ if (image == null || ObjUtil.notEqual(userId, image.getUserId())) {
|
|
|
|
|
+ return success(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ return success(BeanUtils.toBean(image, AiImageRespVO.class));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|