diff --git a/Myshipping.Core/Service/DjyApiAuth/DjyApiAuthService.cs b/Myshipping.Core/Service/DjyApiAuth/DjyApiAuthService.cs index 3986ecd4..3485fbbe 100644 --- a/Myshipping.Core/Service/DjyApiAuth/DjyApiAuthService.cs +++ b/Myshipping.Core/Service/DjyApiAuth/DjyApiAuthService.cs @@ -37,8 +37,8 @@ namespace Myshipping.Core.Service public async Task Page([FromQuery] QueryDjyApiAuthInput input) { var entities = await _rep.AsQueryable() - .WhereIF(!string.IsNullOrWhiteSpace(input.ApiCode), u => u.ApiCode == input.ApiCode) - .WhereIF(!string.IsNullOrWhiteSpace(input.ApiName), u => u.ApiName == input.ApiName) + .WhereIF(!string.IsNullOrWhiteSpace(input.ApiCode), u => u.ApiCode.Contains(input.ApiCode)) + .WhereIF(!string.IsNullOrWhiteSpace(input.ApiName), u => u.ApiName.Contains(input.ApiName)) .WhereIF(!string.IsNullOrWhiteSpace(input.TenantName), u => u.TenantName == input.TenantName) .WhereIF(!string.IsNullOrWhiteSpace(input.UserName), u => u.UserName == input.UserName) .WhereIF(input.IsDisable.HasValue, u => u.IsDisable == input.IsDisable.Value) @@ -59,7 +59,7 @@ namespace Myshipping.Core.Service { entity = input.Adapt(); entity.ApiKey = Guid.NewGuid().ToString().Replace("-", "").ToLower(); - entity.ApiSecret = DESCEncryption.Encrypt(Guid.NewGuid().ToString(), "132456").ToLower(); + entity.ApiSecret = GenSecret(); await _rep.InsertAsync(entity); } else @@ -94,6 +94,30 @@ namespace Myshipping.Core.Service return await _rep.FirstOrDefaultAsync(u => u.Id == input.Id); } + /// + /// 重置秘钥 + /// + /// + /// + [HttpPost("/DjyApiAuth/secretReset")] + public async Task SecretReset(long id) + { + var entity = _rep.AsQueryable().Filter(null, true).First(x => x.Id == id); + entity.ApiSecret = GenSecret(); + await _rep.UpdateAsync(entity); + return entity.ApiSecret; + } + + /// + /// 生成新秘钥 + /// + /// + [NonAction] + private string GenSecret() + { + return DESCEncryption.Encrypt(Guid.NewGuid().ToString(), "13245687").ToLower(); + } + ///// ///// 获取接口授权列表 /////