From fb245f04af0c848128da7d14c61694736b4afde7 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期四, 20 十一月 2025 14:50:46 +0800
Subject: [PATCH] Merge branch 'dev-818-3.4.2.12' of http://120.26.58.240:8888/r/ApiTools into dev-818-3.4.2.12
---
ApiTools.Application/WxUtils/Commands/SaveWxSettingCommandHandler.cs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/ApiTools.Application/WxUtils/Commands/SaveWxSettingCommandHandler.cs b/ApiTools.Application/WxUtils/Commands/SaveWxSettingCommandHandler.cs
new file mode 100644
index 0000000..7267a12
--- /dev/null
+++ b/ApiTools.Application/WxUtils/Commands/SaveWxSettingCommandHandler.cs
@@ -0,0 +1,53 @@
+锘縰sing ApiTools.Core;
+using Furion.DatabaseAccessor;
+using Mapster;
+using MediatR;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ApiTools.CommonServer.Application
+{
+ public class SaveWxSettingCommandHandler(IRepository<WxSetting> rep) :IRequestHandler<SaveWxSettingCommand, Guid>
+ {
+ private readonly IRepository<WxSetting> rep = rep;
+
+ /// <summary>
+ /// 淇濆瓨寰俊閰嶇疆
+ /// </summary>
+ /// <param name="request"></param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public async Task<Guid> Handle(SaveWxSettingCommand request, CancellationToken cancellationToken)
+ {
+ var logier = JwtUtils.GetCurrentLogier();
+ var entity = await rep.AsQueryable()
+ .Where(it => it.Code == request.Code)
+ .FirstOrDefaultAsync();
+ var add = false;
+ if (entity == null)
+ {
+ entity = new WxSetting();
+ entity.Code = request.Code;
+ entity.AppId = request.AppId;
+ entity.AppSecret = request.AppSecret;
+ entity.EnvVersion = request.EnvVersion;
+ add = true;
+ }
+ request.Adapt(entity);
+ if (add)
+ {
+ await rep.InsertAsync(entity);
+ }
+ else
+ {
+ await rep.UpdateAsync(entity);
+ }
+ return entity.Id;
+ //return Guid.NewGuid();
+ }
+ }
+}
--
Gitblit v1.9.1