张同海 9 months ago
commit 697609c5c9

@ -251,5 +251,18 @@ public static class MultiLanguageConst
public const string CodeLaneImportNoData = "Code_Lane_Import_No_Data";
[Description("存在已导入的航线信息")]
public const string CodeLaneImportAlready = "Code_Lane_Import_Already";
[Description("付费方式已存在")]
public const string CodeFrtExist = "Code_Frt_Exist";
[Description("付费方式导入无数据")]
public const string CodeFrtImportNoData = "Code_Frt_Import_No_Data";
[Description("存在已导入的付费方式")]
public const string CodeFrtImportAlready = "Code_Frt_Import_Already";
[Description("结算方式已存在")]
public const string CodeStlModeExist = "Code_StlMode_Exist";
[Description("结算方式导入无数据")]
public const string CodeStlModeImportNoData = "Code_StlMode_Import_No_Data";
[Description("存在已导入的结算方式")]
public const string CodeStlModeImportAlready = "Code_StlMode_Import_Already";
#endregion
}

@ -19,11 +19,16 @@
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="NLog" Version="5.2.6" />
<PackageReference Include="NLog" Version="5.2.8" />
<PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.123" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.136" />
<PackageReference Include="System.ComponentModel" Version="4.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.7" />
<PackageReference Include="UAParser" Version="3.1.47" />
</ItemGroup>
<ItemGroup>
<Folder Include="Middlewares\" />
</ItemGroup>
</Project>

@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System.ComponentModel;
using System.Reflection;
using Newtonsoft.Json.Linq;
namespace DS.Module.Core.Extensions;
@ -460,4 +461,33 @@ public static partial class Extensions
string[] propertyNames = keyName.Split(".");
return propertyNames.Select(o => type.GetProperty(o)).FirstOrDefault()?.Name;
}
/// <summary>
/// 获取long值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static long GetLongValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return 0;
}
var strVal = jt.ToString();
long rtnVal = 0;
long.TryParse(strVal, out rtnVal);
return rtnVal;
}
/// <summary>
/// Object 转 JSON字符串
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ToJsonString(this object obj)
{
return obj == null ? string.Empty : JsonConvert.SerializeObject(obj);
}
}

@ -4,6 +4,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using NLog;
using System.Text;
using System.Text.RegularExpressions;
using DS.Module.Core.Log;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.Module.Core.Filters;
@ -14,10 +18,13 @@ public class GlobalExceptionsFilter : IExceptionFilter
{
private readonly IHostingEnvironment _env;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public GlobalExceptionsFilter(IHostingEnvironment env)
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
public GlobalExceptionsFilter(IHostingEnvironment env, IServiceProvider serviceProvider)
{
_env = env;
_env = env;
_serviceProvider = serviceProvider;
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
}
public void OnException(ExceptionContext context)
@ -46,6 +53,32 @@ public class GlobalExceptionsFilter : IExceptionFilter
exMsg.AppendLine($"【堆栈跟踪:】{context.Exception.StackTrace}");
// logger.LogError(exMsg.ToString());
Logger.Log(NLog.LogLevel.Error, exMsg.ToString());
#region 写入日志库
var className = context.Exception.TargetSite.DeclaringType?.FullName;
var groupCollection = Regex.Match(className, "<(.*?)>").Groups;
var methodName = "";
if (groupCollection.Count > 1)
{
methodName = groupCollection[1].Value;
}
var exLog = new SysLogException()
{
ClassName = className,
MethodName = methodName,
ExceptionName = context.Exception.Message,
ExceptionMsg = context.Exception.Message,
ExceptionSource = context.Exception.Source,
StackTrace = context.Exception.StackTrace,
ParamsObj = context.Exception.TargetSite.GetParameters().ToString(),
};
db.GetConnection(1288018625843826680).Insertable(exLog).ExecuteCommand();
#endregion
// Logger.Log(NLog.LogLevel.Info, "异常信息:" + JsonConvert.SerializeObject(context.Exception));
//采用log4net 进行错误日志记录
//_loggerHelper.Error(json.Message, WriteLog(json.Message, context.Exception));

@ -0,0 +1,81 @@
using System.Diagnostics;
using System.Security.Claims;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Parser = UAParser.Parser;
namespace DS.Module.Core.Filters;
/// <summary>
/// 操作日志 过滤器
/// </summary>
public class OperationLogFilter: IAsyncActionFilter
{
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
public OperationLogFilter(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
}
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
{
var httpContext = context.HttpContext;
var httpRequest = httpContext.Request;
var sw = new Stopwatch();
sw.Start();
var actionContext = await next();
sw.Stop();
var sw2 = Stopwatch.StartNew();
//判断是否请求成功(没有异常就是请求成功)
var isRequestSucceed = actionContext.Exception == null;
var headers = httpRequest.Headers;
var clientInfo = headers.ContainsKey("User-Agent") ? Parser.GetDefault().Parse(headers["User-Agent"]) : null;
var actionDescriptor = context.ActionDescriptor as ControllerActionDescriptor;
var isWriteLog = false;
//请求异常时记录日志
if (!isRequestSucceed || AppSetting.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool())
{
isWriteLog = true;
}
var res = actionContext.Result?.GetType() == typeof(DataResult) ? actionContext.Result.ToJsonString() : "";
if (isWriteLog)
{
var log = new SysLogOperation()
{
// Name = context.User?.FindFirstValue(ClaimConst.CLAINM_NAME),
Ip = HttpUtil.GetClientIP(httpContext),
Success = isRequestSucceed ? true : false,
Location = HttpUtil.GetRequestUrlAddress(httpRequest),
Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
Url = httpRequest.Path,
ClassName = context.Controller.ToString(),
MethodName = actionDescriptor?.ActionName,
ReqMethod = httpRequest.Method,
Param = context.ActionArguments.Count < 1 ? "" : context.ActionArguments.ToJsonString(),
Result = actionContext.Result.ToJsonString(),
ElapsedTime = sw.ElapsedMilliseconds,
OpTime = DateTime.Now,
};
await db.GetConnection(1288018625843826680).Insertable(log).ExecuteCommandAsync();
httpContext.Response.Headers["CheckTimeActionExecute"] = sw.ElapsedMilliseconds.ToString();
sw2.Stop();
httpContext.Response.Headers["CheckTimeRequestActionFilter"] = sw2.ElapsedMilliseconds.ToString();
}
}
}

@ -0,0 +1,60 @@
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.Module.Core.Log;
/// <summary>
/// 系统审计日志
/// </summary>
[global::SqlSugar.SugarTable("sys_log_audit")]
public class SysLogAudit: BaseTenantModel<long>
{
/// <summary>
/// 主键id
/// </summary>
public long KeyId { get; set; }
/// <summary>
/// sql语句
/// </summary>
[SugarColumn(ColumnDescription = "sql语句", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Sql { get; set; }
/// <summary>
/// 请求参数
/// </summary>
[SugarColumn(ColumnDescription = "请求参数", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Param { get; set; }
/// <summary>
/// 旧值
/// </summary>
[SugarColumn(ColumnDescription = "旧值", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
[SugarColumn(ColumnDescription = "新值", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string NewValue { get; set; }
/// <summary>
/// 业务数据
/// </summary>
[SugarColumn(ColumnDescription = "业务数据", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string AopData { get; set; }
/// <summary>
/// 差异数据
/// </summary>
[SugarColumn(ColumnDescription = "差异数据", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string DiffData { get; set; }
// /// <summary>
// /// 创建人姓名
// /// </summary>
// public string CreateUser { get; set; }
/// <summary>
/// 操作方式:新增、更新、删除
/// </summary>
[SugarColumn(ColumnDescription = "操作方式:新增、更新、删除")]
public string OperateType { get; set; }
}

@ -0,0 +1,74 @@
using System.ComponentModel;
using SqlSugar;
namespace DS.Module.Core.Log;
/// <summary>
/// 异常访问日志
/// </summary>
[global::SqlSugar.SugarTable("sys_log_exception")]
public class SysLogException
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 类名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 方法名称
/// </summary>
public string MethodName { get; set; }
/// <summary>
/// 异常名称
/// </summary>
public string ExceptionName { get; set; }
/// <summary>
/// 异常信息
/// </summary>
[SugarColumn(ColumnDescription = "异常信息", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string ExceptionMsg { get; set; }
/// <summary>
/// 异常源
/// </summary>
[SugarColumn(ColumnDescription = "异常源", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string ExceptionSource { get; set; }
/// <summary>
/// 堆栈信息
/// </summary>
[SugarColumn(ColumnDescription = "堆栈信息", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string StackTrace { get; set; }
/// <summary>
/// 参数对象
/// </summary>
[SugarColumn(ColumnDescription = "参数对象", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string ParamsObj { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Description("创建人")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")]
public string CreateBy { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -0,0 +1,112 @@
using System.ComponentModel;
using SqlSugar;
namespace DS.Module.Core.Log;
/// <summary>
/// 系统操作日志
/// </summary>
[global::SqlSugar.SugarTable("sys_log_operation")]
public class SysLogOperation
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 业务id
/// </summary>
public long? KeyId { get; set; }
/// <summary>
/// 是否执行成功true-是false-否)
/// </summary>
public bool Success { get; set; } = true;
/// <summary>
/// 请求参数
/// </summary>
[SugarColumn(ColumnDescription = "请求参数", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Param { get; set; }
/// <summary>
/// IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Location { get; set; }
/// <summary>
/// 浏览器
/// </summary>
public string Browser { get; set; }
/// <summary>
/// 操作系统
/// </summary>
public string Os { get; set; }
/// <summary>
/// 请求地址
/// </summary>
public string Url { get; set; }
/// <summary>
/// 类名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 方法名称
/// </summary>
public string MethodName { get; set; }
/// <summary>
/// 请求方式GET POST PUT DELETE)
/// </summary>
public string ReqMethod { get; set; }
/// <summary>
/// 返回结果
/// </summary>
[SugarColumn(ColumnDescription = "返回结果", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Result { get; set; }
/// <summary>
/// 耗时(毫秒)
/// </summary>
public long ElapsedTime { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime OpTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
[Description("创建人")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true, ColumnDescription = "创建人")]
public string CreateBy { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -0,0 +1,67 @@
using System.ComponentModel;
using SqlSugar;
namespace DS.Module.Core.Log;
/// <summary>
/// 系统访问日志
/// </summary>
[global::SqlSugar.SugarTable("sys_log_visit")]
public class SysLogVisit
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 访问类型 0 登录 1 登出
/// </summary>
public int LoginType { get; set; }
/// <summary>
/// 是否执行成功true-是false-否)
/// </summary>
public bool Success { get; set; } = true;
/// <summary>
/// 登录Id
/// </summary>
public long UserId { get; set; }
/// <summary>
/// 登录账户
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 用户姓名
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime OpTime { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 创建时间
/// </summary>
[Description("创建时间")]
[SqlSugar.SugarColumn(IsOnlyIgnoreUpdate = true, ColumnDescription = "创建时间")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -0,0 +1,50 @@
using System.Text;
using DS.Module.Core.Extensions;
using Microsoft.AspNetCore.Http;
namespace DS.Module.Core;
/// <summary>
///
/// </summary>
public static class HttpUtil
{
public static string GetClientIP(HttpContext context)
{
var ip = context.Request.Headers["X-Forwarded-For"].ObjToString();
if (string.IsNullOrEmpty(ip))
{
ip = context.Connection.RemoteIpAddress.ObjToString();
}
return ip;
}
/// <summary>
/// 获取响应内容
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
public static async Task<string> GetResponse(HttpResponse response)
{
response.Body.Seek(0, SeekOrigin.Begin);
var text = await new StreamReader(response.Body).ReadToEndAsync();
response.Body.Seek(0, SeekOrigin.Begin);
return text;
}
//
// 摘要:
// 获取完整请求地址
//
// 参数:
// request:
public static string GetRequestUrlAddress(HttpRequest request)
{
return new StringBuilder().Append(request.Scheme).Append("://").Append(request.Host)
.Append(request.PathBase)
.Append(request.Path)
.Append(request.QueryString)
.ToString();
}
}

@ -75,7 +75,7 @@ public class JwtHelper
new Claim(JwtRegisteredClaimNames.Aud, aud), // 接收者
// new Claim("OrgId", data.OrgId), // 公司ID
new Claim("UserName", data.Name), // UserName
new Claim("TenantId", data.TenantId), // 租户ID
};
@ -150,7 +150,10 @@ public class JwtHelper
/// Id
/// </summary>
public string Uid { get; set; }
/// <summary>
/// Name
/// </summary>
public string Name { get; set; }
/// <summary>
/// GID
/// </summary>

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />
<ProjectReference Include="..\DS.Module.Log\DS.Module.Log.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.UserModule\DS.Module.UserModule.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="UAParser" Version="3.1.47" />
</ItemGroup>
</Project>

@ -0,0 +1,193 @@
using System.Diagnostics;
using System.Security.Claims;
using System.Text;
using System.Web;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.UserModule;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using Newtonsoft.Json;
using SqlSugar;
using UAParser;
using Parser = UAParser.Parser;
namespace DS.Module.Middleware;
/// <summary>
/// 中间件
/// 记录用户方访问数据
/// </summary>
public class OperationLogMiddleware
{
/// <summary>
///
/// </summary>
private readonly RequestDelegate _next;
private Stopwatch _stopwatch;
private readonly IUser user;
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
/// <summary>
///
/// </summary>
/// <param name="next"></param>
public OperationLogMiddleware(RequestDelegate next, IServiceProvider serviceProvider)
{
_next = next;
_stopwatch = new Stopwatch();
_serviceProvider = serviceProvider;
user = _serviceProvider.GetRequiredService<IUser>();
db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
}
public async Task InvokeAsync(HttpContext context)
{
if (AppSetting.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool())
{
var api = context.Request.Path.ObjToString().TrimEnd('/').ToLower();
if (context.Request.Path.HasValue
&&
(
context.Request.Path.Value.IndexOf("SignalR", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("swagger", StringComparison.InvariantCultureIgnoreCase) > -1
|| context.Request.Path.Value.IndexOf("HealthCheck", StringComparison.InvariantCultureIgnoreCase) >
-1
)
)
{
await _next(context);
}
var ignoreApis = AppSetting.app("Middleware", "RecordAccessLogs", "IgnoreApis");
// 过滤,只有接口
if (api.Contains("api") && !ignoreApis.Contains(api))
{
_stopwatch.Restart();
HttpRequest request = context.Request;
//判断是否请求成功(没有异常就是请求成功)
var headers = request.Headers;
var clientInfo = headers.ContainsKey("User-Agent")
? Parser.GetDefault().Parse(headers["User-Agent"])
: null;
var isWriteLog = false;
var log = new SysLogOperation()
{
// Name = context.User?.FindFirstValue(ClaimConst.CLAINM_NAME),
Ip = GetClientIP(context),
Location = GetRequestUrlAddress(request),
Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
Url = request.Path,
// ClassName = context.Controller.ToString(),
// MethodName = actionDescriptor?.ActionName,
ReqMethod = request.Method,
OpTime = DateTime.Now,
};
// 获取请求body内容
if (request.Method.ToLower().Equals("post") || request.Method.ToLower().Equals("put"))
{
// 启用倒带功能,就可以让 Request.Body 可以再次读取
request.EnableBuffering();
Stream stream = request.Body;
byte[] buffer = new byte[request.ContentLength.Value];
stream.Read(buffer, 0, buffer.Length);
log.Param = Encoding.UTF8.GetString(buffer);
request.Body.Position = 0;
}
else if (request.Method.ToLower().Equals("get") || request.Method.ToLower().Equals("delete"))
{
log.Param =
HttpUtility.UrlDecode(request.QueryString.ObjToString(), Encoding.UTF8);
}
await _next(context);
// // 获取Response.Body内容
// var originalBodyStream = context.Response.Body;
//
// using (var responseBody = new MemoryStream())
// {
// context.Response.Body = responseBody;
// log.Result = await GetResponse(context.Response);
//
// await responseBody.CopyToAsync(originalBodyStream);
// }
// 响应完成记录时间和存入日志
context.Response.OnCompleted(() =>
{
_stopwatch.Stop();
if (context.Response.StatusCode == 200 && !context.Response.HasStarted)
{
log.Success = true;
}
else
{
log.Success = false;
}
log.ElapsedTime = _stopwatch.ElapsedMilliseconds;
return Task.CompletedTask;
});
}
else
{
await _next(context);
}
}
else
{
await _next(context);
}
}
public static string GetClientIP(HttpContext context)
{
var ip = context.Request.Headers["X-Forwarded-For"].ObjToString();
if (string.IsNullOrEmpty(ip))
{
ip = context.Connection.RemoteIpAddress.ObjToString();
}
return ip;
}
/// <summary>
/// 获取响应内容
/// </summary>
/// <param name="response"></param>
/// <returns></returns>
public async Task<string> GetResponse(HttpResponse response)
{
response.Body.Seek(0, SeekOrigin.Begin);
var text = await new StreamReader(response.Body).ReadToEndAsync();
response.Body.Seek(0, SeekOrigin.Begin);
return text;
}
//
// 摘要:
// 获取完整请求地址
//
// 参数:
// request:
public static string GetRequestUrlAddress(HttpRequest request)
{
return new StringBuilder().Append(request.Scheme).Append("://").Append(request.Host)
.Append(request.PathBase)
.Append(request.Path)
.Append(request.QueryString)
.ToString();
}
}

@ -13,4 +13,8 @@
<ProjectReference Include="..\DS.WMS.Core\DS.WMS.Core.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="UAParser" Version="3.1.47" />
</ItemGroup>
</Project>

@ -9,4 +9,5 @@ public interface IMultiLanguageService
/// <param name="language"></param>
/// <returns></returns>
public string GetMultiLanguageInfo(string multiCode,string language);
}

@ -1,13 +1,21 @@
using System.Diagnostics;
using System.Text;
using System.Web;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using NetTaste;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Parser = UAParser.Parser;
namespace DS.Module.MultiLanguage;
/// <summary>
@ -19,12 +27,14 @@ public class MultiLanguageMiddleware
public IMultiLanguageService _invokeService;
private readonly IServiceProvider _serviceProvider;
private readonly SqlSugarScope db;
private Stopwatch _stopwatch;
public MultiLanguageMiddleware(RequestDelegate next, IServiceProvider serviceProvider)
{
_next = next;
_stopwatch = new Stopwatch();
_serviceProvider = serviceProvider;
_invokeService = _serviceProvider.GetRequiredService<IMultiLanguageService>();
// db = (SqlSugarScope)_serviceProvider.GetRequiredService<ISqlSugarClient>();
}
public async Task Invoke(HttpContext context)
@ -46,9 +56,12 @@ public class MultiLanguageMiddleware
// 过滤,只有接口
if (api.Contains("api"))
{
_stopwatch.Restart();
using (var ms = new MemoryStream())
{
HttpResponse response = context.Response;
HttpRequest request = context.Request;
var originalResponseBody = response.Body;
using var newResponseBody = new MemoryStream();
response.Body = newResponseBody;
@ -58,7 +71,11 @@ public class MultiLanguageMiddleware
await new StreamReader(response.Body).ReadToEndAsync();
var msg = JsonConvert.DeserializeObject<DataResult>(responseBodyText);
var serializerSettings = new JsonSerializerSettings
{
// 设置为驼峰命名
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
};
if (msg.IsNotEmptyOrNull())
{
var type = context.Request.Headers["LanguageType"].FirstOrDefault();
@ -66,11 +83,7 @@ public class MultiLanguageMiddleware
{
type = "CN";
}
var serializerSettings = new JsonSerializerSettings
{
// 设置为驼峰命名
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
};
if (msg.MultiCode.IsNotEmptyOrNull())
{
//多语言处理返回信息
@ -82,8 +95,87 @@ public class MultiLanguageMiddleware
}
}
}
}
// if (AppSetting.app("Middleware", "RecordAccessLogs", "Enabled").ObjToBool())
// {
//
// var headers = request.Headers;
// var clientInfo = headers.ContainsKey("User-Agent")
// ? Parser.GetDefault().Parse(headers["User-Agent"])
// : null;
// var controllerName = string.Empty;
// var endpoint = context.Features.Get<IEndpointFeature>()?.Endpoint;
// if (endpoint is RouteEndpoint routeEndpoint)
// {
// controllerName = routeEndpoint.Metadata.GetMetadata<ControllerActionDescriptor>()?.ControllerName;
// }
// var log = new SysLogOperation()
// {
// // Name = context.User?.FindFirstValue(ClaimConst.CLAINM_NAME),
// Ip = HttpUtil.GetClientIP(context),
// Location = HttpUtil.GetRequestUrlAddress(request),
// Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
// Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
// Url = request.Path,
// ClassName = controllerName,
// MethodName = context.GetRouteData().Values["action"].ToString(),
// ReqMethod = request.Method,
// OpTime = DateTime.Now,
// };
//
// // 获取请求body内容
// if (request.Method.ToLower().Equals("post") || request.Method.ToLower().Equals("put"))
// {
// // 启用倒带功能,就可以让 Request.Body 可以再次读取
// request.EnableBuffering();
// byte[] buffer = new byte[request.ContentLength.Value];
// Stream stream = request.Body;
//
// await stream.ReadAsync(buffer, 0, buffer.Length);
//
//
// // request.Body.Seek(0, SeekOrigin.Begin);
// // using (var reader = new StreamReader(request.Body, Encoding.UTF8))
// // {
// // //改为Async异步读流
// // var data = await reader.ReadToEndAsync();
// // log.Param = data;
// // // var obj = JObject.Parse(log.Param) ;
// // log.KeyId = data.IsNullOrEmpty() ? 0: JObject.Parse(data)?.GetLongValue("Id");
// // }
// request.Body.Position = 0;
// log.Param = Encoding.UTF8.GetString(buffer);
// //TODO 待处理问题 KeyId
// // var obj = JObject.Parse(log.Param) ;
// // if (!log.Param.IsNullOrEmpty())
// // {
// // log.KeyId = JObject.Parse(log.Param)?.GetLongValue("Id");
// // }
// }
// else if (request.Method.ToLower().Equals("get") || request.Method.ToLower().Equals("delete"))
// {
// log.Param =
// HttpUtility.UrlDecode(request.QueryString.ObjToString(), Encoding.UTF8);
// }
//
// _stopwatch.Stop();
//
// if (context.Response.StatusCode == 200 && !context.Response.HasStarted)
// {
// log.Success = true;
// }
// else
// {
// log.Success = false;
// }
//
//
// log.Result = JsonConvert.SerializeObject(msg, Formatting.None, serializerSettings);
// log.ElapsedTime = _stopwatch.ElapsedMilliseconds;
// await db.GetConnection(1288018625843826680).Insertable(log).ExecuteCommandAsync();
// }
byte[] array = Encoding.UTF8.GetBytes(responseBodyText);
using var newBodyStream = new MemoryStream(array);
newBodyStream.Seek(0, SeekOrigin.Begin);
@ -93,4 +185,6 @@ public class MultiLanguageMiddleware
}
}
}
}

@ -37,4 +37,5 @@ public class MultiLanguageService:IMultiLanguageService
return result;
}
}

@ -34,6 +34,7 @@
<PackageReference Include="Snowflake.Data" Version="2.2.0" />
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.136" />
<PackageReference Include="UAParser" Version="3.1.47" />
</ItemGroup>
</Project>

@ -9,6 +9,7 @@
<ItemGroup>
<ProjectReference Include="..\Ds.Module.AppStartup\Ds.Module.AppStartup.csproj" />
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />
<ProjectReference Include="..\DS.Module.Log\DS.Module.Log.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.UserModule\DS.Module.UserModule.csproj" />
<ProjectReference Include="..\Ds.Modules.DsEntity\Ds.Modules.DsEntity.csproj" />
@ -19,4 +20,8 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Log\" />
</ItemGroup>
</Project>

@ -29,4 +29,10 @@ public interface ISaasDbService
/// </summary>
/// <returns></returns>
public SqlSugarScopeProvider GetMasterDbScope();
/// <summary>
/// 获取日志库信息
/// </summary>
/// <returns></returns>
public SqlSugarScopeProvider GetLogDb();
}

@ -62,6 +62,15 @@ public class SaasDbService : ISaasDbService
return db.GetConnection("1288018625843826688");
}
/// <summary>
/// 获取日志库信息
/// </summary>
/// <returns></returns>
public SqlSugarScopeProvider GetLogDb()
{
return db.GetConnectionScope("1288018625843826680");
}
/// <summary>
/// 主库根据Id获取业务库Scope

@ -48,7 +48,7 @@ namespace DS.Module.SqlSugar
builder.Services.AddScoped(typeof(DsDataAppService<>));
//sqlsugar注册
builder.Services.AddSqlsugarInstall();
builder.Services.AddSqlSugarInstall();
}
}
}

@ -0,0 +1,78 @@
using System.Text;
using SqlSugar;
namespace DS.Module.SqlSugar;
/// <summary>
/// sqlsuagr差异帮助类
/// </summary>
public static class SqlSugarDiffUtil
{
/// <summary>
/// 比较两个数据对象的修改内容
/// </summary>
/// <param name="beforeData"></param>
/// <param name="afterData"></param>
/// <returns></returns>
public static DiffLog GetDiff(List<DiffLogTableInfo> beforeData, List<DiffLogTableInfo> afterData)
{
string mianID = null;
if (beforeData != null)
{
var keyCoulumn = beforeData[0].Columns.FirstOrDefault(p => p.IsPrimaryKey == true);
if (keyCoulumn != null)
{
mianID = keyCoulumn.Value.ToString();
}
}
else if (afterData != null)
{
var keyCoulumn = afterData[0].Columns.FirstOrDefault(p => p.IsPrimaryKey == true);
if (keyCoulumn != null)
{
mianID = keyCoulumn.Value.ToString();
}
}
StringBuilder sb = new StringBuilder();
if (beforeData != null && afterData != null)
{
var befroeColumns = beforeData[0].Columns;
var afterCloums = afterData[0].Columns;
foreach (var item in befroeColumns)
{
if (IgnoreColumns.Contains(item.ColumnName))
continue;
var afterItem = afterCloums.FirstOrDefault(p => p.ColumnName == item.ColumnName && !p.Value.Equals(item.Value));
if (afterItem != null)
{
sb.Append($"[字段:{item.ColumnDescription},修改前:{item.Value},修改后:{afterItem.Value}]");
}
}
}
return new DiffLog { Id = mianID, DiffData = sb.ToString() };
}
public class DiffLog
{
/// <summary>
/// 主键Id
/// </summary>
public string Id { get; set; }
/// <summary>
/// 差异数据
/// </summary>
public string DiffData { get; set; }
}
/// <summary>
/// 忽略的字段
/// </summary>
private static readonly List<string> IgnoreColumns = new List<string>()
{
"CreateTime",
"CreateBy",
"UpdateTime",
"UpdateBy",
};
}

@ -1,5 +1,7 @@
using Ds.Modules.DsEntity.log;
using DS.Module.Core;
using Ds.Modules.DsEntity.log;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using Newtonsoft.Json;
using SqlSugar;
@ -46,23 +48,71 @@ namespace DS.Module.SqlSugar
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
{
// 新增操作
SqlsugarHelper.InsertByObjectForSqlsugar(entityInfo, user);
if (entityInfo.OperationType == DataFilterType.InsertByObject)
{
if (entityInfo.PropertyName == "Id")
{
if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(string))
{
entityInfo.SetValue(GuidHelper.GetSnowflakeId());
}
if (entityInfo.EntityColumnInfo.IsPrimarykey && entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
{
var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo.EntityValue);
if (id == null || (long)id == 0)
entityInfo.SetValue(SnowFlakeSingle.Instance.NextId());
}
}
if (entityInfo.PropertyName == "CreateTime")
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "TenantId")
{
var tenantId = ((dynamic)entityInfo.EntityValue).TenantId;
if (tenantId == null || tenantId == 0)
entityInfo.SetValue(user.GetTenantId());
}
if (entityInfo.PropertyName == "CreateBy")
{
if (!user.UserId.IsNullOrEmpty())
{
entityInfo.SetValue(user.UserId);
}
else
{
entityInfo.SetValue(1288018625843826688);
}
}
if (entityInfo.PropertyName == "Deleted")
entityInfo.SetValue(false);
}
// 更新操作
SqlsugarHelper.UpdateByObjectForSqlsugar(entityInfo, user);
if (entityInfo.OperationType == DataFilterType.UpdateByObject)
{
if (entityInfo.PropertyName == "UpdateTime")
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "UpdateBy" && user != null)
entityInfo.SetValue(user.UserId);
}
};
dbProvider.Aop.OnDiffLogEvent = (it) =>
dbProvider.Aop.OnDiffLogEvent = it =>
{
Console.WriteLine("执行更新前更新后:");
//操作前记录 包含: 字段描述 列名 值 表名 表描述
//var editBeforeData = it.BeforeData;//插入Before为null之前还没进库
// //操作后记录 包含: 字段描述 列名 值 表名 表描述
//var editAfterData = it.AfterData;
//var sql = it.Sql;
//var parameter = it.Parameters;
//var data = it.BusinessData;//这边会显示你传进来的对象
//var time = it.Time;
//var diffType = it.DiffType;//enum insert 、update and delete
var editBeforeData = it.BeforeData;//插入Before为null之前还没进库
//操作后记录 包含: 字段描述 列名 值 表名 表描述
var editAfterData = it.AfterData;
var sql = it.Sql;
var parameter = it.Parameters;
var data = it.BusinessData;//这边会显示你传进来的对象
var time = it.Time;
var diffType = it.DiffType;//enum insert 、update and delete
// Sys_Log_DataAop
var log = new Sys_Log_DataAop()
{
@ -76,7 +126,7 @@ namespace DS.Module.SqlSugar
};
Console.WriteLine("执行的sql:" + log);
//Write logic
DbScoped.Sugar.GetConnection(200).Insertable(log).ExecuteCommand();
// DbScoped.Sugar.GetConnection(1288018625843826680).Insertable(log).ExecuteCommand();
};
//全局过滤租户
dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == user.GetTenantId());

@ -80,6 +80,7 @@ namespace DS.Module.SqlSugar
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "UpdateBy" && user != null)
entityInfo.SetValue(user.UserId);
}
}

@ -1,8 +1,11 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.UserModule;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using SqlSugar;
namespace DS.Module.SqlSugar;
@ -31,7 +34,7 @@ public static class SqlsugarInstall
/// </summary>
/// <param name="services">依赖注入服务容器</param>
/// <returns></returns>
public static IServiceCollection AddSqlsugarInstall(this IServiceCollection services)
public static IServiceCollection AddSqlSugarInstall(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
Console.WriteLine("开始加载sqlsugar模块");
@ -80,10 +83,10 @@ public static class SqlsugarInstall
// }
// });
//}
var httpContextAccessor = services.GetService<IHttpContextAccessor>();
var user = services.GetService<IUser>();
if (user.IsNullOrEmpty())
{
var httpContextAccessor = services.GetService<IHttpContextAccessor>();
user = new AspNetUser(httpContextAccessor)
{
UserId = "1288018625843826688",
@ -92,89 +95,130 @@ public static class SqlsugarInstall
OrgId = "1288018625843826688"
};
}
//全局上下文生效
SqlSugarScope sqlSugar = new SqlSugarScope(connectConfigList,
db =>
{
// 封装AOP
SqlsugarAopHelper.AopForSqlsugar(db, user, dbList, connectConfigList);
///*
// * 默认只会配置到第一个数据库,这里按照官方文档进行多数据库/多租户文档的说明进行循环配置
// */
//foreach (var c in connectConfigList)
//{
// var dbProvider = db.GetConnectionScope((string)c.ConfigId);
// var user = services.GetService<IUser>();
// //单例参数配置,所有上下文生效
// dbProvider.Ado.CommandTimeOut = 30;
// dbProvider.Aop.OnLogExecuting = (sql, pars) =>
// {
// Logger.Log(LogLevel.Info,
// DateTime.Now.ToString() + "\r\n" +
// UtilMethods.GetSqlString(c.DbType, sql, pars));
// };
// dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
// {
// // 新增操作
// SqlsugarHelper.InsertByObjectForSqlsugar(entityInfo, user);
// // 更新操作
// SqlsugarHelper.UpdateByObjectForSqlsugar(entityInfo, user);
// //if (entityInfo.OperationType == DataFilterType.InsertByObject)
// //{
// // if (entityInfo.PropertyName == "Id")
// // {
// // if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(string))
// // {
// // entityInfo.SetValue(GuidHelper.GetSnowflakeId());
// // }
// // if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
// // {
// // entityInfo.SetValue(SnowFlakeSingle.Instance.NextId());
// // }
// // }
// // if (entityInfo.PropertyName == "CreateTime")
// // entityInfo.SetValue(DateTime.Now);
// // if (!user.UserId.IsNullOrEmpty())
// // {
// // if (entityInfo.PropertyName == "TenantId")
// // entityInfo.SetValue(user.GetTenantId());
// // }
// // if (entityInfo.PropertyName == "CreateBy")
// // {
// // if (!user.UserId.IsNullOrEmpty())
// // {
// // entityInfo.SetValue(user.UserId);
// // }
// // else
// // {
// // entityInfo.SetValue(1288018625843826688);
// // }
// // }
// // if (entityInfo.PropertyName == "Deleted")
// // entityInfo.SetValue(false);
// //}
// //if (entityInfo.OperationType == DataFilterType.UpdateByObject)
// //{
// // if (entityInfo.PropertyName == "UpdateTime")
// // entityInfo.SetValue(DateTime.Now);
// // 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);
// };
// dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == user.GetTenantId());
// //全局软删除过滤
// dbProvider.QueryFilter.AddTableFilter<IDeleted>(m => m.Deleted == false);
//}
// SqlsugarAopHelper.AopForSqlsugar(db, user, dbList, connectConfigList);
Console.WriteLine("开始加载sqlsugar模块 要走过滤 起了");
foreach (var c in connectConfigList)
{
var dbProvider = db.GetConnectionScope((string)c.ConfigId);
// var user = services.GetService<IUser>();
//单例参数配置,所有上下文生效
dbProvider.Ado.CommandTimeOut = 30;
dbProvider.Aop.OnLogExecuting = (sql, pars) =>
{
//执行前事件
//Logger.Log(LogLevel.Info,
// DateTime.Now.ToString() + "\r\n" +
// UtilMethods.GetSqlString(c.DbType, sql, pars));
Console.WriteLine("执行的sql:" + sql);
};
//数据处理事件
dbProvider.Aop.DataExecuting = (oldValue, entityInfo) =>
{
// 新增操作
if (entityInfo.OperationType == DataFilterType.InsertByObject)
{
if (entityInfo.PropertyName == "Id")
{
if (entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(string))
{
entityInfo.SetValue(GuidHelper.GetSnowflakeId());
}
if (entityInfo.EntityColumnInfo.IsPrimarykey &&
entityInfo.EntityColumnInfo.PropertyInfo.PropertyType == typeof(long))
{
var id = entityInfo.EntityColumnInfo.PropertyInfo.GetValue(entityInfo
.EntityValue);
if (id == null || (long)id == 0)
entityInfo.SetValue(SnowFlakeSingle.Instance.NextId());
}
}
if (entityInfo.PropertyName == "CreateTime")
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "TenantId")
{
var tenantId = ((dynamic)entityInfo.EntityValue).TenantId;
if (tenantId == null || tenantId == 0)
entityInfo.SetValue(user.GetTenantId());
}
if (entityInfo.PropertyName == "CreateBy")
{
if (!user.UserId.IsNullOrEmpty())
{
entityInfo.SetValue(user.UserId);
}
else
{
entityInfo.SetValue(1288018625843826688);
}
}
if (entityInfo.PropertyName == "Deleted")
entityInfo.SetValue(false);
}
// 更新操作
if (entityInfo.OperationType == DataFilterType.UpdateByObject)
{
if (entityInfo.PropertyName == "UpdateTime")
entityInfo.SetValue(DateTime.Now);
if (entityInfo.PropertyName == "UpdateBy" && user != null)
entityInfo.SetValue(user.UserId);
}
};
dbProvider.Aop.OnDiffLogEvent = it =>
{
//排除日志库操作
if (Convert.ToInt64(c.ConfigId) != 1288018625843826680)
{
#region 插入日志审计表
//操作前记录 包含: 字段描述 列名 值 表名 表描述
var editBeforeData = it.BeforeData; //插入Before为null之前还没进库
//操作后记录 包含: 字段描述 列名 值 表名 表描述
var editAfterData = it.AfterData;
var sql = it.Sql;
var parameter = it.Parameters;
var data = it.BusinessData; //这边会显示你传进来的对象
var time = it.Time;
var diffType = it.DiffType; //enum insert 、update and delete
var diffData = SqlSugarDiffUtil.GetDiff(editBeforeData,editAfterData);
var auditData = new SysLogAudit()
{
KeyId =Convert.ToInt64(diffData.Id),
Sql = it.Sql,
Param = JsonConvert.SerializeObject(it.Parameters),
OperateType = diffType.ToString(),
OldValue = JsonConvert.SerializeObject(editAfterData),
NewValue = JsonConvert.SerializeObject(editAfterData),
DiffData = diffData.DiffData,
AopData = JsonConvert.SerializeObject(it.BusinessData),
// CreateUser = user.UserName
};
db.GetConnection(1288018625843826680).Insertable(auditData).ExecuteCommand();
#endregion
}
};
//全局过滤租户
dbProvider.QueryFilter.AddTableFilter<ITenantId>(m => m.TenantId == user.GetTenantId());
//全局过滤机构Id
dbProvider.QueryFilter.AddTableFilter<IOrgId>(m => m.OrgId == user.GetOrgId());
//全局软删除过滤
dbProvider.QueryFilter.AddTableFilter<IDeleted>(m => m.Deleted == false);
}
});
services.AddSingleton<ISqlSugarClient>(sqlSugar); //这边是SqlSugarScope用AddSingleton

@ -33,7 +33,7 @@ public class AspNetUser : IUser
if (_userId == null)
{
var claimValue = GetClaimValueByType("jti").FirstOrDefault();
_userId = claimValue != null ? claimValue.ObjToString() : "东胜软件";
_userId = claimValue != null ? claimValue.ObjToString() : "1288018625843826688";
}
return _userId;
}
@ -42,7 +42,24 @@ public class AspNetUser : IUser
_userId = value;
}
}
private string _userName;
public string UserName
{
get
{
if (_userId == null)
{
var claimValue = GetClaimValueByType("Name").FirstOrDefault();
_userName = claimValue != null ? claimValue.ObjToString() : "管理员";
}
return _userName;
}
set
{
_userName = value;
}
}
public long GetTenantId()
{
var token = GetToken();
@ -226,26 +243,29 @@ public class AspNetUser : IUser
var user = _accessor.HttpContext?.User;
if (user == null || !user.Claims.Any())
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
var token = GetToken();
if (string.IsNullOrEmpty(token))
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
var jwtHandler = new JwtSecurityTokenHandler();
if (!jwtHandler.CanReadToken(token))
{
return GetDefaultUserInfo();
return null;
// return GetDefaultUserInfo();
}
JwtSecurityToken jwtToken = jwtHandler.ReadJwtToken(token);
var userInfoJson = jwtToken.Claims.First().Value;
var userInfo = JsonConvert.DeserializeObject<UserInfo>(userInfoJson);
return userInfo ?? GetDefaultUserInfo();
return userInfo ?? null;
}
private UserInfo GetDefaultUserInfo()
@ -391,10 +411,10 @@ public class AspNetUser : IUser
public List<string> GetClaimValueByType(string ClaimType)
{
var claimsIdentity = GetClaimsIdentity();
if (claimsIdentity == null || !claimsIdentity.Any(item => item.Type == ClaimType))
{
return new List<string> { "jti", "TenantId", "CompanyId", "OrgId" }; // 返回包含默认参数的列表
}
// if (claimsIdentity == null || !claimsIdentity.Any(item => item.Type == ClaimType))
// {
// return new List<string> { "jti", "TenantId", "CompanyId", "OrgId" }; // 返回包含默认参数的列表
// }
return claimsIdentity.Where(item => item.Type == ClaimType).Select(item => item.Value).ToList();
}

@ -16,7 +16,11 @@ public interface IUser
/// 获取用户ID
/// </summary>
string UserId { get; }
/// <summary>
/// 获取用户名称
/// </summary>
string UserName { get; }
/// <summary>
/// 获取公司ID
/// </summary>

@ -0,0 +1,63 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Dtos;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 付费方式服务
/// </summary>
public class CodeFrtController : ApiController
{
private readonly ICodeFrtService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public CodeFrtController(ICodeFrtService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetCodeFrtList")]
public DataResult<List<CodeFrtRes>> GetCodeFrtList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditCodeFrt")]
public DataResult EditCodeFrt([FromBody] CodeFrtReq model)
{
var res = _invokeService.EditCodeFrt(model);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetCodeFrtInfo")]
public DataResult<CodeFrtRes> GetCodeFrtInfo([FromQuery] string id)
{
var res = _invokeService.GetCodeFrtInfo(id);
return res;
}
}

@ -0,0 +1,63 @@
using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Dtos;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 结算方式服务
/// </summary>
public class CodeStlModeController : ApiController
{
private readonly ICodeStlModeService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public CodeStlModeController(ICodeStlModeService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetCodeStlModeList")]
public DataResult<List<CodeStlModeRes>> GetCodeStlModeList([FromBody] PageRequest request)
{
var res = _invokeService.GetListByPage(request);
return res;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
[HttpPost]
[Route("EditCodeStlMode")]
public DataResult EditCodeStlMode([FromBody] CodeStlModeReq model)
{
var res = _invokeService.EditCodeStlMode(model);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetCodeStlModeInfo")]
public DataResult<CodeStlModeRes> GetCodeStlModeInfo([FromQuery] string id)
{
var res = _invokeService.GetCodeStlModeInfo(id);
return res;
}
}

@ -228,7 +228,7 @@ public class CommonController : ApiController
/// <returns></returns>
[HttpGet]
[Route("GetUserFieldSet")]
public DataResult<SysUserFieldSet> GetUserFieldSet([FromQuery] string permissionId)
public DataResult<SysFieldSet> GetUserFieldSet([FromQuery] string permissionId)
{
var res = _invokeService.GetUserFieldSet(permissionId);
return res;

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 审计日志模块
/// </summary>
public class LogAuditController : ApiController
{
private readonly ILogAuditService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public LogAuditController(ILogAuditService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetAuditLogList")]
public DataResult<List<AuditLogRes>> GetAuditLogList([FromBody] PageRequest request)
{
var res = _invokeService.GetAuditLogList(request);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetAuditLogInfo")]
public DataResult<AuditLogRes> GetAuditLogInfo([FromQuery] string id)
{
var res = _invokeService.GetAuditLogInfo(id);
return res;
}
}

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 异常日志模块
/// </summary>
public class LogExceptionController : ApiController
{
private readonly ILogExceptionService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public LogExceptionController(ILogExceptionService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetExceptionLogList")]
public DataResult<List<ExceptionLogRes>> GetExceptionLogList([FromBody] PageRequest request)
{
var res = _invokeService.GetExceptionLogList(request);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetExceptionLogInfo")]
public DataResult<ExceptionLogRes> GetExceptionLogInfo([FromQuery] string id)
{
var res = _invokeService.GetExceptionLogInfo(id);
return res;
}
}

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 操作日志模块
/// </summary>
public class LogOperationController : ApiController
{
private readonly ILogOperationService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public LogOperationController(ILogOperationService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetOperationLogList")]
public DataResult<List<OperationLogRes>> GetOperationLogList([FromBody] PageRequest request)
{
var res = _invokeService.GetOperationLogList(request);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetOperationLogInfo")]
public DataResult<OperationLogRes> GetOperationLogInfo([FromQuery] string id)
{
var res = _invokeService.GetOperationLogInfo(id);
return res;
}
}

@ -0,0 +1,49 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc;
namespace DS.WMS.AdminApi.Controllers;
/// <summary>
/// 访问日志模块
/// </summary>
public class LogVisitController : ApiController
{
private readonly ILogVisitService _invokeService;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="invokeService"></param>
public LogVisitController(ILogVisitService invokeService)
{
_invokeService = invokeService;
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("GetVisitLogList")]
public DataResult<List<VisitLogRes>> GetVisitLogList([FromBody] PageRequest request)
{
var res = _invokeService.GetVisitLogList(request);
return res;
}
/// <summary>
/// 详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet]
[Route("GetVisitLogInfo")]
public DataResult<VisitLogRes> GetVisitLogInfo([FromQuery] string id)
{
var res = _invokeService.GetVisitLogInfo(id);
return res;
}
}

@ -85,4 +85,15 @@ public class VersionController : ApiController
var res = _invokeService.GetTenantVersionUpdateList(request);
return res;
}
/// <summary>
/// 更新租户表差异
/// </summary>
/// <returns></returns>
[HttpPost]
[Route("UpdateSaasTableInfo")]
public DataResult UpdateSaasTableInfo()
{
return _invokeService.UpdateSaasTableInfo();
}
}

@ -495,3 +495,143 @@
2024-03-05 16:16:28.3845 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-05 16:16:28.4056 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-05 16:16:28.4584 Info Configuration initialized.
2024-03-06 17:32:32.6384 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-06 17:32:32.7478 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-06 17:32:32.7775 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-06 17:32:32.8505 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-06 17:32:32.9050 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-06 17:32:32.9277 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-06 17:32:32.9741 Info Configuration initialized.
2024-03-06 17:48:48.0058 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-06 17:48:48.1276 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-06 17:48:48.1640 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-06 17:48:48.2346 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-06 17:48:48.2942 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-06 17:48:48.3183 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-06 17:48:48.3738 Info Configuration initialized.
2024-03-07 11:52:21.9801 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 11:52:22.1448 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 11:52:22.1799 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 11:52:22.3513 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 11:52:22.4135 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 11:52:22.4465 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 11:52:22.5127 Info Configuration initialized.
2024-03-07 13:54:47.3578 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 13:54:47.4420 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 13:54:47.4615 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 13:54:47.4969 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 13:54:47.5247 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 13:54:47.5371 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 13:54:47.5652 Info Configuration initialized.
2024-03-07 14:02:19.4154 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 14:02:19.5301 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 14:02:19.5571 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 14:02:19.5955 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 14:02:19.6261 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 14:02:19.6372 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 14:02:19.6716 Info Configuration initialized.
2024-03-07 14:10:05.4579 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 14:10:05.5399 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 14:10:05.5610 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 14:10:05.5998 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 14:10:05.6270 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 14:10:05.6270 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 14:10:05.6743 Info Configuration initialized.
2024-03-07 14:57:44.2164 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 14:57:44.3419 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 14:57:44.3770 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 14:57:44.4455 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 14:57:44.5012 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 14:57:44.5258 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 14:57:44.5794 Info Configuration initialized.
2024-03-07 15:10:03.0440 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 15:10:03.1644 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 15:10:03.2678 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 15:10:03.3579 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 15:10:03.4251 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 15:10:03.4595 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 15:10:03.5358 Info Configuration initialized.
2024-03-07 15:23:08.4713 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 15:23:08.5323 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 15:23:08.5489 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 15:23:08.5766 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 15:23:08.5996 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 15:23:08.5996 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 15:23:08.6363 Info Configuration initialized.
2024-03-07 15:26:22.7802 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 15:26:22.9054 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 15:26:22.9285 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 15:26:22.9793 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 15:26:23.0153 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 15:26:23.0362 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 15:26:23.0766 Info Configuration initialized.
2024-03-07 16:00:35.9383 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:00:36.0453 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:00:36.0734 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:00:36.1376 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:00:36.1745 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:00:36.1913 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:00:36.2225 Info Configuration initialized.
2024-03-07 16:03:04.6474 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:03:04.7398 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:03:04.7621 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:03:04.8224 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:03:04.8723 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:03:04.8972 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:03:04.9368 Info Configuration initialized.
2024-03-07 16:06:00.6253 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:06:00.6634 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:06:00.6799 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:06:00.6961 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:06:00.7775 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:06:00.8048 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:06:00.8768 Info Configuration initialized.
2024-03-07 16:18:00.3701 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:18:00.4034 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:18:00.4377 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:18:00.4698 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:18:00.5190 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:18:00.5405 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:18:00.6048 Info Configuration initialized.
2024-03-07 16:36:29.2160 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:36:29.2424 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:36:29.2825 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:36:29.3307 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:36:29.3854 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:36:29.4059 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:36:29.4556 Info Configuration initialized.
2024-03-07 16:43:12.1187 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:43:12.2237 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:43:12.2542 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:43:12.3038 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:43:12.3434 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:43:12.3643 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:43:12.4007 Info Configuration initialized.
2024-03-07 16:57:48.6793 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:57:48.7936 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:57:48.8282 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:57:48.8958 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:57:48.9439 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:57:48.9624 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:57:48.9986 Info Configuration initialized.
2024-03-07 16:59:27.7180 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 16:59:27.7454 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 16:59:27.7734 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 16:59:27.8319 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 16:59:27.8969 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 16:59:27.9191 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 16:59:27.9782 Info Configuration initialized.
2024-03-07 17:06:59.5184 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-07 17:06:59.5466 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-07 17:06:59.5776 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-07 17:06:59.6175 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-07 17:06:59.6509 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-07 17:06:59.6681 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-07 17:06:59.7206 Info Configuration initialized.
2024-03-08 17:28:31.2096 Info Registered target NLog.Targets.FileTarget(Name=allfile)
2024-03-08 17:28:31.2588 Info Registered target NLog.Targets.FileTarget(Name=ownFile-web)
2024-03-08 17:28:31.2996 Info Registered target NLog.Targets.ColoredConsoleTarget(Name=console)
2024-03-08 17:28:31.3436 Info NLog, Version=5.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 5.2.8.2366. Product version: 5.2.8+f586f1341c46fa38aaaff4c641e7f0fa7e813943. GlobalAssemblyCache: False
2024-03-08 17:28:31.4061 Info Validating config: TargetNames=console, ownFile-web, ConfigItems=54, FilePath=D:\Code\DS\ds8-solution\ds-wms-service\DS.WMS.AdminApi\bin\Debug\net8.0\nlog.config
2024-03-08 17:28:31.4276 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: allfile
2024-03-08 17:28:31.4898 Info Configuration initialized.

@ -31,7 +31,7 @@ builder.Host
builder.Services.AddAppWebInstal();
builder.Services.AddCorsInstall();
builder.Services.AddUserModuleInstall(); //用户服务
builder.Services.AddSqlsugarInstall();
builder.Services.AddSqlSugarInstall();
builder.Services.AddSwaggerInstall();
builder.Services.AddJwtInstall();
builder.Services.AddSaasDbInstall();//分库服务

@ -22,12 +22,11 @@
"DefaultDbString": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_dev",
"DBS": [
{
"ConnId": "1595354960864874496",
"DBType": 1,
"ConnId": "1288018625843826680",
"DBType": 0,
"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"
"Connection": "server=60.209.125.238;port=32006;uid=root;pwd=Djy@Mysql.test;database=shippingweb8_log"
}
]
},
@ -38,5 +37,11 @@
"Version": "1.0",
"Title": "Wms Admin API",
"Description": "Wms Admin API"
},
"Middleware": {
"RecordAccessLogs": {
"Enabled": true,
"IgnoreApis": "/api/permission/getnavigationbar,/api/monitor/getids4users,/api/monitor/getaccesslogs,/api/monitor/server,/api/monitor/getactiveusers,/api/monitor/server,"
}
}
}

@ -0,0 +1,52 @@
using DS.Module.Core;
using FluentValidation;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 付费方式请求实体
/// </summary>
public class CodeFrtReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 付费方式-英文名称
/// </summary>
public string FrtName { get; set; }= "";
/// <summary>
/// 中文名称
/// </summary>
public string CnName { get; set; }= "";
/// <summary>
/// EDI代码
/// </summary>
public string EdiCode { get; set; } = "";
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class CodeFrtReqValidator : AbstractValidator<CodeFrtReq>
{
/// <summary>
/// 构造函数
/// </summary>
public CodeFrtReqValidator()
{
this.RuleFor(o => o.FrtName)
.NotEmpty().WithName("付费方式-英文名称");
}
}

@ -0,0 +1,39 @@
using DS.Module.Core;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 结算方式信息返回
/// </summary>
public class CodeVesselRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 付费方式-英文名称
/// </summary>
public string FrtName { get; set; }
/// <summary>
/// 中文名称
/// </summary>
public string CnName { get; set; }
/// <summary>
/// EDI代码
/// </summary>
public string EdiCode { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}

@ -0,0 +1,57 @@
using DS.Module.Core;
using FluentValidation;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 结算方式请求实体
/// </summary>
public class CodeStlModeReq
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 结算方式唯一代码
/// </summary>
public string StlCode { get; set; } = "";
/// <summary>
/// 结算方式名称
/// </summary>
public string StlName { get; set; } = "";
/// <summary>
/// 英文名称
/// </summary>
public string EnName { get; set; } = "";
/// <summary>
/// 财务软件代码
/// </summary>
public string FinanceSoftCode { get; set; } = "";
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
}
/// <summary>
/// 验证
/// </summary>
public class CodeStlModeReqValidator : AbstractValidator<CodeStlModeReq>
{
/// <summary>
/// 构造函数
/// </summary>
public CodeStlModeReqValidator()
{
this.RuleFor(o => o.StlCode)
.NotEmpty().WithName("结算方式唯一代码");
this.RuleFor(o => o.StlName)
.NotEmpty().WithName("结算方式名称");
}
}

@ -0,0 +1,42 @@
using DS.Module.Core;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 结算方式返回
/// </summary>
public class CodeStlModeRes
{
/// <summary>
/// 主键Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 结算方式唯一代码
/// </summary>
public string StlCode { get; set; }
/// <summary>
/// 结算方式名称
/// </summary>
public string StlName { get; set; }
/// <summary>
/// 英文名称
/// </summary>
public string EnName { get; set; }
/// <summary>
/// 财务软件代码
/// </summary>
public string FinanceSoftCode { get; set; }
/// <summary>
/// 状态 0 启用 1 禁用
/// </summary>
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
}

@ -3,9 +3,9 @@ using DS.Module.Core;
namespace DS.WMS.Core.Code.Dtos;
/// <summary>
/// 船名信息返回
/// 付费方式返回
/// </summary>
public class CodeVesselRes
public class CodeFrtRes
{
/// <summary>
/// 主键Id
@ -14,7 +14,7 @@ public class CodeVesselRes
/// <summary>
/// 船名
/// </summary>
public string VesselName { get; set; } = "";
public string FrtName { get; set; } = "";
/// <summary>
/// 中文说明
/// </summary>

@ -0,0 +1,34 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Code.Entity;
/// <summary>
/// 付费方式表
/// </summary>
[SqlSugar.SugarTable("op_code_frt","付费方式表")]
public class CodeFrt: BaseModel<long>
{
/// <summary>
/// 付费方式-英文名称
/// </summary>
[SugarColumn(ColumnDescription = "付费方式-英文名称", Length = 100)]
public string FrtName { get; set; }
/// <summary>
/// 中文名称
/// </summary>
[SugarColumn(ColumnDescription = "中文名称", Length = 50)]
public string CnName { get; set; }
/// <summary>
/// EDI代码
/// </summary>
[SugarColumn(ColumnDescription = "EDI代码", Length = 5)]
public string EdiCode { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
[SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}

@ -0,0 +1,39 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Code.Entity;
/// <summary>
/// 结算方式表
/// </summary>
// ReSharper disable once StringLiteralTypo
[SqlSugar.SugarTable("op_code_stlmode","结算方式表")]
public class CodeStlMode: BaseModel<long>
{
/// <summary>
/// 结算方式唯一代码
/// </summary>
[SugarColumn(ColumnDescription = "结算方式唯一代码", Length = 10)]
public string StlCode { get; set; }
/// <summary>
/// 结算方式名称
/// </summary>
[SugarColumn(ColumnDescription = "结算方式名称", Length = 30)]
public string StlName { get; set; }
/// <summary>
/// 英文名称
/// </summary>
[SugarColumn(ColumnDescription = "英文名称", Length = 100)]
public string EnName { get; set; }
/// <summary>
/// 财务软件代码
/// </summary>
[SugarColumn(ColumnDescription = "财务软件代码", Length = 30)]
public string FinanceSoftCode { get; set; }
/// <summary>
/// 状态 0启用 1禁用
/// </summary>
[SugarColumn(ColumnDescription = "状态",DefaultValue = "0")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}

@ -0,0 +1,70 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
namespace DS.WMS.Core.Code.Interface;
public interface ICodeFrtService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeFrtRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult EditCodeFrt(CodeFrtReq req);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<CodeFrtRes> GetCodeFrtInfo(string id);
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeFrtRes>> GetClientListByPage(PageRequest request);
/// <summary>
/// 编辑-客户端
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult EditClientCodeFrt(CodeFrtReq req);
/// <summary>
/// 获取详情 -客户端
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<CodeFrtRes> GetClientCodeFrtInfo(string id);
/// <summary>
/// 获取付费方式列表-基础库
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeFrtRes>> GetCodeFrtList(PageRequest request);
/// <summary>
/// 导入付费方式列表
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult ImportCodeFrt(IdModel req);
/// <summary>
/// 获取当前租户已有的付费方式
/// </summary>
/// <returns></returns>
public DataResult<List<string>> GetExistCodeFrtList();
}

@ -0,0 +1,70 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.WMS.Core.Code.Dtos;
namespace DS.WMS.Core.Code.Interface;
public interface ICodeStlModeService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeStlModeRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult EditCodeStlMode(CodeStlModeReq req);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<CodeStlModeRes> GetCodeStlModeInfo(string id);
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeStlModeRes>> GetClientListByPage(PageRequest request);
/// <summary>
/// 编辑-客户端
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult EditClientCodeStlMode(CodeStlModeReq req);
/// <summary>
/// 获取详情 -客户端
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public DataResult<CodeStlModeRes> GetClientCodeStlModeInfo(string id);
/// <summary>
/// 获取结算方式列表-基础库
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<CodeStlModeRes>> GetCodeStlModeList(PageRequest request);
/// <summary>
/// 导入结算方式列表
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
DataResult ImportCodeStlMode(IdModel req);
/// <summary>
/// 获取当前租户已有的结算方式
/// </summary>
/// <returns></returns>
public DataResult<List<string>> GetExistCodeStlModeList();
}

@ -62,7 +62,7 @@ public class CodeCountryService:ICodeCountryService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeCountryService:ICodeCountryService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodeCtnService:ICodeCtnService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeCtnService:ICodeCtnService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -0,0 +1,169 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Code.Method;
public class CodeFrtService:ICodeFrtService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public CodeFrtService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<CodeFrtRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<CodeFrt>()
.Where(whereList)
.Select<CodeFrtRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditCodeFrt(CodeFrtReq req)
{
if (req.Id == 0)
{
if (db.Queryable<CodeFrt>().Where(x=>x.FrtName == req.FrtName.Trim()).Any())
{
return DataResult.Failed("付费方式已存在!",MultiLanguageConst.CodeFrtExist);
}
var data = req.Adapt<CodeFrt>();
var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<CodeFrt>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<CodeFrtRes> GetCodeFrtInfo(string id)
{
var data = db.Queryable<CodeFrt>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeFrtRes>()
.First();
return DataResult<CodeFrtRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult<List<CodeFrtRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeFrt>()
.Where(whereList)
.Select<CodeFrtRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditClientCodeFrt(CodeFrtReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (tenantDb.Queryable<CodeFrt>().Where(x=>x.FrtName == req.FrtName.Trim()).Any())
{
return DataResult.Failed("付费方式已存在!",MultiLanguageConst.CodeFrtExist);
}
var data = req.Adapt<CodeFrt>();
var entity = tenantDb.Insertable(data).EnableDiffLogEvent().ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<CodeFrt>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<CodeFrtRes> GetClientCodeFrtInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeFrt>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeFrtRes>()
.First();
return DataResult<CodeFrtRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult<List<CodeFrtRes>> GetCodeFrtList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<CodeFrt>().Where(a=>a.Status == StatusEnum.Enable)
.Where(whereList)
.Select<CodeFrtRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult ImportCodeFrt(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeFrt>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
return DataResult.Failed("付费方式导入无数据!",MultiLanguageConst.CodeFrtImportNoData);
}
if (tenantDb.Queryable<CodeFrt>().Where(x =>req.Ids.Contains(x.Id) ).Any())
{
return DataResult.Failed("存在已导入的付费方式!",MultiLanguageConst.CodeFrtImportAlready);
}
tenantDb.Insertable(list).ExecuteCommand();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
/// <summary>
/// 获取当前租户已有的船名
/// </summary>
/// <returns></returns>
public DataResult<List<string>> GetExistCodeFrtList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeFrt>()
.Select(n=>n.Id.ToString())
.ToList();
return DataResult<List<string>>.Success(data);
}
}

@ -63,7 +63,7 @@ public class CodeGoodsService:ICodeGoodsService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -112,7 +112,7 @@ public class CodeGoodsService:ICodeGoodsService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeGoodsTypeService:ICodeGoodsTypeService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeIssueTypeService:ICodeIssueTypeService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodeLanesService:ICodeLanesService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeLanesService:ICodeLanesService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodePackageService:ICodePackageService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodePackageService:ICodePackageService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodePortService:ICodePortService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -100,7 +100,7 @@ public class CodePortService:ICodePortService
var data = req.Adapt<CodePort>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
var entity = tenantDb.Insertable(data).EnableDiffLogEvent().ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}

@ -62,7 +62,7 @@ public class CodeSourceDetailService:ICodeSourceDetailService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeSourceDetailService:ICodeSourceDetailService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class CodeSourceService:ICodeSourceService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -110,7 +110,7 @@ public class CodeSourceService:ICodeSourceService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -0,0 +1,169 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using DS.Module.Core.Extensions;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
using DS.WMS.Core.Code.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.Code.Method;
public class CodeStlModeService:ICodeStlModeService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public CodeStlModeService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<CodeStlModeRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<CodeStlMode>()
.Where(whereList)
.Select<CodeStlModeRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditCodeStlMode(CodeStlModeReq req)
{
if (req.Id == 0)
{
if (db.Queryable<CodeStlMode>().Where(x=>x.StlCode == req.StlCode.Trim()).Any())
{
return DataResult.Failed("结算方式已存在!",MultiLanguageConst.CodeStlModeExist);
}
var data = req.Adapt<CodeStlMode>();
var entity = db.Insertable(data).ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = db.Queryable<CodeStlMode>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<CodeStlModeRes> GetCodeStlModeInfo(string id)
{
var data = db.Queryable<CodeStlMode>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeStlModeRes>()
.First();
return DataResult<CodeStlModeRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult<List<CodeStlModeRes>> GetClientListByPage(PageRequest request)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = tenantDb.Queryable<CodeStlMode>()
.Where(whereList)
.Select<CodeStlModeRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult EditClientCodeStlMode(CodeStlModeReq req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
if (req.Id == 0)
{
if (tenantDb.Queryable<CodeStlMode>().Where(x=>x.StlCode == req.StlCode.Trim()).Any())
{
return DataResult.Failed("结算方式已存在!",MultiLanguageConst.CodeStlModeExist);
}
var data = req.Adapt<CodeStlMode>();
var entity = tenantDb.Insertable(data).EnableDiffLogEvent().ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}
else
{
var info = tenantDb.Queryable<CodeStlMode>().Where(x => x.Id == req.Id).First();
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
public DataResult<CodeStlModeRes> GetClientCodeStlModeInfo(string id)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeStlMode>()
.Where(a => a.Id == long.Parse(id))
.Select<CodeStlModeRes>()
.First();
return DataResult<CodeStlModeRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
public DataResult<List<CodeStlModeRes>> GetCodeStlModeList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<CodeStlMode>().Where(a=>a.Status == StatusEnum.Enable)
.Where(whereList)
.Select<CodeStlModeRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult ImportCodeStlMode(IdModel req)
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var list = db.Queryable<CodeStlMode>().Where(x =>req.Ids.Contains(x.Id) ).ToList();
if (list.Count == 0)
{
return DataResult.Failed("结算方式导入无数据!",MultiLanguageConst.CodeStlModeImportNoData);
}
if (tenantDb.Queryable<CodeStlMode>().Where(x =>req.Ids.Contains(x.Id) ).Any())
{
return DataResult.Failed("存在已导入的结算方式!",MultiLanguageConst.CodeStlModeImportAlready);
}
tenantDb.Insertable(list).ExecuteCommand();
return DataResult.Successed("引入成功!",MultiLanguageConst.DataImportSuccess);
}
/// <summary>
/// 获取当前租户已有的船名
/// </summary>
/// <returns></returns>
public DataResult<List<string>> GetExistCodeStlModeList()
{
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
var data = tenantDb.Queryable<CodeStlMode>()
.Select(n=>n.Id.ToString())
.ToList();
return DataResult<List<string>>.Success(data);
}
}

@ -62,7 +62,7 @@ public class CodeVesselService:ICodeVesselService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -100,7 +100,7 @@ public class CodeVesselService:ICodeVesselService
var data = req.Adapt<CodeVessel>();
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
var entity = tenantDb.Insertable(data).EnableDiffLogEvent().ExecuteReturnEntity();
return DataResult.Successed("添加成功!", entity.Id,MultiLanguageConst.DataCreateSuccess);
}

@ -63,7 +63,7 @@ public class CodeVoynoService:ICodeVoynoService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -112,7 +112,7 @@ public class CodeVoynoService:ICodeVoynoService
info = req.Adapt(info);
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -57,7 +57,7 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}
@ -98,7 +98,7 @@ public class ClientFlowTemplateService : IClientFlowTemplateService
return DataResult.Failed("工作流实例存在引用的流程模板不能删除!",MultiLanguageConst.FlowTemplateDelExistImport);
}
db.Deleteable(info).ExecuteCommand();
db.Deleteable(info).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("删除成功!",MultiLanguageConst.DataDelSuccess);
}

@ -62,7 +62,7 @@ public class FlowInstanceService : IFlowInstanceService
}
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -64,7 +64,7 @@ public class FlowTemplateService:IFlowTemplateService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!");
}
}

@ -0,0 +1,61 @@
using DS.Module.Core;
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 审计日志返回实体
/// </summary>
public class AuditLogRes
{
/// <summary>
/// Id
/// </summary>
public long Id { get; set; }
/// <summary>
/// 业务id
/// </summary>
public long KeyId { get; set; }
/// <summary>
/// sql语句
/// </summary>
public string Sql { get; set; }
/// <summary>
/// 请求参数
/// </summary>
public string Param { get; set; }
/// <summary>
/// 旧值
/// </summary>
public string OldValue { get; set; }
/// <summary>
/// 新值
/// </summary>
public string NewValue { get; set; }
/// <summary>
/// 业务数据
/// </summary>
public string AopData { get; set; }
/// <summary>
/// 差异数据
/// </summary>
public string DiffData { get; set; }
/// <summary>
/// 操作方式:新增、更新、删除
/// </summary>
public string OperateType { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Note { get; set; } = "";
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long TenantId { get; set; }
}

@ -18,9 +18,9 @@ public class DictDataReq
public long TypeId { get; set; }
/// <summary>
/// 字典值编码
/// 字典名称
/// </summary>
public string Code { get; set; }
public string Name { get; set; }
/// <summary>
/// 字典值
@ -63,7 +63,7 @@ public class DictDataReqValidator : AbstractValidator<DictDataReq>
{
this.RuleFor(o => o.Value)
.NotEmpty().WithName("字典值");
this.RuleFor(o => o.Code)
.NotEmpty().WithName("字典值编码");
this.RuleFor(o => o.Name)
.NotEmpty().WithName("字典值名称");
}
}

@ -16,9 +16,9 @@ public class DictDataRes
public long TypeId { get; set; }
/// <summary>
/// 字典值编码
/// 字典名称
/// </summary>
public string Code { get; set; }
public string Name { get; set; }
/// <summary>
/// 字典值

@ -11,9 +11,9 @@ public class DropDownData
public string Value { get; set; }
/// <summary>
/// 编码
/// 名称
/// </summary>
public string Code { get; set; }
public string Name { get; set; }
}
/// <summary>

@ -0,0 +1,59 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 异常日志返回实体
/// </summary>
public class ExceptionLogRes
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 类名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 方法名称
/// </summary>
public string MethodName { get; set; }
/// <summary>
/// 异常名称
/// </summary>
public string ExceptionName { get; set; }
/// <summary>
/// 异常信息
/// </summary>
public string ExceptionMsg { get; set; }
/// <summary>
/// 异常源
/// </summary>
public string ExceptionSource { get; set; }
/// <summary>
/// 堆栈信息
/// </summary>
public string StackTrace { get; set; }
/// <summary>
/// 参数对象
/// </summary>
public string ParamsObj { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateBy { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -0,0 +1,17 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户表单设置请求实体
/// </summary>
public class FormSetReq
{
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 字段设置
/// </summary>
public string Content { get; set; }
}

@ -0,0 +1,17 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 租户表单设置返回实体
/// </summary>
public class FormSetRes
{
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 字段设置
/// </summary>
public string Content { get; set; }
}

@ -0,0 +1,98 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 操作日志返回实体
/// </summary>
public class OperationLogRes
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 主键id
/// </summary>
public long? KeyId { get; set; }
/// <summary>
/// 是否执行成功true-是false-否)
/// </summary>
public bool Success { get; set; } = true;
/// <summary>
/// 请求参数
/// </summary>
public string Param { get; set; }
/// <summary>
/// IP
/// </summary>
public string Ip { get; set; }
/// <summary>
/// 地址
/// </summary>
public string Location { get; set; }
/// <summary>
/// 浏览器
/// </summary>
public string Browser { get; set; }
/// <summary>
/// 操作系统
/// </summary>
public string Os { get; set; }
/// <summary>
/// 请求地址
/// </summary>
public string Url { get; set; }
/// <summary>
/// 类名称
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 方法名称
/// </summary>
public string MethodName { get; set; }
/// <summary>
/// 请求方式GET POST PUT DELETE)
/// </summary>
public string ReqMethod { get; set; }
/// <summary>
/// 返回结果
/// </summary>
public string Result { get; set; }
/// <summary>
/// 耗时(毫秒)
/// </summary>
public long ElapsedTime { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime OpTime { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 创建人
/// </summary>
public string CreateBy { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -0,0 +1,59 @@
namespace DS.WMS.Core.System.Dtos;
/// <summary>
/// 访问日志返回实体
/// </summary>
public class VisitLogRes
{
/// <summary>
/// ID
/// </summary>
public int Id { get; set; }
/// <summary>
/// 访问类型 0 登录 1 登出
/// </summary>
public int LoginType { get; set; }
/// <summary>
/// 是否执行成功true-是false-否)
/// </summary>
public bool Success { get; set; } = true;
/// <summary>
/// 登录Id
/// </summary>
public long UserId { get; set; }
/// <summary>
/// 登录账户
/// </summary>
public string UserCode { get; set; }
/// <summary>
/// 用户姓名
/// </summary>
public string UserName { get; set; }
/// <summary>
/// 操作时间
/// </summary>
public DateTime OpTime { get; set; }
/// <summary>
/// 消息
/// </summary>
public string Message { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
}

@ -19,10 +19,10 @@ public class SysDictData : BaseModel<long>
public string Value { get; set; }
/// <summary>
/// 字典值编码
/// 字典名称
/// </summary>
[SqlSugar.SugarColumn(Length = 50,ColumnDescription="编码")]
public string Code { get; set; }
[SqlSugar.SugarColumn(Length = 50,ColumnDescription="字典名称")]
public string Name { get; set; }
/// <summary>
/// 字典名称(英文)

@ -5,8 +5,8 @@ namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 用户字段设置
/// </summary>
[SqlSugar.SugarTable("sys_user_field")]
public class SysUserFieldSet
[SqlSugar.SugarTable("sys_field_set")]
public class SysFieldSet
{
/// <summary>
/// ID

@ -0,0 +1,31 @@
using SqlSugar;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 租户表单设置
/// </summary>
[SqlSugar.SugarTable("sys_tenant_form_set")]
public class SysFormSet
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 表单设置
/// </summary>
public string Content { get; set; }
}

@ -28,13 +28,13 @@ public class SysVersion: BaseModel<long>
/// <summary>
/// 主库更新内容
/// </summary>
[SugarColumn(ColumnDescription = "主库更新内容", IsNullable = true, Length = 5000)]
[SugarColumn(ColumnDescription = "主库更新内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string MainContent { get; set; }
/// <summary>
/// 租户库更新内容
/// </summary>
[SugarColumn(ColumnDescription = "租户库更新内容", IsNullable = true, Length = 5000)]
[SugarColumn(ColumnDescription = "租户库更新内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string TenantContent { get; set; }
/// <summary>

@ -1,4 +1,5 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
namespace DS.WMS.Core.System.Interface;
@ -10,4 +11,5 @@ public interface IAdminService
/// <returns></returns>
DataResult<dynamic> GetServerInfo();
}

@ -154,7 +154,7 @@ public interface ICommonService
/// </summary>
/// <param name="permissionId"></param>
/// <returns></returns>
public DataResult<SysUserFieldSet> GetUserFieldSet(string permissionId);
public DataResult<SysFieldSet> GetUserFieldSet(string permissionId);
/// <summary>

@ -0,0 +1,30 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface IFormSetService
{
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<FormSetRes>> GetListByPage(PageRequest request);
/// <summary>
/// 编辑
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
DataResult EditFormSet(FormSetReq model);
/// <summary>
/// 获取详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<FormSetRes> GetFormSetInfo(string id);
}

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface ILogAuditService
{
/// <summary>
/// 审计日志列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<AuditLogRes>> GetAuditLogList(PageRequest request);
/// <summary>
/// 审计日志详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<AuditLogRes> GetAuditLogInfo(string id);
}

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface ILogExceptionService
{
/// <summary>
/// 异常日志列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<ExceptionLogRes>> GetExceptionLogList(PageRequest request);
/// <summary>
/// 异常日志详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<ExceptionLogRes> GetExceptionLogInfo(string id);
}

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface ILogOperationService
{
/// <summary>
/// 操作日志列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<OperationLogRes>> GetOperationLogList(PageRequest request);
/// <summary>
/// 操作日志详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<OperationLogRes> GetOperationLogInfo(string id);
}

@ -0,0 +1,23 @@
using DS.Module.Core;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface;
public interface ILogVisitService
{
/// <summary>
/// 访问日志列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
DataResult<List<VisitLogRes>> GetVisitLogList(PageRequest request);
/// <summary>
/// 访问日志详情
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
DataResult<VisitLogRes> GetVisitLogInfo(string id);
}

@ -1,9 +1,11 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Helpers;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
@ -77,7 +79,7 @@ public class AdminService:IAdminService
},
};
return DataResult<dynamic>.Success(data);
}
}
#endregion 获取服务器信息
}

@ -11,6 +11,7 @@ using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
using System.Diagnostics;
using System.Runtime.InteropServices;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Entity;
@ -70,6 +71,7 @@ public class CommonService : ICommonService
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = userInfo.Id.ToString(),
Name = userInfo.UserName,
// OrgId = userInfo.OrgId,
// GID = userInfo.GID,
TenantId = userInfo.TenantId.ToString(),
@ -87,10 +89,10 @@ public class CommonService : ICommonService
{
var userId = long.Parse(user.UserId);
var tenantId = user.GetTenantId();
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = user.UserId,
Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName,
// OrgId = userInfo.OrgId,
// GID = userInfo.GID,
TenantId = tenantId.ToString(),
@ -117,6 +119,16 @@ public class CommonService : ICommonService
it.HomePath = "/analysis";
})
.First();
// var context = IhttpContext.HttpContext;
// var log = new SysLogVisit()
// {
// Ip = HttpUtil.GetClientIP(context),
// Location = HttpUtil.GetRequestUrlAddress(request),
// Browser = clientInfo?.UA.Family + clientInfo?.UA.Major,
// Os = clientInfo?.OS.Family + clientInfo?.OS.Major,
// OpTime = DateTime.Now,
// };
return DataResult<CurrentUserViewModel>.Success(data);
}
@ -268,6 +280,7 @@ public class CommonService : ICommonService
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = user.UserId,
Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName,
TenantId = tenantId.ToString(),
};
var data = new RefreshTokenRes
@ -310,6 +323,7 @@ public class CommonService : ICommonService
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = user.UserId,
Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName,
TenantId = tenantId.ToString(),
};
var data = new RefreshTokenRes
@ -358,11 +372,22 @@ public class CommonService : ICommonService
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = userInfo.Id.ToString(),
Name = userInfo.UserName,
// OrgId = orgRelation.OrgId.ToString(),
TenantId = userInfo.TenantId.ToString(),
};
var token = JwtHelper.Encrypt(tokenModel, false, false);
var visLog = new SysLogVisit()
{
LoginType = 0,
UserName = userInfo.UserName,
UserCode = userInfo.UserCode,
TenantId = userInfo.TenantId,
OpTime = DateTime.Now,
Message = "登录成功"
};
saasService.GetLogDb().Insertable(visLog).ExecuteCommand();
return DataResult<string>.Success(token);
}
@ -383,6 +408,7 @@ public class CommonService : ICommonService
var tokenModel = new JwtHelper.JwtTokenModel
{
Uid = user.UserId,
Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName,
// OrgId = user.GetOrgId().ToString(),
TenantId = tenantId.ToString(),
};
@ -409,6 +435,7 @@ public class CommonService : ICommonService
it.HomePath = "/analysis";
})
.First();
return DataResult<CurrentUserViewModel>.Success(data);
}
@ -440,6 +467,7 @@ public class CommonService : ICommonService
{
Uid = userId,
OrgId = id,
Name = sysUser.UserName,
TenantId = tenantId.ToString(),
};
var token = new RefreshTokenRes
@ -1127,12 +1155,12 @@ public class CommonService : ICommonService
/// </summary>
/// <param name="permissionId"></param>
/// <returns></returns>
public DataResult<SysUserFieldSet> GetUserFieldSet(string permissionId)
public DataResult<SysFieldSet> GetUserFieldSet(string permissionId)
{
var info = db.Queryable<SysUserFieldSet>()
var info = db.Queryable<SysFieldSet>()
.Where(x => x.UserId == long.Parse(user.UserId) && x.PermissionId == long.Parse(permissionId)).First();
return DataResult<SysUserFieldSet>.Success(info);
return DataResult<SysFieldSet>.Success(info);
}
/// <summary>
@ -1142,12 +1170,12 @@ public class CommonService : ICommonService
/// <returns></returns>
public DataResult UpdateUserFieldSet(UserFieldSetUpdateReq req)
{
var info = db.Queryable<SysUserFieldSet>()
var info = db.Queryable<SysFieldSet>()
.Where(x => x.UserId == long.Parse(user.UserId) && x.PermissionId == req.PermissionId).First();
if (info.IsNull())
{
var entity = new SysUserFieldSet
var entity = new SysFieldSet
{
UserId = long.Parse(user.UserId),
PermissionId = req.PermissionId,
@ -1194,8 +1222,8 @@ public class CommonService : ICommonService
: db.Queryable<SysDictData>().Where(x => x.TypeId == type.Id && x.Status == StatusEnum.Enable)
.Select(x => new DropDownData
{
Code = x.Code,
Value = x.EnName,
Name = x.EnName,
Value = x.Value,
}).ToList();
return DataResult.Successed("获取字典成功!", data);
@ -1231,8 +1259,8 @@ public class CommonService : ICommonService
: db.Queryable<SysDictData>().Where(x => x.TypeId == item.Id && x.Status == StatusEnum.Enable)
.Select(x => new DropDownData
{
Code = x.Code,
Value = x.EnName,
Name = x.EnName,
Value = x.Value,
}).ToList()
};
list.Add(temp);

@ -68,7 +68,7 @@ public class ConfigService : IConfigService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -69,7 +69,7 @@ public class DataRuleService : IDataRuleService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -0,0 +1,88 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class FormSetService : IFormSetService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public FormSetService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
}
/// <summary>
/// 列表
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public DataResult<List<FormSetRes>> GetListByPage(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = db.Queryable<SysFormSet>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(whereList)
.Select<FormSetRes>().ToQueryPage(request.PageCondition);
return data;
}
/// <summary>
/// 编辑
/// </summary>
/// <param name="req"></param>
/// <returns></returns>
public DataResult EditFormSet(FormSetReq req)
{
var info = db.Queryable<SysFormSet>()
.Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == req.PermissionId).First();
if (info.IsNull())
{
var entity = new SysFormSet
{
TenantId = long.Parse(user.TenantId),
PermissionId = req.PermissionId,
Content = req.Content
};
db.Insertable(entity).ExecuteCommand();
}
else
{
info.Content = req.Content;
db.Updateable(info).ExecuteCommand();
}
return DataResult.Successed("更新成功",MultiLanguageConst.DataUpdateSuccess);
}
/// <summary>
/// 详情
/// </summary>
/// <param name="permissionId"></param>
/// <returns></returns>
public DataResult<FormSetRes> GetFormSetInfo(string permissionId)
{
var data = db.Queryable<SysFormSet>()
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
.Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == long.Parse(permissionId))
.Select<FormSetRes>()
.First();
return DataResult<FormSetRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}

@ -62,7 +62,7 @@ public class LanguageSetService:ILanguageSetService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!");
}
}

@ -0,0 +1,51 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class LogAuditService : ILogAuditService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public LogAuditService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<AuditLogRes>> GetAuditLogList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = saasService.GetLogDb().Queryable<SysLogAudit>().Filter(null,true)
.Where(whereList)
.Select<AuditLogRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult<AuditLogRes> GetAuditLogInfo(string id)
{
var data = saasService.GetLogDb().Queryable<SysLogAudit>().Filter(null,true)
.Where(a => a.Id == long.Parse(id))
.Select<AuditLogRes>()
.First();
return DataResult<AuditLogRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}

@ -0,0 +1,51 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class LogExceptionService : ILogExceptionService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public LogExceptionService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<ExceptionLogRes>> GetExceptionLogList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = saasService.GetLogDb().Queryable<SysLogException>().Filter(null,true)
.Where(whereList)
.Select<ExceptionLogRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult<ExceptionLogRes> GetExceptionLogInfo(string id)
{
var data = saasService.GetLogDb().Queryable<SysLogException>().Filter(null,true)
.Where(a => a.Id == long.Parse(id))
.Select<ExceptionLogRes>()
.First();
return DataResult<ExceptionLogRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}

@ -0,0 +1,51 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class LogOperationService : ILogOperationService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public LogOperationService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<OperationLogRes>> GetOperationLogList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = saasService.GetLogDb().Queryable<SysLogOperation>().Filter(null,true)
.Where(whereList)
.Select<OperationLogRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult<OperationLogRes> GetOperationLogInfo(string id)
{
var data = saasService.GetLogDb().Queryable<SysLogOperation>().Filter(null,true)
.Where(a => a.Id == long.Parse(id))
.Select<OperationLogRes>()
.First();
return DataResult<OperationLogRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}

@ -0,0 +1,51 @@
using DS.Module.Core;
using DS.Module.Core.Extensions;
using DS.Module.Core.Log;
using DS.Module.SqlSugar;
using DS.Module.UserModule;
using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
using DS.WMS.Core.System.Interface;
using Mapster;
using Microsoft.Extensions.DependencyInjection;
using SqlSugar;
namespace DS.WMS.Core.System.Method;
public class LogVisitService : ILogVisitService
{
private readonly IServiceProvider _serviceProvider;
private readonly ISqlSugarClient db;
private readonly IUser user;
private readonly ISaasDbService saasService;
/// <summary>
///
/// </summary>
/// <param name="serviceProvider"></param>
public LogVisitService(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
}
public DataResult<List<VisitLogRes>> GetVisitLogList(PageRequest request)
{
//序列化查询条件
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
var data = saasService.GetLogDb().Queryable<SysLogVisit>().Filter(null,true)
.Where(whereList)
.Select<VisitLogRes>().ToQueryPage(request.PageCondition);
return data;
}
public DataResult<VisitLogRes> GetVisitLogInfo(string id)
{
var data = saasService.GetLogDb().Queryable<SysLogVisit>().Filter(null,true)
.Where(a => a.Id == long.Parse(id))
.Select<VisitLogRes>()
.First();
return DataResult<VisitLogRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
}
}

@ -124,7 +124,7 @@ public class PermissionService : IPermissionService
var info = db.Queryable<SysPermission>().Where(x => x.Id == model.Id).First();
var data = model.Adapt(info);
db.Updateable(data).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(data).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
// db.Updateable(info).IgnoreColumns(ignoreAllNullColumns:true).IgnoreColumns(u => new { u.AddBy,u.CreateTime }).ExecuteCommand();
return DataResult.Successed("更新权限成功!");

@ -68,7 +68,7 @@ public class SequenceRuleService : ISequenceRuleService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -69,7 +69,7 @@ public class SequenceService : ISequenceService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -41,7 +41,7 @@ public class SysDictDataService:ISysDictDataService
{
if (req.Id == 0)
{
var isExist = db.Queryable<SysDictData>().Where(x =>x.TypeId == req.TypeId && x.Code == req.Code).First();
var isExist = db.Queryable<SysDictData>().Where(x =>x.TypeId == req.TypeId && x.Value == req.Value).First();
if (isExist != null)
{
return DataResult.Failed("字典值唯一编码已存在!",MultiLanguageConst.DictCodeExist);
@ -59,7 +59,7 @@ public class SysDictDataService:ISysDictDataService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

@ -62,7 +62,7 @@ public class SysDictTypeService:ISysDictTypeService
info = req.Adapt(info);
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
return DataResult.Successed("更新成功!",MultiLanguageConst.DataUpdateSuccess);
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save