From a3eae2d93882c9869237b158a18596e2b3e6bc29 Mon Sep 17 00:00:00 2001 From: gwbvipvip Date: Fri, 1 Mar 2024 18:47:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Authorization/AuthorizationServices.cs | 18 ++++++++++-- .../Dtos/StoreAuthorizationDto.cs | 14 +++++++++ .../Services/AuthorizationService.cs | 29 +++++++++++++++++-- .../Services/IAuthorizationService.cs | 7 +++-- .../BPA.SAAS.KitChenManage.Application.xml | 25 ++++++++++++++-- .../BPA.SAAS.KitChenManage.Core.xml | 5 ++++ .../Model/BPA_StoreAuthorization.cs | 7 +++++ 7 files changed, 94 insertions(+), 11 deletions(-) diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs index 1947734..ea433f0 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/AuthorizationServices.cs @@ -1,4 +1,5 @@ -using BPA.SAAS.KitChenManage.Application.Food.Services; +using BPA.SAAS.KitChenManage.Application.Authorization.Dtos; +using BPA.SAAS.KitChenManage.Application.Food.Services; using BPA.SAAS.KitChenManage.Core.Base; using BPA.SAAS.KitChenManage.Core.Model; using System; @@ -36,9 +37,9 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization /// /// [HttpPost("/api/authorization/addstoreauthorization")] - public async Task AddStoreAuthorization(string storeId) + public async Task AddStoreAuthorization(CreateOrUpDateStoreAuthorizationDto input) { - return await _authorizationService.AddStoreAuthorization(storeId); + return await _authorizationService.AddStoreAuthorization(input); } /// @@ -52,6 +53,17 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization return await _authorizationService.UpdateStoreAuthorization(id); } + /// + /// 修改店铺授权时间 + /// + /// + /// + [HttpPost("/api/authorization/updatestoreauthtime")] + public async Task UpdateStoreAuthTime(CreateOrUpDateStoreAuthorizationDto input) + { + return await _authorizationService.UpdateStoreAuthTime(input); + } + /// /// CodeFirst /// diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs index 102cfe7..fd96499 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/Dtos/StoreAuthorizationDto.cs @@ -12,4 +12,18 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Dtos public string StoreName { get; set; } public string StoreId { get; set; } } + + public class CreateOrUpDateStoreAuthorizationDto + { + public string Id { get; set; } + + public string Key { get; set; } + + public string StoreId { get; set; } + + /// + /// 有效期 长期有效为空 + /// + public DateTime? PeriodValidity { get; set; } + } } diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs index 7d25477..ddbe32a 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/AuthorizationService.cs @@ -52,9 +52,9 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services /// 添加店铺授权码 /// /// - public async Task AddStoreAuthorization(string storeId) + public async Task AddStoreAuthorization(CreateOrUpDateStoreAuthorizationDto input) { - var data = _db.Queryable().Where(x=>x.StoreId== storeId).ToList(); + var data = _db.Queryable().Where(x=>x.StoreId== input.StoreId).ToList(); if (data.Count > 0) { throw Oops.Oh("店铺授权码已存在"); @@ -62,8 +62,10 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services var res = await _db.Insertable(new BPA_StoreAuthorization() { - StoreId = storeId, + StoreId = input.StoreId, Key = Guid.NewGuid().ToString(), + PeriodValidity = input.PeriodValidity, + UpdateAt=DateTime.Now, }).CallEntityMethod(t => t.Create()).ExecuteCommandAsync(); @@ -83,6 +85,27 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services throw Oops.Oh("授权信息不存在"); } data.Key = Guid.NewGuid().ToString(); + data.UpdateAt = DateTime.Now; + + return await _db.Updateable(data).ExecuteCommandHasChangeAsync(); + } + + + /// + /// 修改店铺授权码 + /// + /// + /// + public async Task UpdateStoreAuthTime(CreateOrUpDateStoreAuthorizationDto input) + { + var data = await _db.Queryable().FirstAsync(x => x.Id == input.Id); + if (data == null) + { + throw Oops.Oh("授权信息不存在"); + } + data.Key = Guid.NewGuid().ToString(); + data.PeriodValidity = input.PeriodValidity; + data.UpdateAt = DateTime.Now; return await _db.Updateable(data).ExecuteCommandHasChangeAsync(); } diff --git a/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs index 5bfdd6d..4c07baf 100644 --- a/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs +++ b/BPA.SAAS.KitChenManage.Application/Authorization/Services/IAuthorizationService.cs @@ -1,4 +1,5 @@ -using BPA.SAAS.KitChenManage.Core.Base; +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; @@ -23,7 +24,7 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services /// 添加店铺授权码 /// /// - Task AddStoreAuthorization(string storeId); + Task AddStoreAuthorization(CreateOrUpDateStoreAuthorizationDto input); /// /// 修改店铺授权码 @@ -32,6 +33,8 @@ namespace BPA.SAAS.KitChenManage.Application.Authorization.Services /// Task UpdateStoreAuthorization(string id); + Task UpdateStoreAuthTime(CreateOrUpDateStoreAuthorizationDto input); + diff --git a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml index 0ad4de7..fc6f7f1 100644 --- a/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml +++ b/BPA.SAAS.KitChenManage.Application/BPA.SAAS.KitChenManage.Application.xml @@ -11,7 +11,7 @@ - + 添加店铺授权码 @@ -24,12 +24,24 @@ + + + 修改店铺授权时间 + + + + CodeFirst + + + 有效期 长期有效为空 + + 分页店铺授权码 @@ -37,7 +49,7 @@ - + 添加店铺授权码 @@ -50,6 +62,13 @@ + + + 修改店铺授权码 + + + + CodeFirst @@ -63,7 +82,7 @@ - + 添加店铺授权码 diff --git a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml index 7ae70bd..d9b952b 100644 --- a/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml +++ b/BPA.SAAS.KitChenManage.Core/BPA.SAAS.KitChenManage.Core.xml @@ -80,6 +80,11 @@ 商品id + + + 有效期 长期有效为空 + + 全局过滤 diff --git a/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs index 8cf5ab3..0123745 100644 --- a/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs +++ b/BPA.SAAS.KitChenManage.Core/Model/BPA_StoreAuthorization.cs @@ -14,5 +14,12 @@ namespace BPA.SAAS.KitChenManage.Core.Model public string StoreId { get; set; } public string Key { get; set; } public string GroupId { get; set; } + + /// + /// 有效期 长期有效为空 + /// + public DateTime? PeriodValidity { get; set; } + + public DateTime UpdateAt { get; set; } } }