mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-06-20 18:58:16 +08:00
@ -16,4 +16,9 @@ public interface IDeptModule : ICrudModule<CreateDeptReq, QueryDeptRsp // 创建
|
||||
/// 编辑部门
|
||||
/// </summary>
|
||||
Task<QueryDeptRsp> EditAsync(EditDeptReq req);
|
||||
|
||||
/// <summary>
|
||||
/// 启用/禁用部门
|
||||
/// </summary>
|
||||
Task SetEnabledAsync(SetDeptEnabledReq req);
|
||||
}
|
@ -16,4 +16,9 @@ public interface IRoleModule : ICrudModule<CreateRoleReq, QueryRoleRsp // 创建
|
||||
/// 编辑角色
|
||||
/// </summary>
|
||||
Task<QueryRoleRsp> EditAsync(EditRoleReq req);
|
||||
|
||||
/// <summary>
|
||||
/// 启用/禁用角色
|
||||
/// </summary>
|
||||
Task SetEnabledAsync(SetRoleEnabledReq req);
|
||||
}
|
@ -119,6 +119,13 @@ public sealed class DeptService(BasicRepository<Sys_Dept, long> rpo) //
|
||||
.ConfigureAwait(false)).Adapt<IEnumerable<QueryDeptRsp>>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task SetEnabledAsync(SetDeptEnabledReq req)
|
||||
{
|
||||
req.ThrowIfInvalid();
|
||||
return UpdateAsync(req, [nameof(req.Enabled)]);
|
||||
}
|
||||
|
||||
private ISelect<Sys_Dept> QueryInternal(QueryReq<QueryDeptReq> req, bool asTreeCte = false)
|
||||
{
|
||||
var ret = Rpo.Select.WhereDynamicFilter(req.DynamicFilter)
|
||||
|
@ -75,8 +75,8 @@ public sealed class JobService(BasicRepository<Sys_Job, long> rpo, IJobRecordSer
|
||||
.Set(a => a.RequestBody == req.RequestBody)
|
||||
.Set(a => a.RequestUrl == req.RequestUrl)
|
||||
.Set(a => a.UserId == req.UserId)
|
||||
.Where(a => a.Id == req.Id)
|
||||
.Where(a => a.Version == req.Version);
|
||||
.Set(a => a.Summary == req.Summary)
|
||||
.Where(a => a.Id == req.Id);
|
||||
|
||||
#if DBTYPE_SQLSERVER
|
||||
return (await update.ExecuteUpdatedAsync().ConfigureAwait(false)).FirstOrDefault()?.Adapt<QueryJobRsp>();
|
||||
@ -276,11 +276,22 @@ public sealed class JobService(BasicRepository<Sys_Job, long> rpo, IJobRecordSer
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<int> ReleaseStuckTaskAsync()
|
||||
public async Task<int> ReleaseStuckTaskAsync()
|
||||
{
|
||||
return UpdateAsync( //
|
||||
new Sys_Job { Status = JobStatues.Idle }, [nameof(Sys_Job.Status)], null
|
||||
, a => a.Status == JobStatues.Running && a.LastExecTime < DateTime.Now.AddSeconds(-Numbers.SECS_TIMEOUT_JOB));
|
||||
var ret1 = await UpdateAsync( // 运行中,运行时间超过超时设定;置为空闲状态
|
||||
new Sys_Job { Status = JobStatues.Idle }, [nameof(Sys_Job.Status)], null
|
||||
, a => a.Status == JobStatues.Running &&
|
||||
a.LastExecTime < DateTime.Now.AddSeconds(-Numbers.SECS_TIMEOUT_JOB)
|
||||
, true)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var ret2 = await UpdateAsync( // 空闲中,下次执行时间在当前时间减去超时时间以前;将下次执行时间调整到现在
|
||||
new Sys_Job { NextExecTime = DateTime.Now, NextTimeId = DateTime.Now.TimeUnixUtc() }
|
||||
, [nameof(Sys_Job.NextExecTime), nameof(Sys_Job.NextTimeId)], null
|
||||
, a => a.Status == JobStatues.Idle && a.NextExecTime < DateTime.Now.AddSeconds(-Numbers.SECS_TIMEOUT_JOB)
|
||||
, true)
|
||||
.ConfigureAwait(false);
|
||||
return ret1 + ret2;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -123,6 +123,13 @@ public sealed class RoleService(BasicRepository<Sys_Role, long> rpo) //
|
||||
return ret.Adapt<IEnumerable<QueryRoleRsp>>();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task SetEnabledAsync(SetRoleEnabledReq req)
|
||||
{
|
||||
req.ThrowIfInvalid();
|
||||
return UpdateAsync(req, [nameof(req.Enabled)]);
|
||||
}
|
||||
|
||||
private ISelect<Sys_Role> QueryInternal(QueryReq<QueryRoleReq> req)
|
||||
{
|
||||
var ret = Rpo.Select.IncludeMany(a => a.Depts.Select(b => new Sys_Dept { Id = b.Id }))
|
||||
|
Reference in New Issue
Block a user