diff --git a/Bootstrap.Admin/Controllers/Api/HomeController.cs b/Bootstrap.Admin/Controllers/Api/CssController.cs similarity index 94% rename from Bootstrap.Admin/Controllers/Api/HomeController.cs rename to Bootstrap.Admin/Controllers/Api/CssController.cs index 44e0d8ac..da85ecb2 100644 --- a/Bootstrap.Admin/Controllers/Api/HomeController.cs +++ b/Bootstrap.Admin/Controllers/Api/CssController.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers.Api { [Route("api/[controller]")] - public class HomeController : Controller + public class CssController : Controller { /// /// 获得当前样式接口 diff --git a/Bootstrap.Admin/Controllers/Api/SettingsController.cs b/Bootstrap.Admin/Controllers/Api/SettingsController.cs index 7d939d8e..a3977699 100644 --- a/Bootstrap.Admin/Controllers/Api/SettingsController.cs +++ b/Bootstrap.Admin/Controllers/Api/SettingsController.cs @@ -1,9 +1,8 @@ using Bootstrap.DataAccess; +using Bootstrap.Security; using Longbow.Cache; using Microsoft.AspNetCore.Mvc; -using Newtonsoft.Json.Linq; using System.Collections.Generic; -using System.Linq; namespace Bootstrap.Admin.Controllers.Api { @@ -19,11 +18,10 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpPost] - public bool Post(JObject value) + public bool Post([FromBody]BootstrapDict value) { //保存个性化设置 - dynamic json = value; - return DictHelper.SaveSettings((string)json.name, (string)json.code, (string)json.category); + return DictHelper.SaveSettings(value); } /// /// diff --git a/Bootstrap.Admin/Controllers/Api/UsersController.cs b/Bootstrap.Admin/Controllers/Api/UsersController.cs index a8322862..87a5ec3f 100644 --- a/Bootstrap.Admin/Controllers/Api/UsersController.cs +++ b/Bootstrap.Admin/Controllers/Api/UsersController.cs @@ -31,9 +31,9 @@ namespace Bootstrap.Admin.Controllers.Api /// /// [HttpPut] - public bool Put(User value) + public bool Put([FromBody]User value) { - if(value.UserStatus == 3) + if (value.UserStatus == 3) { return UserHelper.SaveUserCssByName(value.UserName, value.Css); } @@ -79,19 +79,9 @@ namespace Bootstrap.Admin.Controllers.Api /// /// /// - /// - /// - [HttpGet] - public BootstrapUser Get(string userName) - { - return BootstrapUser.RetrieveUserByUserName(userName); - } - /// - /// - /// /// [HttpPost] - public bool Post(User value) + public bool Post([FromBody]User value) { value.Description = string.Format("管理员{0}创建用户", User.Identity.Name); value.ApprovedBy = User.Identity.Name; diff --git a/Bootstrap.Admin/Controllers/HomeController.cs b/Bootstrap.Admin/Controllers/HomeController.cs index ae3eff64..4e9ef534 100644 --- a/Bootstrap.Admin/Controllers/HomeController.cs +++ b/Bootstrap.Admin/Controllers/HomeController.cs @@ -1,11 +1,6 @@ using Bootstrap.Admin.Models; using Bootstrap.DataAccess; -using Bootstrap.Security; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; namespace Bootstrap.Admin.Controllers { @@ -23,20 +18,5 @@ namespace Bootstrap.Admin.Controllers var v = new HeaderBarModel(User.Identity) { HomeUrl = DictHelper.RetrieveHomeUrl() }; return v.HomeUrl.StartsWith("~/") ? (ActionResult)View(v) : Redirect(v.HomeUrl); } - /// - /// - /// - /// - public async Task Lock() - { - await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme); - var user = BootstrapUser.RetrieveUserByUserName(User.Identity.Name); - return View(new LockModel - { - UserName = user.UserName, - DisplayName = user.DisplayName, - ReturnUrl = Request.Path - }); - } } } \ No newline at end of file diff --git a/Bootstrap.Admin/Models/LockModel.cs b/Bootstrap.Admin/Models/LockModel.cs deleted file mode 100644 index 3b01d641..00000000 --- a/Bootstrap.Admin/Models/LockModel.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Bootstrap.Admin.Models -{ - /// - /// - /// - public class LockModel : LoginModel - { - /// - /// - /// - public string DisplayName { get; set; } - /// - /// - /// - public string ReturnUrl { get; set; } - } -} \ No newline at end of file diff --git a/Bootstrap.Admin/Views/Admin/Profiles.cshtml b/Bootstrap.Admin/Views/Admin/Profiles.cshtml index f33d9160..4232d84b 100644 --- a/Bootstrap.Admin/Views/Admin/Profiles.cshtml +++ b/Bootstrap.Admin/Views/Admin/Profiles.cshtml @@ -8,6 +8,7 @@ + } @@ -17,8 +18,8 @@ }
基本资料
-
-
+
+
@@ -26,45 +27,45 @@
- +
修改密码
-
-
+
+
- +
- +
- +
网站皮肤
-
+
@@ -86,7 +87,7 @@
diff --git a/Bootstrap.Admin/Views/Home/Lock.cshtml b/Bootstrap.Admin/Views/Home/Lock.cshtml deleted file mode 100644 index 9b958828..00000000 --- a/Bootstrap.Admin/Views/Home/Lock.cshtml +++ /dev/null @@ -1,35 +0,0 @@ -@model Bootstrap.Admin.Models.LockModel -@{ - ViewBag.Title = "系统登陆"; - Layout = "~/Views/Shared/_Layout.cshtml"; -} -@section css { - -} -@section javascript { - - - -} -
-
-
- lock avatar -

@Model.DisplayName

- 系统已锁定 -
- -
-
- - - - - -
-
-
-
-
\ No newline at end of file diff --git a/Bootstrap.Admin/Views/Shared/_Admin.cshtml b/Bootstrap.Admin/Views/Shared/_Admin.cshtml index 21f87ed8..5bf6e189 100644 --- a/Bootstrap.Admin/Views/Shared/_Admin.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Admin.cshtml @@ -4,9 +4,9 @@ @section css { + @RenderSection("css", false) - @RenderSection("css", false) } @section javascript { diff --git a/Bootstrap.Admin/Views/Shared/_Default.cshtml b/Bootstrap.Admin/Views/Shared/_Default.cshtml index 0e7d68d6..6f8f066c 100644 --- a/Bootstrap.Admin/Views/Shared/_Default.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Default.cshtml @@ -10,6 +10,7 @@ + @RenderSection("Javascript", false) } diff --git a/Bootstrap.Admin/Views/Shared/_Layout.cshtml b/Bootstrap.Admin/Views/Shared/_Layout.cshtml index 6a285b84..f43874f0 100644 --- a/Bootstrap.Admin/Views/Shared/_Layout.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Layout.cshtml @@ -4,11 +4,11 @@ @section css { - + + @RenderSection("css", false) - @RenderSection("css", false) } @section javascript { @@ -16,7 +16,6 @@ @RenderSection("Javascript", false) } - @Html.Partial("Header") @RenderBody() @Html.Partial("Footer") diff --git a/Bootstrap.Admin/Views/Shared/_Root.cshtml b/Bootstrap.Admin/Views/Shared/_Root.cshtml index b2950955..9a27c81c 100644 --- a/Bootstrap.Admin/Views/Shared/_Root.cshtml +++ b/Bootstrap.Admin/Views/Shared/_Root.cshtml @@ -18,6 +18,7 @@
@RenderBody() + @RenderSection("Javascript", false) diff --git a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js index bbd5e254..c904f524 100644 --- a/Bootstrap.Admin/wwwroot/js/Longbow.Common.js +++ b/Bootstrap.Admin/wwwroot/js/Longbow.Common.js @@ -244,7 +244,7 @@ // Menus Menu = { url: 'api/Menus/', - iconView: '../Admin/IconView', + iconView: 'Admin/IconView', title: "授权菜单" }; @@ -256,7 +256,8 @@ // Dicts Dicts = { - url: 'api/Dicts/' + url: 'api/Dicts/', + css: 'api/Css/', }; // Profiles @@ -454,7 +455,7 @@ $(function () { // loading customer css $.bc({ - url: "api/Home", swal: false, method: 'get', + url: Dicts.css, swal: false, method: 'get', callback: function (result) { if (result.length > 0) $('head').append($.format('', $('#pathBase').attr('href'), result)); diff --git a/Bootstrap.Admin/wwwroot/js/Profiles.js b/Bootstrap.Admin/wwwroot/js/Profiles.js index 678f07a5..ef6bc581 100644 --- a/Bootstrap.Admin/wwwroot/js/Profiles.js +++ b/Bootstrap.Admin/wwwroot/js/Profiles.js @@ -20,32 +20,6 @@ if (!!url) $headerIcon.attr('src', url); }); - $('#infoDataForm').autoValidate({ - displayName: { - required: true, - maxlength: 50 - } - }, { - button: ['btnSaveDisplayName'] - }); - $('#passwordDataForm').autoValidate({ - currentPassword: { - required: true, - maxlength: 50 - }, - newPassword: { - required: true, - maxlength: 50 - }, - confirmPassword: { - required: true, - equalTo: "#newPassword", - maxlength: 50 - } - }, { - button: ['btnSavePassword'] - }); - var bsa = new BootstrapAdmin({ url: Profiles.url, bootstrapTable: null, @@ -57,41 +31,34 @@ UserName: "userName", Css: "css" } - }), - click: { - assign: [{ - id: 'btnSavePassword', - click: function (row, data) { - if ($(this).attr('data-valid') == "true") { - data.UserStatus = 2; - $.bc({ url: User.url, method: "PUT", data: data, title: "更改密码" }); - } - } - }, { - id: 'btnSaveDisplayName', - click: function (row, data) { - if ($(this).attr('data-valid') == "true") { - data.UserStatus = 1; - $.bc({ - url: User.url, method: "PUT", data: data, title: "修改用户显示名称", - callback: function (result) { - if (result) { - $('#userDisplayName').text(data.DisplayName); - } - } - }); - } - } - }, { - id: 'btnSaveCss', - click: function (row, data) { - data.UserStatus = 3; - $.bc({ url: User.url, method: "PUT", data: data, title: "保存样式" }); - } - }] - } + }) }); + $('button[data-method]').on('click', function (e) { + var $this = $(this); + var data = bsa.dataEntity.get(); + switch ($this.attr('data-method')) { + case 'password': + data.UserStatus = 2; + $.bc({ url: User.url, method: "PUT", data: data, title: "更改密码" }); + break; + case 'user': + data.UserStatus = 1; + $.bc({ + url: User.url, method: "PUT", data: data, title: "修改用户显示名称", + callback: function (result) { + if (result) { + $('#userDisplayName').text(data.DisplayName); + } + } + }); + break; + case 'css': + data.UserStatus = 3; + $.bc({ url: User.url, method: "PUT", data: data, title: "保存样式" }); + break; + } + }); $('button[data-admin="False"]').removeAttr('disabled'); $('#kvFileinputModal').appendTo('body'); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/Settings.js b/Bootstrap.Admin/wwwroot/js/Settings.js index b177acb0..5eed3389 100644 --- a/Bootstrap.Admin/wwwroot/js/Settings.js +++ b/Bootstrap.Admin/wwwroot/js/Settings.js @@ -162,12 +162,12 @@ }); $.bc({ - url: 'api/Home', swal: false, + url: Dicts.css, swal: false, callback: function (result) { var html = result.map(function (ele, index) { return $.format('
  • {0}
  • ', ele.Name, ele.Code); }).join(''); $('#cssContainer').append(html); $.bc({ - url: 'api/Home', swal: false, method: 'get', + url: Dicts.css, swal: false, method: 'get', callback: function (result) { if (result.length > 0) $('.lgbDropdown').lgbDropdown('val', result); diff --git a/Bootstrap.Admin/wwwroot/js/Users.js b/Bootstrap.Admin/wwwroot/js/Users.js index c1b68732..ac297924 100644 --- a/Bootstrap.Admin/wwwroot/js/Users.js +++ b/Bootstrap.Admin/wwwroot/js/Users.js @@ -110,7 +110,7 @@ required: true, maxlength: 50, remote: { - url: "../api/Users/", + url: $.formatUrl("/api/Users/"), type: "PUT", data: { UserStatus: 9 diff --git a/Bootstrap.DataAccess/CacheCleanUtility.cs b/Bootstrap.DataAccess/CacheCleanUtility.cs index d04e54ef..42baa17d 100644 --- a/Bootstrap.DataAccess/CacheCleanUtility.cs +++ b/Bootstrap.DataAccess/CacheCleanUtility.cs @@ -100,7 +100,7 @@ namespace Bootstrap.DataAccess /// internal static void ClearCache(IEnumerable keys) { - CacheManager.Clear(k => keys.Any(key => key == k)); + CacheManager.Clear(keys); CacheManager.CorsClear(keys); } } diff --git a/Bootstrap.DataAccess/DictHelper.cs b/Bootstrap.DataAccess/DictHelper.cs index 4a052247..556d3322 100644 --- a/Bootstrap.DataAccess/DictHelper.cs +++ b/Bootstrap.DataAccess/DictHelper.cs @@ -94,7 +94,7 @@ namespace Bootstrap.DataAccess /// /// /// - public static bool SaveSettings(string name, string code, string category) + public static bool SaveSettings(BootstrapDict dict) { var ret = false; string sql = "Update Dicts set Code = @Code where Category = @Category and Name = @Name"; @@ -102,9 +102,9 @@ namespace Bootstrap.DataAccess { using (DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql)) { - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", name)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", code)); - cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", category)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Name", dict.Name)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Code", dict.Code)); + cmd.Parameters.Add(DBAccessManager.SqlDBAccess.CreateParameter("@Category", dict.Category)); DBAccessManager.SqlDBAccess.ExecuteNonQuery(cmd); } CacheCleanUtility.ClearCache(dictIds: string.Empty); diff --git a/DatabaseScripts/InitData.sql b/DatabaseScripts/InitData.sql index 2263adf4..4270b5e2 100644 --- a/DatabaseScripts/InitData.sql +++ b/DatabaseScripts/InitData.sql @@ -45,7 +45,6 @@ INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [C INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (12, 0, N'通知管理', 120, N'fa fa-bell', N'~/Admin/Notifications', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (13, 0, N'系统日志', 130, N'fa fa-gears', N'~/Admin/Logs', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (14, 0, N'程序异常', 140, N'fa fa-cubes', N'~/Admin/Exceptions', N'0') -INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (15, 0, N'锁定屏幕', 10, N'fa fa-lock', N'~/Home/Lock', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (16, 0, N'工具集合', 160, N'fa fa-gavel', N'#', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (17, 16, N'客户端测试', 10, N'fa fa-wrench', N'~/Admin/Mobile', N'0') INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (18, 16, N'API文档', 10, N'fa fa-wrench', N'~/Admin/Api', N'0') @@ -79,7 +78,6 @@ INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (1, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (2, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (3, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (10, 2) -INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (15, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (16, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (17, 2) INSERT [dbo].[NavigationRole] ([NavigationID], [RoleID]) VALUES (18, 2)