chore(core): 清理Demo代码并优化配置文件
删除DemoController和PostReviewStatusEnum等测试/废弃代码; .gitignore、SaTokenConfigure、SendMailUtils、application.yml小幅更新; AppleAppStoreConfig改用流式读取私钥,适配容器化部署。
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -35,3 +35,6 @@ build/
|
||||
/CLAUDE.md
|
||||
/AGENTS.md
|
||||
/src/test/
|
||||
/.claude/agents/backend-architect.md
|
||||
/.dockerignore
|
||||
/Dockerfile
|
||||
|
||||
@@ -49,8 +49,7 @@ public class AppleAppStoreConfig {
|
||||
public AppStoreServerAPIClient appStoreServerAPIClient() throws Exception {
|
||||
// 加载私钥文件
|
||||
Resource keyResource = resourceLoader.getResource(properties.getPrivateKeyPath());
|
||||
Path keyPath = keyResource.getFile().toPath();
|
||||
String encodedKey = Files.readString(keyPath);
|
||||
String encodedKey = new String(keyResource.getInputStream().readAllBytes());
|
||||
|
||||
// 获取环境配置(沙盒或生产)
|
||||
Environment env = Environment.valueOf(properties.getEnvironment());
|
||||
|
||||
@@ -79,6 +79,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
||||
"/user/verifyMailCode",
|
||||
"/character/listWithNotLogin",
|
||||
"/character/listByTagWithNotLogin",
|
||||
"/character/listByTag",
|
||||
"/character/detailWithNotLogin",
|
||||
"/character/addUserCharacter",
|
||||
"/character/list",
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
package com.yolo.keyborad.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.yolo.keyborad.common.BaseResponse;
|
||||
import com.yolo.keyborad.common.ResultUtils;
|
||||
|
||||
import com.yolo.keyborad.model.dto.EmbedSaveReq;
|
||||
import com.yolo.keyborad.model.dto.IosPayVerifyReq;
|
||||
import com.yolo.keyborad.model.dto.SearchEmbedReq;
|
||||
import com.yolo.keyborad.model.dto.TextSearchReq;
|
||||
import com.yolo.keyborad.model.vo.QdrantSearchItem;
|
||||
import com.yolo.keyborad.service.impl.QdrantVectorService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.embedding.Embedding;
|
||||
import org.springframework.ai.embedding.EmbeddingResponse;
|
||||
import org.springframework.ai.openai.OpenAiChatOptions;
|
||||
import org.springframework.ai.openai.OpenAiEmbeddingModel;
|
||||
import org.springframework.boot.context.properties.bind.DefaultValue;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* @author: ziin
|
||||
* @date: 2025/10/28 20:42
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/demo")
|
||||
@Slf4j
|
||||
@CrossOrigin
|
||||
@Tag(name = "测试控制器", description = "测试控制器")
|
||||
public class DemoController {
|
||||
|
||||
@Resource
|
||||
private ChatClient client;
|
||||
|
||||
@Resource
|
||||
private OpenAiEmbeddingModel embeddingModel;
|
||||
|
||||
@Resource
|
||||
private QdrantVectorService qdrantVectorService;
|
||||
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
@Operation(summary = "测试接口", description = "测试接口")
|
||||
public BaseResponse<String> testDemo(){
|
||||
return ResultUtils.success("hello world");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/talk")
|
||||
@Operation(summary = "测试聊天接口", description = "测试接口")
|
||||
@Parameter(name = "userInput",required = true,description = "测试聊天接口",example = "talk to something")
|
||||
public Flux<String> testTalk(@DefaultValue("you are so cute!") String userInput){
|
||||
return client
|
||||
.prompt("""
|
||||
You're a 25-year-old guy—witty and laid-back, always replying in English.
|
||||
|
||||
Read the user's last message, then write three short and funny replies that sound like something a guy would say.
|
||||
Go easy on the emojis.
|
||||
Keep each under 20 words.
|
||||
|
||||
User message: %s
|
||||
""".formatted(userInput))
|
||||
.system("""
|
||||
Format rules (very important):
|
||||
- Return EXACTLY 3 replies.
|
||||
- Use "<SPLIT>" as the separator between replies.
|
||||
- Output format: reply1<SPLIT>reply2<SPLIT>reply3
|
||||
- Do NOT use "<SPLIT>" inside any reply.
|
||||
""")
|
||||
.user(userInput)
|
||||
.options(OpenAiChatOptions.builder()
|
||||
.user(StpUtil.getLoginIdAsString())// ✅ 这里每次请求都会重新取当前登录用户
|
||||
.build())
|
||||
.stream()
|
||||
.content();
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/embed")
|
||||
@Operation(summary = "测试向量接口", description = "测试向量接口")
|
||||
@Parameter(name = "userInput",required = true,description = "测试向量接口",example = "you are so cute!")
|
||||
public BaseResponse<Embedding> testEmbed(@DefaultValue("you are so cute!") @RequestBody List<String> userInput){
|
||||
EmbeddingResponse response = embeddingModel.embedForResponse(userInput);
|
||||
return ResultUtils.success(response.getResult());
|
||||
}
|
||||
|
||||
|
||||
// @PostMapping("/testSaveEmbed")
|
||||
// @Operation(summary = "测试存储向量接口", description = "测试存储向量接口")
|
||||
// @Parameter(name = "userInput",required = true,description = "测试存储向量接口")
|
||||
// public BaseResponse<Boolean> testSaveEmbed(@RequestBody EmbedSaveReq embedSaveReq) {
|
||||
// qdrantVectorService.upsertPoint(embedSaveReq.getRecordItem().getId()
|
||||
// , embedSaveReq.getVector()
|
||||
// , JSONUtil.toJsonStr(embedSaveReq.getRecordItem()));
|
||||
// return ResultUtils.success(true);
|
||||
// }
|
||||
|
||||
|
||||
// @PostMapping("/testSearch")
|
||||
// @Operation(summary = "测试搜索向量接口", description = "测试搜索向量接口")
|
||||
// @Parameter(name = "userInput",required = true,description = "测试搜索向量接口")
|
||||
// public BaseResponse<List<QdrantSearchItem>> testSearch(@RequestBody SearchEmbedReq searchEmbedReq) {
|
||||
// return ResultUtils.success(qdrantVectorService.searchPoint(searchEmbedReq.getUserInputEmbed(), 3));
|
||||
// }
|
||||
|
||||
|
||||
@PostMapping("/tsetSearchText")
|
||||
@Operation(summary = "测试搜索语义接口", description = "测试搜索语义接口")
|
||||
@Parameter(name = "userInput",required = true,description = "测试搜索语义接口")
|
||||
public BaseResponse<List<QdrantSearchItem>> testSearchText(@RequestBody TextSearchReq textSearchReq) {
|
||||
return ResultUtils.success(qdrantVectorService.searchText(textSearchReq.getUserInput()));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.yolo.keyborad.model.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 帖子审核状态枚举
|
||||
*
|
||||
* @author yupi
|
||||
*/
|
||||
public enum PostReviewStatusEnum {
|
||||
|
||||
REVIEWING("待审核", 0),
|
||||
PASS("通过", 1),
|
||||
REJECT("拒绝", 2);
|
||||
|
||||
private final String text;
|
||||
|
||||
private final int value;
|
||||
|
||||
PostReviewStatusEnum(String text, int value) {
|
||||
this.text = text;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取值列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> getValues() {
|
||||
return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class SendMailUtils {
|
||||
|
||||
Email email = new Email();
|
||||
|
||||
email.setFrom("verify code", "MS_JqR6MO@no-replay.loveamorkey.com");
|
||||
email.setFrom("verify code", "MS_m2Gj3Q@no-replay.loveamorkey.com");
|
||||
|
||||
Recipient recipient = new Recipient(userName, userMail);
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SendMailUtils {
|
||||
|
||||
email.setSubject("no-replay");
|
||||
|
||||
email.setTemplateId("k68zxl28q79lj905");
|
||||
email.setTemplateId("pq3enl6ddq7g2vwr");
|
||||
|
||||
email.addPersonalization(recipient, "code", code);
|
||||
|
||||
|
||||
@@ -56,4 +56,4 @@ mybatis-plus:
|
||||
appid: loveKeyboard
|
||||
appsecret: kZJM39HYvhxwbJkG1fmquQRVkQiLAh2H
|
||||
|
||||
mail_access_token: mlsn.f2aafcaf4bccf01529f8636fa13a2c16c33a934d5e14be3adb0cc21c2fe40fe1
|
||||
mail_access_token: mlsn.3b1a3387055e0f53c0869cad91c6acad5401e9dcb4511ace2f82ab31d897fba6
|
||||
Reference in New Issue
Block a user