diff --git a/Bootstrap.Admin/wwwroot/js/profiles.js b/Bootstrap.Admin/wwwroot/js/profiles.js
index 1dba29b3..70ddd1af 100644
--- a/Bootstrap.Admin/wwwroot/js/profiles.js
+++ b/Bootstrap.Admin/wwwroot/js/profiles.js
@@ -67,7 +67,8 @@
NewPassword: "#newPassword",
DisplayName: "#displayName",
UserName: "#userName",
- Css: "#css"
+ Css: "#css",
+ App: '#app'
});
$('button[data-method]').on('click', function (e) {
@@ -100,6 +101,16 @@
}
});
break;
+ case 'app':
+ data.UserStatus = 'SaveApp';
+ $.bc({
+ url: User.url, method: "put", data: data, title: "保存应用", callback: function (result) {
+ if (result) {
+ window.setTimeout(function () { window.location.reload(true); }, 1000);
+ }
+ }
+ });
+ break;
}
});
$('[data-admin="False"]').removeClass('d-none');
@@ -107,4 +118,5 @@
$('.card-img').removeClass('d-none');
}
$('#css').dropdown('val');
+ $('#app').dropdown('val');
});
\ No newline at end of file
diff --git a/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj b/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj
index ff512612..58c1c04e 100644
--- a/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj
+++ b/Bootstrap.Client.DataAccess/Bootstrap.Client.DataAccess.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/Bootstrap.DataAccess.MongoDB/User.cs b/Bootstrap.DataAccess.MongoDB/User.cs
index 30581c6f..b0a35b5c 100644
--- a/Bootstrap.DataAccess.MongoDB/User.cs
+++ b/Bootstrap.DataAccess.MongoDB/User.cs
@@ -51,6 +51,13 @@ namespace Bootstrap.DataAccess.MongoDB
return u != null && !string.IsNullOrEmpty(u.PassSalt) && u.Password == LgbCryptography.ComputeHash(password, u.PassSalt);
}
+ public override bool SaveApp(string userName, string app)
+ {
+ var update = Builders.Update.Set(u => u.App, app);
+ DbManager.Users.FindOneAndUpdate(u => u.UserName.ToLowerInvariant() == UserName.ToLowerInvariant(), update);
+ return true;
+ }
+
///
///
///
diff --git a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
index 425d4cbd..655b9c0e 100644
--- a/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
+++ b/Bootstrap.DataAccess/Bootstrap.DataAccess.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/Bootstrap.DataAccess/Dict.cs b/Bootstrap.DataAccess/Dict.cs
index b7e56bbc..0b808899 100644
--- a/Bootstrap.DataAccess/Dict.cs
+++ b/Bootstrap.DataAccess/Dict.cs
@@ -96,8 +96,26 @@ namespace Bootstrap.DataAccess
///
/// 获得默认的前台首页地址,默认为~/Home/Index
///
+ ///
///
- public virtual string RetrieveHomeUrl() => (DictHelper.RetrieveDicts().FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0) ?? new BootstrapDict() { Code = "~/Home/Index" }).Code;
+ public virtual string RetrieveHomeUrl(string appCode)
+ {
+ // https://gitee.com/LongbowEnterprise/dashboard/issues?id=IS0WK
+ var url = "~/Home/Index";
+ var dicts = DictHelper.RetrieveDicts();
+ if (appCode != "0")
+ {
+ var appUrl = dicts.FirstOrDefault(d => d.Name.Equals(appCode, StringComparison.OrdinalIgnoreCase) && d.Category == "应用首页" && d.Define == 0)?.Code;
+ if (!string.IsNullOrEmpty(appUrl))
+ {
+ url = appUrl;
+ return url;
+ }
+ }
+ var defaultUrl = dicts.FirstOrDefault(d => d.Name == "前台首页" && d.Category == "网站设置" && d.Define == 0)?.Code;
+ if (!string.IsNullOrEmpty(defaultUrl)) url = defaultUrl;
+ return url;
+ }
///
///
diff --git a/Bootstrap.DataAccess/Helper/DictHelper.cs b/Bootstrap.DataAccess/Helper/DictHelper.cs
index 184467d1..7a839958 100644
--- a/Bootstrap.DataAccess/Helper/DictHelper.cs
+++ b/Bootstrap.DataAccess/Helper/DictHelper.cs
@@ -106,8 +106,9 @@ namespace Bootstrap.DataAccess
///
/// 获得默认的前台首页地址,默认为~/Home/Index
///
+ /// 应用程序编码
///
- public static string RetrieveHomeUrl() => DbContextManager.Create().RetrieveHomeUrl();
+ public static string RetrieveHomeUrl(string appCode) => DbContextManager.Create().RetrieveHomeUrl(appCode);
///
///
diff --git a/Bootstrap.DataAccess/Helper/UserHelper.cs b/Bootstrap.DataAccess/Helper/UserHelper.cs
index 735a53de..2b4a5403 100644
--- a/Bootstrap.DataAccess/Helper/UserHelper.cs
+++ b/Bootstrap.DataAccess/Helper/UserHelper.cs
@@ -1,6 +1,7 @@
using Bootstrap.Security;
using Longbow.Cache;
using Longbow.Data;
+using System;
using System.Collections.Generic;
namespace Bootstrap.DataAccess
@@ -48,6 +49,19 @@ namespace Bootstrap.DataAccess
return ret;
}
+ ///
+ /// 保存用户默认App
+ ///
+ ///
+ ///
+ ///
+ public static bool SaveApp(string userName, string app)
+ {
+ var ret = DbContextManager.Create().SaveApp(userName, app);
+ if (ret) CacheCleanUtility.ClearCache(cacheKey: $"{RetrieveUsersDataKey}*");
+ return ret;
+ }
+
///
/// 保存新建
///
@@ -163,6 +177,7 @@ namespace Bootstrap.DataAccess
return ret;
}
+ ///
/// 根据用户名修改用户头像
///
///
diff --git a/Bootstrap.DataAccess/User.cs b/Bootstrap.DataAccess/User.cs
index de890fef..5beed944 100644
--- a/Bootstrap.DataAccess/User.cs
+++ b/Bootstrap.DataAccess/User.cs
@@ -81,6 +81,14 @@ namespace Bootstrap.DataAccess
return user != null && !string.IsNullOrEmpty(user.PassSalt) && user.Password == LgbCryptography.ComputeHash(password, user.PassSalt);
}
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public virtual bool SaveApp(string userName, string app) => DbManager.Create().Update("set App = @1 where UserName = @0", userName, app) == 1;
+
///
///
///
@@ -358,6 +366,10 @@ namespace Bootstrap.DataAccess
///
///
///
- RejectUser
+ RejectUser,
+ ///
+ ///
+ ///
+ SaveApp
}
}
diff --git a/DatabaseScripts/MongoDB/BootstrapAdmin.Users.json b/DatabaseScripts/MongoDB/BootstrapAdmin.Users.json
index 1d204b45..eb8ff07f 100644
--- a/DatabaseScripts/MongoDB/BootstrapAdmin.Users.json
+++ b/DatabaseScripts/MongoDB/BootstrapAdmin.Users.json
@@ -11,6 +11,7 @@
"Description": "系统默认创建",
"Icon": "default.jpg",
"Css": null,
+ "App": null,
"Roles": [
"5bd7cc105fa31256f77e4eb7"
],
@@ -30,6 +31,7 @@
"Description": "管理员Admin创建用户",
"Icon": "default.jpg",
"Css": null,
+ "App": null,
"Groups": [
],
diff --git a/UnitTest/Bootstrap.Admin/Api/UsersTest.cs b/UnitTest/Bootstrap.Admin/Api/UsersTest.cs
index 930c4f24..c3936c2c 100644
--- a/UnitTest/Bootstrap.Admin/Api/UsersTest.cs
+++ b/UnitTest/Bootstrap.Admin/Api/UsersTest.cs
@@ -110,6 +110,12 @@ namespace Bootstrap.Admin.Api
resp = await client.PutAsJsonAsync(usr);
Assert.True(resp);
+ // change app
+ usr.App = "UnitTest";
+ usr.UserStatus = UserStates.SaveApp;
+ resp = await client.PutAsJsonAsync(usr);
+ Assert.True(resp);
+
// delete
usr.Delete(usr.Retrieves().Where(u => u.UserName == usr.UserName).Select(u => u.Id));
}
diff --git a/UnitTest/Bootstrap.DataAccess/DictsTest.cs b/UnitTest/Bootstrap.DataAccess/DictsTest.cs
index cd16ca9a..d25afa82 100644
--- a/UnitTest/Bootstrap.DataAccess/DictsTest.cs
+++ b/UnitTest/Bootstrap.DataAccess/DictsTest.cs
@@ -80,7 +80,7 @@ namespace Bootstrap.DataAccess
public void RetrieveHomeUrl_Ok()
{
var dict = new Dict();
- Assert.Equal("~/Home/Index", dict.RetrieveHomeUrl());
+ Assert.Equal("~/Home/Index", dict.RetrieveHomeUrl("0"));
}
[Fact]