Skip to content
This repository was archived by the owner on Feb 21, 2022. It is now read-only.

Commit 201db1d

Browse files
author
magicodes
committed
CRUD
1 parent 5b29747 commit 201db1d

File tree

200 files changed

+35958
-2010
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+35958
-2010
lines changed

Magicodes.Core.Web/GlobalConfigurationManager.cs

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
using System.Web.OData.Builder;
1313
using System.Web.Routing;
1414
using System.Web.OData.Extensions;
15+
using Magicodes.Web.Interfaces;
16+
using System.Web;
17+
using System.Text.RegularExpressions;
1518

1619
//======================================================================
1720
//
@@ -129,7 +132,6 @@ static void GlobalConfigurationManager_OnConfiguration_Config_MVC(object sender,
129132
break;
130133
case MvcPlusTypes.MVC:
131134
{
132-
//var pluginNameSuffix = mvcPlus.PlusName.StartsWith("magicodes.", StringComparison.CurrentCultureIgnoreCase) ? mvcPlus.PlusName.Substring(10) : mvcPlus.PlusName;
133135
RouteTable.Routes.MapRoute(name: "MCV_" + mvcPlus.PlusName, url: "_{pluginName}/{controller}/{action}/{id}", defaults: new { action = "Index", id = UrlParameter.Optional, pluginName = mvcPlus.PlusName });
134136
}
135137
break;
@@ -138,6 +140,49 @@ static void GlobalConfigurationManager_OnConfiguration_Config_MVC(object sender,
138140
}
139141

140142
}
143+
//注册请求事件,处理插件资源加载问题
144+
GlobalApplicationObject.Current.EventsManager.BeginRequest += (requestSender,arg) =>
145+
{
146+
//应用程序对象
147+
var application = (HttpApplication)requestSender;
148+
//HTTP上下文对象
149+
var context = application.Context;
150+
#region 如果非站内请求,随它去吧
151+
if (!context.Request.IsLocal)
152+
return;
153+
#endregion
154+
#region 如果非插件类请求,随它去吧
155+
if (!context.Request.Url.AbsolutePath.StartsWith("/Magicodes.", StringComparison.CurrentCultureIgnoreCase))
156+
return;
157+
#endregion
158+
foreach (var plusItem in MvcConfigManager.MVCPlusList)
159+
{
160+
//插件名称
161+
var plusName = plusItem.PlusName;
162+
//插件路径
163+
var plusPath = "/plus/Plugins/" + plusName;
164+
//匹配当前插件路径
165+
if (context.Request.Url.AbsolutePath.StartsWith("/" + plusName + "/", StringComparison.CurrentCultureIgnoreCase))
166+
{
167+
//非bundles路径,则跳转到相应插件目录加载资源
168+
if (!context.Request.Url.AbsolutePath.StartsWith("/" + plusName + "/bundles", StringComparison.CurrentCultureIgnoreCase))
169+
{
170+
var url = Regex.Replace(context.Request.Url.AbsolutePath, "/" + plusName + "/", plusPath + "/", RegexOptions.IgnoreCase);
171+
context.Response.Redirect(url);
172+
}
173+
else
174+
{
175+
//如果Accept不为*/*或者text/css(脚本和样式),则去掉bundles进行跳转
176+
if (!context.Request.AcceptTypes.Any(t => t.Equals("text/css", StringComparison.OrdinalIgnoreCase) || t.Equals("*/*", StringComparison.OrdinalIgnoreCase)))
177+
{
178+
var url = Regex.Replace(context.Request.Url.AbsolutePath, "/" + plusName + "/bundles/", plusPath + "/", RegexOptions.IgnoreCase);
179+
context.Response.Redirect(url);
180+
}
181+
}
182+
return;
183+
}
184+
}
185+
};
141186
}
142187
static void GlobalConfigurationManager_OnConfiguration_Config_WEBAPI(object sender, EventArgs e)
143188
{

Magicodes.Core.Web/Magicodes.Core.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@
148148
<Compile Include="Editor\EditorController.cs" />
149149
<Compile Include="Controllers\JSONActionResult.cs" />
150150
<Compile Include="Controllers\AdminControllerBase.cs" />
151-
<Compile Include="Controllers\AdminODataControllerBase.cs" />
152151
<Compile Include="Controllers\Viewer\DocumentViewerController.cs" />
153152
<Compile Include="Controllers\ODataControllerBase.cs" />
154153
<Compile Include="Controllers\PlusControllerBase.cs" />
@@ -166,6 +165,7 @@
166165
<Compile Include="Mvc\MvcConfigManager.cs" />
167166
<Compile Include="Mvc\PluginControllerFactory.cs" />
168167
<Compile Include="Mvc\PluginRazorViewEngine.cs" />
168+
<Compile Include="OData\ODataAdminControllerbase.cs" />
169169
<Compile Include="Properties\AssemblyInfo.cs" />
170170
<Compile Include="Security\AntiXssAttribute.cs" />
171171
<Compile Include="Security\AuthHelper.cs" />
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
1-
using Magicodes.Web.Interfaces;
1+
using Magicodes.Core.Web.Controllers;
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Text;
66
using System.Threading.Tasks;
7-
using System.Web.OData;
8-
using Microsoft.AspNet.Identity;
9-
using System.Web.Mvc;
10-
using Magicodes.Core.Web.Security;
11-
using System.Web;
12-
using System.Net;
7+
using System.Web.Http;
8+
139
//======================================================================
1410
//
1511
// Copyright (C) 2014-2016 Magicodes团队
1612
// All rights reserved
1713
//
18-
// filename :ODataControllerBase
14+
// filename :ODataBaseControllerbase
1915
// description :
2016
//
21-
// created by 雪雁 at 2014/11/12 22:20:56
17+
// created by 雪雁 at 2015/2/6 14:04:20
2218
// http://www.magicodes.net
2319
//
2420
//======================================================================
25-
namespace Magicodes.Core.Web.Controllers
21+
namespace Magicodes.Core.Web.OData
2622
{
27-
public class AdminODataControllerBase : ODataControllerBase
23+
[Authorize]
24+
public class ODataAdminControllerbase : ODataControllerBase
2825
{
29-
26+
3027
}
3128
}

Magicodes.Core/Config/ConfigManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ public override void SaveConfig<T>(T configType)
7272
lock (_locker)
7373
{
7474
var path = Path.Combine(GlobalApplicationObject.Current.ApplicationContext.SitePaths.SiteConfigDirPath, typeof(T).Name + ".config");
75+
configType.UpdateTime = DateTime.Now;
7576
SerializeHelper.Save(configType, path);
7677
//Configs.AddOrUpdate(typeof(T), configType, (tKey, existingVal) => { return configType; });
7778
}

Magicodes.Services.Mvc/Controller/UsersODtataController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using Magicodes.Core.Web.Controllers;
1515
using Magicodes.Models.Mvc.Models.Account;
1616
using Magicodes.Services.Mvc.ViewModels;
17+
using Magicodes.Core.Web.OData;
1718

1819
//======================================================================
1920
//
@@ -30,7 +31,7 @@
3031
namespace Magicodes.Services.Mvc.Controller
3132
{
3233
[ODataRoutePrefix("Users")]
33-
public class UsersODtataController : ODataControllerBase
34+
public class UsersODtataController : ODataAdminControllerbase
3435
{
3536
private AppDbContext db = new AppDbContext();
3637
UserManager<AppUser, string> userManager;

Magicodes.Web.Interfaces/Data/API/SiteNavs/SiteAdminNavigationBase.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Magicodes.Web.Interfaces.Models;
22
using System;
33
using System.Collections.Generic;
4+
using System.ComponentModel;
45
using System.ComponentModel.DataAnnotations;
56
using System.Linq;
67
using System.Text;
@@ -29,12 +30,14 @@ public class SiteAdminNavigationBase<TUserKeyType> : CommonBusinessModelBase<Gui
2930
/// <summary>
3031
/// 父级Id
3132
/// </summary>
33+
[Display(Name = "父级Id")]
3234
public Guid? ParentId { get; set; }
3335
/// <summary>
3436
/// 显示名称
3537
/// </summary>
3638
[MaxLength(100)]
3739
[Display(Name = "显示文本")]
40+
[Required]
3841
public string Text { get; set; }
3942
/// <summary>
4043
/// 菜单链接
@@ -74,11 +77,14 @@ public class SiteAdminNavigationBase<TUserKeyType> : CommonBusinessModelBase<Gui
7477
/// 插件Id
7578
/// </summary>
7679
[Display(Name = "插件Id")]
80+
[Description("为插件唯一标识,请不要更改。")]
81+
[ReadOnly(true)]
7782
public Guid? PlusId { get; set; }
7883
/// <summary>
7984
/// 排序号
8085
/// </summary>
8186
[Display(Name = "排序号")]
87+
[Description("排序号,越小越靠前。")]
8288
public int SortNo { get; set; }
8389
}
8490
}

Magicodes.Web/Magicodes.Web.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2045,7 +2045,7 @@
20452045
<Content Include="Scripts\knockout\knockout.mapping.min.js.map">
20462046
<DependentUpon>knockout.mapping.min.js</DependentUpon>
20472047
</Content>
2048-
<Content Include="Upload\Magicodes.NET框架说明文档.pdf" />
2048+
<Content Include="Scripts\Upload\Magicodes.NET框架说明文档.pdf" />
20492049
<Content Include="Scripts\knockout\knockout.min.js.map">
20502050
<DependentUpon>knockout.min.js</DependentUpon>
20512051
</Content>
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)