diff --git a/src/main/java/com/wonderland/stardewvalley/constant/BackGroundConstant.java b/src/main/java/com/wonderland/stardewvalley/constant/BackGroundConstant.java index 4f864c4..3a9552a 100644 --- a/src/main/java/com/wonderland/stardewvalley/constant/BackGroundConstant.java +++ b/src/main/java/com/wonderland/stardewvalley/constant/BackGroundConstant.java @@ -5,8 +5,17 @@ import lombok.Getter; @Getter public class BackGroundConstant { - private static final String BACKGROUND_SPRING = "春天"; - private static final String BACKGROUND_SUMMER = "夏天"; - private static final String BACKGROUND_AUTUMN = "秋天"; - private static final String BACKGROUND_WINTER = "冬天"; + public static final String BACKGROUND_SPRING = "春天"; + public static final String BACKGROUND_SUMMER = "夏天"; + public static final String BACKGROUND_AUTUMN = "秋天"; + public static final String BACKGROUND_WINTER = "冬天"; + + public static final String BACKGROUND_SPRING_DESCRIPTION = "“春种一粒粟,秋收万颗子”\n" + + "耕种 收获提升,户外活动(节日)比例增加"; + public static final String BACKGROUND_SUMMER_DESCRIPTION = "“日复一日的劳作,是生活的底色”\n" + + "钓鱼 收获提升,室内活动(节日)比例增加"; + public static final String BACKGROUND_AUTUMN_DESCRIPTION = "“收获的喜悦,也伴随着失去的阵痛”\n" + + "耕种 收获提升,户外活动(节日)比例增加,随机事件大幅增加"; + public static final String BACKGROUND_WINTER_DESCRIPTION = "“寒冷的季节,也是心灵的沉淀”\n" + + "作息 影响健康值幅度增加,室内活动(节日)比例增加"; } diff --git a/src/main/java/com/wonderland/stardewvalley/constant/CityCode.java b/src/main/java/com/wonderland/stardewvalley/constant/CityCode.java new file mode 100644 index 0000000..9e33ef6 --- /dev/null +++ b/src/main/java/com/wonderland/stardewvalley/constant/CityCode.java @@ -0,0 +1,12 @@ +package com.wonderland.stardewvalley.constant; + +public enum CityCode { + + WuHan("420100"); + + private final String code; + + CityCode(String code){ + this.code = code; + } +} diff --git a/src/main/java/com/wonderland/stardewvalley/constant/GuideConstant.java b/src/main/java/com/wonderland/stardewvalley/constant/GuideConstant.java index b8ad9ff..3c7b81b 100644 --- a/src/main/java/com/wonderland/stardewvalley/constant/GuideConstant.java +++ b/src/main/java/com/wonderland/stardewvalley/constant/GuideConstant.java @@ -2,7 +2,7 @@ package com.wonderland.stardewvalley.constant; public class GuideConstant { - final public static String GUIDE = "\uD83C\uDF31 在这个名为“如果人生是星露谷”的世界中,玩家扮演的是一位现实世界中的普通人 ,在某种“精神投射”或“虚拟现实”中,进入了一个与《星露谷物语》相似的模拟世界。这个世界并非简单的幻想乡,而是对现实生活的重构与映射 ,玩家通过在现实世界中“种田、打工、探索、运动”等行为,影响游戏中的生活节奏与心理状态。\n" + + final public static String GUIDE = "\uD83C\uDF31 在这个名为“如果人生是星露谷”的世界中,玩家扮演的是一位现实世界中的普通人 ,在某种“精神投射”或“虚拟现实”中,进入了一个与《星露谷物语》相似的模拟世界。这个世界并非简单的幻想乡,而是对现实生活的重构与映射 ,玩家通过在现实世界中“工作、探索、运动”等行为,影响游戏中的生活节奏与心理状态。\n" + "\n" + "\uD83C\uDFAE 游戏说明:\n" + "\uD83C\uDF06 车水马龙的街道,拥挤的人潮,在这充满快节奏的水泥森林里,人们被巨大的压力裹挟着,疲惫不堪,宛若行尸走肉。改不完的稿子,数不完的ddl,望不到头的前路,许久没体会过的放松....生活什么时变得这么累了\n" + diff --git a/src/main/java/com/wonderland/stardewvalley/entity/AIChatRequest.java b/src/main/java/com/wonderland/stardewvalley/entity/AIChatRequest.java index 0178a61..6f047e8 100644 --- a/src/main/java/com/wonderland/stardewvalley/entity/AIChatRequest.java +++ b/src/main/java/com/wonderland/stardewvalley/entity/AIChatRequest.java @@ -2,6 +2,9 @@ package com.wonderland.stardewvalley.entity; import lombok.Data; +/** + * 封装 AI 请求:背景信息 + 内容 + */ @Data public class AIChatRequest { private String backGround; diff --git a/src/main/java/com/wonderland/stardewvalley/exception/BusinessException.java b/src/main/java/com/wonderland/stardewvalley/exception/BusinessException.java index 2e7e308..e87a68e 100644 --- a/src/main/java/com/wonderland/stardewvalley/exception/BusinessException.java +++ b/src/main/java/com/wonderland/stardewvalley/exception/BusinessException.java @@ -1,6 +1,8 @@ package com.wonderland.stardewvalley.exception; - +/** + * 运行时异常封装为业务异常 + */ public class BusinessException extends RuntimeException{ private final int code; diff --git a/src/main/java/com/wonderland/stardewvalley/exception/ErrorCode.java b/src/main/java/com/wonderland/stardewvalley/exception/ErrorCode.java index 49f401f..c2771d5 100644 --- a/src/main/java/com/wonderland/stardewvalley/exception/ErrorCode.java +++ b/src/main/java/com/wonderland/stardewvalley/exception/ErrorCode.java @@ -1,17 +1,16 @@ package com.wonderland.stardewvalley.exception; - import lombok.Getter; +/** + * 错误码 + */ @Getter public enum ErrorCode { SUCCESS(0, "ok"), PARAMS_ERROR(40000, "请求参数错误"), - NOT_LOGIN_ERROR(40100, "未登录"), - NO_AUTH_ERROR(40101, "无权限"), NOT_FOUND_ERROR(40400, "请求数据不存在"), - FORBIDDEN_ERROR(40300, "禁止访问"), SYSTEM_ERROR(50000, "系统内部异常"), OPERATION_ERROR(50001, "操作失败"); diff --git a/src/main/java/com/wonderland/stardewvalley/exception/ThrowUtils.java b/src/main/java/com/wonderland/stardewvalley/exception/ThrowUtils.java index 9958897..15dabd5 100644 --- a/src/main/java/com/wonderland/stardewvalley/exception/ThrowUtils.java +++ b/src/main/java/com/wonderland/stardewvalley/exception/ThrowUtils.java @@ -1,6 +1,8 @@ package com.wonderland.stardewvalley.exception; - +/** + * 根据条件抛出异常 + */ public class ThrowUtils { public static void throwIf(boolean condition, RuntimeException runtimeException) { diff --git a/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java b/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java index 2a72787..f348da0 100644 --- a/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java +++ b/src/main/java/com/wonderland/stardewvalley/lark/EventListener.java @@ -26,7 +26,7 @@ public class EventListener { // System.out.printf("[ onCustomizedEvent access ], type: message, data: %s\n", new String(event.getBody(), StandardCharsets.UTF_8)); // } // }) - // 菜单交互 + // 监听点击菜单事件 .onP2BotMenuV6(new ApplicationService.P2BotMenuV6Handler() { @Override public void handle(P2BotMenuV6 event) throws Exception { diff --git a/src/main/java/com/wonderland/stardewvalley/lark/LarkUtil.java b/src/main/java/com/wonderland/stardewvalley/lark/LarkUtil.java index eb70681..04f18c9 100644 --- a/src/main/java/com/wonderland/stardewvalley/lark/LarkUtil.java +++ b/src/main/java/com/wonderland/stardewvalley/lark/LarkUtil.java @@ -23,6 +23,11 @@ public class LarkUtil { // 复制该 Demo 后, 需要将 "YOUR_APP_ID", "YOUR_APP_SECRET" 替换为自己应用的 APP_ID, APP_SECRET. // 以下示例代码默认根据文档示例值填充,如果存在代码问题,请在 API 调试台填上相关必要参数后再复制代码使用 + /** + * 发送简单的文本消息 + * @param content 发送的内容 + * @throws Exception 异常 + */ public static void sendText(String content) throws Exception { // 构建client Client client = Client.newBuilder(LarkConstant.APP_ID, LarkConstant.APP_SECRET).build(); diff --git a/src/main/java/com/wonderland/stardewvalley/util/ResultUtil.java b/src/main/java/com/wonderland/stardewvalley/util/ResultUtil.java index 7c73fcc..4ceadf9 100644 --- a/src/main/java/com/wonderland/stardewvalley/util/ResultUtil.java +++ b/src/main/java/com/wonderland/stardewvalley/util/ResultUtil.java @@ -4,6 +4,9 @@ package com.wonderland.stardewvalley.util; import com.wonderland.stardewvalley.entity.BaseResponse; import com.wonderland.stardewvalley.exception.ErrorCode; +/** + * 返回统一的格式 + */ public class ResultUtil { public static BaseResponse success(T data) { diff --git a/src/test/java/com/wonderland/stardewvalley/ai/ChatUtilTest.java b/src/test/java/com/wonderland/stardewvalley/ai/ChatUtilTest.java new file mode 100644 index 0000000..8cbaa70 --- /dev/null +++ b/src/test/java/com/wonderland/stardewvalley/ai/ChatUtilTest.java @@ -0,0 +1,20 @@ +package com.wonderland.stardewvalley.ai; + +import com.wonderland.stardewvalley.constant.BackGroundConstant; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.junit.jupiter.api.Assertions.*; + +@SpringBootTest +class ChatUtilTest { + + @Resource + private ChatUtil chatUtil; + + @Test + void doChat() { + System.out.println(chatUtil.doChat(BackGroundConstant.BACKGROUND_SPRING + BackGroundConstant.BACKGROUND_SPRING_DESCRIPTION, "根据背景给出春天的特点,不需要输出背景以外的信息")); + } +} \ No newline at end of file