diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/AnalyseController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/AnalyseController.cs index 3344d501..07cf9a0b 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/AnalyseController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/AnalyseController.cs @@ -8,7 +8,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 网站分析控制器 /// [Route("api/[controller]")] [Authorize] @@ -16,11 +16,11 @@ namespace Bootstrap.Admin.Controllers.Api public class AnalyseController : ControllerBase { /// - /// + /// 通过 logType 查询分析数据接口 /// /// [HttpGet()] - public ActionResult Get([FromQuery]string logType = "") + public ActionResult Get([FromQuery]string logType) { var ret = new AnalyseData(); if (logType.Equals("LoginUsers", StringComparison.OrdinalIgnoreCase)) @@ -60,19 +60,19 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 分析数据实体类 /// public class AnalyseData { /// - /// + /// 获得/设置 折线数据集合 /// - public IEnumerable Polylines { get; set; } = new List(); + public IEnumerable Polylines { get; set; } = new string[0]; /// - /// + /// 获得 数据集合 /// - public List> Datas { get; set; } = new List>(); + public List> Datas { get; } = new List>(); } } } diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/AppsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/AppsController.cs index 2047677a..bf338c6c 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/AppsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/AppsController.cs @@ -1,4 +1,4 @@ -using Bootstrap.DataAccess; +using Bootstrap.DataAccess; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; @@ -6,7 +6,7 @@ using System.Collections.Generic; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 应用程序控制器 /// [Route("api/[controller]")] [Authorize] @@ -14,7 +14,7 @@ namespace Bootstrap.Admin.Controllers.Api public class AppsController : ControllerBase { /// - /// + /// 通过角色ID获取其授权的所有应用程序集合 /// /// /// diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs index c6187c15..53944ae3 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/CategoryController.cs @@ -15,7 +15,7 @@ namespace Bootstrap.Admin.Controllers.Api public class CategoryController : ControllerBase { /// - /// 获取字典表中所有Category数据 + /// 获取字典表中所有 Category 数据 /// /// [HttpGet] @@ -26,7 +26,7 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 获取所有菜单数据 /// /// [HttpGet] @@ -36,7 +36,7 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 获取所有父级菜单数据 /// /// [HttpGet] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/DictsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/DictsController.cs index 61e9df13..3dfc82b8 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/DictsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/DictsController.cs @@ -10,7 +10,7 @@ using System.Collections.Generic; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 字典表维护控制器 /// [Route("api/[controller]")] [Authorize] @@ -18,7 +18,7 @@ namespace Bootstrap.Admin.Controllers.Api public class DictsController : ControllerBase { /// - /// + /// 获取所有字典表数据方法 /// /// /// @@ -28,7 +28,7 @@ namespace Bootstrap.Admin.Controllers.Api return value.RetrieveData(); } /// - /// + /// 保存字典方法 /// /// [HttpPost] @@ -38,7 +38,7 @@ namespace Bootstrap.Admin.Controllers.Api return DictHelper.Save(value); } /// - /// + /// 删除字典项方法 /// /// [HttpDelete] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs index 01e1b590..d7e4d48a 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/ExceptionsController.cs @@ -80,12 +80,12 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 查询服务器端日志文件参数类 /// public class ExceptionFileQuery { /// - /// + /// 获取/设置 文件名称 /// public string FileName { get; set; } = ""; } diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/GroupsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/GroupsController.cs index c7493b99..3d910144 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/GroupsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/GroupsController.cs @@ -10,7 +10,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 部门维护控制器 /// [Route("api/[controller]")] [Authorize] @@ -18,7 +18,7 @@ namespace Bootstrap.Admin.Controllers.Api public class GroupsController : ControllerBase { /// - /// + /// 部门数据查询方法 /// /// /// @@ -29,18 +29,7 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// - /// - /// - /// - [HttpGet("{id}")] - public Group Get(string id) - { - return GroupHelper.Retrieves().FirstOrDefault(t => t.Id == id); - } - - /// - /// + /// 保存部门方法 /// /// [HttpPost] @@ -51,7 +40,7 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 删除部门方法 /// /// [HttpDelete] @@ -64,7 +53,7 @@ namespace Bootstrap.Admin.Controllers.Api /// /// 获取部门授权 /// - /// + /// 用户ID或者角色ID /// /// [HttpPost("{id}")] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/NewController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/NewController.cs index 789bd9bb..02496093 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/NewController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/NewController.cs @@ -7,7 +7,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers { /// - /// + /// 新用户注册控制器 /// [Route("api/[controller]")] [Authorize] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/ProfilesController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/ProfilesController.cs index c843a1f0..4b6d06bf 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/ProfilesController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/ProfilesController.cs @@ -11,7 +11,7 @@ using System.Threading.Tasks; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 个人中心控制器 /// [Route("api/[controller]")] [Authorize] @@ -30,9 +30,6 @@ namespace Bootstrap.Admin.Controllers.Api public JsonResult Post(string id, [FromServices]IWebHostEnvironment env, [FromForm]DeleteFileCollection files) { if (!id.Equals("Delete", StringComparison.OrdinalIgnoreCase)) return new JsonResult(new object()); - - var previewUrl = string.Empty; - long fileSize = 0; var userName = User.Identity.Name; var fileName = files.Key; @@ -41,9 +38,9 @@ namespace Bootstrap.Admin.Controllers.Api fileName = "default.jpg"; var webSiteUrl = DictHelper.RetrieveIconFolderPath(); var filePath = Path.Combine(env.WebRootPath, webSiteUrl.Replace("~", string.Empty).Replace('/', Path.DirectorySeparatorChar).TrimStart(Path.DirectorySeparatorChar) + fileName); - fileSize = new FileInfo(filePath).Length; + var fileSize = new FileInfo(filePath).Length; var iconName = $"{fileName}?v={DateTime.Now.Ticks}"; - previewUrl = Url.Content($"{webSiteUrl}{iconName}"); + var previewUrl = Url.Content($"{webSiteUrl}{iconName}"); if (!string.IsNullOrEmpty(userName)) UserHelper.SaveUserIconByName(userName, iconName); return new JsonResult(new @@ -57,12 +54,12 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 待删除文件集合类 /// public class DeleteFileCollection { /// - /// + /// 获得/设置 文件名称 /// public string Key { get; set; } = ""; } @@ -109,7 +106,7 @@ namespace Bootstrap.Admin.Controllers.Api } /// - /// + /// 个人中心操作方法 更改样式 更改显示名称 更改默认应用 /// /// [HttpPut] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/RolesController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/RolesController.cs index 6b0040d1..cfbb3bd5 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/RolesController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/RolesController.cs @@ -11,7 +11,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 角色维护控制器 /// [Route("api/[controller]")] [Authorize] @@ -19,7 +19,7 @@ namespace Bootstrap.Admin.Controllers.Api public class RolesController : ControllerBase { /// - /// + /// 获取所有角色数据 /// /// /// @@ -37,7 +37,7 @@ namespace Bootstrap.Admin.Controllers.Api [HttpPost("{id}")] public IEnumerable Post(string id, [FromQuery]string type) { - IEnumerable ret = new List(); + IEnumerable ret = new Role[0]; switch (type) { case "user": @@ -53,7 +53,7 @@ namespace Bootstrap.Admin.Controllers.Api return ret.Select(m => new { m.Id, m.Checked, m.RoleName, m.Description }); } /// - /// 保存角色 + /// 保存角色授权方法 /// /// 角色ID /// 选中的ID集合 @@ -82,7 +82,7 @@ namespace Bootstrap.Admin.Controllers.Api return ret; } /// - /// + /// 保存角色方法 /// /// [HttpPost] @@ -92,7 +92,7 @@ namespace Bootstrap.Admin.Controllers.Api return RoleHelper.Save(value); } /// - /// + /// 删除角色方法 /// /// [HttpDelete] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs index 90fe3b3f..ec0bb679 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/SettingsController.cs @@ -9,7 +9,7 @@ using System.Collections.Generic; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 网站设置控制器 /// [Route("api/[controller]")] [Authorize] @@ -17,7 +17,7 @@ namespace Bootstrap.Admin.Controllers.Api public class SettingsController : ControllerBase { /// - /// + /// 保存网站设置方法 /// /// /// @@ -26,7 +26,7 @@ namespace Bootstrap.Admin.Controllers.Api public bool Post([FromBody]BootstrapDict value) => DictHelper.SaveSettings(value); /// - /// + /// 获取网站缓存站点集合 /// [HttpGet] public IEnumerable Get() => CacheManager.CorsSites; diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/TasksController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/TasksController.cs index 4265df72..68cde87f 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/TasksController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/TasksController.cs @@ -7,7 +7,7 @@ using System.Linq; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 任务管理控制器 /// [Route("api/[controller]")] [Authorize] @@ -15,7 +15,7 @@ namespace Bootstrap.Admin.Controllers.Api public class TasksController : ControllerBase { /// - /// + /// 获取所有任务数据 /// /// [HttpGet] diff --git a/src/admin/Bootstrap.Admin/Controllers/Api/TasksLogController.cs b/src/admin/Bootstrap.Admin/Controllers/Api/TasksLogController.cs index dcabd56e..9e9924b3 100644 --- a/src/admin/Bootstrap.Admin/Controllers/Api/TasksLogController.cs +++ b/src/admin/Bootstrap.Admin/Controllers/Api/TasksLogController.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace Bootstrap.Admin.Controllers.Api { /// - /// + /// 任务日志控制器 /// [Route("api/[controller]")] [Authorize] diff --git a/src/admin/Bootstrap.Admin/Query/QueryExceptionOption.cs b/src/admin/Bootstrap.Admin/Query/QueryExceptionOption.cs index 60f768fb..47810e93 100644 --- a/src/admin/Bootstrap.Admin/Query/QueryExceptionOption.cs +++ b/src/admin/Bootstrap.Admin/Query/QueryExceptionOption.cs @@ -6,20 +6,22 @@ using System.Linq; namespace Bootstrap.Admin.Query { /// - /// + /// 程序异常查询条件类 /// public class QueryExceptionOption : PaginationOption { /// - /// + /// 获得/设置 开始时间 /// public DateTime? StartTime { get; set; } + /// - /// + /// 获得/设置 结束时间 /// public DateTime? EndTime { get; set; } + /// - /// + /// 查询方法 /// /// public QueryData Retrieves() diff --git a/src/admin/Bootstrap.DataAccess/App.cs b/src/admin/Bootstrap.DataAccess/App.cs index 71f2a251..5f547608 100644 --- a/src/admin/Bootstrap.DataAccess/App.cs +++ b/src/admin/Bootstrap.DataAccess/App.cs @@ -34,7 +34,7 @@ namespace Bootstrap.DataAccess public virtual IEnumerable RetrievesByRoleId(string roleId) { using var db = DbManager.Create(); - var ret = db.Fetch($"select d.Code as Id, d.Name as AppName, case ra.AppId when d.Code then 'checked' else '' end Checked from Dicts d left join RoleApp ra on d.Code = ra.AppId and ra.RoleId = @1 where d.Code > '0' and d.Category = @0", "应用程序", roleId); + var ret = db.Fetch($"select d.Code as Id, d.Name as AppName, case ra.AppId when d.Code then 'checked' else '' end Checked from Dicts d left join RoleApp ra on d.Code = ra.AppId and ra.RoleId = @1 where d.Category = @0", "应用程序", roleId); // 判断是否为Administrators var role = RoleHelper.Retrieves().FirstOrDefault(r => r.Id == roleId); diff --git a/src/admin/Bootstrap.DataAccess/Helper/UserHelper.cs b/src/admin/Bootstrap.DataAccess/Helper/UserHelper.cs index 2174fd37..77cbc35e 100644 --- a/src/admin/Bootstrap.DataAccess/Helper/UserHelper.cs +++ b/src/admin/Bootstrap.DataAccess/Helper/UserHelper.cs @@ -36,10 +36,10 @@ namespace Bootstrap.DataAccess private static bool UserChecker(User user) { - if (user.Description?.Length > 500) user.Description = user.Description.Substring(0, 500); - if (user.UserName?.Length > 16) user.UserName = user.UserName.Substring(0, 16); - if (user.Password?.Length > 50) user.Password = user.Password.Substring(0, 50); - if (user.DisplayName?.Length > 20) user.DisplayName = user.DisplayName.Substring(0, 20); + if (user.Description.Length > 500) user.Description = user.Description.Substring(0, 500); + if (user.UserName.Length > 16) user.UserName = user.UserName.Substring(0, 16); + if (user.Password.Length > 50) user.Password = user.Password.Substring(0, 50); + if (user.DisplayName.Length > 20) user.DisplayName = user.DisplayName.Substring(0, 20); var pattern = @"^[a-zA-Z0-9_@.]*$"; return Regex.IsMatch(user.UserName, pattern); } diff --git a/test/UnitTest/Bootstrap.Admin/Api/SQLServer/GroupsTest.cs b/test/UnitTest/Bootstrap.Admin/Api/SQLServer/GroupsTest.cs index 77a095fd..f07d2a19 100644 --- a/test/UnitTest/Bootstrap.Admin/Api/SQLServer/GroupsTest.cs +++ b/test/UnitTest/Bootstrap.Admin/Api/SQLServer/GroupsTest.cs @@ -22,14 +22,6 @@ namespace Bootstrap.Admin.Api.SqlServer Assert.Single(qd.rows); } - [Fact] - public async void GetById_Ok() - { - var id = GroupHelper.Retrieves().Where(gp => gp.GroupName == "Admin").First().Id; - var g = await Client.GetAsJsonAsync(id); - Assert.Equal("Admin", g.GroupName); - } - [Fact] public async void PostAndDelete_Ok() {