修改同步賬號

This commit is contained in:
dev02 2023-01-04 15:25:24 +08:00
parent 84bddaaa94
commit e4de0c624a
6 changed files with 153 additions and 5 deletions

View File

@ -253,6 +253,7 @@
<script>
var rolAuthTable = null;
$(function () {
asyncUser();
clearPagSes();
getRoleSel();
loadAccManTable();
@ -904,4 +905,16 @@
}
ytAjax = new YourTeam.Ajax(url, objSendData, success, null, "POST").send();
}
function asyncUser() {
getUserByBaja(syncUsrCallBack)
}
function syncUsrCallBack(rel) {
let url = baseApiUrl + "/User/SyncUser";
var data = JSON.parse(rel);
objSendData.Data = data.data;
console.log(objSendData);
ytAjax = new YourTeam.Ajax(url, objSendData, null, null, "POST").send();
}
</script>

View File

@ -136,7 +136,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<aside class="page-sidebar hidden-lg-up">
<div class="page-logo">
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<img name="webLogo" src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<span class="page-logo-text mr-1">System</span>
<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
<i class="fal fa-angle-down d-inline-block ml-1 fs-lg color-primary-300"></i>
@ -1416,7 +1416,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<!-- we need this logo when user switches to nav-function-top -->
<div class="page-logo">
<a href="javascript:;" name="topFunBtn" data-page="dashboard" class="page-logo-link press-scale-down d-flex align-items-center position-relative">
<img src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<img name="webLogo" src="img/logo.png" alt="SmartAdmin WebApp" aria-roledescription="logo">
<!--<span class="page-logo-text mr-1">SmartAdmin WebApp</span>
<span class="position-absolute text-white opacity-50 small pos-top pos-right mr-2 mt-n2"></span>
@ -2081,6 +2081,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
"datatables.net.b4",
"n4js/alarmbaja",
"n4js/historybaja",
"n4js/accmanbaja",
"lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle",
"lib/jquery-validation/dist/jquery.validate",
@ -2139,6 +2140,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
function isValidLogin() {
$("#app").load("_dashboard.html", loadCallback);
getLogo();
iniFroList();
showMainSys();
getBuiList();
@ -2778,6 +2780,17 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}
}, null, "POST").send();
}
function getLogo() {
$.ajax({
method: "post",
url: 'api/GetLogo',
async: false,
success: function (rel) {
$('[name=webLogo]').attr('src', 'img/' + rel);
}
})
}
</script>
</body>

View File

@ -0,0 +1,32 @@
function getUserByBaja(callback) {
var _result = "";
var _ss = "";
var _index = 0;
var syncAcc = [];
require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|station:|slot:/Services/UserService|bql:select * from baja:User where enabled = 'true' and toString != 'defaultPrototype'").get()
.then(function (table) {
table.cursor({
each: function (item) {
if (_index == 0)
_ss += '{"Account": "' + item.$map.$map.toString.$display + '"}';
else
_ss += ',{"Account": "' + item.$map.$map.toString.$display + '"}';
_index++;
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += _ss;
_result += ']}';
if (typeof callback === 'function') {
callback(_result);
}
},
limit: -1,
offset: 0
})
});
});
}

View File

@ -27,7 +27,7 @@
<div class="blankpage-form-field">
<div class="page-logo m-0 w-100 align-items-center justify-content-center rounded border-bottom-left-radius-0 border-bottom-right-radius-0 px-4">
<div class="page-logo-link press-scale-down d-flex align-items-center">
<img src="img/logo.png" aria-roledescription="logo">
<img name="webLogo" src="img/logo.png" aria-roledescription="logo">
<span class="page-logo-text mr-1">全方位監控系統</span>
</div>
</div>
@ -198,8 +198,9 @@
e.preventDefault();
})
getLogo();
}
function Login(account, e) {
cookies = new YourTeam.Utility.Cookie();
e ? e.preventDefault() : "";
@ -244,6 +245,17 @@
}
function getLogo() {
$.ajax({
method: "post",
url: 'api/GetLogo',
async: false,
success: function (rel) {
$('[name=webLogo]').attr('src', 'img/' + rel);
}
})
}
</script>
<script type="text/javascript">

View File

@ -904,5 +904,60 @@ namespace FrontendWebApi.ApiControllers
}
return Ok(apiResult);
}
[HttpPost]
public async Task<ActionResult<ApiResult<string>>> SyncUser([FromBody] List<SaveUserManager> post)
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
//await backendRepository.ExecuteSql("update userinfo deleted = 1 where deleted = 0");
if (post != null)
{
if (post.Count > 0)
{
foreach(var acc in post)
{
var account = await frontendRepository.GetOneAsync<UserManagerList>("select * from userinfo where account = @account", new { @account = acc.Account });
if (account != null)
{
await backendRepository.ExecuteSql("update userinfo deleted = 0 where userinfo_guid = @guid", new { @guid = account.Userinfo_guid });
}
else
{
//產生一組GUID
var guid = Guid.NewGuid(); //角色GUID
Dictionary<string, object> role = new Dictionary<string, object>();
role = new Dictionary<string, object>()
{
{ "@role_guid", guid},
{ "@full_name", acc.Account},
{ "@account", acc.Account},
{ "@role_guid", "F127F501-A7BB-4C46-AB82-0809C1C8D2C1"},
{ "@created_by", myUser.userinfo_guid},
{ "@created_at", DateTime.Now}
};
await backendRepository.AddOneByCustomTable(role, "role");
}
}
}
}
apiResult.Code = "0000";
apiResult.Data = "同步成功";
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
return Ok(apiResult);
}
return Ok(apiResult);
}
}
}

View File

@ -155,5 +155,28 @@ namespace FrontendWebApi.ApiControllers
return apiResult;
}
[HttpPost]
[Route("api/GetLogo")]
public async Task<ApiResult<string>> GetLogo()
{
ApiResult<string> apiResult = new ApiResult<string>();
try
{
var sqlString = $@"select system_type from variable where system_type = 'logo'";
var data = await backendRepository.GetOneAsync<string>(sqlString);
apiResult.Code = "0000";
apiResult.Data = data;
}
catch (Exception exception)
{
apiResult.Code = "9999";
apiResult.Msg = "系統內部錯誤,請聯絡管理者。";
Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message);
}
return apiResult;
}
}
}