mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-12-29 00:55:48 +08:00
refactor: ♻️ 基础框架的实体更新逻辑 (#137)
Co-authored-by: tk <fiyne1a@dingtalk.com>
This commit is contained in:
@@ -95,13 +95,4 @@ public sealed class ApiController(IApiCache cache) : ControllerBase<IApiCache, I
|
||||
{
|
||||
return Cache.SyncAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新接口
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<NopReq> UpdateAsync(NopReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,15 @@ public sealed class ConfigController(IConfigCache cache) : ControllerBase<IConfi
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryConfigRsp> EditAsync(EditConfigReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 配置是否存在
|
||||
/// </summary>
|
||||
@@ -90,13 +99,4 @@ public sealed class ConfigController(IConfigCache cache) : ControllerBase<IConfi
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新配置
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryConfigRsp> UpdateAsync(UpdateConfigReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,15 @@ public sealed class DeptController(IDeptCache cache) : ControllerBase<IDeptCache
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDeptRsp> EditAsync(EditDeptReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 部门是否存在
|
||||
/// </summary>
|
||||
@@ -82,13 +91,4 @@ public sealed class DeptController(IDeptCache cache) : ControllerBase<IDeptCache
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新部门
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDeptRsp> UpdateAsync(UpdateDeptReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,24 @@ public sealed class DicController(IDicCache cache) : ControllerBase<IDicCache, I
|
||||
return Cache.DeleteContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<int> EditCatalogAsync(EditDicCatalogReq req)
|
||||
{
|
||||
return Cache.EditCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicContentRsp> EditContentAsync(EditDicContentReq req)
|
||||
{
|
||||
return Cache.EditContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取单个字典目录
|
||||
/// </summary>
|
||||
@@ -124,22 +142,4 @@ public sealed class DicController(IDicCache cache) : ControllerBase<IDicCache, I
|
||||
{
|
||||
return Cache.QueryContentAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新字典目录
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicCatalogRsp> UpdateCatalogAsync(UpdateDicCatalogReq req)
|
||||
{
|
||||
return Cache.UpdateCatalogAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新字典内容
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryDicContentRsp> UpdateContentAsync(UpdateDicContentReq req)
|
||||
{
|
||||
return Cache.UpdateContentAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public sealed class JobController(IJobCache cache) : ControllerBase<IJobCache, I
|
||||
/// 编辑作业
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryJobRsp> EditAsync(UpdateJobReq req)
|
||||
public Task<QueryJobRsp> EditAsync(EditJobReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
@@ -144,18 +144,8 @@ public sealed class JobController(IJobCache cache) : ControllerBase<IJobCache, I
|
||||
/// <summary>
|
||||
/// 启用/禁用作业
|
||||
/// </summary>
|
||||
public Task SetEnabledAsync(UpdateJobReq req)
|
||||
public Task SetEnabledAsync(SetJobEnabledReq req)
|
||||
{
|
||||
return Cache.SetEnabledAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新计划作业
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<QueryJobRsp> UpdateAsync(UpdateJobReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -110,14 +110,4 @@ public sealed class LogController(IRequestLogCache cache) : ControllerBase<IRequ
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新请求日志
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
[Transaction]
|
||||
public Task<NopReq> UpdateAsync(NopReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,15 @@ public sealed class MenuController(IMenuCache cache) : ControllerBase<IMenuCache
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryMenuRsp> EditAsync(EditMenuReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单是否存在
|
||||
/// </summary>
|
||||
@@ -83,15 +92,6 @@ public sealed class MenuController(IMenuCache cache) : ControllerBase<IMenuCache
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新菜单
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryMenuRsp> UpdateAsync(UpdateMenuReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户菜单
|
||||
/// </summary>
|
||||
|
||||
@@ -49,6 +49,15 @@ public sealed class RoleController(IRoleCache cache) : ControllerBase<IRoleCache
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryRoleRsp> EditAsync(EditRoleReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色是否存在
|
||||
/// </summary>
|
||||
@@ -81,13 +90,4 @@ public sealed class RoleController(IRoleCache cache) : ControllerBase<IRoleCache
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新角色
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryRoleRsp> UpdateAsync(UpdateRoleReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,15 @@ public sealed class SiteMsgController(ISiteMsgCache cache) : ControllerBase<ISit
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑站内信
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QuerySiteMsgRsp> EditAsync(EditSiteMsgReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 站内信是否存在
|
||||
/// </summary>
|
||||
@@ -102,7 +111,7 @@ public sealed class SiteMsgController(ISiteMsgCache cache) : ControllerBase<ISit
|
||||
/// <summary>
|
||||
/// 设置站内信状态
|
||||
/// </summary>
|
||||
public Task SetSiteMsgStatusAsync(UpdateSiteMsgFlagReq req)
|
||||
public Task SetSiteMsgStatusAsync(SetUserSiteMsgStatusReq req)
|
||||
{
|
||||
return Cache.SetSiteMsgStatusAsync(req);
|
||||
}
|
||||
@@ -114,13 +123,4 @@ public sealed class SiteMsgController(ISiteMsgCache cache) : ControllerBase<ISit
|
||||
{
|
||||
return Cache.UnreadCountAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新站内信
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QuerySiteMsgRsp> UpdateAsync(UpdateSiteMsgReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -70,6 +70,15 @@ public sealed class UserController(IUserCache cache, IConfigCache configCache)
|
||||
return Cache.DeleteAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryUserRsp> EditAsync(EditUserReq req)
|
||||
{
|
||||
return Cache.EditAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户是否存在
|
||||
/// </summary>
|
||||
@@ -165,7 +174,7 @@ public sealed class UserController(IUserCache cache, IConfigCache configCache)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户头像
|
||||
/// 设置用户头像
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<UserInfoRsp> SetAvatarAsync(SetAvatarReq req)
|
||||
@@ -209,15 +218,6 @@ public sealed class UserController(IUserCache cache, IConfigCache configCache)
|
||||
return Cache.SetPasswordAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryUserRsp> UpdateAsync(UpdateUserReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当前用户信息
|
||||
/// </summary>
|
||||
|
||||
@@ -97,15 +97,6 @@ public sealed class VerifyCodeController(IVerifyCodeCache cache, ICaptchaCache c
|
||||
return await Cache.SendVerifyCodeAsync(req).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新验证码
|
||||
/// </summary>
|
||||
[NonAction]
|
||||
public Task<QueryVerifyCodeRsp> UpdateAsync(UpdateVerifyCodeReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 完成验证
|
||||
/// </summary>
|
||||
|
||||
@@ -81,13 +81,4 @@ public sealed class ExampleController(IExampleCache cache) : ControllerBase<IExa
|
||||
{
|
||||
return Cache.QueryAsync(req);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新示例
|
||||
/// </summary>
|
||||
[Transaction]
|
||||
public Task<QueryExampleRsp> UpdateAsync(UpdateExampleReq req)
|
||||
{
|
||||
return Cache.UpdateAsync(req);
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public sealed class ScheduledJob : WorkBase<ScheduledJob>, IJob
|
||||
};
|
||||
_ = await _jobRecordService.CreateAsync(jobRecord).ConfigureAwait(false);
|
||||
await _jobService
|
||||
.FinishJobAsync(job.Adapt<UpdateJobReq>() with {
|
||||
.FinishJobAsync(job.Adapt<FinishJobReq>() with {
|
||||
LastStatusCode = rsp.StatusCode
|
||||
, LastDuration = jobRecord.Duration
|
||||
})
|
||||
|
||||
@@ -23,11 +23,11 @@ public sealed class EmailCodeSender(ILogger<EmailCodeSender> logger) : IEventSub
|
||||
|
||||
// 发送...
|
||||
var verifyCodeService = App.GetService<IVerifyCodeService>();
|
||||
_ = await verifyCodeService.UpdateAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with {
|
||||
_ = await verifyCodeService.SetVerifyCodeStatusAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<SetVerifyCodeStatusReq>() with {
|
||||
Status = VerifyCodeStatues.Sent
|
||||
})
|
||||
.ConfigureAwait(false);
|
||||
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已处理完毕}");
|
||||
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.SetVerifyCodeStatusAsync)} {Ln.已处理完毕}");
|
||||
}
|
||||
}
|
||||
@@ -23,11 +23,11 @@ public sealed class SmsCodeSender(ILogger<SmsCodeSender> logger) : IEventSubscri
|
||||
|
||||
// 发送...
|
||||
var verifyCodeService = App.GetService<IVerifyCodeService>();
|
||||
_ = await verifyCodeService.UpdateAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<UpdateVerifyCodeReq>() with {
|
||||
_ = await verifyCodeService.SetVerifyCodeStatusAsync(
|
||||
verifyCodeCreatedEvent.Data.Adapt<SetVerifyCodeStatusReq>() with {
|
||||
Status = VerifyCodeStatues.Sent
|
||||
})
|
||||
.ConfigureAwait(false);
|
||||
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.UpdateAsync)} {Ln.已处理完毕}");
|
||||
logger.Info($"{nameof(IVerifyCodeService)}.{nameof(IVerifyCodeService.SetVerifyCodeStatusAsync)} {Ln.已处理完毕}");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user