From 38202c0a665ac4946b07593768211e2e98c55529 Mon Sep 17 00:00:00 2001 From: liuhll <1029765111@qq.com> Date: Sat, 22 Jul 2023 11:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IAnotherApplication/IAnotherAppService.cs | 8 ++++++++ .../TestApplication/AppService/TestAppService.cs | 16 +++++++++------- .../WsHostDemo/AppService/AnotherAppService.cs | 10 ++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/framework/test/IAnotherApplication/IAnotherAppService.cs b/framework/test/IAnotherApplication/IAnotherAppService.cs index ac002798..74e2b715 100644 --- a/framework/test/IAnotherApplication/IAnotherAppService.cs +++ b/framework/test/IAnotherApplication/IAnotherAppService.cs @@ -33,6 +33,14 @@ public interface IAnotherAppService [GetCachingIntercept("Query1:id{id}:code:{code}")] Task Query1(long id, long? code); + [HttpPut("update/{id:long}")] + [UpdateCachingIntercept("Query1:id{id}:code:{code}")] + Task Update(long id, long? code); + + [HttpDelete("delete/{id:long}")] + [RemoveMatchKeyCachingIntercept(typeof(string), "Query1:id{id}:code:*")] + Task Delete(long id); + Task ReturnNullTest(); } } \ No newline at end of file diff --git a/framework/test/TestApplication/AppService/TestAppService.cs b/framework/test/TestApplication/AppService/TestAppService.cs index 422308df..07bad543 100644 --- a/framework/test/TestApplication/AppService/TestAppService.cs +++ b/framework/test/TestApplication/AppService/TestAppService.cs @@ -67,6 +67,7 @@ public async Task Get(long id) { throw new UserFriendlyException($"不存在Id为{id}的数据"); } + return test.Adapt(); } @@ -97,18 +98,19 @@ public async Task DeleteAsync(long id) { throw new UserFriendlyException($"不存在Id为{id}的数据"); } - + await _testRepository.DeleteAsync(entity); await _distributedCache.RemoveAsync($"name:{entity.Name}"); return "删除数据成功"; } - public async Task> Search1(string name, string address, IList ids, int pageIndex = 1, int pageSize = 10) + public async Task> Search1(string name, string address, IList ids, int pageIndex = 1, + int pageSize = 10) { return await _testRepository.AsQueryable(false) .Where(!name.IsNullOrEmpty(), p => p.Name.Contains(name)) .Where(!address.IsNullOrEmpty(), p => p.Address.Contains(name)) - .Where(!ids.IsNullOrEmpty(),p=> ids.Contains(p.Id)) + .Where(!ids.IsNullOrEmpty(), p => ids.Contains(p.Id)) .ProjectToType() .ToPagedListAsync(pageIndex, pageSize); } @@ -118,13 +120,13 @@ public async Task> Search2(SearchInput query) return await _testRepository.AsQueryable(false) .Where(!query.Name.IsNullOrEmpty(), p => p.Name.Contains(query.Name)) .Where(!query.Address.IsNullOrEmpty(), p => p.Address.Contains(query.Address)) - .Where(!query.Ids.IsNullOrEmpty(),p=> query.Ids.Contains(p.Id)) + .Where(!query.Ids.IsNullOrEmpty(), p => query.Ids.Contains(p.Id)) .ProjectToType() .SortBy("Name-Asc") .ToPagedListAsync(query.PageIndex, query.PageSize); } - public Task> Search3(long[] Ids,Sort[] sorts) + public Task> Search3(long[] Ids, Sort[] sorts) { throw new System.NotImplementedException(); } @@ -210,8 +212,8 @@ public async Task> GetObjectList() public async Task InvokeQuery1() { - var result = await _invokeTemplate.GetForObjectAsync("/api/another/query1/{id:long}", 1,2); - return result; + var result = await _invokeTemplate.GetForObjectAsync("/api/another/query1/{id:long}", 1, 2); + return result; } public async Task GetObject() diff --git a/framework/test/WsHostDemo/AppService/AnotherAppService.cs b/framework/test/WsHostDemo/AppService/AnotherAppService.cs index e30043ba..3f6f0ba8 100644 --- a/framework/test/WsHostDemo/AppService/AnotherAppService.cs +++ b/framework/test/WsHostDemo/AppService/AnotherAppService.cs @@ -46,6 +46,16 @@ public async Task Query1(long id, long? code) return id.ToString() + code ?? ""; } + public async Task Update(long id, long? code) + { + return id.ToString() + code ?? ""; + } + + public async Task Delete(long id) + { + return id.ToString(); + } + public Task ReturnNullTest() { return Task.CompletedTask;