mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-02-01 16:08:17 +00:00
编辑贴图类型。
This commit is contained in:
parent
34d696b817
commit
0ac73423b8
@ -20,5 +20,10 @@ namespace ShadowEditor.Model.Map
|
||||
/// 名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别
|
||||
/// </summary>
|
||||
public string Category { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +21,16 @@ namespace ShadowEditor.Model.Map
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别ID
|
||||
/// </summary>
|
||||
public string CategoryID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类别名称
|
||||
/// </summary>
|
||||
public string CategoryName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 全拼
|
||||
/// </summary>
|
||||
|
||||
@ -30,12 +30,30 @@ namespace ShadowEditor.Server.Controllers
|
||||
public JsonResult List()
|
||||
{
|
||||
var mongo = new MongoHelper();
|
||||
var docs = mongo.FindAll(Constant.MapCollectionName);
|
||||
|
||||
// 获取所有类别
|
||||
var filter = Builders<BsonDocument>.Filter.Eq("Type", "Map");
|
||||
var categories = mongo.FindMany(Constant.CategoryCollectionName, filter);
|
||||
|
||||
var maps = mongo.FindAll(Constant.MapCollectionName);
|
||||
|
||||
var list = new List<MapModel>();
|
||||
|
||||
foreach (var i in docs)
|
||||
foreach (var i in maps)
|
||||
{
|
||||
var categoryID = "";
|
||||
var categoryName = "";
|
||||
|
||||
if (i.Contains("Category") && !i["Category"].IsBsonNull && !string.IsNullOrEmpty(i["Category"].ToString()))
|
||||
{
|
||||
var doc = categories.Where(n => n["_id"].ToString() == i["Category"].ToString()).FirstOrDefault();
|
||||
if (doc != null)
|
||||
{
|
||||
categoryID = doc["_id"].ToString();
|
||||
categoryName = doc["Name"].ToString();
|
||||
}
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
|
||||
if (i["Url"].IsBsonDocument) // 立体贴图
|
||||
@ -56,6 +74,8 @@ namespace ShadowEditor.Server.Controllers
|
||||
{
|
||||
ID = i["ID"].AsObjectId.ToString(),
|
||||
Name = i["Name"].AsString,
|
||||
CategoryID = categoryID,
|
||||
CategoryName = categoryName,
|
||||
TotalPinYin = i["TotalPinYin"].ToString(),
|
||||
FirstPinYin = i["FirstPinYin"].ToString(),
|
||||
Type = i["Type"].AsString,
|
||||
@ -238,7 +258,19 @@ namespace ShadowEditor.Server.Controllers
|
||||
var update1 = Builders<BsonDocument>.Update.Set("Name", model.Name);
|
||||
var update2 = Builders<BsonDocument>.Update.Set("TotalPinYin", pinyin.TotalPinYin);
|
||||
var update3 = Builders<BsonDocument>.Update.Set("FirstPinYin", pinyin.FirstPinYin);
|
||||
var update = Builders<BsonDocument>.Update.Combine(update1, update2, update3);
|
||||
|
||||
UpdateDefinition<BsonDocument> update5;
|
||||
|
||||
if (string.IsNullOrEmpty(model.Category))
|
||||
{
|
||||
update5 = Builders<BsonDocument>.Update.Unset("Category");
|
||||
}
|
||||
else
|
||||
{
|
||||
update5 = Builders<BsonDocument>.Update.Set("Category", model.Category);
|
||||
}
|
||||
|
||||
var update = Builders<BsonDocument>.Update.Combine(update1, update2, update3, update5);
|
||||
mongo.UpdateOne(Constant.MapCollectionName, filter, update);
|
||||
|
||||
return Json(new
|
||||
|
||||
@ -31,7 +31,8 @@ namespace ShadowEditor.Server.Controllers
|
||||
var mongo = new MongoHelper();
|
||||
|
||||
// 获取所有类别
|
||||
var categories = mongo.FindAll(Constant.CategoryCollectionName);
|
||||
var filter = Builders<BsonDocument>.Filter.Eq("Type", "Mesh");
|
||||
var categories = mongo.FindMany(Constant.CategoryCollectionName, filter);
|
||||
|
||||
var meshes = mongo.FindAll(Constant.MeshCollectionName);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user