[try]字典管理调整为异步

This commit is contained in:
wintel 2025-03-03 22:09:21 +08:00
parent 0392a1ff30
commit 09c47a7a07
3 changed files with 18 additions and 19 deletions

View File

@ -60,14 +60,14 @@ namespace OpenAuth.App
return result;
}
public void Add(AddOrUpdateCategoryReq req)
public async Task Add(AddOrUpdateCategoryReq req)
{
var obj = req.MapTo<Category>();
obj.CreateTime = DateTime.Now;
var user = _auth.GetCurrentUser().User;
obj.CreateUserId = user.Id;
obj.CreateUserName = user.Name;
Repository.Add(obj);
await Repository.AddAsync(obj);
}
public void Update(AddOrUpdateCategoryReq obj)

View File

@ -51,12 +51,12 @@ namespace OpenAuth.Mvc.Controllers
}
[HttpPost]
public string Add(AddOrUpdateCategoryReq obj)
public async Task<string> Add(AddOrUpdateCategoryReq obj)
{
Response resp = new Response();
try
{
_app.Add(obj);
await _app.Add(obj);
}
catch (Exception e)
{

View File

@ -46,13 +46,12 @@ namespace OpenAuth.WebApi.Controllers
/// </summary>
/// <returns></returns>
[HttpPost]
public Response Add([FromBody] AddOrUpdateCategoryReq obj)
public async Task<Response> Add([FromBody] AddOrUpdateCategoryReq obj)
{
var result = new Response();
try
{
_app.Add(obj);
await _app.Add(obj);
}
catch (Exception ex)
{