feat: add method to retrieve task sections assigned to a user and enhance permission code structure
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace GozareshgirProgramManager.Application._Common.Constants;
|
||||
|
||||
public static class ProgramManagerPermissionCode
|
||||
{
|
||||
|
||||
public const int Code = 99;
|
||||
|
||||
/// <summary>
|
||||
@@ -10,17 +13,50 @@ public static class ProgramManagerPermissionCode
|
||||
public static class Board
|
||||
{
|
||||
public const int Code = 991;
|
||||
/// <summary>
|
||||
/// تب همه
|
||||
/// </summary>
|
||||
|
||||
/// <summary>
|
||||
/// تب همه
|
||||
/// </summary>
|
||||
public static class All
|
||||
{
|
||||
public const int Code = 99101;
|
||||
|
||||
/// <summary>
|
||||
/// دیدن همه تسک ها
|
||||
/// </summary>
|
||||
public const int ViewAll = 9910101;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static List<int> GetAllCodes()
|
||||
{
|
||||
var result = new List<int>();
|
||||
|
||||
void Collect(Type type)
|
||||
{
|
||||
// Collect const int fields directly declared on this type
|
||||
var fields = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.DeclaredOnly);
|
||||
foreach (var f in fields)
|
||||
{
|
||||
if (f.FieldType == typeof(int) && f.IsLiteral && !f.IsInitOnly)
|
||||
{
|
||||
var raw = f.GetRawConstantValue();
|
||||
if (raw is int value)
|
||||
{
|
||||
result.Add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Recurse into nested types
|
||||
var nestedTypes = type.GetNestedTypes(BindingFlags.Public | BindingFlags.NonPublic);
|
||||
foreach (var nt in nestedTypes)
|
||||
{
|
||||
Collect(nt);
|
||||
}
|
||||
}
|
||||
|
||||
Collect(typeof(ProgramManagerPermissionCode));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -28,4 +28,11 @@ public class TaskSectionRepository:RepositoryBase<Guid,TaskSection>,ITaskSection
|
||||
.Include(x => x.AdditionalTimes)
|
||||
.FirstOrDefaultAsync(x => x.Id == id, cancellationToken);
|
||||
}
|
||||
|
||||
public async Task<List<TaskSection>> GetAssignedToUserAsync(long userId)
|
||||
{
|
||||
return await _context.TaskSections
|
||||
.Where(x => x.CurrentAssignedUserId == userId)
|
||||
.ToListAsync();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user