doc: 增加方法注释信息

This commit is contained in:
Argo Zhang 2019-09-01 11:22:31 +08:00
parent dabf5c5ba9
commit bc5301679a
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
13 changed files with 62 additions and 57 deletions

View File

@ -5,10 +5,16 @@ using System.Linq;
namespace Bootstrap.Client.DataAccess.MongoDB
{
/// <summary>
///
/// 应用程序实体类
/// </summary>
public class App : DataAccess.App
{
/// <summary>
/// 获取所有应用程序数据方法
/// </summary>
/// <returns></returns>
private IEnumerable<KeyValuePair<string, string>> RetrieveApps() => DictHelper.RetrieveDicts().Where(d => d.Category == "应用程序" && d.Define == 0).Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(d => d.Key);
/// <summary>
/// 根据指定用户名获得授权应用程序集合
/// </summary>
@ -18,9 +24,9 @@ namespace Bootstrap.Client.DataAccess.MongoDB
{
var ret = new List<string>();
var roles = RoleHelper.RetrievesByUserName(userName);
if (roles.Contains("Administrators", StringComparer.OrdinalIgnoreCase))
if (roles.Any(r => r.Equals("Administrators", StringComparison.OrdinalIgnoreCase)))
{
ret.AddRange(DictHelper.RetrieveApps().Select(kv => kv.Key));
ret.AddRange(RetrieveApps().Select(kv => kv.Key));
}
else
{

View File

@ -18,7 +18,7 @@ namespace Bootstrap.Client.DataAccess.MongoDB
private static readonly object _locker = new object();
/// <summary>
///
/// BA数据库 IMongoDatabase 实例
/// </summary>
private static IMongoDatabase BADatabase
{

View File

@ -7,12 +7,12 @@ using System.Linq;
namespace Bootstrap.Client.DataAccess.MongoDB
{
/// <summary>
///
/// 字典表实体类
/// </summary>
public class Dict : DataAccess.Dict
internal class Dict : DataAccess.Dict
{
/// <summary>
///
/// 获取所有字典表数据方法
/// </summary>
/// <returns></returns>
public override IEnumerable<BootstrapDict> RetrieveDicts() => DbManager.Dicts.Find(FilterDefinition<BootstrapDict>.Empty).ToList();

View File

@ -4,7 +4,10 @@ using System.Collections.Generic;
namespace Bootstrap.Client.DataAccess.MongoDB
{
class Group : BootstrapGroup
/// <summary>
/// Group 实体类
/// </summary>
internal class Group : BootstrapGroup
{
/// <summary>
/// 获得/设置 群组描述
@ -12,12 +15,12 @@ namespace Bootstrap.Client.DataAccess.MongoDB
public string Description { get; set; }
/// <summary>
///
/// 获得/设置 当前组授权角色数据集合
/// </summary>
public IEnumerable<string> Roles { get; set; }
/// <summary>
///
/// 获得所有组数据方法
/// </summary>
/// <returns></returns>
public IEnumerable<Group> Retrieves()

View File

@ -5,15 +5,18 @@ using System.Linq;
namespace Bootstrap.Client.DataAccess.MongoDB
{
class GroupHelper
/// <summary>
/// 组数据相关操作帮助类
/// </summary>
internal class GroupHelper
{
/// <summary>
///
/// 组数据缓存键值
/// </summary>
public const string RetrieveGroupsDataKey = "GroupHelper-RetrieveGroups";
/// <summary>
///
/// 获取所有组数据集合方法
/// </summary>
/// <returns></returns>
public static IEnumerable<Group> Retrieves()

View File

@ -1,14 +1,18 @@
using Longbow.Cache;
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Client.DataAccess.MongoDB
{
class RoleHelper
/// <summary>
/// 角色数据相关操作帮助类
/// </summary>
internal class RoleHelper
{
/// <summary>
///
/// 角色数据缓存键值
/// </summary>
public const string RetrieveRolesDataKey = "RoleHelper-RetrieveRoles";
@ -19,14 +23,14 @@ namespace Bootstrap.Client.DataAccess.MongoDB
public static IEnumerable<Role> Retrieves() => CacheManager.GetOrAdd(RetrieveRolesDataKey, key => DbManager.Roles.Find(FilterDefinition<Role>.Empty).ToList());
/// <summary>
///
/// 通过指定用户名获取角色集合方法
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public static IEnumerable<string> RetrievesByUserName(string userName)
{
var roles = new List<string>();
var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase));
if (user != null)
{
var role = Retrieves();

View File

@ -5,7 +5,10 @@ using System.Collections.Generic;
namespace Bootstrap.Client.DataAccess.MongoDB
{
class UserHelper
/// <summary>
/// 用户表相关操作帮助类
/// </summary>
internal class UserHelper
{
/// <summary>
/// 获取所有用户缓存数据键值

View File

@ -9,7 +9,7 @@ namespace Bootstrap.Client.DataAccess.MongoDB
/// <summary>
/// 菜单实体类
/// </summary>
public class Menu : DataAccess.Menu
internal class Menu : DataAccess.Menu
{
/// <summary>
/// 通过当前用户名获得所有菜单
@ -18,7 +18,7 @@ namespace Bootstrap.Client.DataAccess.MongoDB
/// <returns></returns>
public override IEnumerable<BootstrapMenu> RetrieveAllMenus(string userName)
{
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase));
if (user == null) return Enumerable.Empty<BootstrapMenu>();
var roles = RoleHelper.Retrieves().Cast<Role>();

View File

@ -1,13 +1,14 @@
using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Bootstrap.Client.DataAccess.MongoDB
{
/// <summary>
///
/// 角色实体类
/// </summary>
public class Role : DataAccess.Role
internal class Role : DataAccess.Role
{
/// <summary>
/// 此角色关联的所有菜单
@ -35,14 +36,14 @@ namespace Bootstrap.Client.DataAccess.MongoDB
public string Description { get; set; }
/// <summary>
///
/// 通过指定登录名获取授权角色名称数据集合
/// </summary>
/// <param name="userName"></param>
/// <param name="userName">登录名</param>
/// <returns></returns>
public override IEnumerable<string> RetrievesByUserName(string userName)
{
var roles = new List<string>();
var user = UserHelper.Retrieves().Cast<User>().FirstOrDefault(u => u.UserName.ToLowerInvariant() == userName.ToLowerInvariant());
var user = UserHelper.Retrieves().FirstOrDefault(u => u.UserName.Equals(userName, StringComparison.OrdinalIgnoreCase));
if (user != null)
{
var role = RoleHelper.Retrieves();
@ -61,8 +62,8 @@ namespace Bootstrap.Client.DataAccess.MongoDB
public override IEnumerable<string> RetrievesByUrl(string url)
{
var menu = DbManager.Menus.Find(md => md.Url.StartsWith(url)).FirstOrDefault();
var ret = RoleHelper.Retrieves().Cast<Role>().Where(md => md.Menus != null && md.Menus.Contains(menu.Id)).Select(m => m.RoleName).ToList();
if (!ret.Contains("Administrators")) ret.Add("Administrators");
var ret = RoleHelper.Retrieves().Where(md => md.Menus != null && md.Menus.Any(m => m.Equals(menu.Id, StringComparison.OrdinalIgnoreCase))).Select(m => m.RoleName).ToList();
if (!ret.Any(r => r.Equals("Administrators", StringComparison.OrdinalIgnoreCase))) ret.Add("Administrators");
return ret;
}
}

View File

@ -8,7 +8,7 @@ namespace Bootstrap.Client.DataAccess.MongoDB
/// <summary>
/// 用户表实体类
/// </summary>
public class User : DataAccess.User
internal class User : DataAccess.User
{
/// <summary>
/// 获得/设置 用户主键ID
@ -21,17 +21,17 @@ namespace Bootstrap.Client.DataAccess.MongoDB
public DateTime? ApprovedTime { get; set; }
/// <summary>
///
/// 获得/设置 用户授权角色ID集合
/// </summary>
public IEnumerable<string> Roles { get; set; }
/// <summary>
///
/// 获得/设置 用户授权组ID集合
/// </summary>
public IEnumerable<string> Groups { get; set; }
/// <summary>
///
/// 通过指定登录名获取 BootstrapUser 实例方法
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>

View File

@ -8,7 +8,7 @@ using System.Linq;
namespace Bootstrap.Client.DataAccess
{
/// <summary>
///
/// 字典表实体类
/// </summary>
public class Dict : BootstrapDict
{
@ -47,13 +47,13 @@ namespace Bootstrap.Client.DataAccess
public string RetrieveLocaleIPSvr() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "系统设置" && d.Name == "IP地理位置接口" && d.Define == 0)?.Code;
/// <summary>
///
/// 获取 IP 地理位置查询服务缓存时长
/// </summary>
/// <returns></returns>
public string RetrieveLocaleIPSvrCachePeriod() => DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "系统设置" && d.Name == "IP请求缓存时长" && d.Define == 0)?.Code;
/// <summary>
/// 获得 项目是否获取登录地点 默认为false
/// 获得 项目是否获取登录地点 默认为 false
/// </summary>
/// <param name="ipSvr">服务提供名称</param>
/// <returns></returns>
@ -83,12 +83,6 @@ namespace Bootstrap.Client.DataAccess
/// <returns></returns>
public bool RetrieveSidebarStatus() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Category == "网站设置" && d.Name == "侧边栏状态" && d.Define == 0)?.Code ?? "1") == "1";
/// <summary>
///
/// </summary>
/// <returns></returns>
public virtual IEnumerable<KeyValuePair<string, string>> RetrieveApps() => DictHelper.RetrieveDicts().Where(d => d.Category == "应用程序" && d.Define == 0).Select(d => new KeyValuePair<string, string>(d.Code, d.Name)).OrderBy(d => d.Key);
/// <summary>
/// 获取头像路径
/// </summary>

View File

@ -6,7 +6,7 @@ using System.Collections.Generic;
namespace Bootstrap.Client.DataAccess
{
/// <summary>
///
/// 应用操作帮助类
/// </summary>
public static class AppHelper
{

View File

@ -7,38 +7,29 @@ using System.Collections.Generic;
namespace Bootstrap.Client.DataAccess
{
/// <summary>
///
/// 字典操作帮助类
/// </summary>
public static class DictHelper
{
/// <summary>
///
/// </summary>
/// <summary>
/// 缓存索引BootstrapAdmin后台清理缓存时使用
/// </summary>
public const string RetrieveDictsDataKey = DbHelper.RetrieveDictsDataKey;
/// <summary>
///
/// 获取所有字典表数据方法
/// </summary>
/// <returns></returns>
public static IEnumerable<BootstrapDict> RetrieveDicts() => CacheManager.GetOrAdd(RetrieveDictsDataKey, key => DbContextManager.Create<Dict>().RetrieveDicts());
/// <summary>
///
/// </summary>
/// <returns></returns>
public static IEnumerable<KeyValuePair<string, string>> RetrieveApps() => DbContextManager.Create<Dict>().RetrieveApps();
/// <summary>
///
/// 获取站点 Title 配置信息
/// </summary>
/// <returns></returns>
public static string RetrieveWebTitle() => DbContextManager.Create<Dict>().RetrieveWebTitle();
/// <summary>
///
/// 获取站点 Footer 配置信息
/// </summary>
/// <returns></returns>
public static string RetrieveWebFooter() => DbContextManager.Create<Dict>().RetrieveWebFooter();
@ -50,20 +41,20 @@ namespace Bootstrap.Client.DataAccess
public static string RetrieveActiveTheme() => DbContextManager.Create<Dict>().RetrieveActiveTheme();
/// <summary>
///
/// 获取 IP地理位置查询服务请求地址
/// </summary>
/// <returns></returns>
public static string RetrieveLocaleIPSvr() => DbContextManager.Create<Dict>().RetrieveLocaleIPSvr();
/// <summary>
///
/// 通过 IP 地理位置查询服务名称获得请求地址方法
/// </summary>
/// <param name="ipSvr">ip地址请求服务名称</param>
/// <returns></returns>
public static string RetrieveLocaleIPSvrUrl(string ipSvr) => DbContextManager.Create<Dict>().RetrieveLocaleIPSvrUrl(ipSvr);
/// <summary>
///
/// 获取 IP 地理位置查询服务缓存时长
/// </summary>
/// <returns></returns>
public static string RetrieveLocaleIPSvrCachePeriod() => DbContextManager.Create<Dict>().RetrieveLocaleIPSvrCachePeriod();