提交代码
This commit is contained in:
parent
995ec10239
commit
c9f8d868e8
|
|
@ -12,7 +12,7 @@ namespace XLib.DotNetCore.CacheHelper
|
|||
/// </summary>
|
||||
public class MemoryCacheHelper
|
||||
{
|
||||
private static MemoryCache cache = new MemoryCache(new MemoryCacheOptions());
|
||||
public static MemoryCache cache = new MemoryCache(new MemoryCacheOptions());
|
||||
|
||||
/// <summary>
|
||||
/// 获取缓存
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AlipayEasySDK.Kernel" Version="1.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.1.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ namespace HuanMeng.MiaoYu.Code.Category
|
|||
public BaseResponse<List<RecommendDto<DataListBaseDto>>> GetRecommendList()
|
||||
{
|
||||
List<RecommendDto<DataListBaseDto>> recommendDtos = new List<RecommendDto<DataListBaseDto>>();
|
||||
|
||||
var menuList = MiaoYuCache.CategoryChildMenuList.Where(it => it.IsEnabled).ToList();
|
||||
var node = DictionaryInfo.GetDictionariesChildNode(T_Sys_DictionaryEnum.categorymenu);
|
||||
node.ForEach(_node =>
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ public class ChatBLL : MiaoYuBase
|
|||
/// <exception cref="ArgumentException"></exception>
|
||||
public async Task<BaseResponse<ChatMessageDataDto>> Message(int characterId, string message)
|
||||
{
|
||||
|
||||
ChatMessageDataDto chatListDto = new ChatMessageDataDto();
|
||||
List<ChatMessageDto> chatMessageDtos = new List<ChatMessageDto>();
|
||||
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<ChatMessageDataDto>(ResonseCode.Success, $"", chatListDto);
|
||||
}
|
||||
|
||||
if (_UserId == 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AgileConfig.Client" Version="1.7.3" />
|
||||
<PackageReference Include="AlipayEasySDK" Version="2.1.3" />
|
||||
<PackageReference Include="AlipayEasySDK.Kernel" Version="1.0.6" />
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.6" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
|
||||
|
|
|
|||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// app配置项扩展
|
||||
/// </summary>
|
||||
public static class AppConfigurationExtend
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据
|
||||
/// </summary>
|
||||
public static ConfigClient AppConfigClient { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 配置版本号
|
||||
/// </summary>
|
||||
public static string AppVersion
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
src/0-core/HuanMeng.MiaoYu.Code/Payment/AlipayPayment.cs
Normal file
12
src/0-core/HuanMeng.MiaoYu.Code/Payment/AlipayPayment.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
}
|
||||
}
|
||||
24
src/0-core/HuanMeng.MiaoYu.Code/Payment/Contract/IPayment.cs
Normal file
24
src/0-core/HuanMeng.MiaoYu.Code/Payment/Contract/IPayment.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 支付接口
|
||||
/// </summary>
|
||||
public interface IPayment
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建订单
|
||||
/// </summary>
|
||||
/// <param name="orderId">订单id</param>
|
||||
/// <param name="productName">产品名称</param>
|
||||
/// <param name="price">价格</param>
|
||||
/// <param name="args">其它参数</param>
|
||||
/// <returns></returns>
|
||||
string CreateOrder(string orderId, string productName, string price, params object[] args);
|
||||
}
|
||||
}
|
||||
43
src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
Normal file
43
src/0-core/HuanMeng.MiaoYu.Code/Payment/PaymentExtend.cs
Normal file
|
|
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class PaymentExtend
|
||||
{
|
||||
public static void AddAlipay(IConfiguration configuration)
|
||||
{
|
||||
var x = configuration.GetSection("Payment:AlipayConfig").Get<Config>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
|
|||
/// </summary>
|
||||
public class DictionaryInfoServerNetwork : IDictionaryInfoServer
|
||||
{
|
||||
private IConfiguration configuration;
|
||||
private IConfiguration configuration { get; set; }
|
||||
private IHttpClientFactory httpClientFactory;
|
||||
/// <summary>
|
||||
/// 数据字典
|
||||
|
|
@ -44,7 +44,7 @@ namespace HuanMeng.MiaoYu.Code.SysDictionary.DictionaryNetwork
|
|||
{
|
||||
return Dictionarys.Values.ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<T_Sys_Dictionary> GetDictionaries(ITenantInfo tenantInfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AgileConfig.Client" Version="1.7.3" />
|
||||
<PackageReference Include="AutoMapper" Version="13.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<MiaoYuBase>), serviceProvider =>
|
||||
{
|
||||
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
|
||||
return loggerFactory.CreateLogger<MiaoYuBase>();
|
||||
});
|
||||
//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()
|
||||
// 其他配置...
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user