!81 修复域名转发获取ip地址长度过长问题。

* !80 修复域名转发获取ip地址长度过长问题。
* !78 修复mysql数据库遗留问题
* !76 调整全局错误返回提示语
* !74 修复商品批量处理报错的问题并优化展示界面。#I3X8PP
This commit is contained in:
大灰灰
2021-07-24 16:27:13 +00:00
parent fa1204affb
commit 217bb85127
9 changed files with 26 additions and 13 deletions
+4 -1
View File
@@ -95,7 +95,10 @@ namespace CoreCms.Net.Middlewares
var ip = context.Request.Headers["X-Forwarded-For"].ObjectToString();
if (string.IsNullOrEmpty(ip))
{
ip = context.Connection.RemoteIpAddress.ObjectToString();
if (context.Connection.RemoteIpAddress != null)
{
ip = context.Connection.RemoteIpAddress.MapToIPv4().ObjectToString();
}
}
return ip;
}
@@ -409,7 +409,8 @@ namespace CoreCms.Net.Services
billPayments.type = type;
billPayments.status = (int)GlobalEnumVars.BillPaymentsStatus.NoPay;
billPayments.paymentCode = paymentCode;
billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
billPayments.parameters = @params != null ? JsonConvert.SerializeObject(@params) : "";
billPayments.createTime = DateTime.Now;
@@ -385,7 +385,7 @@ namespace CoreCms.Net.Services
formSubmitModel.payStatus = false;
formSubmitModel.status = false;
formSubmitModel.createTime = DateTime.Now;
formSubmitModel.ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString();
formSubmitModel.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
var formSubmitId = await _formSubmitServices.InsertReturnIdentityAsync(formSubmitModel);
@@ -87,7 +87,7 @@ namespace CoreCms.Net.Services
oldLog.code = type;
oldLog.createTime = DateTime.Now;
oldLog.mobile = mobile;
oldLog.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
oldLog.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
oldLog.isUsed = false;
var obj = new
{
@@ -238,7 +238,8 @@ namespace CoreCms.Net.Services
oldLog.parameters = JsonConvert.SerializeObject(parameters);
oldLog.contentBody = str;
oldLog.createTime = DateTime.Now;
oldLog.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
oldLog.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
oldLog.isUsed = isUsed;
await _dal.InsertAsync(oldLog);
@@ -532,7 +532,7 @@ namespace CoreCms.Net.Services
order.orderDiscountAmount = cartDto.orderPromotionMoney > 0 ? cartDto.orderPromotionMoney : 0;
order.goodsDiscountAmount = cartDto.goodsPromotionMoney > 0 ? cartDto.goodsPromotionMoney : 0;
order.couponDiscountAmount = cartDto.couponPromotionMoney;
order.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
order.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
//以上保存了订单主体表信息,以下生成订单明细表
var items = FormatOrderItems(cartDto.list, order.orderId);
if (!items.Any())
@@ -630,7 +630,8 @@ namespace CoreCms.Net.Services
var log = new CoreCmsUserLog();
log.userId = userInfo.id;
log.state = isReg ? (int)GlobalEnumVars.UserLogTypes.注册 : (int)GlobalEnumVars.UserLogTypes.登录;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = isReg ? GlobalEnumVars.UserLogTypes.注册.ToString() : GlobalEnumVars.UserLogTypes.登录.ToString();
await _userLogServices.InsertAsync(log);
@@ -137,7 +137,9 @@ namespace CoreCms.Net.Web.Admin.Controllers
//插入登录日志
var log = new SysLoginRecord();
log.username = model.userName;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.os = RuntimeInformation.OSDescription;
if (_httpContextAccessor.HttpContext != null)
log.browser = _httpContextAccessor.HttpContext.Request.Headers[HeaderNames.UserAgent];
@@ -152,7 +154,9 @@ namespace CoreCms.Net.Web.Admin.Controllers
//插入登录日志
var log = new SysLoginRecord();
log.username = model.userName;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.os = RuntimeInformation.OSDescription;
if (_httpContextAccessor.HttpContext != null)
log.browser = _httpContextAccessor.HttpContext.Request.Headers[HeaderNames.UserAgent];
@@ -212,7 +216,9 @@ namespace CoreCms.Net.Web.Admin.Controllers
if (_httpContextAccessor.HttpContext != null)
{
if (_httpContextAccessor.HttpContext.Connection.RemoteIpAddress != null)
{
log.ip = _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString();
}
log.os = RuntimeInformation.OSDescription;
log.browser = _httpContextAccessor.HttpContext.Request.Headers[HeaderNames.UserAgent];
}
@@ -208,7 +208,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = user.id;
log.state = (int)GlobalEnumVars.UserLogTypes.登录;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes.登录.ToString();
await _userLogServices.InsertAsync(log);
@@ -316,7 +316,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = user.id;
log.state = (int)GlobalEnumVars.UserLogTypes.登录;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes.登录.ToString();
await _userLogServices.InsertAsync(log);
@@ -522,7 +522,9 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var log = new CoreCmsUserLog();
log.userId = id;
log.state = (int)GlobalEnumVars.UserLogTypes.注册;
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString() : "127.0.0.1";
log.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ?
_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
log.createTime = DateTime.Now;
log.parameters = GlobalEnumVars.UserLogTypes.注册.ToString();
await _userLogServices.InsertAsync(log);
@@ -8190,7 +8190,6 @@ INSERT INTO `SysMenu` (`id`, `parentId`, `identificationCode`, `menuName`, `menu
(52, 51, 'goods', '商品列表', '', 'good/goods/index', 'good/goods/list', 0, 1, 'good:goods:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:18:55'),
(53, 51, 'goodscategory', '商品分类', '', 'good/goodscategory/index', 'good/goodscategory/list', 0, 10, 'good:goodscategory:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:18:58'),
(54, 51, 'goodsbrand', '品牌列表', '', 'good/goodsbrand/index', 'good/goodsbrand/list', 0, 20, 'good:goodsbrand:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:19:02'),
(55, 51, 'goodstype', '商品类型', '', 'good/goodstype/index', 'good/goodstype/list', 0, 30, 'good:goodstype:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:19:05'),
(56, 51, 'goodscomment', '商品评价', '', 'good/goodscomment/index', 'good/goodscomment/list', 0, 40, 'good:goodscomment:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:19:16'),
(57, 51, 'goodsparams', '参数列表', '', 'good/goodsparams/index', 'good/goodsparams/list', 0, 35, 'good:goodsparams:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:19:12'),
(58, 51, 'goodsTypeSpec', '商品属性', '', 'good/goodsTypeSpec/index', 'good/goodsTypeSpec/list', 0, 32, 'good:goodsTypeSpec:index', NULL, NULL, b'0', b'0', '2020-07-17 01:08:11', '2020-07-17 16:19:09'),