# Conflicts:
#	ds-wms-service/DS.WMS.Core/System/Method/CommonService.cs
master
ZR20090193-陈敬勇 10 months ago
commit 4bd4aaa202

@ -21,6 +21,8 @@
<PackageReference Include="MediatR.Contracts" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNet.SignalR" Version="2.4.3" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.11" />
<PackageReference Include="NETCore.MailKit" Version="2.1.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NLog" Version="5.2.7" />
@ -28,6 +30,8 @@
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="2.35.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="2.20.1" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Work" Version="2.24.0" />
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="Snowflake.Data" Version="2.1.5" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.132" />
</ItemGroup>

@ -7,7 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.4.132" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.134" />
</ItemGroup>
<ItemGroup>
@ -17,4 +17,6 @@
<ProjectReference Include="..\DS.Module.UserModule\DS.Module.UserModule.csproj" />
</ItemGroup>
</Project>

@ -1,29 +0,0 @@
using Microsoft.Extensions.Configuration;
using SqlSugar;
using System.Configuration;
namespace DS.Module.SqlSugar
{
public class Ds_Repository<T> where T : class, new()
{
private readonly ISqlSugarClient _sqlSugarClient;
private readonly IConfiguration _configuration;
public Ds_Repository(IConfiguration _configuration)
{
var connectionConfig = new ConnectionConfig
{
ConnectionString = _configuration.GetConnectionString("YourConnectionStringName"), // 这里替换为你的连接字符串
DbType = DbType.SqlServer, // 数据库类型
IsAutoCloseConnection = true, // 自动释放数据务,如果存在事务,在事务结束后释放
InitKeyType = InitKeyType.Attribute // 从实体特性中读取主键自增列信息
};
_sqlSugarClient = new SqlSugarClient(connectionConfig);
}
public List<T> GetAll()
{
return _sqlSugarClient.Queryable<T>().ToList();
}
}
}

@ -1,22 +1,23 @@
using Ds.Module.AppStartup;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Builder;
namespace DS.Module.SqlSugar
{
public class SqlSugarAppStartup : Ds_StartupAttribute
[DsStartup(7)]
public class SqlSugarAppStartup : IDynamicStartup
{
public void ConfigureServices(IServiceCollection services)
public void Configure(WebApplication app)
{
// 配置服务
// 其他服务配置...
}
public void Configure(object app)
public void ConfigureServices(WebApplicationBuilder builder)
{
// 配置中间件
// 其他中间件配置...
builder.Services.AddSqlsugarInstall();
}
}
}

@ -1,13 +1,11 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using Microsoft.Extensions.DependencyInjection;
using NLog;
using SqlSugar;
using System.Linq.Dynamic.Core;
using System.Linq.Expressions;
using System.Reflection;
using DS.Module.Core.Data;
using LogLevel = NLog.LogLevel;
namespace DS.Module.SqlSugar;
@ -153,15 +151,15 @@ public static class SqlsugarInstall
{
if (entityInfo.PropertyName == "UpdateTime")
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "UpdateBy" && !user.UserId.IsNullOrEmpty())
entityInfo.SetValue(user.UserId);
if (entityInfo.PropertyName == "UpdateBy" && user != null)
entityInfo.SetValue(user.UserId);
}
};
dbProvider.Aop.OnError = (exp) => //执行SQL 错误事件
{
Logger.Error(DateTime.Now.ToString() + "\r\n" + exp.Sql + "\r\n" + exp.Parametres);
};
//全局过滤租户Id
dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == user.GetTenantId());
//全局软删除过滤
dbProvider.QueryFilter.AddTableFilter<IDeleted>(m => m.Deleted == false);

@ -326,4 +326,6 @@ public class PermissionService : IPermissionService
}
return DataResult.Successed("更新成功!");
}
}

@ -93,7 +93,7 @@ public class UserService : IUserService
// data.CompanyId = "Comcab2d43f60454327af30a131fc1d3abd";
//data.GID = Guid.NewGuid();
var entity = db.Insertable(data).ExecuteReturnEntity();
if (model.RoleIds.Count() > 0)
@ -126,7 +126,7 @@ public class UserService : IUserService
var existRoles = db.Queryable<SysRoleUser>().Where(x => x.UserId == userId).Select(n => n.RoleId)
.ToArray();
IEnumerable<long?> delRoles = existRoles.AsQueryable().Except(model.RoleIds);
if (delRoles.Count() > 0)
{
@ -134,7 +134,7 @@ public class UserService : IUserService
.Where(it => it.UserId == userId && delRoles.Contains(it.RoleId))
.ExecuteCommand();
}
IEnumerable<long?> addRoles = model.RoleIds.AsQueryable().Except(existRoles);
if (addRoles.Count() > 0)
{

@ -7,13 +7,12 @@
[ApiController]
public class CostExchangeRateController : DsBaseController
{
/// <summary>
/// Get
/// 根据ID查询汇率基本信息
/// </summary>
/// <returns></returns>
[HttpGet("GetCostBasic")]
public async Task<IActionResult> GetCostBasic(Guid id)
public async Task<IActionResult> GetCostBasic(long id)
{
var getUserQuery = new CostExchangeRateCommand { Id = id };
@ -21,5 +20,28 @@
return Ok(result);
}
/// <summary>
/// 根据ID删除或者禁用相关的币别
/// </summary>
/// <returns></returns>
[HttpGet("DelCostBasic")]
public async Task<IActionResult> DelCostBasic(long id)
{
var getUserQuery = new CostExchangeForDelCommand { Id = id };
var result = await Mediator.Send(getUserQuery);
return Ok(result);
}
/// <summary>
/// 币别添加
/// </summary>
/// <returns></returns>
[HttpPost("AddForCostBasic")]
public async Task<IActionResult> AddForCostBasic(CostExchangeForAddCommand dto)
{
var result = await Mediator.Send(dto);
return Ok(result);
}
}
}

@ -14,13 +14,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DS.Module.AutofacModule\DS.Module.AutofacModule.csproj" />
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />
<ProjectReference Include="..\Ds.Module.MediatR\Ds.Module.MediatR.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.SqlSugar\DS.Module.SqlSugar.csproj" />
<ProjectReference Include="..\DS.Module.Swagger\DS.Module.Swagger.csproj" />
<ProjectReference Include="..\Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj" />
<ProjectReference Include="..\Ds.WMS.WebCore\Ds.WMS.WebCore.csproj" />
</ItemGroup>
<ItemGroup>

@ -1,32 +1,18 @@
using Ds.WMS.WebCore;
using Microsoft.OpenApi.Models;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddControllers();
// 使用扩展方法来加载其他 Startup 类
//// 注册 SqlSugarClient
builder.Services.AddScoped<SqlSugar.ISqlSugarClient>(provider =>
{
var connectionConfig = new SqlSugar.ConnectionConfig
{
ConnectionString = builder.Configuration.GetConnectionString("YourConnectionStringName"), // 这里替换为你的连接字符串
DbType = SqlSugar.DbType.MySql, // 数据库类型
IsAutoCloseConnection = true, // 自动释放数据务,如果存在事务,在事务结束后释放
InitKeyType = SqlSugar.InitKeyType.Attribute // 从实体特性中读取主键自增列信息
};
var sqlSugarClient = new SqlSugar.SqlSugarClient(connectionConfig);
return sqlSugarClient;
});
// 注册 MediatR 和请求处理器
var assembly = AppDomain.CurrentDomain.Load("Ds.WMS.Finance.MediatR");
builder.Services.AddMediatR(c =>
{
c.RegisterServicesFromAssembly(assembly);
});
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
@ -34,10 +20,13 @@ builder.Services.AddSwaggerGen(c =>
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
});
// 使用动态启动类
builder.UseDynamicStartups();
//builder.Services.AddMediatR(Assembly.GetExecutingAssembly());
var app = builder.Build();
app.UseDynamicStartups();
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
@ -47,6 +36,7 @@ var app = builder.Build();
// 启用中间件服务生成 Swagger 作为 JSON 终结点
app.UseSwagger();
// 启用中间件服务对 swagger-ui指定 Swagger JSON 终结点
app.UseSwaggerUI(c =>
{

@ -5,6 +5,23 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
"testConnection": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_dev"
},
"DBInfo": {
"DefaultDbConnId": "1288018625843826688",
"DefaultDbType": 0,
"DefaultDbString": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_dev",
"DBS": [
{
"ConnId": "1595354960864874496",
"DBType": 1,
"Enabled": false,
"HitRate": 40,
"Connection": "Data Source=47.105.193.36,11435;Initial Catalog=SHIPPINGWEB_JNHJ;Integrated Security=False;Connect Timeout=500;User ID=sa;Password=Ds20040201",
"ProviderName": "System.Data.SqlClient"
}
]
}
}

@ -0,0 +1,18 @@
namespace Ds.Module.AppStartup
{
/// <summary>
///
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class DsStartupAttribute : Attribute
{
public int Order { get; set; }
public DsStartupAttribute(int order)
{
Order = order;
}
}
}

@ -1,104 +0,0 @@
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace Ds.Module.AppStartup
{
/// <summary>
///
/// </summary>
[AttributeUsage(AttributeTargets.Class)]
public class Ds_StartupAttribute : Attribute
{ }
public interface IDs_App_Startup
{
void ConfigureServices(IServiceCollection services);
void Configure(object app);
}
/// <summary>
///
/// </summary>
public static class Ds_App_Startup
{
public static void Run()
{
try
{
var startupTypes = Assembly.GetCallingAssembly().GetTypes()
.Where(type => type.GetCustomAttribute<Ds_StartupAttribute>() != null);
var services = new ServiceCollection();
foreach (var startupType in startupTypes)
{
var startupInstance = Activator.CreateInstance(startupType) as IDs_App_Startup;
startupInstance?.ConfigureServices(services);
}
// 构建 IServiceProvider
var serviceProvider = services.BuildServiceProvider();
foreach (var startupType in startupTypes)
{
var startupInstance = Activator.CreateInstance(startupType);
var configureMethod = startupType.GetMethod("Configure");
if (configureMethod != null)
{
configureMethod.Invoke(startupInstance, new[] { serviceProvider });
}
}
}
catch (Exception ex)
{
// 友好的错误消息和日志记录
Console.WriteLine($"An error occurred: {ex.Message}");
// 日志记录
// Logger.LogError(ex, "An error occurred during startup.");
}
}
}
//// 示例启动类
//[MyFrameworkStartup]
//public class MyFrameworkStartup : IMyFrameworkStartup
//{
// public void ConfigureServices(IServiceCollection services)
// {
// // 配置服务
// services.AddTransient<IMyService, MyService>();
// // 其他服务配置...
// }
// public void Configure(object app)
// {
// // 配置中间件
// // 其他中间件配置...
// }
//}
// 示例服务
//public interface IMyService
//{
// void DoSomething();
//}
//public class MyService : IMyService
//{
// public void DoSomething()
// {
// Console.WriteLine("Doing something...");
// }
//}
//internal class Program
//{
// private static void Main()
// {
// MyFramework.Run();
// }
//}
}

@ -0,0 +1,9 @@
using Microsoft.AspNetCore.Builder;
namespace Ds.Module.AppStartup
{
public interface IDynamicStartup
{
void ConfigureServices(WebApplicationBuilder builder);
void Configure(WebApplication app);
}
}

@ -1,5 +1,4 @@
using System.ComponentModel;
using SqlSugar;
using SqlSugar;
namespace Ds.Modules.DsEntity.Base
{
@ -8,63 +7,64 @@ namespace Ds.Modules.DsEntity.Base
/// <summary>
/// 备注
/// </summary>
[Description("备注")]
[SugarColumn(ColumnDataType = "300")]
public string DsNote { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "备注")]
public string? DsNote { get; set; } = "0qaqq";
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间", InsertServerTime = true)]
public DateTime DsAddTime { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "创建时间")]
public DateTime DsAddTime { get; set; } = DateTime.Now;
/// <summary>
/// 创建人
/// </summary>
[Description("创建人")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")]
public string DsAddUserInfo { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "创建人")]
public string? DsAddUserInfo { get; set; } = "admin";
/// <summary>
/// 修改人
/// </summary>
[Description("修改人")]
[SqlSugar.SugarColumn(IsNullable = true, ColumnDescription = "修改人")]
public string DsUpdateUserInfo { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "修改人")]
public string? DsUpdateUserInfo { get; set; } = "admin";
/// <summary>
/// 更新时间
/// </summary>
[Description("更新时间")]
[SqlSugar.SugarColumn(ColumnDescription = "更新时间", UpdateServerTime = true)]
public DateTime DsUpdateTime { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "更新时间")]
public DateTime DsUpdateTime { get; set; } = DateTime.Now;
/// <summary>
/// 删除
/// </summary>
[Description("删除")]
[SqlSugar.SugarColumn(ColumnDescription = "是否删除")]
public bool DsIsDel { get; set; } = false;
/// <summary>
/// 删除时间
/// </summary>
[Description("删除时间")]
[SqlSugar.SugarColumn(ColumnDescription = "删除时间")]
public DateTime DsDeleteTime { get; set; } = DateTime.Now;
/// <summary>
/// 删除人
/// </summary>
[Description("删除人")]
[SqlSugar.SugarColumn(IsNullable = true, ColumnDescription = "删除人")]
public string DsDeleteUserInfo { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "删除人")]
public string? DsDeleteUserInfo { get; set; } = "admin";
/// <summary>
/// 排序
/// </summary>
public int DsSort { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "排序")]
public int DsSort { get; set; } = 0;
}
/// <summary>
@ -142,16 +142,23 @@ namespace Ds.Modules.DsEntity.Base
/// <typeparam name="Tkey"></typeparam>
public abstract class BaseEntityGuid : BaseComEntity
{
public BaseEntityGuid()
{
var worker = new Snowflake.Core.IdWorker(1, 1);
Id = worker.NextId();
}
/// <summary>
/// 主键ID
/// </summary>
[Description("主键ID")]
[SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")]
public Guid Id { get; set; } = Guid.NewGuid();
[SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")]
public long Id { get; set; }
/// <summary>
/// 租户编号
/// </summary>
public string TenantNumber { get; set; }
[SqlSugar.SugarColumn(ColumnDescription = "租户编号")]
public long TenantNumber { get; set; }
}
}

@ -6,6 +6,11 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="Snowflake.Data" Version="2.1.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
</ItemGroup>

@ -0,0 +1,6 @@
namespace Snowflake
{
internal class Net
{
}
}

@ -8,6 +8,48 @@
/// <summary>
/// 主键
/// </summary>
public Guid Id { get; set; }
public long Id { get; set; }
}
/// <summary>
/// 根据ID删除或者禁用币别
/// </summary>
public class CostExchangeForDelCommand : IRequest<bool>
{
/// <summary>
/// 主键
/// </summary>
public long Id { get; set; }
}
/// <summary>
/// 新增币别
/// </summary>
public class CostExchangeForAddCommand : IRequest<bool>
{
/// <summary>
/// 币别代码
/// </summary>
public string? CodeName { get; set; }
/// <summary>
/// 币别名称
/// </summary>
public string? Name { get; set; }
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
/// </summary>
public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
/// <summary>
/// 财务软件对应代码
/// </summary>
public string? FinanceSoftCodes { get; set; }
}
}

@ -8,7 +8,9 @@
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ds.Module.AppStartup\Ds.Module.AppStartup.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.SqlSugar\DS.Module.SqlSugar.csproj" />
<ProjectReference Include="..\Ds.Modules.DsEntity\Ds.Modules.DsEntity.csproj" />
</ItemGroup>

@ -5,14 +5,112 @@
/// <summary>
/// 主键
/// </summary>
public Guid Id { get; set; }
public long Id { get; set; }
/// <summary>
/// 币别代码
/// </summary>
public string? CodeName { get; set; }
/// <summary>
/// 币别名称
/// </summary>
public string? Name { get; set; }
/// <summary>
/// 描述
/// </summary>
public string? Description { get; set; }
/// <summary>
/// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
/// </summary>
public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
/// <summary>
/// 财务软件对应代码
/// </summary>
public string? FinanceSoftCodes { get; set; }
}
public class AddCurrencyDto
{
}
public class Currency
/// <summary>
/// 币别
/// </summary>
[SugarTable("Ds_Op_Code_Currency")]
public class Code_Currency : BaseEntityGuid
{
/// <summary>
/// 主键
/// 币别代码
/// </summary>
[SugarColumn(ColumnDescription = "币别代码")]
public string? CodeName { get; set; }
/// <summary>
/// 币别名称
/// </summary>
[SugarColumn(ColumnDescription = "币别名称")]
public string? Name { get; set; }
/// <summary>
/// 描述
/// </summary>
[SugarColumn(ColumnDescription = "描述")]
public string? Description { get; set; }
/// <summary>
/// 默认对人民币汇率,录入费用时如果汇率设置里没有设置汇率,提此处汇率
/// </summary>
[SugarColumn(ColumnDescription = "默认对人民币汇率")]
public decimal? DefaultRate { get; set; } = Math.Round(1.123456789m, 8);
/// <summary>
/// 财务软件对应代码
/// </summary>
[SugarColumn(ColumnDescription = "财务软件对应代码")]
public string? FinanceSoftCodes { get; set; }
}
/// <summary>
/// 币别
/// </summary>
[SugarTable("Ds_Op_Currency_Exchange")]
public class Currency_Exchange : BaseEntityGuid
{
/// <summary>
/// /*币别代码*/
/// </summary>
[SugarColumn(ColumnDescription = "币别代码")]
public long Code_Currency_Id { get; set; }
///<summary>
/// *应收汇率*/
/// </summary>
[SugarColumn(ColumnDescription = "应收汇率")]
public decimal Drvalue { get; set; } = Math.Round(1.123456789m, 8);
/// <summary>
/// /*开始日期*/
/// </summary>
[SugarColumn(ColumnDescription = "开始日期")]
public DateTime StartTime { get; set; } = DateTime.Today;
/// <summary>
/// /*结束日期*/
/// </summary>
[SugarColumn(ColumnDescription = "结束日期")]
public DateTime EndTime { get; set; } = DateTime.Today;
/// <summary>
/// /*应付汇率*/
/// </summary>
[SugarColumn(ColumnDescription = "应付汇率")]
public decimal Crvalue { get; set; } = Math.Round(1.123456789m, 8);
/// <summary>
/// 本位币
/// </summary>
[SugarColumn(ColumnDescription = "本位币")]
public string Localcurr { get; set; } = "RMB";
/// <summary>
/// 是否是默认
/// </summary>
public Guid Id { get; set; }
[SugarColumn(ColumnDescription = "是否是默认")]
public bool IsDefault { get; set; } = false;
}
}

@ -1,3 +1,5 @@
global using Ds.WMS.Finance.MediatR.Command;
global using Ds.Modules.DsEntity.Base;
global using Ds.WMS.Finance.MediatR.Command;
global using Ds.WMS.Finance.MediatR.Entity;
global using MediatR;
global using SqlSugar;

@ -0,0 +1,34 @@
using Ds.Module.AppStartup;
using DS.Module.SqlSugar;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
namespace Ds.WMS.Finance.MediatR
{
[DsStartup(10)]
public class MediatRAppStartup : IDynamicStartup
{
public void Configure(WebApplication app)
{
}
public void ConfigureServices(WebApplicationBuilder builder)
{
builder.Services.AddSqlsugarInstall();
var assembly = AppDomain.CurrentDomain.Load("Ds.WMS.Finance.MediatR");
builder.Services.AddMediatR(c =>
{
c.RegisterServicesFromAssembly(assembly);
});
//builder.Services.AddSwaggerGen(c =>
// {
// c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
// var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
// var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
// c.IncludeXmlComments(xmlPath);
// });
}
}
}

@ -1,6 +1,4 @@
using SqlSugar;
namespace Ds.WMS.Finance.MediatR.handlers
namespace Ds.WMS.Finance.MediatR.handlers
{
/// <summary>
/// 具体的业务逻辑
@ -20,11 +18,57 @@ namespace Ds.WMS.Finance.MediatR.handlers
/// <returns></returns>
async Task<CurrencyDto> IRequestHandler<CostExchangeRateCommand, CurrencyDto>.Handle(CostExchangeRateCommand request, CancellationToken cancellationToken)
{
return await _db.Queryable<Currency>()
var list = await _db.Queryable<Code_Currency>()
.Where(x => x.Id == request.Id)
.Select<CurrencyDto>()
.FirstAsync();
return await Task.FromResult(list);
}
}
/// <summary>
/// 添加
/// </summary>
public class AddCostBasicHandler : IRequestHandler<CostExchangeForAddCommand, bool>
{
private readonly ISqlSugarClient _db;
public AddCostBasicHandler(ISqlSugarClient db)
{
_db = db;
}
public async Task<bool> Handle(CostExchangeForAddCommand request, CancellationToken cancellationToken)
{
var list = await _db.Insertable<Code_Currency>(new Code_Currency()
{
CodeName = request.CodeName,
DefaultRate = request.DefaultRate,
Description = request.Description,
FinanceSoftCodes = request.FinanceSoftCodes,
Name = request.Name
}).ExecuteCommandAsync() > 0;
return await Task.FromResult(list);
}
}
/// <summary>
/// 删除
/// </summary>
public class DelCostBasicHandler : IRequestHandler<CostExchangeForDelCommand, bool>
{
private readonly ISqlSugarClient _db;
public DelCostBasicHandler(ISqlSugarClient db)
{
_db = db;
}
public async Task<bool> Handle(CostExchangeForDelCommand request, CancellationToken cancellationToken)
{
var list = await _db.Updateable<Code_Currency>()
.Where(p => p.Id.Equals(request.Id))
.IgnoreColumns(true)
.SetColumns(p => p.DsIsDel == true)
.ExecuteCommandAsync() > 0;
return await Task.FromResult(list);
}
}
}

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Ds.Module.AppStartup\Ds.Module.AppStartup.csproj" />
<ProjectReference Include="..\Ds.Module.MediatR\Ds.Module.MediatR.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.SqlSugar\DS.Module.SqlSugar.csproj" />
<ProjectReference Include="..\Ds.Modules.DsEntity\Ds.Modules.DsEntity.csproj" />
<ProjectReference Include="..\Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,35 @@
using System.Runtime.Loader;
namespace Ds.WMS.WebCore
{
public class LoadAndExecuteAssembly
{
public static void LoadAndExecuteAssemblyF(string assemblyPath)
{
// 创建一个新的AssemblyLoadContext实例来加载程序集
var assemblyLoadContext = new AssemblyLoadContext(null, isCollectible: true);
// 使用AssemblyLoadContext.LoadFromAssemblyPath方法来加载程序集
var assembly = assemblyLoadContext.LoadFromAssemblyPath(assemblyPath);
// 获取程序集中的类型
var types = assembly.GetTypes();
// 遍历类型并执行某些操作
foreach (var type in types)
{
// 这里只是一个示例,你可以根据需要执行其他操作
// 假设我们有一个名为"Execute"的无参数方法
var method = type.GetMethod("Execute");
if (method != null)
{
var instance = Activator.CreateInstance(type);
method.Invoke(instance, null);
}
}
// 卸载程序集
assemblyLoadContext.Unload();
}
}
}

@ -0,0 +1,79 @@
using Ds.Module.AppStartup;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;
namespace Ds.WMS.WebCore
{
/// <summary>
///
/// </summary>
public static class WebApplicationBuilderExtensions
{
public static WebApplicationBuilder UseDynamicStartups(this WebApplicationBuilder builder)
{
var dynamicStartups = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(a => a.GetTypes())
.Select(t =>
new
{
Type = t,
Attribute = t.GetCustomAttribute<DsStartupAttribute>()
})
.Where(x => x.Attribute != null)
.OrderBy(x => x.Attribute.Order)
.Select(x => Activator.CreateInstance(x.Type))
.OfType<IDynamicStartup>();
// var list = AssemblyLoadContext.Default.Assemblies.SelectMany(a => a.GetTypes())
//.Select(t => new
//{
// Type = t,
// Attribute = t.GetCustomAttribute<DsStartupAttribute>()
//})
//// .Where(x => x.Attribute != null)
// .OfType<IDynamicStartup>()
//.ToList();
// var dynamicStartups = AssemblyLoadContext.Default.Assemblies
//.SelectMany(a => a.GetTypes())
//.Select(t => new
//{
// Type = t,
// Attribute = t.GetCustomAttribute<DsStartupAttribute>()
//})
//.Where(x => x.Attribute != null)
//.OrderBy(x => x.Attribute.Order)
//.Select(x => Activator.CreateInstance(x.Type))
//.OfType<IDynamicStartup>();
foreach (var startup in dynamicStartups)
{
startup.ConfigureServices(builder);
}
builder.Services.AddSingleton(dynamicStartups);
return builder;
}
}
public static class WebApplicationExtensions
{
public static WebApplication UseDynamicStartups(this WebApplication app)
{
var dynamicStartups = app.Services.GetRequiredService<IEnumerable<IDynamicStartup>>();
foreach (var startup in dynamicStartups)
{
startup.Configure(app);
}
return app;
}
}
}

@ -51,11 +51,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.Module.Mailkit", "Ds.Mod
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.Modules.DsEntity", "Ds.Modules.DsEntity\Ds.Modules.DsEntity.csproj", "{2DC9559E-AFC4-4C95-88DB-EFF8E04CB03A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DS.WMS.FinanceApi", "DS.WMS.FinanceApi\DS.WMS.FinanceApi.csproj", "{1FC0D999-2532-4999-84B3-CBA55644B7A6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DS.WMS.FinanceApi", "DS.WMS.FinanceApi\DS.WMS.FinanceApi.csproj", "{1FC0D999-2532-4999-84B3-CBA55644B7A6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Finance", "Finance", "{8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ds.WMS.Finance.MediatR", "Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj", "{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.Finance.MediatR", "Ds.WMS.Finance.MediatR\Ds.WMS.Finance.MediatR.csproj", "{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Ds.WMS.WebCore", "Ds.WMS.WebCore\Ds.WMS.WebCore.csproj", "{9FB4A2AF-2414-4258-8B16-287EA3EB098D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -155,6 +157,10 @@ Global
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B}.Release|Any CPU.Build.0 = Release|Any CPU
{9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9FB4A2AF-2414-4258-8B16-287EA3EB098D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -183,6 +189,7 @@ Global
{2DC9559E-AFC4-4C95-88DB-EFF8E04CB03A} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
{1FC0D999-2532-4999-84B3-CBA55644B7A6} = {8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}
{B6DB4CF2-BF1D-49D6-96FB-3B1A2E78062B} = {8A1A89DE-7D82-4771-82F4-BDDB3AA11A4E}
{9FB4A2AF-2414-4258-8B16-287EA3EB098D} = {518DB9B5-80A8-4B2C-8570-52BD406458DE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {66115F23-94B4-43C0-838E-33B5CF77F788}

Loading…
Cancel
Save