lhpqaq commented on code in PR #46:
URL: https://github.com/apache/bigtop-manager/pull/46#discussion_r1720886359


##########
bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/AIChatController.java:
##########
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.bigtop.manager.server.controller;
+
+import org.apache.bigtop.manager.server.enums.ResponseStatus;
+import org.apache.bigtop.manager.server.model.converter.PlatformConverter;
+import org.apache.bigtop.manager.server.model.dto.PlatformDTO;
+import org.apache.bigtop.manager.server.model.req.PlatformReq;
+import org.apache.bigtop.manager.server.model.vo.ChatMessageVO;
+import org.apache.bigtop.manager.server.model.vo.ChatThreadVO;
+import org.apache.bigtop.manager.server.model.vo.PlatformAuthorizedVO;
+import org.apache.bigtop.manager.server.model.vo.PlatformVO;
+import org.apache.bigtop.manager.server.service.AIChatService;
+import org.apache.bigtop.manager.server.utils.ResponseEntity;
+
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+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.servlet.mvc.method.annotation.SseEmitter;
+
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+
+import jakarta.annotation.Resource;
+import java.util.List;
+
+@Tag(name = "AI Chat Controller")
+@RestController
+@RequestMapping("/ai/chat/")
+public class AIChatController {
+
+    @Resource
+    private AIChatService chatService;
+
+    @Operation(summary = "platforms", description = "Get all platforms")
+    @GetMapping("/platforms")
+    public ResponseEntity<List<PlatformVO>> platforms() {
+        return ResponseEntity.success(chatService.platforms());
+    }
+
+    @Operation(summary = "platforms", description = "Get authorized platforms")
+    @GetMapping("/platforms/authorized")
+    public ResponseEntity<List<PlatformAuthorizedVO>> authorizedPlatforms() {
+        return ResponseEntity.success(chatService.authorizedPlatforms());
+    }
+
+    @Operation(summary = "platforms", description = "Add authorized platforms")
+    @PutMapping("/platforms")
+    public ResponseEntity<PlatformVO> addAuthorizedPlatform(@RequestBody 
PlatformReq platformReq) {
+        PlatformDTO platformDTO = 
PlatformConverter.INSTANCE.fromReq2DTO(platformReq);
+        return 
ResponseEntity.success(chatService.addAuthorizedPlatform(platformDTO));
+    }
+
+    @Operation(summary = "platforms", description = "Delete authorized 
platforms")
+    @DeleteMapping("/platforms/{platformId}")
+    public ResponseEntity<Integer> deleteAuthorizedPlatform(@PathVariable Long 
platformId) {
+        int code = chatService.deleteAuthorizedPlatform(platformId);
+        if (code != 0) {
+            return ResponseEntity.error(ResponseStatus.PARAMETER_ERROR, 
"Permission denied");
+        }
+        return ResponseEntity.success(0);
+    }
+
+    @Operation(summary = "new threads", description = "Create a chat threads")
+    @PutMapping("/platforms/{platformId}/threads")
+    public ResponseEntity<ChatThreadVO> createChatThreads(@PathVariable Long 
platformId, @RequestParam String model) {
+        return 
ResponseEntity.success(chatService.createChatThreads(platformId, model));
+    }
+
+    @Operation(summary = "delete threads", description = "Delete a chat 
threads")
+    @DeleteMapping("platforms/{platformId}/threads/{threadId}")
+    public ResponseEntity<Integer> deleteChatThreads(@PathVariable Long 
platformId, @PathVariable Long threadId) {

Review Comment:
   I’m not quite sure what the most appropriate return format here is—an empty 
`success()`, a `code`, or a `boolean`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@bigtop.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to