diff --git a/BPA.KitChen.GroupMealOrder.Application/BaseDto/DtoValidator.cs b/BPA.KitChen.GroupMealOrder.Application/BaseDto/DtoValidator.cs
index 04f176e..16cc0e7 100644
--- a/BPA.KitChen.GroupMealOrder.Application/BaseDto/DtoValidator.cs
+++ b/BPA.KitChen.GroupMealOrder.Application/BaseDto/DtoValidator.cs
@@ -1,82 +1,159 @@
-using BPA.KitChen.GroupMealOrder.Core.Entity;
-using BPA.KitChen.GroupMealOrder.Core.Enum;
-using BPA.KitChen.GroupMealOrder.SqlSugar;
-using MySqlConnector;
+using Furion.JsonSerialization;
+using Newtonsoft.Json;
+using NPOI.POIFS.Crypt.Dsig;
+using NPOI.SS.Formula.Functions;
+using NPOI.Util.ArrayExtensions;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
+using System.Reflection;
+using System.Text;
namespace BPA.KitChen.GroupMealOrder.Application.BaseDto
{
+
+
+
///
/// Dto参数验证
///
- public class DtoValidator
+ public static class DtoValidator
{
- ///
- /// 验证会员
- ///
- ///
- ///
- public static ValidationResult Member(string id)
- {
- var data = SqlSugarDb.Db.Queryable().First(x => x.Id == id&&x.IsDeleted==0);
- return data == null ? new ValidationResult("会员不存在") : ValidationResult.Success;
- }
+ /////
+ ///// 获取签名
+ /////
+ /////
+ /////
+ ///// 0-不排序 1-按名称ASCII排序
+ /////
+ //public static string GetSign(T t, int otype = 1)
+ //{
+ // string retstr = "";
+ // //定义PropertyInfo的List
+ // List proplist = new List();
+ // //遍历泛型类的每个属性加入到List里面
+ // Array.ForEach(typeof(T).GetProperties(),
+ // p => proplist.Add(p));
+ // //根据参数进行排序 0-不排序 1-按名称ASCII码排序
+ // if (otype == 1)
+ // proplist = proplist.OrderBy(k => k.Name).ToList();
+ // //遍历List泛型生成我们要签名的字符串
+ // proplist.ForEach(p =>
+ // {
+ // if (p.Name.ToLower() != "sign".ToLower())
+ // {
+ // if (p.GetValue(t, null) != null && p.GetValue(t, null).ToString() != "")
+ // {
- ///
- /// 验证会员标签的合法性
- ///
- ///
- ///
- public static ValidationResult MemberTag(string id)
- {
- var data = SqlSugarDb.Db.Queryable().First(x=>x.Id==id);
- return data == null ? new ValidationResult("会员标签不存在") : ValidationResult.Success;
- }
- ///
- /// 验证会员标签的合法性
- ///
- ///
- ///
- public static ValidationResult MemberTagList(List ids)
- {
- var data = SqlSugarDb.Db.Queryable().Where(x => ids.Contains(x.Id) && x.IsDeleted == 0&&x.Status== CommonStatus.ENABLE).ToList();
- return data.Count<=0 ? new ValidationResult("会员标签不存在") : ValidationResult.Success;
- }
+ // var type = p.GetValue(t, null).GetType().FullName;
- ///
- /// 会员平台
- ///
- ///
- ///
- public static ValidationResult MemberPlatformType(int type)
- {
- return !System.Enum.IsDefined(typeof(PlatformType), type) ? new ValidationResult("平台类型不存在") : ValidationResult.Success;
+ // if (type == "System.String" || type == "System.Boolean" || type == "System.Int32" || type == "System.DateTime")
+ // {
+ // retstr = retstr + p.Name + "=" + p.GetValue(t, null) + "&";
+ // }
+ // else
+ // {
- }
+ // retstr = retstr + p.Name + "=" + JsonConvert.SerializeObject(p.GetValue(t, null)) + "&";
+ // }
+
+ // }
+
+ // }
+ // });
+ // //把字符串最后一位截断
+ // retstr = retstr.Substring(0, retstr.Length - 1);
+ // //输出字符串
+ // return retstr;
+ //}
///
- /// 会员平台
+ /// 获取签名
///
- ///
+ ///
///
- public static ValidationResult Status(int type)
+ public static string GetSign(object t)
{
- return !System.Enum.IsDefined(typeof(CommonStatus), type) ? new ValidationResult("状态错误") : ValidationResult.Success;
+ string retstr = "";
+ //定义PropertyInfo的List
+ List proplist = new List();
+ //遍历泛型类的每个属性加入到List里面
+ Array.ForEach(t.GetType().GetProperties(),
+ p => proplist.Add(p));
+ //根据参数进行排序 0-不排序 1-按名称ASCII码排序
+ proplist = proplist.OrderBy(k => k.Name).ToList();
+
+ //遍历List泛型生成我们要签名的字符串
+ proplist.ForEach(p =>
+ {
+ if (p.Name.ToLower() != "sign".ToLower())
+ {
+ if (p.GetValue(t, null) != null && p.GetValue(t, null).ToString() != "")
+ {
+
+ var type = p.GetValue(t, null).GetType().FullName;
+ if (type == "System.String" || type == "System.Boolean" || type == "System.Int32" || type == "System.DateTime")
+ {
+ retstr = retstr + p.Name + "=" + p.GetValue(t, null) + "&";
+ }
+ else
+ {
+ var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
+
+ retstr = retstr + p.Name + "=" + JsonConvert.SerializeObject(p.GetValue(t, null), Formatting.None, jsonSetting) + "&";
+
+ }
+
+ }
+
+ }
+ });
+ //把字符串最后一位截断
+ retstr = retstr.Substring(0, retstr.Length - 1);
+ //输出字符串
+ return retstr;
}
+
+
///
- /// 优惠券使用
+ /// 获取属性值
///
- ///
+ ///
+ ///
///
- public static ValidationResult CouponUseType(int type)
+ public static string GetAttributePrice(object obj, string name)
{
- return !System.Enum.IsDefined(typeof(CouponUseType), type) ? new ValidationResult("状态错误") : ValidationResult.Success;
+ string retstr = "";
+ //定义PropertyInfo的List
+ List proplist = new List();
+ //遍历泛型类的每个属性加入到List里面
+ Array.ForEach(obj.GetType().GetProperties(),
+ p => proplist.Add(p));
+ //根据参数进行排序 0-不排序 1-按名称ASCII码排序
+ proplist = proplist.OrderBy(k => k.Name).ToList();
+
+ //遍历List泛型生成我们要签名的字符串
+ proplist.ForEach(p =>
+ {
+ if (p.Name.ToLower() == name.ToLower())
+ {
+ if (p.GetValue(obj, null).GetType().FullName.Contains("System.Collections.Generic.List"))
+ {
+ retstr = JsonConvert.SerializeObject(p.GetValue(obj, null));
+ }
+ else
+ {
+ retstr = p.GetValue(obj, null)?.ToString();
+ }
+
+ }
+ });
+ //输出字符串
+ return retstr;
}
}
}
diff --git a/BPA.KitChen.GroupMealOrder.Application/Service/AExternalPlatform/Service/WeighOrder/WeighOrderServices.cs b/BPA.KitChen.GroupMealOrder.Application/Service/AExternalPlatform/Service/WeighOrder/WeighOrderServices.cs
index f18cabf..5845d13 100644
--- a/BPA.KitChen.GroupMealOrder.Application/Service/AExternalPlatform/Service/WeighOrder/WeighOrderServices.cs
+++ b/BPA.KitChen.GroupMealOrder.Application/Service/AExternalPlatform/Service/WeighOrder/WeighOrderServices.cs
@@ -79,7 +79,7 @@ namespace BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Servi
/// 更具openid获取称重订单
///
///
- [HttpPost("/api/WeighOrder/GetWeighOrderByOpenId")]
+ [HttpPost("/api/ExternalPlatform/WeighOrder/GetWeighOrderByOpenId")]
public async Task GetWeighOrderByOpenId(GetWeighOrderByOpenIdInputDto inputDto)
{
return await _weighOrderService.GetWeighOrderByOpenId(inputDto);
diff --git a/BPA.KitChen.GroupMealOrder/Handlers/RequestAuditFiltercs.cs b/BPA.KitChen.GroupMealOrder/Handlers/RequestAuditFiltercs.cs
index 693e6eb..00d7366 100644
--- a/BPA.KitChen.GroupMealOrder/Handlers/RequestAuditFiltercs.cs
+++ b/BPA.KitChen.GroupMealOrder/Handlers/RequestAuditFiltercs.cs
@@ -1,4 +1,5 @@
-using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.CheckService.Services;
+using BPA.KitChen.GroupMealOrder.Application.BaseDto;
+using BPA.KitChen.GroupMealOrder.Application.Service.AExternalPlatform.Service.CheckService.Services;
using BPA.KitChen.GroupMealOrder.Core;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
@@ -52,19 +53,19 @@ namespace BPA.KitChen.GroupMealOrder.Handlers
//}
- //if (requestUrl.ToUpper().Contains("ExternalPlatform".ToUpper()))
- //{
+ if (requestUrl.ToUpper().Contains("ExternalPlatform".ToUpper()))
+ {
- // var key = httpRequest.Headers["key"];
- // var sign = httpRequest.Headers["sign"];
- // List proplist = new List();
- // foreach (var parameter in parameters)
- // {
- // var stingA = DtoValidator.GetSign(parameter.Value);
- // //var sign = DtoValidator.GetAttributePrice(parameter.Value, "sign");
- // await _checkServices.CheckSign(key, stingA, sign);
- // }
- //}
+ var key = httpRequest.Headers["key"];
+ var sign = httpRequest.Headers["sign"];
+ List proplist = new List();
+ foreach (var parameter in parameters)
+ {
+ var stingA = DtoValidator.GetSign(parameter.Value);
+ //var sign = DtoValidator.GetAttributePrice(parameter.Value, "sign");
+ await _checkServices.CheckSign(key, stingA, sign);
+ }
+ }
//============== 这里是执行方法之后获取数据 ====================
var actionContext = await next();
diff --git a/BPA.KitChen.GroupMealOrder/Program.cs b/BPA.KitChen.GroupMealOrder/Program.cs
index bdbcde6..5d879bf 100644
--- a/BPA.KitChen.GroupMealOrder/Program.cs
+++ b/BPA.KitChen.GroupMealOrder/Program.cs
@@ -12,6 +12,7 @@ builder.Services.AddUnifyResult();
builder.Services.AddControllers().AddInject();
builder.Services.AddSqlsugarSetup();
+builder.Services.AddMvcFilter();
var app = builder.Build();