using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Results;
using System.Web;
using System.IO;
using System.Configuration;
using MongoDB.Bson;
using MongoDB.Driver;
using Newtonsoft.Json.Linq;
using ShadowEditor.Server.Base;
using ShadowEditor.Server.Helpers;
using ShadowEditor.Model.System;
namespace ShadowEditor.Server.Controllers.System
{
///
/// 配置控制器
///
public class ConfigController : ApiBase
{
///
/// 获取配置信息
///
///
[HttpGet]
public JsonResult Get()
{
var helper = new MongoHelper();
var filter = Builders.Filter.Empty;
var config = helper.FindOne(Constant.ConfigCollectionName, filter);
if (config == null)
{
config = new BsonDocument
{
["ID"] = ObjectId.GenerateNewId(),
};
helper.InsertOne(Constant.ConfigCollectionName, config);
}
var model = new JObject
{
["ID"] = config["ID"].ToString(),
["EnableAuthority"] = ConfigurationManager.AppSettings["EnableAuthority"] == "true",
};
return Json(new
{
Code = 200,
Msg = "Get Successfully!",
Data = model,
});
}
}
}