♻️ Finish centerlizing the data models

This commit is contained in:
2025-09-27 15:14:05 +08:00
parent e70d8371f8
commit 9ce31c4dd8
167 changed files with 780 additions and 42880 deletions

View File

@@ -1,6 +1,7 @@
namespace DysonNetwork.Pass.Permission;
using System;
using DysonNetwork.Shared.Models;
[AttributeUsage(AttributeTargets.Method)]
public class RequiredPermissionAttribute(string area, string key) : Attribute
@@ -21,7 +22,7 @@ public class PermissionMiddleware(RequestDelegate next)
if (attr != null)
{
if (httpContext.Items["CurrentUser"] is not Account.Account currentUser)
if (httpContext.Items["CurrentUser"] is not SnAccount currentUser)
{
httpContext.Response.StatusCode = StatusCodes.Status403Forbidden;
await httpContext.Response.WriteAsync("Unauthorized");

View File

@@ -1,7 +1,6 @@
using Microsoft.EntityFrameworkCore;
using NodaTime;
using System.Text.Json;
using DysonNetwork.Pass;
using DysonNetwork.Shared.Cache;
using DysonNetwork.Shared.Models;

View File

@@ -4,7 +4,6 @@ using DysonNetwork.Shared.Proto;
using Google.Protobuf.WellKnownTypes;
using System.Text.Json;
using NodaTime.Serialization.Protobuf;
using DysonNetwork.Shared.Models;
namespace DysonNetwork.Pass.Permission;
@@ -76,22 +75,3 @@ public class PermissionServiceGrpc(
return new RemovePermissionNodeFromGroupResponse { Success = true };
}
}
public static class PermissionExtensions
{
public static DysonNetwork.Shared.Proto.PermissionNode ToProtoValue(this PermissionNode node)
{
return new DysonNetwork.Shared.Proto.PermissionNode
{
Id = node.Id.ToString(),
Actor = node.Actor,
Area = node.Area,
Key = node.Key,
Value = Value.Parser.ParseJson(node.Value.RootElement.GetRawText()),
ExpiredAt = node.ExpiredAt?.ToTimestamp(),
AffectedAt = node.AffectedAt?.ToTimestamp(),
GroupId = node.GroupId?.ToString() ?? string.Empty
};
}
}