diff --git a/ShadowEditor.Server/Controllers/AnimationController.cs b/ShadowEditor.Server/Controllers/AnimationController.cs index c0d7957b..5eb8e1be 100644 --- a/ShadowEditor.Server/Controllers/AnimationController.cs +++ b/ShadowEditor.Server/Controllers/AnimationController.cs @@ -35,11 +35,37 @@ namespace ShadowEditor.Server.Controllers var filter = Builders.Filter.Eq("Type", "Animation"); var categories = mongo.FindMany(Constant.CategoryCollectionName, filter).ToList(); - var meshes = mongo.FindAll(Constant.AnimationCollectionName).ToList(); + var docs = new List(); + + if (ConfigHelper.EnableAuthority) + { + var user = UserHelper.GetCurrentUser(); + + if (user != null) + { + var filter1 = Builders.Filter.Eq("UserID", user.ID); + + if (user.Name == "Administrator") + { + var filter2 = Builders.Filter.Exists("UserID"); + var filter3 = Builders.Filter.Not(filter2); + var filter4 = Builders.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(); - foreach (var i in meshes) + foreach (var i in docs) { var categoryID = ""; var categoryName = ""; diff --git a/ShadowEditor.Server/Helpers/ConfigHelper.cs b/ShadowEditor.Server/Helpers/ConfigHelper.cs new file mode 100644 index 00000000..9cce8998 --- /dev/null +++ b/ShadowEditor.Server/Helpers/ConfigHelper.cs @@ -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 +{ + /// + /// 配置管理器 + /// + public sealed class ConfigHelper + { + /// + /// 是否开启权限 + /// + public static bool EnableAuthority + { + get + { + return ConfigurationManager.AppSettings["EnableAuthority"] == "true"; + } + } + } +} diff --git a/ShadowEditor.Server/ShadowEditor.Server.csproj b/ShadowEditor.Server/ShadowEditor.Server.csproj index 3c9287a6..8a937849 100644 --- a/ShadowEditor.Server/ShadowEditor.Server.csproj +++ b/ShadowEditor.Server/ShadowEditor.Server.csproj @@ -131,6 +131,7 @@ +