code reorg
This commit is contained in:
parent
d0c79e449d
commit
229971783a
52 changed files with 5721 additions and 14 deletions
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
namespace Yavsc.Models.Access
|
||||
{
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Yavsc.Abstract.Identity.Security;
|
||||
using Models.Relationship;
|
||||
using Yavsc.Services;
|
||||
|
||||
public class CircleAuthorizationToFile : FileAccessControlRulePayload
|
||||
{
|
||||
public FileAccessRight Access { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class FileAccessControlRulePayload : CircleAuthorization
|
||||
{
|
||||
public virtual string FileId { get; set; }
|
||||
|
||||
[ForeignKey("CircleId")]
|
||||
public virtual Circle Allowed { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
using IdentityServer8.EntityFramework.Entities;
|
||||
using IdentityServer8.EntityFramework.Entities;
|
||||
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
|
|
@ -96,6 +96,15 @@ namespace Yavsc.Models
|
|||
builder.Entity<UserActivity>().HasKey(u => new { u.DoesCode, u.UserId });
|
||||
builder.Entity<Instrumentation>().HasKey(u => new { u.InstrumentId, u.UserId });
|
||||
builder.Entity<CircleAuthorizationToBlogPost>().HasKey(a => new { a.CircleId, a.BlogPostId });
|
||||
builder.Entity<CircleAuthorizationToFile>().HasKey(a => new { a.CircleId, a.FileId });
|
||||
builder.Entity<CircleAuthorizationToFile>()
|
||||
.HasOne(a => a.Allowed)
|
||||
.WithMany()
|
||||
.HasForeignKey(a => a.CircleId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
builder.Entity<CircleAuthorizationToFile>()
|
||||
.Property(a => a.Access)
|
||||
.HasConversion<byte>();
|
||||
builder.Entity<CircleMember>().HasKey(c => new { c.MemberId, c.CircleId });
|
||||
builder.Entity<DismissClicked>().HasKey(c => new { uid = c.UserId, notid = c.NotificationId });
|
||||
builder.Entity<HairTaintInstance>().HasKey(ti => new { ti.TaintId, ti.PrestationId });
|
||||
|
|
@ -367,6 +376,8 @@ namespace Yavsc.Models
|
|||
|
||||
public DbSet<CircleAuthorizationToBlogPost> CircleAuthorizationToBlogPost { get; set; }
|
||||
|
||||
public DbSet<CircleAuthorizationToFile> CircleAuthorizationToFile { get; set; }
|
||||
|
||||
public DbSet<CommandForm> CommandForm { get; set; }
|
||||
|
||||
public DbSet<Ban> Ban { get; set; }
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.Extensions.Options;
|
||||
using rules;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Access;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
namespace Yavsc.Services
|
||||
|
|
@ -98,7 +99,35 @@ namespace Yavsc.Services
|
|||
|
||||
public void SetAccess(long circleId, string normalizedFullPath, FileAccessRight access)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var acl = _dbContext.CircleAuthorizationToFile.SingleOrDefault(a =>
|
||||
a.CircleId == circleId && a.FileId == normalizedFullPath);
|
||||
|
||||
if (access == FileAccessRight.None)
|
||||
{
|
||||
if (acl != null)
|
||||
{
|
||||
_dbContext.CircleAuthorizationToFile.Remove(acl);
|
||||
}
|
||||
|
||||
_dbContext.SaveChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
if (acl == null)
|
||||
{
|
||||
_dbContext.CircleAuthorizationToFile.Add(new CircleAuthorizationToFile
|
||||
{
|
||||
CircleId = circleId,
|
||||
FileId = normalizedFullPath,
|
||||
Access = access
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
acl.Access = access;
|
||||
}
|
||||
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue