@@ -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; } | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// Dto参数验证 | |||
/// </summary> | |||
public static class DtoValidator | |||
{ | |||
/// <summary> | |||
/// 获取签名 | |||
/// </summary> | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="t"></param> | |||
/// <param name="otype">0-不排序 1-按名称ASCII排序</param> | |||
/// <returns></returns> | |||
public static string GetSign<T>(T t, int otype = 1) | |||
{ | |||
string retstr = ""; | |||
//定义PropertyInfo的List | |||
List<PropertyInfo> proplist = new List<PropertyInfo>(); | |||
//遍历泛型类的每个属性加入到List里面 | |||
Array.ForEach<PropertyInfo>(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; | |||
} | |||
} | |||
} |
@@ -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<T> | |||
{ | |||
public int statusCode { get; set; } | |||
public ResultSAASManageDataDto<T> 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<T> | |||
{ | |||
public List<T> 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; } | |||
} | |||
} |
@@ -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"]; | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 系统错误码 | |||
/// </summary> | |||
[ErrorCodeType] | |||
[Description("系统错误码")] | |||
public enum ErrorCodeEnum | |||
{ | |||
/// <summary> | |||
/// 用户没有注册 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("用户没有注册")] | |||
Code1000, | |||
/// <summary> | |||
/// 操作错误 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("操作错误")] | |||
Code1001, | |||
/// <summary> | |||
/// 重复添加 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("重复添加")] | |||
Code1002, | |||
/// <summary> | |||
/// 操作数据不存在 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("操作数据不存在")] | |||
Code1003, | |||
/// <summary> | |||
/// key不正确 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("key不正确")] | |||
Code1004, | |||
/// <summary> | |||
/// 签名错误 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("签名错误")] | |||
Code1005, | |||
/// <summary> | |||
/// 签名错误 | |||
/// </summary> | |||
[ErrorCodeItemMetadata("签名过期")] | |||
Code1006, | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> | |||
/// 获取店铺授权码列表 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/Auth/GetListStoreAuthKey")] | |||
public async Task<List<StoreAuthKeyDto>> GetListStoreAuthKey(BaseDto.BaseEPDto input) | |||
{ | |||
return await _authService.GetListStoreAuthKey(input); | |||
} | |||
/// <summary> | |||
/// 获取店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/Auth/GetStoreAuthKey")] | |||
public async Task<StoreAuthKeyDto> GetStoreAuthKey(StoreAuthDto input) | |||
{ | |||
return await _authService.GetStoreAuthKey(input); | |||
} | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpPost("/api/Auth/AddStoreAuthKey")] | |||
public async Task<bool> AddStoreAuthKey(StoreAuthDto inputDto) | |||
{ | |||
return await _authService.AddStoreAuthKey(inputDto); | |||
} | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/Auth/UpdateStoreAuthKey")] | |||
public async Task<bool> UpdateStoreAuthKey(StoreAuthDto inputDto) | |||
{ | |||
return await _authService.UpdateStoreAuthKey(inputDto); | |||
} | |||
} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> | |||
/// 获取店铺授权码列表 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
public async Task<List<StoreAuthKeyDto>> GetListStoreAuthKey(BaseEPDto input) | |||
{ | |||
DtoValidator.CheckTenant(input.TenantId); | |||
var res = await _db.Queryable<BPA_StoreAuthorization, BPA_Store>((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; | |||
} | |||
/// <summary> | |||
/// 获取店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
public async Task<StoreAuthKeyDto> GetStoreAuthKey(StoreAuthDto input) | |||
{ | |||
var res = await _db.Queryable<BPA_StoreAuthorization, BPA_Store>((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; | |||
} | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<bool> AddStoreAuthKey(StoreAuthDto inputDto) | |||
{ | |||
var data = _db.Queryable<BPA_StoreAuthorization>().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; | |||
} | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateStoreAuthKey(StoreAuthDto inputDto) | |||
{ | |||
var data = await _db.Queryable<BPA_StoreAuthorization>().FirstAsync(x => x.StoreId == inputDto.StoreId); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh("授权信息不存在"); | |||
} | |||
data.Key = Guid.NewGuid().ToString(); | |||
return await _db.Updateable(data).ExecuteCommandHasChangeAsync(); | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 获取店铺授权码列表 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<List<StoreAuthKeyDto>> GetListStoreAuthKey(BaseDto.BaseEPDto input); | |||
/// <summary> | |||
/// 获取店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<StoreAuthKeyDto> GetStoreAuthKey(StoreAuthDto input); | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<bool> AddStoreAuthKey(StoreAuthDto inputDto); | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateStoreAuthKey(StoreAuthDto inputDto); | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> | |||
///检查Sign | |||
/// </summary> | |||
public async Task CheckSign<T>(T dto) | |||
{ | |||
await _checkServices.CheckSign(dto); | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
///检查Sign | |||
/// </summary> | |||
public async Task CheckSign<T>(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); | |||
} | |||
} | |||
/// <summary> | |||
/// 获取模型值 | |||
/// </summary> | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="t"></param> | |||
/// <returns></returns> | |||
public string GetModelValue<T>(T t, string name) | |||
{ | |||
string retstr = ""; | |||
//定义PropertyInfo的List | |||
List<PropertyInfo> proplist = new List<PropertyInfo>(); | |||
//遍历泛型类的每个属性加入到List里面 | |||
Array.ForEach<PropertyInfo>(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 ""; | |||
} | |||
/// <summary> | |||
/// 检查店铺key验证 | |||
/// </summary> | |||
/// <param name="key"></param> | |||
public async Task CheckKey(string key) | |||
{ | |||
var data = await SqlSugarDb.Db.Queryable<BPA_StoreAuthorization>() | |||
.FirstAsync(x => x.Key == key); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh(ErrorCodeEnum.Code1004); | |||
} | |||
} | |||
/// <summary> | |||
/// 检查租户 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public async Task CheckTenant(string tenantId) | |||
{ | |||
Dictionary<string, string> dic = new Dictionary<string, string>(); | |||
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<ResultSAASManageDto<ResultTenantDataItemDto>>(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); | |||
} | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
///检查Sign | |||
/// </summary> | |||
Task CheckSign<T>(T dto); | |||
} | |||
} |
@@ -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 | |||
{ | |||
} | |||
} |
@@ -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 | |||
{ | |||
} | |||
} |
@@ -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 | |||
{ | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> | |||
/// 分页店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/authorization/pagestoreauthorization")] | |||
public async Task<PageUtil> PageStoreAuthorization(PageInputBase input) | |||
{ | |||
return await _authorizationService.PageStoreAuthorization(input); | |||
} | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
[HttpPost("/api/authorization/addstoreauthorization")] | |||
public async Task<bool> AddStoreAuthorization(string storeId) | |||
{ | |||
return await _authorizationService.AddStoreAuthorization(storeId); | |||
} | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
[HttpPost("/api/authorization/updatestoreauthorization")] | |||
public async Task<bool> UpdateStoreAuthorization(string id) | |||
{ | |||
return await _authorizationService.UpdateStoreAuthorization(id); | |||
} | |||
/// <summary> | |||
/// CodeFirst | |||
/// </summary> | |||
/// <param name="tableNames"></param> | |||
public void CodeFirst() | |||
{ | |||
_authorizationService.CodeFirst(); | |||
} | |||
} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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; | |||
} | |||
/// <summary> | |||
/// 分页店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
public async Task<PageUtil> PageStoreAuthorization(PageInputBase input) | |||
{ | |||
RefAsync<int> total = 0; | |||
var res = await _db.Queryable<BPA_StoreAuthorization,BPA_Store>((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; | |||
} | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
public async Task<bool> AddStoreAuthorization(string storeId) | |||
{ | |||
var data = _db.Queryable<BPA_StoreAuthorization>().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; | |||
} | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
public async Task<bool> UpdateStoreAuthorization(string id) | |||
{ | |||
var data = await _db.Queryable<BPA_StoreAuthorization>().FirstAsync(x => x.Id == id); | |||
if (data == null) | |||
{ | |||
throw Oops.Oh("授权信息不存在"); | |||
} | |||
data.Key = Guid.NewGuid().ToString(); | |||
return await _db.Updateable(data).ExecuteCommandHasChangeAsync(); | |||
} | |||
/// <summary> | |||
/// CodeFirst | |||
/// </summary> | |||
/// <param name="tableNames"></param> | |||
public void CodeFirst() | |||
{ | |||
try | |||
{ | |||
var list = new List<string>() | |||
{ | |||
"BPA_PlatformAuthorization", | |||
"BPA_StoreAuthorization" | |||
}; | |||
var types = Assembly.Load("BPA.SAAS.KitChenManage.Core").GetTypes() | |||
.Where(x => x.Namespace != null | |||
&& x.GetCustomAttribute<SugarTable>() != 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; | |||
} | |||
} | |||
} | |||
} |
@@ -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 | |||
{ | |||
/// <summary> | |||
/// 分页店铺授权码 | |||
/// </summary> | |||
/// <param name="input"></param> | |||
/// <returns></returns> | |||
Task<PageUtil> PageStoreAuthorization(PageInputBase input); | |||
/// <summary> | |||
/// 添加店铺授权码 | |||
/// </summary> | |||
/// <returns></returns> | |||
Task<bool> AddStoreAuthorization(string storeId); | |||
/// <summary> | |||
/// 修改店铺授权码 | |||
/// </summary> | |||
/// <param name="id"></param> | |||
/// <returns></returns> | |||
Task<bool> UpdateStoreAuthorization(string id); | |||
/// <summary> | |||
/// CodeFirst | |||
/// </summary> | |||
/// <param name="tableNames"></param> | |||
void CodeFirst(); | |||
} | |||
} |
@@ -26,4 +26,9 @@ | |||
<ProjectReference Include="..\BPA.SAAS.KitChenManage.Core\BPA.SAAS.KitChenManage.Core.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<Folder Include="AExternalPlatform\Service\CheckService\Dtos\" /> | |||
<Folder Include="AExternalPlatform\Service\Platform\Material\Dtos\" /> | |||
</ItemGroup> | |||
</Project> |
@@ -4,6 +4,192 @@ | |||
<name>BPA.SAAS.KitChenManage.Application</name> | |||
</assembly> | |||
<members> | |||
<member name="P:BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.BaseEPDto.TenantId"> | |||
<summary> | |||
租户Id | |||
</summary> | |||
</member> | |||
<member name="T:BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.DtoValidator"> | |||
<summary> | |||
Dto参数验证 | |||
</summary> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.DtoValidator.CheckTenant(System.String)"> | |||
<summary> | |||
检查租户 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="T:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Enum.ErrorCodeEnum"> | |||
<summary> | |||
系统错误码 | |||
</summary> | |||
</member> | |||
<member name="F:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Enum.ErrorCodeEnum.Code1000"> | |||
<summary> | |||
用户没有注册 | |||
</summary> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.AuthServices.GetListStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.BaseEPDto)"> | |||
<summary> | |||
获取店铺授权码列表 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.AuthServices.GetStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
获取店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.AuthServices.AddStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.AuthServices.UpdateStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.AuthService.GetListStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.BaseEPDto)"> | |||
<summary> | |||
获取店铺授权码列表 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.AuthService.GetStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
获取店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.AuthService.AddStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.AuthService.UpdateStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.IAuthService.GetListStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.BaseDto.BaseEPDto)"> | |||
<summary> | |||
获取店铺授权码列表 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.IAuthService.GetStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
获取店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.IAuthService.AddStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Services.IAuthService.UpdateStoreAuthKey(BPA.SAAS.KitChenManage.Application.AExternalPlatform.Service.Authorization.Dtos.StoreAuthDto)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.AuthorizationServices.PageStoreAuthorization(BPA.SAAS.KitChenManage.Core.Base.PageInputBase)"> | |||
<summary> | |||
分页店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.AuthorizationServices.AddStoreAuthorization(System.String)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.AuthorizationServices.UpdateStoreAuthorization(System.String)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.AuthorizationServices.CodeFirst"> | |||
<summary> | |||
CodeFirst | |||
</summary> | |||
<param name="tableNames"></param> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.AuthorizationService.PageStoreAuthorization(BPA.SAAS.KitChenManage.Core.Base.PageInputBase)"> | |||
<summary> | |||
分页店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.AuthorizationService.AddStoreAuthorization(System.String)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.AuthorizationService.UpdateStoreAuthorization(System.String)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.AuthorizationService.CodeFirst"> | |||
<summary> | |||
CodeFirst | |||
</summary> | |||
<param name="tableNames"></param> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.IAuthorizationService.PageStoreAuthorization(BPA.SAAS.KitChenManage.Core.Base.PageInputBase)"> | |||
<summary> | |||
分页店铺授权码 | |||
</summary> | |||
<param name="input"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.IAuthorizationService.AddStoreAuthorization(System.String)"> | |||
<summary> | |||
添加店铺授权码 | |||
</summary> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.IAuthorizationService.UpdateStoreAuthorization(System.String)"> | |||
<summary> | |||
修改店铺授权码 | |||
</summary> | |||
<param name="id"></param> | |||
<returns></returns> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Authorization.Services.IAuthorizationService.CodeFirst"> | |||
<summary> | |||
CodeFirst | |||
</summary> | |||
<param name="tableNames"></param> | |||
</member> | |||
<member name="M:BPA.SAAS.KitChenManage.Application.Device.DevicePushRecodeServices.Page(BPA.SAAS.KitChenManage.Application.Device.Dtos.DevicePushRecodeDtoPageInput)"> | |||
<summary> | |||
分页 | |||
@@ -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(); | |||
/// <summary> | |||
/// Get 请求 | |||
/// </summary> | |||
/// <param name="url"></param> | |||
/// <param name="postDataStr"></param> | |||
/// <param name="headers"></param> | |||
/// <param name="platform"></param> | |||
/// <param name="contentType"></param> | |||
/// <returns></returns> | |||
public static string HttpGet(string url, string postDataStr, Dictionary<string, string> 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<string, string> 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<string, string> headers) | |||
{ | |||
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(url); | |||
myReq.Method = "POST"; | |||
myReq.Timeout = 600 * 60; | |||
byte[] byteArray = encoding.GetBytes(postData); | |||
myReq.ContentType = ContentType; | |||
//对键值对进行遍历 | |||
foreach (KeyValuePair<string, string> 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; | |||
} | |||
} | |||
} |
@@ -18,6 +18,7 @@ | |||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="4.9.1.35" /> | |||
<PackageReference Include="Furion.Pure" Version="4.9.1.35" /> | |||
<PackageReference Include="SqlSugarCore" Version="5.1.4.67" /> | |||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -80,5 +80,29 @@ | |||
商品id | |||
</summary> | |||
</member> | |||
<member name="M:BPA.KitChen.GroupMeal.SqlSugar.SqlSugarDb.TableFilterItem(SqlSugar.SqlSugarClient)"> | |||
<summary> | |||
全局过滤 | |||
</summary> | |||
</member> | |||
<member name="M:BPA.KitChen.GroupMeal.SqlSugar.SqlSugarDb.DataExecuting(SqlSugar.SqlSugarClient)"> | |||
<summary> | |||
附默认值 | |||
</summary> | |||
<param name="db"></param> | |||
</member> | |||
<member name="M:BPA.KitChen.GroupMeal.SqlSugar.SqlSugarDb.InsertByObject(SqlSugar.DataFilterModel)"> | |||
<summary> | |||
插入数据时附默认值 | |||
</summary> | |||
<param name="entityInfo"></param> | |||
</member> | |||
<member name="M:BPA.KitChen.GroupMeal.SqlSugar.SqlSugarDb.UpdateByObject(System.Object,SqlSugar.DataFilterModel)"> | |||
<summary> | |||
修改数据时附默认值 | |||
</summary> | |||
<param name="oldValue"></param> | |||
<param name="entityInfo"></param> | |||
</member> | |||
</members> | |||
</doc> |
@@ -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; } | |||
} | |||
} |
@@ -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; } | |||
} | |||
} |
@@ -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 全局过滤器及配置 | |||
/// <summary> | |||
/// 全局过滤 | |||
/// </summary> | |||
private static void TableFilterItem(SqlSugarClient db) | |||
{ | |||
//添加默认值 | |||
DataExecuting(db); | |||
db.QueryFilter.AddTableFilter<IGroupId>(it => it.GroupId == ""); | |||
} | |||
/// <summary> | |||
/// 附默认值 | |||
/// </summary> | |||
/// <param name="db"></param> | |||
private static void DataExecuting(SqlSugarClient db) | |||
{ | |||
//全局字段赋值 | |||
db.Aop.DataExecuting = (oldValue, entityInfo) => | |||
{ | |||
InsertByObject(entityInfo); | |||
UpdateByObject(oldValue, entityInfo); | |||
}; | |||
} | |||
/// <summary> | |||
///插入数据时附默认值 | |||
/// </summary> | |||
/// <param name="entityInfo"></param> | |||
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; | |||
} | |||
} | |||
/// <summary> | |||
/// 修改数据时附默认值 | |||
/// </summary> | |||
/// <param name="oldValue"></param> | |||
/// <param name="entityInfo"></param> | |||
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 | |||
} | |||
} |
@@ -22,7 +22,7 @@ | |||
"dotnetRunMessages": true, | |||
"launchBrowser": true, | |||
"launchUrl": "", | |||
"applicationUrl": "http://192.168.1.19:5008", | |||
"applicationUrl": "http://localhost:5008", | |||
"environmentVariables": { | |||
"ASPNETCORE_ENVIRONMENT": "Development" | |||
} | |||