mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
开权限只能看到自己的动画。
This commit is contained in:
parent
2cff9e942a
commit
6bb2e9eddb
@ -35,11 +35,37 @@ namespace ShadowEditor.Server.Controllers
|
||||
var filter = Builders<BsonDocument>.Filter.Eq("Type", "Animation");
|
||||
var categories = mongo.FindMany(Constant.CategoryCollectionName, filter).ToList();
|
||||
|
||||
var meshes = mongo.FindAll(Constant.AnimationCollectionName).ToList();
|
||||
var docs = new List<BsonDocument>();
|
||||
|
||||
if (ConfigHelper.EnableAuthority)
|
||||
{
|
||||
var user = UserHelper.GetCurrentUser();
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
var filter1 = Builders<BsonDocument>.Filter.Eq("UserID", user.ID);
|
||||
|
||||
if (user.Name == "Administrator")
|
||||
{
|
||||
var filter2 = Builders<BsonDocument>.Filter.Exists("UserID");
|
||||
var filter3 = Builders<BsonDocument>.Filter.Not(filter2);
|
||||
var filter4 = Builders<BsonDocument>.Filter.Or(filter1, filter3);
|
||||
docs = mongo.FindMany(Constant.AnimationCollectionName, filter4).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
docs = mongo.FindMany(Constant.AnimationCollectionName, filter1).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
docs = mongo.FindAll(Constant.AnimationCollectionName).ToList();
|
||||
}
|
||||
|
||||
var list = new List<AnimationModel>();
|
||||
|
||||
foreach (var i in meshes)
|
||||
foreach (var i in docs)
|
||||
{
|
||||
var categoryID = "";
|
||||
var categoryName = "";
|
||||
|
||||
26
ShadowEditor.Server/Helpers/ConfigHelper.cs
Normal file
26
ShadowEditor.Server/Helpers/ConfigHelper.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Configuration;
|
||||
|
||||
namespace ShadowEditor.Server.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置管理器
|
||||
/// </summary>
|
||||
public sealed class ConfigHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否开启权限
|
||||
/// </summary>
|
||||
public static bool EnableAuthority
|
||||
{
|
||||
get
|
||||
{
|
||||
return ConfigurationManager.AppSettings["EnableAuthority"] == "true";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -131,6 +131,7 @@
|
||||
<Compile Include="Controllers\SceneController.cs" />
|
||||
<Compile Include="CustomAttribute\AuthorityAttribute.cs" />
|
||||
<Compile Include="CustomAttribute\SortAttribute.cs" />
|
||||
<Compile Include="Helpers\ConfigHelper.cs" />
|
||||
<Compile Include="Helpers\DownloadHelper.cs" />
|
||||
<Compile Include="Helpers\DirectoryHelper.cs" />
|
||||
<Compile Include="Helpers\HtmlHelper.cs" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user