增加功能:字典表增加开关配置项是否获取客户端登录地点 closed #ITAJX

#Issue
https://gitee.com/LongbowEnterprise/dashboard/issues?id=ITAJX
This commit is contained in:
Argo Zhang 2019-03-08 16:21:31 +08:00
parent e4bc9fd06a
commit 6e9b880101
9 changed files with 38 additions and 3 deletions

View File

@ -1,4 +1,5 @@
using Longbow.Configuration;
using Bootstrap.DataAccess;
using Longbow.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Concurrent;
@ -58,7 +59,7 @@ namespace Bootstrap.Admin
/// <returns></returns>
public string RetrieveLocaleByIp(string ip = null)
{
if (ip.IsNullOrEmpty() || _local.Any(p => p == ip)) return "本地连接";
if (DictHelper.RetrieveLocaleIP() == 0 || ip.IsNullOrEmpty() || _local.Any(p => p == ip)) return "本地连接";
var url = ConfigurationManager.AppSettings["IPSvrUrl"];
var task = _client.GetAsJsonAsync<IPLocator>($"{url}{ip}");

View File

@ -150,6 +150,12 @@ namespace Bootstrap.DataAccess
/// Cookie保存时长 默认7天
/// </summary>
/// <returns></returns>
public int RetrieveCookieExpiresPeriod() => LgbConvert.ReadValue(DictHelper.RetrieveDicts().Where(d => d.Category == "系统设置" && d.Name == "Cookie保留时长" && d.Define == 0).FirstOrDefault()?.Code, 7);
public int RetrieveCookieExpiresPeriod() => LgbConvert.ReadValue(DictHelper.RetrieveDicts().Where(d => d.Category == "系统设置" && d.Name == "Cookie保留时长" && d.Define == 0).FirstOrDefault()?.Code, 7);
/// <summary>
/// 获得 项目是否获取登录地点 默认为false
/// </summary>
/// <returns></returns>
public int RetrieveLocaleIP() => LgbConvert.ReadValue(DictHelper.RetrieveDicts().Where(d => d.Category == "系统设置" && d.Name == "获取IP地点" && d.Define == 0).FirstOrDefault()?.Code, 0);
}
}

View File

@ -139,5 +139,11 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <returns></returns>
public static int RetrieveCookieExpiresPeriod() => DbContextManager.Create<Dict>().RetrieveCookieExpiresPeriod();
/// <summary>
///
/// </summary>
/// <returns></returns>
public static int RetrieveLocaleIP() => DbContextManager.Create<Dict>().RetrieveLocaleIP();
}
}

View File

@ -39,6 +39,8 @@ INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设
-- 时长单位 天
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'Cookie保留时长', '7', 0)
INSERT [dbo].[Dicts] ([Category], [Name], [Code], [Define]) VALUES (N'系统设置', N'获取IP地点', '0', 0)
DELETE FROM Navigations
SET IDENTITY_INSERT [dbo].[Navigations] ON
INSERT [dbo].[Navigations] ([ID], [ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (1, 0, N'后台管理', 10, N'fa fa-gear', N'~/Admin/Index', N'0')

View File

@ -306,5 +306,12 @@
"Name": "Cookie保留时长",
"Code": "7",
"Define": NumberInt(0)
},
{
"_id": ObjectId("5bd6c73d5fa31256f77e4a44"),
"Category": "系统设置",
"Name": "获取IP地点",
"Code": "0",
"Define": NumberInt(0)
}
]

View File

@ -36,6 +36,8 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '登录
-- 时长单位 天
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'Cookie保留时长', '7', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '获取IP地点', '0', 0);
DELETE FROM Navigations;
ALTER TABLE Navigations MODIFY COLUMN ID INT NOT NULL;
INSERT INTO Navigations (ID, ParentId, Name, `Order`, Icon, Url, Category) VALUES (1, 0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0');

View File

@ -36,6 +36,8 @@ INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '登录
-- 时长单位 天
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', 'Cookie保留时长', '7', 0);
INSERT INTO Dicts (Category, Name, Code, Define) VALUES ('系统设置', '获取IP地点', '0', 0);
DELETE FROM Navigations;
ALTER SEQUENCE navigations_id_seq RESTART WITH 1;
INSERT INTO Navigations (ParentId, Name, "order", Icon, Url, Category) VALUES (0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0');

View File

@ -34,6 +34,8 @@ INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置
-- 时长单位 天
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', 'Cookie保留时长', '7', 0);
INSERT INTO [Dicts] ([Category], [Name], [Code], [Define]) VALUES ('系统设置', '获取IP地点', '0', 0);
DELETE FROM Navigations;
INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, '后台管理', 10, 'fa fa-gear', '~/Admin/Index', '0');
INSERT INTO [Navigations] ([ParentId], [Name], [Order], [Icon], [Url], [Category]) VALUES (0, '个人中心', 20, 'fa fa-suitcase', '~/Admin/Profiles', '0');

View File

@ -124,5 +124,12 @@ namespace Bootstrap.DataAccess
var dict = new Dict();
Assert.Equal(12, dict.RetrieveLogsPeriod());
}
[Fact]
public void RetrieveLocaleIP_Ok()
{
var dict = new Dict();
Assert.Equal(0, dict.RetrieveLocaleIP());
}
}
}