diff --git a/src/0-core/HuanMeng.DotNetCore/CacheHelper/MemoryCacheHelper.cs b/src/0-core/HuanMeng.DotNetCore/CacheHelper/MemoryCacheHelper.cs
index 8b9758e..15b52f5 100644
--- a/src/0-core/HuanMeng.DotNetCore/CacheHelper/MemoryCacheHelper.cs
+++ b/src/0-core/HuanMeng.DotNetCore/CacheHelper/MemoryCacheHelper.cs
@@ -12,7 +12,7 @@ namespace XLib.DotNetCore.CacheHelper
///
public class MemoryCacheHelper
{
- private static MemoryCache cache = new MemoryCache(new MemoryCacheOptions());
+ public static MemoryCache cache = new MemoryCache(new MemoryCacheOptions());
///
/// 获取缓存
diff --git a/src/0-core/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj b/src/0-core/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj
index 98024de..0a85b54 100644
--- a/src/0-core/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj
+++ b/src/0-core/HuanMeng.DotNetCore/HuanMeng.DotNetCore.csproj
@@ -7,6 +7,7 @@
+
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Category/CategoryBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Category/CategoryBLL.cs
index a3a8658..31c54f6 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Category/CategoryBLL.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Category/CategoryBLL.cs
@@ -69,7 +69,6 @@ namespace HuanMeng.MiaoYu.Code.Category
public BaseResponse>> GetRecommendList()
{
List> recommendDtos = new List>();
-
var menuList = MiaoYuCache.CategoryChildMenuList.Where(it => it.IsEnabled).ToList();
var node = DictionaryInfo.GetDictionariesChildNode(T_Sys_DictionaryEnum.categorymenu);
node.ForEach(_node =>
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs b/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
index 4b6cf83..1f92b9b 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Chat/ChatBLL.cs
@@ -128,6 +128,7 @@ public class ChatBLL : MiaoYuBase
///
public async Task> Message(int characterId, string message)
{
+
ChatMessageDataDto chatListDto = new ChatMessageDataDto();
List chatMessageDtos = new List();
if (TextCensor.TextCensor(message))
@@ -152,6 +153,21 @@ public class ChatBLL : MiaoYuBase
{
throw new ArgumentException("角色不存在");
}
+ if (message.Contains("openai", StringComparison.OrdinalIgnoreCase) || message.Contains("gpt", StringComparison.OrdinalIgnoreCase))
+ {
+ var chatMessage = new ChatMessageDto()
+ {
+ Id = 0,
+ Role = ChatRole.assistant.ToString(),
+ ClaudeType = "text",
+ Content = $"我是{charact.Name}",
+ Timestamp = DateTime.Now,
+ UserIcon = ""
+ };
+ chatMessageDtos.Add(chatMessage);
+ chatListDto.ChatList = chatMessageDtos;
+ return new BaseResponse(ResonseCode.Success, $"", chatListDto);
+ }
if (_UserId == 0)
{
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/HuanMeng.MiaoYu.Code.csproj b/src/0-core/HuanMeng.MiaoYu.Code/HuanMeng.MiaoYu.Code.csproj
index ecff960..b6fefec 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/HuanMeng.MiaoYu.Code.csproj
+++ b/src/0-core/HuanMeng.MiaoYu.Code/HuanMeng.MiaoYu.Code.csproj
@@ -8,6 +8,9 @@
+
+
+
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Other/AppConfigurationExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/Other/AppConfigurationExtend.cs
new file mode 100644
index 0000000..4abd2d4
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Other/AppConfigurationExtend.cs
@@ -0,0 +1,75 @@
+using AgileConfig.Client;
+
+using Alipay.EasySDK.Kernel;
+
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+using XLib.DotNetCore.CacheHelper;
+
+namespace HuanMeng.MiaoYu.Code.Other
+{
+ ///
+ /// app配置项扩展
+ ///
+ public static class AppConfigurationExtend
+ {
+ ///
+ /// 配置数据
+ ///
+ public static ConfigClient AppConfigClient { get; set; }
+
+ ///
+ /// 配置版本号
+ ///
+ public static string AppVersion
+ {
+ get;
+ set;
+ }
+ ///
+ ///
+ ///
+ ///
+ public static void ConfigClient_ConfigChanged(ConfigReloadedArgs args)
+ {
+ if (args.OldConfigs.TryGetValue("Version", out var vresion) && args.NewConfigs.TryGetValue("Version", out var newVersion))
+ {
+ if (vresion != newVersion)
+ {
+ MemoryCacheHelper.cache.Clear();
+ }
+ }
+
+ }
+
+ public static WebApplicationBuilder AddAppConfigClient(this WebApplicationBuilder builder)
+ {
+ var configClient = new ConfigClient(builder.Configuration);
+ builder.Host.UseAgileConfig(configClient, ConfigClient_ConfigChanged);
+ //var config = builder.Configuration;
+ //builder.Host.ConfigureAppConfiguration((context, config) =>
+ // {
+ // //new一个client实例,无参构造会从本地appsettings.json文件读取配置
+ // var configClient = new ConfigClient(context.Configuration);
+ // //使用AddAgileConfig配置一个新的IConfigurationSource
+ // config.AddAgileConfig(configClient);
+ // AppConfigClient = configClient;
+ // ConfigClient_ConfigChanged(null);
+ // //注册配置项修改事件
+ // configClient.ConfigChanged += ConfigClient_ConfigChanged;
+ // });
+
+ return builder;
+
+ }
+
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/Alipay/AlipayPayment.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/Alipay/AlipayPayment.cs
new file mode 100644
index 0000000..83724a5
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/Alipay/AlipayPayment.cs
@@ -0,0 +1,49 @@
+using HuanMeng.MiaoYu.Code.Payment.Contract;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Alipay.EasySDK.Factory;
+using Alipay.EasySDK.Kernel;
+using Alipay.EasySDK.Kernel.Util;
+using Alipay.EasySDK.Payment.FaceToFace.Models;
+
+namespace HuanMeng.MiaoYu.Code.Payment.Alipay
+{
+ ///
+ ///
+ ///
+ public class AlipayPayment : IPayment
+ {
+ public string CreateOrder(string orderId, string productName, string price, params object[] args)
+ {
+ if (string.IsNullOrEmpty(productName))
+ {
+ throw new ArgumentNullException($"产品名称不能为空!");
+ }
+ if (string.IsNullOrEmpty(price))
+ {
+ throw new ArgumentNullException($"价格不能为空!");
+ }
+ if (string.IsNullOrEmpty(orderId))
+ {
+ orderId = Guid.NewGuid().ToString();
+ }
+ //.SetOptions(GetConfig());
+ var response = Factory.Payment.App().Pay(productName, orderId, price);
+ if (ResponseChecker.Success(response))
+ {
+ Console.WriteLine("调用成功");
+ }
+ else
+ {
+ throw new Exception("创建订单失败!");
+ }
+ //.PreCreate("Apple iPhone11 128G", "2234567234890", "5799.00");
+ var zfbOrderId = response.Body;
+ return zfbOrderId;
+ }
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/AlipayPayment.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/AlipayPayment.cs
new file mode 100644
index 0000000..01a0913
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/AlipayPayment.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HuanMeng.MiaoYu.Code.Payment
+{
+ public class AlipayPayment
+ {
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/Contract/IPayment.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/Contract/IPayment.cs
new file mode 100644
index 0000000..a7c595e
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/Contract/IPayment.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HuanMeng.MiaoYu.Code.Payment.Contract
+{
+ ///
+ /// 支付接口
+ ///
+ public interface IPayment
+ {
+ ///
+ /// 创建订单
+ ///
+ /// 订单id
+ /// 产品名称
+ /// 价格
+ /// 其它参数
+ ///
+ string CreateOrder(string orderId, string productName, string price, params object[] args);
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
new file mode 100644
index 0000000..4a5662d
--- /dev/null
+++ b/src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
@@ -0,0 +1,43 @@
+using Alipay.EasySDK.Factory;
+using Alipay.EasySDK.Kernel;
+
+using Microsoft.Extensions.Configuration;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HuanMeng.MiaoYu.Code.Payment
+{
+ ///
+ ///
+ ///
+ public static class PaymentExtend
+ {
+ public static void AddAlipay(IConfiguration configuration)
+ {
+ var x = configuration.GetSection("Payment:AlipayConfig").Get();
+ var config = new Config()
+ {
+ Protocol = "https",
+ GatewayHost = "openapi.alipay.com",
+ SignType = "RSA2",
+ AppId = "<-- 请填写您的AppId,例如:2019091767145019 -->",
+ // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中
+ MerchantPrivateKey = "<-- 请填写您的应用私钥,例如:MIIEvQIBADANB ... ... -->",
+ //MerchantCertPath = "<-- 请填写您的应用公钥证书文件路径,例如:/foo/appCertPublicKey_2019051064521003.crt -->",
+ //AlipayCertPath = "<-- 请填写您的支付宝公钥证书文件路径,例如:/foo/alipayCertPublicKey_RSA2.crt -->",
+ //AlipayRootCertPath = "<-- 请填写您的支付宝根证书文件路径,例如:/foo/alipayRootCert.crt -->",
+
+ // 如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可
+ AlipayPublicKey = "<-- 请填写您的支付宝公钥,例如:MIIBIjANBg... -->",
+
+ //可设置异步通知接收服务地址(可选)
+ NotifyUrl = "<-- 请填写您的支付类接口异步通知接收服务地址,例如:https://www.test.com/callback -->",
+ };
+ Factory.SetOptions(config);
+ }
+ }
+}
diff --git a/src/0-core/HuanMeng.MiaoYu.Code/SysDictionary/DictionaryNetwork/DictionaryInfoServerNetwork.cs b/src/0-core/HuanMeng.MiaoYu.Code/SysDictionary/DictionaryNetwork/DictionaryInfoServerNetwork.cs
index 2d13935..49704e8 100644
--- a/src/0-core/HuanMeng.MiaoYu.Code/SysDictionary/DictionaryNetwork/DictionaryInfoServerNetwork.cs
+++ b/src/0-core/HuanMeng.MiaoYu.Code/SysDictionary/DictionaryNetwork/DictionaryInfoServerNetwork.cs
@@ -22,7 +22,7 @@ namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
///
public class DictionaryInfoServerNetwork : IDictionaryInfoServer
{
- private IConfiguration configuration;
+ private IConfiguration configuration { get; set; }
private IHttpClientFactory httpClientFactory;
///
/// 数据字典
@@ -44,7 +44,7 @@ namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
{
return Dictionarys.Values.ToList();
}
-
+
public List GetDictionaries(ITenantInfo tenantInfo)
{
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.csproj b/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.csproj
index 6687090..4b54bb5 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.csproj
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.csproj
@@ -11,6 +11,7 @@
+
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.http b/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.http
index 386786e..b151fbd 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.http
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/HuanMeng.MiaoYu.WebApi.http
@@ -1,4 +1,4 @@
-@HuanMeng.MiaoYu.WebApi_HostAddress = http://localhost:5083
+@HuanMeng.MiaoYu.WebApi_HostAddress = http://localhost:90
GET {{HuanMeng.MiaoYu.WebApi_HostAddress}}/weatherforecast/
Accept: application/json
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/Program.cs b/src/2-api/HuanMeng.MiaoYu.WebApi/Program.cs
index c5db5ac..0213ebd 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebApi/Program.cs
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/Program.cs
@@ -1,25 +1,29 @@
-using System.Diagnostics;
-using System.Reflection;
-using HuanMeng.MiaoYu.Code.MultiTenantUtil;
+using AgileConfig.Client;
+
+using HuanMeng.DotNetCore.CustomExtension;
using HuanMeng.DotNetCore.MiddlewareExtend;
-using HuanMeng.MiaoYu.WebApi.Base;
-using Microsoft.OpenApi.Models;
+using HuanMeng.DotNetCore.Utility.AssemblyHelper;
+using HuanMeng.MiaoYu.Code.Base;
+using HuanMeng.MiaoYu.Code.JwtUtil;
+using HuanMeng.MiaoYu.Code.MultiTenantUtil;
+using HuanMeng.MiaoYu.Code.Other;
+using HuanMeng.MiaoYu.Code.Payment;
+using HuanMeng.MiaoYu.Code.SysDictionary;
using HuanMeng.MiaoYu.Code.TencentUtile;
using HuanMeng.MiaoYu.Code.Users.UserAccount.VerificationCodeManager;
-using HuanMeng.MiaoYu.Code.JwtUtil;
-using Microsoft.AspNetCore.Authentication.JwtBearer;
-using HuanMeng.DotNetCore.CustomExtension;
-using HuanMeng.MiaoYu.Code.Cache;
-using HuanMeng.MiaoYu.Code.Chat;
-using Serilog;
using HuanMeng.MiaoYu.Model.Dto;
-using System.Text.Json.Serialization;
-using HuanMeng.DotNetCore.Json;
+using HuanMeng.MiaoYu.WebApi.Base;
+
+using Microsoft.AspNetCore.Authentication.JwtBearer;
+using Microsoft.Extensions.Configuration;
+using Microsoft.OpenApi.Models;
+
using Newtonsoft.Json.Serialization;
-using HuanMeng.MiaoYu.Code.SysDictionary;
-using HuanMeng.MiaoYu.Code.Base;
-using HuanMeng.MiaoYu.Code.Other;
-using HuanMeng.DotNetCore.Utility.AssemblyHelper;
+
+using Serilog;
+
+using System.Diagnostics;
+using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
//Log.Logger = new LoggerConfiguration()
// .WriteTo.Console()
@@ -29,11 +33,28 @@ builder.Host.UseSerilog((context, services, configuration) => configuration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext());
+//var config = builder.Configuration;
+builder.AddAppConfigClient();
+//builder.Host.ConfigureAppConfiguration((context, config) =>
+// {
+
+// //new一个client实例,无参构造会从本地appsettings.json文件读取配置
+// var configClient = new ConfigClient(context.Configuration);
+// //使用AddAgileConfig配置一个新的IConfigurationSource
+// config.AddAgileConfig(configClient);
+// AppConfigurationExtend.AppConfigClient = configClient;
+// //找一个变量挂载client实例,以便其他地方可以直接使用实例访问配置
+// //ConfigClient = configClient;
+// //注册配置项修改事件
+// configClient.ConfigChanged += AppConfigurationExtend.ConfigClient_ConfigChanged;
+// });
+
builder.Services.AddSingleton(typeof(ILogger), serviceProvider =>
{
var loggerFactory = serviceProvider.GetRequiredService();
return loggerFactory.CreateLogger();
});
+//PaymentExtend.AddAlipay(builder.Configuration);
// 检索程序集信息
AssemblyInfo assemblyInfo = AssemblyInfoHelper.GetAssemblyInfo();
// Add services to the container.
@@ -64,9 +85,9 @@ builder.Services.AddControllers()
options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; // 忽略循环引用
options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();// 首字母小写(驼峰样式)
options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";// 时间格式化
- #if !DEBUG
+#if !DEBUG
options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.None;
- #endif
+#endif
//options.SerializerSettings.Converters.Add()
// 其他配置...
})
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.Development.json b/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.Development.json
index d3edfbb..6a2b73d 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.Development.json
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.Development.json
@@ -2,7 +2,7 @@
"ConnectionStrings": {
"MiaoYu_SqlServer_Db": "Server=192.168.195.2;Database=MiaoYu;User Id=zpc;Password=zpc;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=True;"
},
-
+
//腾讯云配置
"TencentCloud": {
"SecretId": "AKIDVyMfzKZdZP8zkNyOdsFuSsBJDB7EScs0",
@@ -20,7 +20,7 @@
"TemplateId": "2209122"
}
},
-
+
"AllowedHosts": "*",
//服务器配置
"Kestrel": {
@@ -29,5 +29,11 @@
"Url": "http://*:90"
}
}
+ },
+ "AgileConfig": {
+ "appId": "huanmeng",
+ "secret": "dfa47997-fb5c-b644-3770-880f5e7fb403",
+ "nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
+ "env": "DEV"
}
}
diff --git a/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.json b/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.json
index a329d9f..92d117c 100644
--- a/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.json
+++ b/src/2-api/HuanMeng.MiaoYu.WebApi/appsettings.json
@@ -35,7 +35,7 @@
"path": "../output/logs/error/log-.txt",
"rollingInterval": "Day", //日志文件按天滚动生成。
"restrictedToMinimumLevel": "Error", //写入日志的级别 //包括 Verbose、Debug、Information、Warning、Error 和 Fatal
- "shared": true, //不占用文件
+ "shared": true //不占用文件
// "outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level}] {Message}{NewLine}{Exception}"
}
},
@@ -52,6 +52,7 @@
],
"Enrich": [ "FromLogContext", "WithMachineName", "WithThreadId" ]
},
+ "AllowedHosts": "*",
//腾讯云配置
"TencentCloud": {
"SecretId": "AKIDLbhdP0Vs57yd7QZWu8A2jFbno8JKBUp6",
@@ -82,11 +83,15 @@
"refreshTokenExpiration": 10100
},
- "AllowedHosts": "*",
"SystemConfig": {
- "DictionaryUrl": "https://adminapi.shhuanmeng.com/api/v1/admin/SysDictionary/GetList",
"TextCensorDir": "DataStorage/TextCensor/"
},
+ "AgileConfig": {
+ "appId": "huanmeng",
+ "secret": "dfa47997-fb5c-b644-3770-880f5e7fb403",
+ "nodes": "http://10.0.12.5:94", //多个节点使用逗号分隔
+ "env": "PROD"
+ },
//服务器配置
"Kestrel": {
"Endpoints": {