From 875a0b78b3e48167c54c73f2c315a0f213374ee6 Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sat, 5 Oct 2024 18:23:02 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=AF=B9=E6=8E=A5=E7=99=BE?= =?UTF-8?q?=E5=BA=A6=E5=BC=80=E5=8F=91=E8=80=85=E4=B8=AD=E5=BF=83=E6=96=87?= =?UTF-8?q?=E5=BF=83=E4=B8=80=E8=A8=80=E7=9A=84=E8=81=8A=E5=A4=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- skyeye-ai/.gitignore | 17 ++ skyeye-ai/ai-common/pom.xml | 29 ++++ .../target/ai-common-1.0-SNAPSHOT.jar | Bin 0 -> 1574 bytes .../target/maven-archiver/pom.properties | 5 + .../compile/default-compile/inputFiles.lst | 0 .../default-testCompile/inputFiles.lst | 0 skyeye-ai/ai-pro/pom.xml | 62 +++++++ .../ai/core/config/AiConfiguration.java | 30 ++++ .../ai/core/config/SkyeyeAiProperties.java | 29 ++++ .../skyeye/ai/core/enums/AiPlatformEnum.java | 48 ++++++ .../com/skyeye/ai/core/factory/AiFactory.java | 63 +++++++ .../skyeye/ai/core/factory/AiFactoryImpl.java | 82 +++++++++ .../message/controller/MessageController.java | 41 +++++ .../message/service/MessageService.java | 22 +++ .../service/impl/MessageServiceImpl.java | 50 ++++++ skyeye-ai/ai-web/pom.xml | 91 ++++++++++ .../java/com/skyeye/SkyAiApplication.java | 29 ++++ .../db/config/BaseDataSourceConfig.java | 163 ++++++++++++++++++ .../ai-web/src/main/resources/banner.txt | 34 ++++ .../ai-web/src/main/resources/bootstrap.yml | 47 +++++ .../ai-web/src/main/resources/jvm调优参数配置 | 22 +++ .../src/main/resources/log4j.properties | 70 ++++++++ skyeye-ai/pom.xml | 38 ++++ 23 files changed, 972 insertions(+) create mode 100644 skyeye-ai/.gitignore create mode 100644 skyeye-ai/ai-common/pom.xml create mode 100644 skyeye-ai/ai-common/target/ai-common-1.0-SNAPSHOT.jar create mode 100644 skyeye-ai/ai-common/target/maven-archiver/pom.properties create mode 100644 skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 skyeye-ai/ai-pro/pom.xml create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/AiConfiguration.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/SkyeyeAiProperties.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/enums/AiPlatformEnum.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactory.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactoryImpl.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/message/controller/MessageController.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/MessageService.java create mode 100644 skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/impl/MessageServiceImpl.java create mode 100644 skyeye-ai/ai-web/pom.xml create mode 100644 skyeye-ai/ai-web/src/main/java/com/skyeye/SkyAiApplication.java create mode 100644 skyeye-ai/ai-web/src/main/java/com/skyeye/db/config/BaseDataSourceConfig.java create mode 100644 skyeye-ai/ai-web/src/main/resources/banner.txt create mode 100644 skyeye-ai/ai-web/src/main/resources/bootstrap.yml create mode 100644 skyeye-ai/ai-web/src/main/resources/jvm调优参数配置 create mode 100644 skyeye-ai/ai-web/src/main/resources/log4j.properties create mode 100644 skyeye-ai/pom.xml diff --git a/skyeye-ai/.gitignore b/skyeye-ai/.gitignore new file mode 100644 index 00000000..bdd1e1a8 --- /dev/null +++ b/skyeye-ai/.gitignore @@ -0,0 +1,17 @@ +*.class + +# Package Files # +*.war +*.ear + +class +.idea +*.iml +.settings +*.classpath +/bin +classes +/target/ +/.project/ +/.metadata/ +/logs/ \ No newline at end of file diff --git a/skyeye-ai/ai-common/pom.xml b/skyeye-ai/ai-common/pom.xml new file mode 100644 index 00000000..41dc20e6 --- /dev/null +++ b/skyeye-ai/ai-common/pom.xml @@ -0,0 +1,29 @@ + + + + skyeye-ai + com.skyeye + 1.0-SNAPSHOT + + 4.0.0 + + ai-common + + + UTF-8 + + + + + + + com.skyeye + skyeye-common-rest + 1.0-SNAPSHOT + + + + + \ No newline at end of file diff --git a/skyeye-ai/ai-common/target/ai-common-1.0-SNAPSHOT.jar b/skyeye-ai/ai-common/target/ai-common-1.0-SNAPSHOT.jar new file mode 100644 index 0000000000000000000000000000000000000000..e0ec46b8c92d0321c219e399799746a7d2c4fb4d GIT binary patch literal 1574 zcmWIWW@h1H0D;&P*GMn}N^k;cU)K;vT~9wZ{Q#&k4u%+@GTk*3XXXN>TYy*uS(&e+ zpQoE^aEP9-+h^Z1r+vJ2^)B*y>uQ}lbAEG>!4=~NPm6TC&YjTl)^*}wf3hTOikS8R zm5QBnyo`&zO6F><6{!jO{ORx z&0TStHx;~fzVJNiW?;}J(u4w_b1HIkdV_ZR9X1fT`&m?R z_ggWEfTzon7#c$~f*3c>dLqQrDSPwXYvx~^9i5GgosF$??{nU7e7eLpYOBMxIo0R( zK97^XH9KvkJ=@ZqB6k<`MmO>+O)?bsG~cny#*N)k|4YWYC(JI#w&yI|eQ>W~W&4Dl zUdM!Kn_tLn2;tl*F=t}!olUVe^&c%g(^vfrGMnl1A>}-0S@c@7otCfpbK83q^|mA` zH7$$z+*fvWU(bv}v;Q*h^OJo_W13EU-0+v*$-L*8Pou%ZBBRt(AFRb@UbeW>Z#;uB zY0f0Js9<4L_nodvGapX!KFPE?^6E_I>QoaO`#lo#c=R+Q7cAwzw8ha_(zz;Da89yU zn8Eqz?WZg@=^1H;tqrr*n%V5?Xr43Gebb^j%NJ~zrY!1M;c)WVp|FLCT8x_=BSffOhKgx{xYP%{(eAk7W)_;yg-dVNLkMrn+=8oK^>@yFoIes3!9&A{z{Y?JopU=Pl zZmp>NCYZG&Dl6Ue$N%ehg=T)zoxqf9mi~PINe%P7sxQ|T6g_?V^pHF(^>Kjn&_%ob z$BTi{SpvjHBt&aLQGP*cQAuWMad4UcS#Mo09Z%mtk5wTbe099fK7Ja+=cg0+!Cx=X zz#!DXWRsEEMkCYk0zSS#10w^YhflSjxyZN~5U-yI0M&EPi zuWFxL=d;%5=~FKqt&=|9K6;E?>S?c-Qj0z}9%BY(AVww;X50k<&>uh`!0^@)L?aao zFm2ci29RP9SkkBtB;neSiV1ucgYqr}2r&Hre+n3_>?Hg0o3 zc^d*ij?f0?S2RZ;nS-3uVJ2eF>o7ByH0Ba%A~feC!V7z9Lm2D=ELMndD#&0&+6(Yz RWdoVP4uqUcK$-=_0{~dS>6`!n literal 0 HcmV?d00001 diff --git a/skyeye-ai/ai-common/target/maven-archiver/pom.properties b/skyeye-ai/ai-common/target/maven-archiver/pom.properties new file mode 100644 index 00000000..9a864e59 --- /dev/null +++ b/skyeye-ai/ai-common/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Sat Oct 05 12:34:57 CST 2024 +version=1.0-SNAPSHOT +groupId=com.skyeye +artifactId=ai-common diff --git a/skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 00000000..e69de29b diff --git a/skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/skyeye-ai/ai-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 00000000..e69de29b diff --git a/skyeye-ai/ai-pro/pom.xml b/skyeye-ai/ai-pro/pom.xml new file mode 100644 index 00000000..73564168 --- /dev/null +++ b/skyeye-ai/ai-pro/pom.xml @@ -0,0 +1,62 @@ + + + + skyeye-ai + com.skyeye + 1.0-SNAPSHOT + + 4.0.0 + + ai-pro + + + UTF-8 + + 0.9.5.2 + 1.0.25 + + + + + + + com.skyeye + ai-common + 1.0-SNAPSHOT + + + + org.apache.commons + commons-dbcp2 + 2.1.1 + + + + com.jayway.jsonpath + json-path + 2.8.0 + + + + + com.mchange + c3p0 + ${c3p0.version} + + + com.alibaba + druid + ${druid.version} + + + + com.baidubce + qianfan + 0.1.1 + + + + + \ No newline at end of file diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/AiConfiguration.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/AiConfiguration.java new file mode 100644 index 00000000..cffcd691 --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/AiConfiguration.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.ai.core.config; + +import com.skyeye.ai.core.factory.AiFactory; +import com.skyeye.ai.core.factory.AiFactoryImpl; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * @ClassName: AiConfiguration + * @Description: AI配置类 + * @author: skyeye云系列--卫志强 + * @date: 2024/8/18 22:10 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@Configuration +@EnableConfigurationProperties(SkyeyeAiProperties.class) +public class AiConfiguration { + + @Bean + public AiFactory aiClientFactory() { + return new AiFactoryImpl(); + } + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/SkyeyeAiProperties.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/SkyeyeAiProperties.java new file mode 100644 index 00000000..bb17a871 --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/config/SkyeyeAiProperties.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.ai.core.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * @ClassName: SkyeyeAiProperties + * @Description: Skyeye AI 配置类 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 18:03 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@Data +@ConfigurationProperties(prefix = "spring.ai") +public class SkyeyeAiProperties { + + private QianfanProperties qianfan; + + @Data + public static class QianfanProperties { + private String apiKey; + private String secretKey; + } +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/enums/AiPlatformEnum.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/enums/AiPlatformEnum.java new file mode 100644 index 00000000..198fa15a --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/enums/AiPlatformEnum.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.ai.core.enums; + +import cn.hutool.core.util.StrUtil; +import com.skyeye.common.base.classenum.SkyeyeEnumClass; +import com.skyeye.exception.CustomException; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +/** + * @ClassName: AiPlatformEnum + * @Description: AI 模型平台 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 11:33 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@Getter +@NoArgsConstructor +@AllArgsConstructor +public enum AiPlatformEnum implements SkyeyeEnumClass { + + YI_YAN("YiYan", "文心一言", "百度", true, false); + + private String key; + + private String value; + + private String remark; + + private Boolean show; + + private Boolean isDefault; + + public static AiPlatformEnum getName(String key) { + for (AiPlatformEnum bean : AiPlatformEnum.values()) { + if (StrUtil.equals(key, bean.getKey())) { + return bean; + } + } + throw new CustomException("非法的AI平台状态"); + } + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactory.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactory.java new file mode 100644 index 00000000..44f16d62 --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactory.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.ai.core.factory; + +import com.skyeye.ai.core.enums.AiPlatformEnum; + +/** + * @ClassName: AiFactory + * @Description: AI Model 模型工厂的接口类 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 11:33 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +public interface AiFactory { + + /** + * 基于指定配置,获得 ChatModel 对象 + *

+ * 如果不存在,则进行创建 + * + * @param platform 平台 + * @param apiKey API KEY + * @param url API URL + * @return ChatModel 对象 + */ + Object getOrCreateChatModel(AiPlatformEnum platform, String apiKey, String secretKey, String url); + + /** + * 基于默认配置,获得 ChatModel 对象 + *

+ * 默认配置,指的是在 application.yaml 配置文件中的 spring.ai 相关的配置 + * + * @param platform 平台 + * @return ChatModel 对象 + */ + Object getDefaultChatModel(AiPlatformEnum platform); + + /** + * 基于默认配置,获得 ImageModel 对象 + *

+ * 默认配置,指的是在 application.yaml 配置文件中的 spring.ai 相关的配置 + * + * @param platform 平台 + * @return ImageModel 对象 + */ + Object getDefaultImageModel(AiPlatformEnum platform); + + /** + * 基于指定配置,获得 ImageModel 对象 + *

+ * 如果不存在,则进行创建 + * + * @param platform 平台 + * @param apiKey API KEY + * @param url API URL + * @return ImageModel 对象 + */ + Object getOrCreateImageModel(AiPlatformEnum platform, String apiKey, String url); + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactoryImpl.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactoryImpl.java new file mode 100644 index 00000000..4288ba1f --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/ai/core/factory/AiFactoryImpl.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.ai.core.factory; + +import cn.hutool.core.lang.Singleton; +import cn.hutool.core.lang.func.Func0; +import cn.hutool.core.util.ArrayUtil; +import cn.hutool.core.util.StrUtil; +import com.baidubce.qianfan.Qianfan; +import com.baidubce.qianfan.core.auth.Auth; +import com.skyeye.ai.core.config.SkyeyeAiProperties; +import com.skyeye.ai.core.enums.AiPlatformEnum; +import com.skyeye.exception.CustomException; +import org.springframework.beans.factory.annotation.Autowired; + +/** + * @ClassName: AiFactoryImpl + * @Description: AI Model 模型工厂的实现类 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 14:09 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +public class AiFactoryImpl implements AiFactory { + + @Autowired + private SkyeyeAiProperties skyeyeAiProperties; + + @Override + public Object getOrCreateChatModel(AiPlatformEnum platform, String apiKey, String secretKey, String url) { + String cacheKey = buildClientCacheKey(platform, apiKey, url); + return Singleton.get(cacheKey, (Func0) () -> { + switch (platform) { + case YI_YAN: + return buildYiYanChatModel(apiKey, secretKey); + default: + throw new IllegalArgumentException(StrUtil.format("未知平台({})", platform)); + } + }); + } + + @Override + public Object getDefaultChatModel(AiPlatformEnum platform) { + return getOrCreateChatModel(platform, skyeyeAiProperties.getQianfan().getApiKey(), skyeyeAiProperties.getQianfan().getSecretKey(), null); + } + + @Override + public Object getDefaultImageModel(AiPlatformEnum platform) { + switch (platform) { + case YI_YAN: +// return SpringUtil.getBean(Qianfan.class); + default: + throw new CustomException(StrUtil.format("未知平台({})", platform)); + } + } + + @Override + public Object getOrCreateImageModel(AiPlatformEnum platform, String apiKey, String url) { + switch (platform) { + case YI_YAN: + default: + throw new CustomException(StrUtil.format("未知平台({})", platform)); + } + } + + private static String buildClientCacheKey(Object... params) { + if (ArrayUtil.isEmpty(params)) { + throw new CustomException("请指定参数"); + } + return StrUtil.format("{}", ArrayUtil.join(params, "_")); + } + + // ========== 各种创建 spring-ai 客户端的方法 ========== + + private static Qianfan buildYiYanChatModel(String apiKey, String secretKey) { + Qianfan qianFanApi = new Qianfan(Auth.TYPE_OAUTH, apiKey, secretKey); + return qianFanApi; + } + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/controller/MessageController.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/controller/MessageController.java new file mode 100644 index 00000000..ff285597 --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/controller/MessageController.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.message.controller; + +import com.skyeye.annotation.api.Api; +import com.skyeye.annotation.api.ApiImplicitParam; +import com.skyeye.annotation.api.ApiImplicitParams; +import com.skyeye.annotation.api.ApiOperation; +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; +import com.skyeye.message.service.MessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @ClassName: MessageController + * @Description: 消息控制层 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 17:24 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@RestController +@Api(value = "消息管理", tags = "消息管理", modelName = "消息管理") +public class MessageController { + + @Autowired + private MessageService messageService; + + @ApiOperation(id = "sendMessage", value = "发送消息", method = "POST", allUse = "0") + @ApiImplicitParams({ + @ApiImplicitParam(id = "message", name = "message", value = "消息", required = "required")}) + @RequestMapping("/post/MessageController/sendMessage") + public void sendMessage(InputObject inputObject, OutputObject outputObject) { + messageService.sendMessage(inputObject, outputObject); + } + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/MessageService.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/MessageService.java new file mode 100644 index 00000000..e3a27cb4 --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/MessageService.java @@ -0,0 +1,22 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.message.service; + +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; + +/** + * @ClassName: MessageService + * @Description: 消息服务接口 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 17:24 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +public interface MessageService { + + void sendMessage(InputObject inputObject, OutputObject outputObject); + +} diff --git a/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/impl/MessageServiceImpl.java b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/impl/MessageServiceImpl.java new file mode 100644 index 00000000..58fe664b --- /dev/null +++ b/skyeye-ai/ai-pro/src/main/java/com/skyeye/message/service/impl/MessageServiceImpl.java @@ -0,0 +1,50 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.message.service.impl; + +import com.baidubce.qianfan.Qianfan; +import com.baidubce.qianfan.core.builder.ChatBuilder; +import com.baidubce.qianfan.model.chat.ChatResponse; +import com.skyeye.ai.core.enums.AiPlatformEnum; +import com.skyeye.ai.core.factory.AiFactory; +import com.skyeye.annotation.service.SkyeyeService; +import com.skyeye.common.constans.CommonNumConstants; +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; +import com.skyeye.message.service.MessageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Map; + +/** + * @ClassName: MessageServiceImpl + * @Description: 消息服务实现类 + * @author: skyeye云系列--卫志强 + * @date: 2024/10/5 17:25 + * @Copyright: 2024 https://gitee.com/doc_wei01/skyeye Inc. All rights reserved. + * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 + */ +@Service +@SkyeyeService(name = "消息管理", groupName = "消息管理") +public class MessageServiceImpl implements MessageService { + + @Autowired + private AiFactory aiFactory; + + @Override + public void sendMessage(InputObject inputObject, OutputObject outputObject) { + Map params = inputObject.getParams(); + String message = params.get("message").toString(); + Qianfan qianfan = (Qianfan) aiFactory.getDefaultChatModel(AiPlatformEnum.YI_YAN); + ChatBuilder bulder = qianfan.chatCompletion() + .model("ERNIE-Speed-8K");//你要使用的大模型款式,最好和我一样,其他的很有可能是收费的 + bulder.addMessage("user", message);//你的问题 + ChatResponse response = bulder.execute(); + outputObject.setBean(response); + outputObject.settotal(CommonNumConstants.NUM_ONE); + } + +} diff --git a/skyeye-ai/ai-web/pom.xml b/skyeye-ai/ai-web/pom.xml new file mode 100644 index 00000000..271863d9 --- /dev/null +++ b/skyeye-ai/ai-web/pom.xml @@ -0,0 +1,91 @@ + + + + skyeye-ai + com.skyeye + 1.0-SNAPSHOT + + 4.0.0 + + ai-web + + + UTF-8 + + + + + + com.skyeye + ai-pro + 1.0-SNAPSHOT + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-actuator + + + + org.jolokia + jolokia-core + + + + + ${project.artifactId} + + + + org.apache.maven.plugins + maven-resources-plugin + + UTF-8 + + + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + + repackage + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 8 + 8 + UTF-8 + + + + + + \ No newline at end of file diff --git a/skyeye-ai/ai-web/src/main/java/com/skyeye/SkyAiApplication.java b/skyeye-ai/ai-web/src/main/java/com/skyeye/SkyAiApplication.java new file mode 100644 index 00000000..b3e6d4e4 --- /dev/null +++ b/skyeye-ai/ai-web/src/main/java/com/skyeye/SkyAiApplication.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.transaction.annotation.EnableTransactionManagement; + + +@SpringBootApplication +@EnableAutoConfiguration(exclude = { + org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class +}) +@EnableTransactionManagement//启注解事务管理,等同于xml配置方式的 +@EnableDiscoveryClient // 开启服务发现 +@EnableFeignClients +public class SkyAiApplication { + + public static void main(String[] args) { + System.setProperty("spring.devtools.restart.enabled", "false"); + SpringApplication.run(SkyAiApplication.class, args); + } + +} diff --git a/skyeye-ai/ai-web/src/main/java/com/skyeye/db/config/BaseDataSourceConfig.java b/skyeye-ai/ai-web/src/main/java/com/skyeye/db/config/BaseDataSourceConfig.java new file mode 100644 index 00000000..561a9bfd --- /dev/null +++ b/skyeye-ai/ai-web/src/main/java/com/skyeye/db/config/BaseDataSourceConfig.java @@ -0,0 +1,163 @@ +/******************************************************************************* + * Copyright 卫志强 QQ:598748873@qq.com Inc. All rights reserved. 开源地址:https://gitee.com/doc_wei01/skyeye + ******************************************************************************/ + +package com.skyeye.db.config; + +import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean; +import com.skyeye.common.constans.CommonConstants; +import com.skyeye.exception.CustomException; +import org.apache.commons.collections.CollectionUtils; +import org.apache.ibatis.session.SqlSessionFactory; +import org.mybatis.spring.SqlSessionTemplate; +import org.mybatis.spring.annotation.MapperScan; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.jdbc.DataSourceBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.core.io.Resource; +import org.springframework.core.io.ResourceLoader; +import org.springframework.core.io.support.PathMatchingResourcePatternResolver; +import org.springframework.core.io.support.ResourcePatternResolver; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.transaction.PlatformTransactionManager; + +import javax.sql.DataSource; +import java.io.IOException; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Properties; + +@Configuration +@MapperScan(basePackages = { + "com.skyeye.eve.*.dao", + "com.skyeye.*.dao"}, sqlSessionFactoryRef = "baseSqlSessionFactory") +public class BaseDataSourceConfig { + + private static final Logger LOGGER = LoggerFactory.getLogger(BaseDataSourceConfig.class); + + protected static Properties databaseTypeMappings = CommonConstants.getDefaultDatabaseTypeMappings(); + + @Autowired + protected ResourceLoader resourceLoader; + + /** + * Primary 必须加此注解,不然报错,下一个类则不需要添加,表示这个数据源是默认数据源 + * ConfigurationProperties(prefix)值必须是application.properteis中对应属性的前缀 + * + * @return + */ + @Bean(name = "baseDataSource") + @Primary + @ConfigurationProperties(prefix = "spring.datasource") + public DataSource baseDataSource() { + return DataSourceBuilder.create().build(); + } + + /** + * a、SqlSessionFactory 一旦被创建就应该在应用的运行期间一直存在,没有任何理由对它进行清除或重建。 + * b、使用 SqlSessionFactory 的最佳实践是在应用运行期间不要重复创建多次,多次重建 SqlSessionFactory 被视为一种代码“坏味道(bad smell)”。 + * c、因此 SqlSessionFactory 的最佳作用域是应用作用域。有很多方法可以做到,最简单的就是使用单例模式或者静态单例模式。 + * + * @param dataSource + * @return + */ + @Primary + @Bean(name = "baseSqlSessionFactory") + public SqlSessionFactory baseSqlSessionFactory(@Qualifier("baseDataSource") DataSource dataSource) { + MybatisSqlSessionFactoryBean sqlSessionFactoryBean = new MybatisSqlSessionFactoryBean(); + + sqlSessionFactoryBean.setDataSource(dataSource); + String databaseType = this.initDatabaseType(dataSource); + if (databaseType == null) { + throw new CustomException("couldn't deduct database type"); + } else { + try { + // 添加XML目录 + sqlSessionFactoryBean.setMapperLocations(resolveMapperLocations()); + sqlSessionFactoryBean.afterPropertiesSet(); + return sqlSessionFactoryBean.getObject(); + } catch (Exception var5) { + throw new CustomException("Could not create sqlSessionFactory", var5); + } + } + } + + public Resource[] resolveMapperLocations() { + ResourcePatternResolver resourceResolver = new PathMatchingResourcePatternResolver(); + List mapperLocations = new ArrayList<>(); + mapperLocations.add("classpath*:mapper/**/*.xml"); + List resources = new ArrayList(); + if (!CollectionUtils.isEmpty(mapperLocations)) { + for (String mapperLocation : mapperLocations) { + try { + Resource[] mappers = resourceResolver.getResources(mapperLocation); + resources.addAll(Arrays.asList(mappers)); + } catch (IOException e) { + LOGGER.error("Get myBatis resources happened exception", e); + } + } + } + return resources.toArray(new Resource[resources.size()]); + } + + @Primary + @Bean(name = "transactionManager") + public PlatformTransactionManager transactionManager(@Qualifier("baseDataSource") DataSource dataSourceOne) { + return new DataSourceTransactionManager(dataSourceOne); + } + + @Primary + @Bean(name = "sqlSessionTemplate") + public SqlSessionTemplate sqlSessionTemplate(@Qualifier("baseSqlSessionFactory") SqlSessionFactory sqlSessionFactory) { + // 使用上面配置的Factory + return new SqlSessionTemplate(sqlSessionFactory); + } + + /** + * 初始化 + * + * @param dataSource + * @return + */ + protected String initDatabaseType(@Qualifier("baseDataSource") DataSource dataSource) { + String databaseType = null; + Connection connection = null; + + try { + connection = dataSource.getConnection(); + DatabaseMetaData databaseMetaData = connection.getMetaData(); + String databaseProductName = databaseMetaData.getDatabaseProductName(); + LOGGER.info("database product name: '{}'", databaseProductName); + databaseType = databaseTypeMappings.getProperty(databaseProductName); + if (databaseType == null) { + throw new CustomException("couldn't deduct database type from database product name '" + databaseProductName + "'"); + } + + LOGGER.info("using database type: {}", databaseType); + } catch (SQLException var14) { + LOGGER.error("Exception while initializing Database connection", var14); + } finally { + try { + if (connection != null) { + connection.close(); + } + } catch (SQLException var13) { + LOGGER.error("Exception while closing the Database connection", var13); + } + + } + databaseType = ("dm".equals(databaseType)) ? "oracle" : databaseType; + return databaseType; + } + +} diff --git a/skyeye-ai/ai-web/src/main/resources/banner.txt b/skyeye-ai/ai-web/src/main/resources/banner.txt new file mode 100644 index 00000000..e1b7251a --- /dev/null +++ b/skyeye-ai/ai-web/src/main/resources/banner.txt @@ -0,0 +1,34 @@ +/** + * _ooOoo_ + * o8888888o + * 88" . "88 + * (| -_- |) + * O\ = /O + * ____/`---'\____ + * .' \\| |// `. + * / \\||| : |||// \ + * / _||||| -:- |||||- \ + * | | \\\ - /// | | + * | \_| ''\---/'' | | + * \ .-\__ `-` ___/-. / + * ___`. .' /--.--\ `. . __ + * ."" '< `.___\_<|>_/___.' >'"". + * | | : `- \`.;`\ _ /`;.`/ - ` : | | + * \ \ `-. \_ __\ /__ _/ .-` / / + * ======`-.____`-.___\_____/___.-`____.-'====== + * `=---=' + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * 佛祖保佑 永无BUG + * 佛曰: + * 写字楼里写字间,写字间里程序员; + * 程序人员写程序,又拿程序换酒钱。 + * 酒醒只在网上坐,酒醉还来网下眠; + * 酒醉酒醒日复日,网上网下年复年。 + * 但愿老死电脑间,不愿鞠躬老板前; + * 奔驰宝马贵者趣,公交自行程序员。 + * 别人笑我忒疯癫,我笑自己命太贱; + * 不见满街漂亮妹,哪个归得程序员? + * :: springboot 2.x + * :: Skyeye系列框架,作者:卫志强 + * :: 作者独家专属,未购买禁止私自使用 +*/ \ No newline at end of file diff --git a/skyeye-ai/ai-web/src/main/resources/bootstrap.yml b/skyeye-ai/ai-web/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..60bfb01d --- /dev/null +++ b/skyeye-ai/ai-web/src/main/resources/bootstrap.yml @@ -0,0 +1,47 @@ +server: + port: 8120 + +spring: + application: + name: skyeye-ai-${spring.profiles.active} # 服务名 + main: + allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 + allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 + data: + redis: + repositories: + enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 + profiles: + active: dev + cloud: + nacos: + discovery: + server-addr: 172.18.92.40:8848 # 配置服务注册nacos地址 + namespace: ${spring.profiles.active} # 配置命名空间 + service: ${spring.application.name} # 配置服务名 + config: + # 指定nacos server的地址 + server-addr: 172.18.92.40:8848 + # 配置文件后缀 + file-extension: yml + # 命名空间 常用场景之一是不同环境的配置的区分隔离,例如开发测试环境和生产环境的资源(如配置、服务)隔离等 + namespace: ${spring.profiles.active} # 配置命名空间 + # 支持多个共享 Data Id 的配置,优先级小于ext-config,自定义 Data Id 配置 属性是个集合,内部由 Config POJO 组成。Config 有 3 个属性,分别是 dataId, group 以及 refresh + ext-config: + - data-id: skyeye-common.yml # 配置文件名-Data Id + group: DEFAULT_GROUP # 默认为DEFAULT_GROUP + refresh: true # 是否动态刷新,默认为false + ai: + qianfan: # 文心一言 https://console.bce.baidu.com/qianfan/ais/console/applicationConsole/application/v1 + apiKey: EVdFG9fbFMmwtjQ57Efwftox + secretKey: XJ8jcR6jK06S5BCrPRYFoWqqlqbwyCXx +logging: + level: + com.skyeye: debug + +feign: + client: + config: + # 全局配置 + default: + loggerLevel: FULL diff --git a/skyeye-ai/ai-web/src/main/resources/jvm调优参数配置 b/skyeye-ai/ai-web/src/main/resources/jvm调优参数配置 new file mode 100644 index 00000000..ccedd4b5 --- /dev/null +++ b/skyeye-ai/ai-web/src/main/resources/jvm调优参数配置 @@ -0,0 +1,22 @@ +-- jvm堆的最小值3G +-Xms3072m +-- jvm堆的最大值3G +-Xmx3072m +-- 新生代内存区域的大小,设置新生代区域后,老年代内存=堆内存 - 新生代内存;老年代的最大内存 = 堆内存 - 新生代最大内存 +-Xmn2048M +-- 新生代内存区域中Eden和Survivor的比例,SurvivorRatio=8,那么Eden区占8/10,2个Survivor区各占1/10 +-XX:SurvivorRatio=8 +-- 大小为区间为[0,15],如果高于15,JDK7 会默认15,JDK 8会启动报错 +-XX:MaxTenuringThreshold=15 +-- 输出GC的时间戳(以日期的形式,如 2019-05-04T21:53:59.234+0800) +-XX:+PrintGCDateStamps +-- 打印出GC的详细信息 +-XX:+PrintGCDetails +-- 在进行GC的前后打印出堆的信息 +-XX:+PrintHeapAtGC +-- 打印年轻代各个引用的数量以及时长 +-XX:+PrintReferenceGC +-- 开启gc日志 +-verbose:gc +-- gc日志的存放位置 +-Xloggc:d:/gc.log diff --git a/skyeye-ai/ai-web/src/main/resources/log4j.properties b/skyeye-ai/ai-web/src/main/resources/log4j.properties new file mode 100644 index 00000000..840b663a --- /dev/null +++ b/skyeye-ai/ai-web/src/main/resources/log4j.properties @@ -0,0 +1,70 @@ +### set log levels这里的INFO,Stdout,D,E可以理解为变量,也可以说是输出平台,在下面我们可以看到 ### +log4j.rootLogger = INFO, C, D, E + +### console控制台输出 ### +log4j.appender.C = org.apache.log4j.ConsoleAppender +### System.out也就是输出 out输出是黑色字体,err输出的字体是红色 ### +log4j.appender.C.Target = System.out +### layout是指布局,也就是说输出日志信息的格式样式,在这里我们使用的是log4j提供的 ### +log4j.appender.C.layout = org.apache.log4j.PatternLayout +### 这里就是指定我们日志文件以哪一种格式去输出 ### +log4j.appender.C.layout.ConversionPattern = [skyeye-promote][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n + + +### log file INFO级别输出日志文件 ### +log4j.appender.D = org.apache.log4j.DailyRollingFileAppender +### 指定日志输出位置 ### +log4j.appender.D.File = ../logs/skyeye.log +### 这个的意思是指是追加还是覆盖 默认是 true true是追加 false是覆盖 ### +log4j.appender.D.Append = true +### 这个是指日志输出的级别在这里指定的是 INFO级别 ### +log4j.appender.D.Threshold = INFO +### layout是指布局,也就是说输出日志信息的格式样式,在这里我们使用的是log4j提供的 ### +log4j.appender.D.layout = org.apache.log4j.PatternLayout +### 这里就是指定我们日志文件以哪一种格式去输出 ### +log4j.appender.D.layout.ConversionPattern = [skyeye-promote][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n + + +### exception ERROR级别输出日志文件 ### +#这个跟上面一样 只不过是日志级别是 ERROR级的,方便我们直接查看系统异常信息 +log4j.appender.E = org.apache.log4j.DailyRollingFileAppender +log4j.appender.E.File = ../logs/skyeye_error.log +log4j.appender.E.Append = true +log4j.appender.E.Threshold = ERROR +log4j.appender.E.layout = org.apache.log4j.PatternLayout +log4j.appender.E.layout.ConversionPattern = [skyeye-promote][%p] [%-d{yyyy-MM-dd HH:mm:ss}] %C.%M(%L) | %m%n + +#localhost日志文件输出级别为INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO +#localhost日志文件输出处理类2localhost.org.apache.juli.FileHandler +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler + +#manager日志文件输出级别为INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO +#manager日志文件输出处理类3manager.org.apache.juli.FileHandler +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler + +#host-manager日志文件输出级别为INFO +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO +#host-manager日志文件输出处理类4host-manager.org.apache.juli.FileHandler +org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.FileHandler + +#设置包名的输出级别 +log4j.logger.com.skyeye.common.filter=info, database +# 记录日志至数据库 +# 这里定义了数据源 +log4j.appender.database=org.apache.log4j.jdbc.JDBCAppender +log4j.appender.database.driver=com.mysql.jdbc.Driver +# BufferSize就是每次缓存多少条数据然后插入数据库,为了演示这里设置为1 +log4j.appender.database.BufferSize=1 +# 数据库连接池 +# 设置要将日志插入到数据库的驱动 +log4j.appender.database.Threshold=info +log4j.appender.database.URL=${jdbc.database.path} +log4j.appender.database.user=${jdbc.database.username} +log4j.appender.database.password=${jdbc.database.password} +# 看名字也该明白这里是定义Sql语句的啦 +log4j.appender.database.sql=insert into sys_work_log (id, class, mothod, create_time, log_level, log_line, message, user_name, file_name, real_path, req_ip) values (REPLACE(UUID(), '-', ''), '%C', '%M', '%d{yyyy-MM-dd HH:mm:ss}', '%p', '%l', '%m', '%X{userName}', '%F', '%X{realPath}', '%X{ip}') +log4j.appender.database.layout=org.apache.log4j.PatternLayout + + diff --git a/skyeye-ai/pom.xml b/skyeye-ai/pom.xml new file mode 100644 index 00000000..86665e4a --- /dev/null +++ b/skyeye-ai/pom.xml @@ -0,0 +1,38 @@ + + + 4.0.0 + + + com.skyeye + skyeye-parent + 1.0-SNAPSHOT + + + com.skyeye + skyeye-ai + pom + 1.0-SNAPSHOT + + + ai-web + ai-pro + ai-common + + + + + + huaweicloud + huawei + https://mirrors.huaweicloud.com/repository/maven/ + + + aliyunmaven + aliyun + https://maven.aliyun.com/repository/public + + + + \ No newline at end of file From 470e3e26c3a2d16dca87afd94835f80b833c0674 Mon Sep 17 00:00:00 2001 From: SUCH HAVE YOU <2207141659@qq.com> Date: Sat, 5 Oct 2024 20:47:47 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E4=BC=9A=E5=91=98=E7=AD=89?= =?UTF-8?q?=E7=BA=A7=E6=B3=A8=E9=87=8A=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../skyeye/level/controller/ShopMemberLevelController.java | 4 ++-- .../skyeye/level/service/impl/ShopMemberLevelServiceImpl.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/level/controller/ShopMemberLevelController.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/level/controller/ShopMemberLevelController.java index 549db25c..393cadd0 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/level/controller/ShopMemberLevelController.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/level/controller/ShopMemberLevelController.java @@ -62,12 +62,12 @@ public class ShopMemberLevelController { } /** - * 批量删除快递运费费用模版信息 + * 批量删除快递运费费用模版信息[ids] * * @param inputObject 入参以及用户信息等获取对象 * @param outputObject 出参以及提示信息的返回值对象 */ - @ApiOperation(id = "deleteMemberLeveByIds", value = "批量删除快递运费模版信息", method = "DELETE", allUse = "2") + @ApiOperation(id = "deleteMemberLeveByIds", value = "批量删除会员等级信息", method = "DELETE", allUse = "2") @ApiImplicitParams({ @ApiImplicitParam(id = "ids", name = "ids", value = "主键id列表,多个id用逗号分隔", required = "required")}) @RequestMapping("/post/ShopMemberLevelController/deleteMemberLeveByIds") diff --git a/skyeye-shop/shop-store/src/main/java/com/skyeye/level/service/impl/ShopMemberLevelServiceImpl.java b/skyeye-shop/shop-store/src/main/java/com/skyeye/level/service/impl/ShopMemberLevelServiceImpl.java index fa31cba4..b8743df6 100644 --- a/skyeye-shop/shop-store/src/main/java/com/skyeye/level/service/impl/ShopMemberLevelServiceImpl.java +++ b/skyeye-shop/shop-store/src/main/java/com/skyeye/level/service/impl/ShopMemberLevelServiceImpl.java @@ -61,7 +61,7 @@ public class ShopMemberLevelServiceImpl extends SkyeyeBusinessServiceImpl Date: Sat, 5 Oct 2024 21:24:33 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E6=94=AF=E4=BB=98=E6=B8=A0?= =?UTF-8?q?=E9=81=93=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/skyeye/pay/entity/PayChannel.java | 10 ++++++-- .../com/skyeye/pay/service/PayAppService.java | 2 ++ .../skyeye/pay/service/PayChannelService.java | 1 + .../pay/service/impl/PayAppServiceImpl.java | 1 + .../service/impl/PayChannelServiceImpl.java | 25 +++++++++++++++++-- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/entity/PayChannel.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/entity/PayChannel.java index 12b6d585..9fa9528c 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/entity/PayChannel.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/entity/PayChannel.java @@ -9,10 +9,12 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.skyeye.annotation.api.ApiModel; import com.skyeye.annotation.api.ApiModelProperty; +import com.skyeye.annotation.api.Property; import com.skyeye.annotation.cache.RedisCacheField; import com.skyeye.annotation.unique.UniqueField; import com.skyeye.common.constans.RedisConstants; import com.skyeye.common.entity.features.OperatorUserInfo; +import com.skyeye.pay.core.PayClientConfig; import lombok.Data; /** @@ -26,7 +28,7 @@ import lombok.Data; @Data @UniqueField({"codeNum", "appId"}) @RedisCacheField(name = "skyeye:payChannel", cacheTime = RedisConstants.THIRTY_DAY_SECONDS) -@TableName("skyeye_pay_channel") +@TableName(value = "skyeye_pay_channel", autoResultMap = true) @ApiModel("支付渠道实体类") public class PayChannel extends OperatorUserInfo { @@ -50,9 +52,13 @@ public class PayChannel extends OperatorUserInfo { @ApiModelProperty(value = "应用id", required = "required") private String appId; + @TableField(exist = false) + @Property("应用信息") + private PayApp appMation; + @TableField("config") @ApiModelProperty(value = "支付渠道配置", required = "required") - private String config; + private PayClientConfig config; @TableField("remark") @ApiModelProperty(value = "备注") diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayAppService.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayAppService.java index 72d9533f..b7397b55 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayAppService.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayAppService.java @@ -18,5 +18,7 @@ import com.skyeye.pay.entity.PayApp; * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 */ public interface PayAppService extends SkyeyeBusinessService { + void updateEnabled(InputObject inputObject, OutputObject outputObject); + } diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayChannelService.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayChannelService.java index 69a36278..01be5dc2 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayChannelService.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/PayChannelService.java @@ -16,4 +16,5 @@ import com.skyeye.pay.entity.PayChannel; * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 */ public interface PayChannelService extends SkyeyeBusinessService { + } diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayAppServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayAppServiceImpl.java index d6626198..91587b71 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayAppServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayAppServiceImpl.java @@ -50,6 +50,7 @@ public class PayAppServiceImpl extends SkyeyeBusinessServiceImpl queryWrapper = new QueryWrapper<>(); queryWrapper.eq(CommonConstants.ID, id); diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayChannelServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayChannelServiceImpl.java index 14cfc35c..15d53277 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayChannelServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/pay/service/impl/PayChannelServiceImpl.java @@ -12,11 +12,15 @@ import com.skyeye.common.constans.CommonConstants; import com.skyeye.common.object.InputObject; import com.skyeye.exception.CustomException; import com.skyeye.pay.dao.PayChannelDao; -import com.skyeye.pay.entity.PayApp; import com.skyeye.pay.entity.PayChannel; +import com.skyeye.pay.service.PayAppService; import com.skyeye.pay.service.PayChannelService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.Map; + /** * @ClassName: PayChannelServiceImpl * @Description: 支付渠道服务层 @@ -26,9 +30,26 @@ import org.springframework.stereotype.Service; * 注意:本内容仅限购买后使用.禁止私自外泄以及用于其他的商业目的 */ @Service -@SkyeyeService(name = "支付渠道",groupName = "支付渠道") +@SkyeyeService(name = "支付渠道", groupName = "支付渠道") public class PayChannelServiceImpl extends SkyeyeBusinessServiceImpl implements PayChannelService { + @Autowired + private PayAppService payAppService; + + @Override + public List> queryPageDataList(InputObject inputObject) { + List> beans = super.queryPageDataList(inputObject); + payAppService.setMationForMap(beans, "appId", "appMation"); + return beans; + } + + @Override + public PayChannel selectById(String id) { + PayChannel payChannel = super.selectById(id); + payAppService.setDataMation(payChannel, PayChannel::getAppId); + return payChannel; + } + @Override public void updatePrepose(PayChannel payChannel) { QueryWrapper queryWrapper = new QueryWrapper<>();