diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/BaseEPDto.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/BaseEPDto.cs
new file mode 100644
index 0000000..f2ad44c
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/BaseEPDto.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto
+{
+ public class BaseEPDto
+ {
+ public string Sign { get; set; }
+
+ public string Key { get; set; }
+ }
+
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/DtoValidator.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/DtoValidator.cs
new file mode 100644
index 0000000..9e0e318
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/DtoValidator.cs
@@ -0,0 +1,60 @@
+
+using BPA.KitChen.GroupMeal.SqlSugar;
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Enum;
+using BPA.SAAS.KitChenManage.Comm.Tool;
+using Furion.JsonSerialization;
+using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Reflection;
+using System.Text;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto
+{
+
+
+ ///
+ /// Dto参数验证
+ ///
+ public static class DtoValidator
+ {
+
+ ///
+ /// 获取签名
+ ///
+ ///
+ ///
+ /// 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() != "")
+ {
+ retstr = retstr + p.Name + "=" + p.GetValue(t, null) + "&";
+ }
+
+ }
+ });
+ //把字符串最后一位截断
+ retstr = retstr.Substring(0, retstr.Length - 1);
+ //输出字符串
+ return retstr;
+ }
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/ResultSAASManageDto.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/ResultSAASManageDto.cs
new file mode 100644
index 0000000..6e7a4fc
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/ResultSAASManageDto.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto
+{
+ public class ResultSAASManageDto
+ {
+ public int statusCode { get; set; }
+
+ public ResultSAASManageDataDto data { get; set; }
+
+ public string succeeded { get; set; }
+
+ public string errors { get; set; }
+
+ public string extras { get; set; }
+
+ public int timestamp { get; set; }
+ }
+
+ public class ResultSAASManageDataDto
+ {
+ public List data { get; set; }
+
+ public int total { get; set; }
+ }
+ public class ResultTenantDataItemDto
+ {
+ public string id { get; set; }
+
+ public string name { get; set; }
+
+ public string adminName { get; set; }
+
+ public string email { get; set; }
+
+ public string phone { get; set; }
+
+ public string remark { get; set; }
+
+ public string logo { get; set; }
+
+ public string createAt { get; set; }
+
+ public int status { get; set; }
+
+ public string sysRoleId { get; set; }
+
+ public int type { get; set; }
+ }
+
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/UserAnalysis.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/UserAnalysis.cs
new file mode 100644
index 0000000..ccb6661
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/BaseDto/UserAnalysis.cs
@@ -0,0 +1,21 @@
+using BPA.SAAS.KitChenManage.Core;
+using Furion;
+using Microsoft.AspNetCore.Http;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto
+{
+ public class UserAnalysis
+ {
+ public UserAnalysis()
+ {
+
+ CurrentUser.GroupId = App.HttpContext.Request.Headers["TenantId"];
+ // CurrentUser.Sign = App.HttpContext.Request.Headers["Sign"];
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
new file mode 100644
index 0000000..a94bed0
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Enum/ErrorCodeEnum.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Enum
+{
+ ///
+ /// 系统错误码
+ ///
+ [ErrorCodeType]
+ [Description("系统错误码")]
+ public enum ErrorCodeEnum
+ {
+ ///
+ /// 用户没有注册
+ ///
+ [ErrorCodeItemMetadata("用户没有注册")]
+ Code1000,
+
+ ///
+ /// 操作错误
+ ///
+ [ErrorCodeItemMetadata("操作错误")]
+ Code1001,
+
+ ///
+ /// 重复添加
+ ///
+ [ErrorCodeItemMetadata("重复添加")]
+ Code1002,
+
+ ///
+ /// 操作数据不存在
+ ///
+ [ErrorCodeItemMetadata("操作数据不存在")]
+ Code1003,
+
+ ///
+ /// key不正确
+ ///
+ [ErrorCodeItemMetadata("key不正确")]
+ Code1004,
+
+ ///
+ /// 签名错误
+ ///
+ [ErrorCodeItemMetadata("签名错误")]
+ Code1005,
+
+ ///
+ /// 签名错误
+ ///
+ [ErrorCodeItemMetadata("签名过期")]
+ Code1006,
+
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/AuthServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/AuthServices.cs
new file mode 100644
index 0000000..fe03023
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/AuthServices.cs
@@ -0,0 +1,71 @@
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services;
+using BPA.SAAS.KitChenManage.Application.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using NetTaste;
+using ProtoBuf.Meta;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization
+{
+
+
+ [ApiDescriptionSettings("开放平台", Tag = "授权管理"), AllowAnonymous, NonUnify]
+ public class AuthServices : IDynamicApiController
+ {
+ private readonly IAuthService _authService;
+ public AuthServices(IAuthService authService)
+ {
+ _authService = authService;
+ }
+
+
+ ///
+ /// 获取店铺授权码列表
+ ///
+ ///
+ ///
+ [HttpPost("/api/Auth/GetListStoreAuthKey")]
+ public async Task> GetListStoreAuthKey(BaseDto.BaseEPDto input)
+ {
+ return await _authService.GetListStoreAuthKey(input);
+ }
+
+ ///
+ /// 获取店铺授权码
+ ///
+ ///
+ ///
+ [HttpPost("/api/Auth/GetStoreAuthKey")]
+ public async Task GetStoreAuthKey(StoreAuthDto input)
+ {
+ return await _authService.GetStoreAuthKey(input);
+ }
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ [HttpPost("/api/Auth/AddStoreAuthKey")]
+ public async Task AddStoreAuthKey(StoreAuthDto inputDto)
+ {
+ return await _authService.AddStoreAuthKey(inputDto);
+ }
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ [HttpPost("/api/Auth/UpdateStoreAuthKey")]
+ public async Task UpdateStoreAuthKey(StoreAuthDto inputDto)
+ {
+ return await _authService.UpdateStoreAuthKey(inputDto);
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Dtos/StoreAuthDto.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Dtos/StoreAuthDto.cs
new file mode 100644
index 0000000..192ca67
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Dtos/StoreAuthDto.cs
@@ -0,0 +1,22 @@
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos
+{
+ public class StoreAuthDto : BaseEPDto
+ {
+ public string StoreId { get; set; }
+ }
+
+ public class StoreAuthKeyDto
+ {
+ public string Id { get; set; }
+ public string Key { get; set; }
+ public string StoreName { get; set; }
+ public string StoreId { get; set; }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/AuthService.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/AuthService.cs
new file mode 100644
index 0000000..a041472
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/AuthService.cs
@@ -0,0 +1,110 @@
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto;
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Application.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using Microsoft.AspNetCore.Components.Forms;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services
+{
+ public class AuthService : IAuthService, ITransient
+ {
+ private readonly ISqlSugarClient _db;
+ public AuthService(ISqlSugarClient db)
+ {
+ _db = db;
+ }
+
+
+ ///
+ /// 获取店铺授权码列表
+ ///
+ ///
+ ///
+ public async Task> GetListStoreAuthKey(BaseEPDto input)
+ {
+ DtoValidator.CheckTenant(input.TenantId);
+
+ var res = await _db.Queryable((a, b) => new JoinQueryInfos(
+ JoinType.Left, a.StoreId == b.Id))
+ .Where((a, b) => a.GroupId == input.TenantId)
+ .OrderBy((a, b) => a.CreateAt, OrderByType.Desc)
+ .Select((a, b) => new StoreAuthKeyDto
+ {
+ Id = a.Id,
+ Key = a.Key,
+ StoreId = a.StoreId,
+ StoreName = b.Name
+ }).ToListAsync();
+ return res;
+ }
+
+ ///
+ /// 获取店铺授权码
+ ///
+ ///
+ ///
+ public async Task GetStoreAuthKey(StoreAuthDto input)
+ {
+ var res = await _db.Queryable((a, b) => new JoinQueryInfos(
+ JoinType.Left, a.StoreId == b.Id))
+ .Where((a, b) => a.GroupId == input.TenantId && a.StoreId == input.StoreId)
+ .OrderBy((a, b) => a.CreateAt, OrderByType.Desc)
+ .Select((a, b) => new StoreAuthKeyDto
+ {
+ Id = a.Id,
+ Key = a.Key,
+ StoreId = a.StoreId,
+ StoreName = b.Name
+ }).FirstAsync();
+ return res;
+ }
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ public async Task AddStoreAuthKey(StoreAuthDto inputDto)
+ {
+ var data = _db.Queryable().Where(x => x.StoreId == inputDto.StoreId).ToList();
+ if (data.Count > 0)
+ {
+ throw Oops.Oh("店铺授权码已存在");
+ }
+
+ var res = await _db.Insertable(new BPA_StoreAuthorization()
+ {
+ StoreId = inputDto.StoreId,
+ Key = Guid.NewGuid().ToString(),
+
+ }).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
+
+ return res > 0;
+ }
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ public async Task UpdateStoreAuthKey(StoreAuthDto inputDto)
+ {
+ var data = await _db.Queryable().FirstAsync(x => x.StoreId == inputDto.StoreId);
+ if (data == null)
+ {
+ throw Oops.Oh("授权信息不存在");
+ }
+ data.Key = Guid.NewGuid().ToString();
+
+ return await _db.Updateable(data).ExecuteCommandHasChangeAsync();
+ }
+
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/IAuthService.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/IAuthService.cs
new file mode 100644
index 0000000..27b09e1
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Authorization/Services/IAuthService.cs
@@ -0,0 +1,46 @@
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services
+{
+ public interface IAuthService
+ {
+
+
+ ///
+ /// 获取店铺授权码列表
+ ///
+ ///
+ ///
+ Task> GetListStoreAuthKey(BaseDto.BaseEPDto input);
+
+ ///
+ /// 获取店铺授权码
+ ///
+ ///
+ ///
+ Task GetStoreAuthKey(StoreAuthDto input);
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ Task AddStoreAuthKey(StoreAuthDto inputDto);
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ Task UpdateStoreAuthKey(StoreAuthDto inputDto);
+
+
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/CheckServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/CheckServices.cs
new file mode 100644
index 0000000..8216799
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/CheckServices.cs
@@ -0,0 +1,38 @@
+using BPA.SAAS.Manage.Application.AExternalPlatform.Enum;
+using BPA.SAAS.Manage.Application.AExternalPlatform.Service.Material.Dtos;
+using BPA.SAAS.Manage.Comm.Enum;
+using BPA.SAAS.Manage.Core.Base;
+using BPA.SAAS.Manage.Core.DataBase;
+using BPA.SAAS.Manage.Core;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Components.Forms;
+using BPA.SAAS.Manage.Application.AExternalPlatform.BaseDto;
+using BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService.Services;
+
+namespace BPA.SAAS.Manage.Application.AExternalPlatform.Service.CheckService
+{
+
+ [ApiDescriptionSettings("开放平台", Tag = "检查"), AllowAnonymous]
+ public class CheckServices : IDynamicApiController
+ {
+ private readonly ICheckServices _checkServices;
+ public CheckServices(ICheckServices checkServices)
+ {
+ _checkServices = checkServices;
+ }
+
+ ///
+ ///检查Sign
+ ///
+ public async Task CheckSign(T dto)
+ {
+ await _checkServices.CheckSign(dto);
+ }
+
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/CheckServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/CheckServices.cs
new file mode 100644
index 0000000..77b290f
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/CheckServices.cs
@@ -0,0 +1,116 @@
+using BPA.KitChen.GroupMeal.SqlSugar;
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto;
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Enum;
+using BPA.SAAS.KitChenManage.Comm.Tool;
+using BPA.SAAS.KitChenManage.Core;
+using BPA.SAAS.KitChenManage.Core.Model;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.CheckService.Services
+{
+ public class CheckServices : ICheckServices, ITransient
+ {
+ ///
+ ///检查Sign
+ ///
+ public async Task CheckSign(T dto)
+ {
+
+ var key = GetModelValue(dto, "Key");
+ var sign = GetModelValue(dto, "Sign");
+ var timestamp = GetModelValue(dto, "TimeStamp");
+
+
+ //检查租户
+ await CheckTenant(CurrentUser.GroupId);
+
+ //检查key
+ await CheckKey(key);
+
+
+ var thisSign = DtoValidator.GetSign(dto);
+
+
+ if (MD5Encryption.Encrypt(thisSign).ToUpper() != sign.ToUpper())
+ {
+ throw Oops.Oh(ErrorCodeEnum.Code1005);
+ }
+ }
+
+
+
+ ///
+ /// 获取模型值
+ ///
+ ///
+ ///
+ ///
+ public string GetModelValue(T t, string name)
+ {
+ string retstr = "";
+ //定义PropertyInfo的List
+ List proplist = new List();
+ //遍历泛型类的每个属性加入到List里面
+ Array.ForEach(typeof(T).GetProperties(),
+ p => proplist.Add(p));
+
+ foreach (PropertyInfo prop in proplist)
+ {
+ if (prop.Name.ToLower() == name.ToLower())
+ {
+ var data = prop.GetValue(t, null);
+ if (data != null)
+ {
+ return data.ToString();
+ }
+ }
+ }
+
+ return "";
+ }
+
+ ///
+ /// 检查店铺key验证
+ ///
+ ///
+ public async Task CheckKey(string key)
+ {
+ var data = await SqlSugarDb.Db.Queryable()
+ .FirstAsync(x => x.Key == key);
+ if (data == null)
+ {
+ throw Oops.Oh(ErrorCodeEnum.Code1004);
+ }
+
+ }
+
+
+ ///
+ /// 检查租户
+ ///
+ ///
+ ///
+ public async Task CheckTenant(string tenantId)
+ {
+ Dictionary dic = new Dictionary();
+ var url = App.Configuration["baseurl"] + "api/company/companypage";
+ var inputData = "{ \"current\": 1, \"pageSize\": 999 }";
+ var jsonData = HttpHelper.PostData(url, inputData, Encoding.UTF8, "application/json", dic);
+ var data = JsonConvert.DeserializeObject>(jsonData);
+ if (data.statusCode != 200) throw Oops.Oh(ErrorCodeEnum.Code1000);
+ if (data.data.data.Count <= 0) throw Oops.Oh(ErrorCodeEnum.Code1000);
+ var tenant = data.data.data.FirstOrDefault(x => x.id == tenantId);
+ if (tenant == null)
+ {
+ throw Oops.Oh(ErrorCodeEnum.Code1000);
+ }
+
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/ICheckServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/ICheckServices.cs
new file mode 100644
index 0000000..a2f562c
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/CheckService/Services/ICheckServices.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.CheckService.Services
+{
+ public interface ICheckServices
+ {
+ ///
+ ///检查Sign
+ ///
+ Task CheckSign(T dto);
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/MaterialServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/MaterialServices.cs
new file mode 100644
index 0000000..c267e70
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/MaterialServices.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Platform.Material
+{
+ [ApiDescriptionSettings("开放平台", Tag = "物料管理"), AllowAnonymous, NonUnify]
+ public class MaterialServices : IDynamicApiController
+ {
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/IMaterialServices.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/IMaterialServices.cs
new file mode 100644
index 0000000..d147f4d
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/IMaterialServices.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Platform.Material.Services
+{
+ public interface IMaterialServices
+ {
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/MaterialService.cs b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/MaterialService.cs
new file mode 100644
index 0000000..5df6a25
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/AExternalPlatform/Service/Platform/Material/Services/MaterialService.cs
@@ -0,0 +1,15 @@
+using BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Platform.Material.Services
+{
+ public class MaterialService : IMaterialServices, ITransient
+ {
+
+
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs
new file mode 100644
index 0000000..1947734
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs
@@ -0,0 +1,64 @@
+using BPA.SAAS.KitChenManage.Application.Food.Services;
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.Authorization
+{
+
+ [ApiDescriptionSettings("授权管理", Tag = "授权管理")]
+ public class AuthorizationServices: IDynamicApiController
+ {
+ private readonly Services.IAuthorizationService _authorizationService;
+ public AuthorizationServices(Services.IAuthorizationService authorizationService)
+ {
+ _authorizationService = authorizationService;
+ }
+
+
+ ///
+ /// 分页店铺授权码
+ ///
+ ///
+ ///
+ [HttpPost("/api/authorization/pagestoreauthorization")]
+ public async Task PageStoreAuthorization(PageInputBase input)
+ {
+ return await _authorizationService.PageStoreAuthorization(input);
+ }
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ [HttpPost("/api/authorization/addstoreauthorization")]
+ public async Task AddStoreAuthorization(string storeId)
+ {
+ return await _authorizationService.AddStoreAuthorization(storeId);
+ }
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ [HttpPost("/api/authorization/updatestoreauthorization")]
+ public async Task UpdateStoreAuthorization(string id)
+ {
+ return await _authorizationService.UpdateStoreAuthorization(id);
+ }
+
+ ///
+ /// CodeFirst
+ ///
+ ///
+ public void CodeFirst()
+ {
+ _authorizationService.CodeFirst();
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs
new file mode 100644
index 0000000..102cfe7
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs
@@ -0,0 +1,15 @@
+using BPA.SAAS.KitChenManage.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.Authorization.Dtos
+{
+ public class StoreAuthorizationDto: BPA_StoreAuthorization
+ {
+ public string StoreName { get; set; }
+ public string StoreId { get; set; }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs
new file mode 100644
index 0000000..7d25477
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs
@@ -0,0 +1,123 @@
+using BPA.SAAS.KitChenManage.Application.Authorization.Dtos;
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
+{
+ public class AuthorizationService: IAuthorizationService, ITransient
+ {
+ private readonly ISqlSugarClient _db;
+ public AuthorizationService(ISqlSugarClient db)
+ {
+ _db = db;
+ }
+
+
+
+
+ ///
+ /// 分页店铺授权码
+ ///
+ ///
+ ///
+ public async Task PageStoreAuthorization(PageInputBase input)
+ {
+ RefAsync total = 0;
+ var res = await _db.Queryable((a,b) => new JoinQueryInfos(
+ JoinType.Left,a.StoreId==b.Id))
+ .OrderBy((a, b) => a.CreateAt, OrderByType.Desc)
+ .Select((a, b) =>new StoreAuthorizationDto
+ {
+ Id = a.Id,
+ Key = a.Key,
+ StoreId = a.StoreId,
+ StoreName = b.Name
+ })
+ .ToPageListAsync(input.Current, input.PageSize, total);
+ PageUtil util = new PageUtil()
+ {
+ Total = total,
+ Data = res
+ };
+ return util;
+ }
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ public async Task AddStoreAuthorization(string storeId)
+ {
+ var data = _db.Queryable().Where(x=>x.StoreId== storeId).ToList();
+ if (data.Count > 0)
+ {
+ throw Oops.Oh("店铺授权码已存在");
+ }
+
+ var res = await _db.Insertable(new BPA_StoreAuthorization()
+ {
+ StoreId = storeId,
+ Key = Guid.NewGuid().ToString(),
+
+ }).CallEntityMethod(t => t.Create()).ExecuteCommandAsync();
+
+ return res > 0;
+ }
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ public async Task UpdateStoreAuthorization(string id)
+ {
+ var data = await _db.Queryable().FirstAsync(x => x.Id == id);
+ if (data == null)
+ {
+ throw Oops.Oh("授权信息不存在");
+ }
+ data.Key = Guid.NewGuid().ToString();
+
+ return await _db.Updateable(data).ExecuteCommandHasChangeAsync();
+ }
+
+
+ ///
+ /// CodeFirst
+ ///
+ ///
+ public void CodeFirst()
+ {
+ try
+ {
+ var list = new List()
+ {
+ "BPA_PlatformAuthorization",
+ "BPA_StoreAuthorization"
+
+ };
+ var types = Assembly.Load("BPA.SAAS.KitChenManage.Core").GetTypes()
+ .Where(x => x.Namespace != null
+ && x.GetCustomAttribute() != null
+ && x.Namespace.Contains("BPA.SAAS.KitChenManage.Core.Model")
+ && list.Contains(x.Name))
+ .ToArray();
+
+ _db.CodeFirst.InitTables(types);
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine(e);
+ throw;
+ }
+
+
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs
new file mode 100644
index 0000000..5bfdd6d
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs
@@ -0,0 +1,47 @@
+using BPA.SAAS.KitChenManage.Core.Base;
+using BPA.SAAS.KitChenManage.Core.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Application.Authorization.Services
+{
+ public interface IAuthorizationService
+ {
+
+
+ ///
+ /// 分页店铺授权码
+ ///
+ ///
+ ///
+ Task PageStoreAuthorization(PageInputBase input);
+
+ ///
+ /// 添加店铺授权码
+ ///
+ ///
+ Task AddStoreAuthorization(string storeId);
+
+ ///
+ /// 修改店铺授权码
+ ///
+ ///
+ ///
+ Task UpdateStoreAuthorization(string id);
+
+
+
+
+
+
+
+ ///
+ /// CodeFirst
+ ///
+ ///
+ void CodeFirst();
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj
index f89edf0..a94e098 100644
--- a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj
+++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.csproj
@@ -25,4 +25,9 @@
+
+
+
+
+
diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml
index bb9d29e..edb353b 100644
--- a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml
+++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml
@@ -4,6 +4,192 @@
BPA.SAAS.KitChenManage.Application
+
+
+ 租户Id
+
+
+
+
+ Dto参数验证
+
+
+
+
+ 检查租户
+
+
+
+
+
+
+ 系统错误码
+
+
+
+
+ 用户没有注册
+
+
+
+
+ 获取店铺授权码列表
+
+
+
+
+
+
+ 获取店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ 获取店铺授权码列表
+
+
+
+
+
+
+ 获取店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ 获取店铺授权码列表
+
+
+
+
+
+
+ 获取店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ 分页店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ CodeFirst
+
+
+
+
+
+ 分页店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ CodeFirst
+
+
+
+
+
+ 分页店铺授权码
+
+
+
+
+
+
+ 添加店铺授权码
+
+
+
+
+
+ 修改店铺授权码
+
+
+
+
+
+
+ CodeFirst
+
+
+
分页
diff --git a/BPA.SAAS.KitChenManage.Comm/Tool/HttpHelper.cs b/BPA.SAAS.KitChenManage.Comm/Tool/HttpHelper.cs
new file mode 100644
index 0000000..d474ce1
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Comm/Tool/HttpHelper.cs
@@ -0,0 +1,72 @@
+using System.Net;
+using System.Text;
+
+namespace BPA.SAAS.KitChenManage.Comm.Tool
+{
+ public static class HttpHelper
+ {
+ private static readonly HttpClient client = new HttpClient();
+
+ ///
+ /// Get 请求
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static string HttpGet(string url, string postDataStr, Dictionary headers, string contentType = "")
+ {
+ var result = string.Empty;
+ HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + postDataStr);
+
+ request.ServicePoint.Expect100Continue = false; //加了这一行代码 就OK了
+ request.Method = "GET";
+ request.ContentType = contentType;
+ foreach (KeyValuePair kv in headers)
+ {
+ request.Headers.Add(kv.Key, kv.Value);
+ }
+ HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+ Stream myResponseStream = response.GetResponseStream();
+ StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
+ result = myStreamReader.ReadToEnd();
+ myStreamReader.Close();
+ myResponseStream.Close();
+ return result;
+ }
+
+
+ public static string PostData(string url, string postData, Encoding encoding, string ContentType, Dictionary headers)
+ {
+
+ HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url);
+
+ myReq.Method = "POST";
+ myReq.Timeout = 600 * 60;
+ byte[] byteArray = encoding.GetBytes(postData);
+ myReq.ContentType = ContentType;
+ //对键值对进行遍历
+ foreach (KeyValuePair kv in headers)
+ {
+ myReq.Headers.Add(kv.Key, kv.Value);
+ }
+ Stream dataStream = myReq.GetRequestStream();
+ dataStream.Write(byteArray, 0, byteArray.Length);
+ dataStream.Close();
+
+ HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
+ dataStream = HttpWResp.GetResponseStream();
+ string result = "";
+ using (StreamReader myStreamReader = new StreamReader(dataStream, encoding))
+ {
+ result = myStreamReader.ReadToEnd();
+ myStreamReader.Close();
+ }
+ dataStream.Close();
+ HttpWResp.Close();
+ return result;
+ }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj
index 82e9de3..5e9484b 100644
--- a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj
+++ b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.csproj
@@ -18,6 +18,7 @@
+
diff --git a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml
index 97f099a..cf7033b 100644
--- a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml
+++ b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml
@@ -80,5 +80,29 @@
商品id
+
+
+ 全局过滤
+
+
+
+
+ 附默认值
+
+
+
+
+
+ 插入数据时附默认值
+
+
+
+
+
+ 修改数据时附默认值
+
+
+
+
diff --git a/BPA.SAAS.KitChenManage.Core/CurrentUser.cs b/BPA.SAAS.KitChenManage.Core/CurrentUser.cs
new file mode 100644
index 0000000..0be2e66
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Core/CurrentUser.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Core
+{
+ public static class CurrentUser
+ {
+ public static string GroupId { get; set; }
+
+ public static string key { get; set; }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs
new file mode 100644
index 0000000..8cf5ab3
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs
@@ -0,0 +1,18 @@
+using BPA.SAAS.KitChenManage.Core.Base;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BPA.SAAS.KitChenManage.Core.Model
+{
+ [SugarTable("bpa_storeauthorization")]
+ public class BPA_StoreAuthorization : IBaseEntity, IGroupId
+ {
+ public string StoreId { get; set; }
+ public string Key { get; set; }
+ public string GroupId { get; set; }
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Core/SqlSugarDb.cs b/BPA.SAAS.KitChenManage.Core/SqlSugarDb.cs
new file mode 100644
index 0000000..08f427e
--- /dev/null
+++ b/BPA.SAAS.KitChenManage.Core/SqlSugarDb.cs
@@ -0,0 +1,115 @@
+
+using BPA.SAAS.KitChenManage.Core;
+using BPA.SAAS.KitChenManage.Core.Base;
+using Furion;
+using SqlSugar;
+using System;
+using System.Linq;
+using System.Linq.Dynamic.Core;
+using System.Linq.Expressions;
+using System.Reflection;
+
+namespace BPA.KitChen.GroupMeal.SqlSugar
+{
+ public class SqlSugarDb
+ {
+
+
+
+ public static SqlSugarScope Db { get; set; }
+
+ public static SqlSugarScope SqlSugarScope(ConnectionConfig configConnection)
+ {
+ //全局过滤
+
+ Db = new SqlSugarScope(configConnection, db =>
+ {
+ //全局过滤
+ TableFilterItem(db);
+ db.Aop.OnLogExecuting = (sql, pars) =>
+ {
+ //sql 执行前
+ };
+ db.Aop.OnLogExecuted = (sql, pars) =>
+ {
+ //sql 执行后
+ };
+ db.Aop.OnError = ex =>
+ {
+ //sql 异常
+ };
+ });
+
+ return Db;
+ }
+
+ #region 全局过滤器及配置
+ ///
+ /// 全局过滤
+ ///
+ private static void TableFilterItem(SqlSugarClient db)
+ {
+
+ //添加默认值
+ DataExecuting(db);
+ db.QueryFilter.AddTableFilter(it => it.GroupId == "");
+ }
+
+ ///
+ /// 附默认值
+ ///
+ ///
+ private static void DataExecuting(SqlSugarClient db)
+ {
+ //全局字段赋值
+ db.Aop.DataExecuting = (oldValue, entityInfo) =>
+ {
+ InsertByObject(entityInfo);
+ UpdateByObject(oldValue, entityInfo);
+ };
+
+ }
+ ///
+ ///插入数据时附默认值
+ ///
+ ///
+ private static void InsertByObject(DataFilterModel entityInfo)
+ {
+ if (entityInfo.OperationType != DataFilterType.InsertByObject) return;
+ switch (entityInfo.PropertyName)
+ {
+ case "CreateAt":
+ entityInfo.SetValue(DateTime.Now);
+ break;
+ case "CreateBy":
+ entityInfo.SetValue("");
+ break;
+ case "GroupId":
+ entityInfo.SetValue(CurrentUser.GroupId);
+ break;
+ }
+ }
+
+ ///
+ /// 修改数据时附默认值
+ ///
+ ///
+ ///
+ private static void UpdateByObject(object oldValue, DataFilterModel entityInfo)
+ {
+ if (entityInfo.OperationType != DataFilterType.UpdateByObject) return;
+
+ switch (entityInfo.PropertyName)
+ {
+ case "UpdateAt":
+ entityInfo.SetValue(DateTime.Now);
+ break;
+ case "UpdateBy":
+ entityInfo.SetValue("");
+ break;
+ }
+
+ }
+ #endregion
+ }
+}
diff --git a/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json
index b8afba7..870d479 100644
--- a/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json
+++ b/BPA.SAAS.KitChenManage.Web.Entry/Properties/launchSettings.json
@@ -22,7 +22,7 @@
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "",
- "applicationUrl": "http://192.168.1.19:5008",
+ "applicationUrl": "http://localhost:5008",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}