diff --git a/SolarPower/Controllers/RoleController.cs b/SolarPower/Controllers/RoleController.cs index 6902af0..704789f 100644 --- a/SolarPower/Controllers/RoleController.cs +++ b/SolarPower/Controllers/RoleController.cs @@ -69,9 +69,9 @@ namespace SolarPower.Controllers totalRecords = roles.Count(); recFilter = roles.Count(); - foreach(var role in roles) + foreach (var role in roles) { - if(role.Layer == (int)RoleLayerEnum.PlatformAdmin || role.Layer == (int)RoleLayerEnum.CompanyAdmin) + if (role.Layer == (int)RoleLayerEnum.PlatformAdmin || role.Layer == (int)RoleLayerEnum.CompanyAdmin) { //管理階層的角色無法被刪除 role.Function = ""; } @@ -170,7 +170,7 @@ namespace SolarPower.Controllers } - if(!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) + if (!IsPlatformLayer(myUser.Role.Layer) && myUser.CompanyId != post.SelectedCompanyId) { //非平台人員,就只能新增自己公司的角色 apiResult.Code = "9993"; apiResult.Msg = errorCode.GetString(apiResult.Code); @@ -202,11 +202,33 @@ namespace SolarPower.Controllers "CreatedBy", }; - await roleRepository.AddAsync(role, properties); + var id = await roleRepository.AddOneAsync(role, properties); + + #endregion + + #region 增加角色的權限(地圖總覽) + List roleAuths = new List(); + + RoleAuth roleAuth = new RoleAuth(); + roleAuth.Id = role.Id; + roleAuth.AuthCode = "A"; + roleAuth.CreatedBy = myUser.Id; + + roleAuths.Add(roleAuth); + + List roleAuth_properties = new List() + { + "Id", + "AuthCode", + "CreatedBy", + }; + + await roleRepository.AddRoleAuthAsync(roleAuths, roleAuth_properties); + #endregion apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; - #endregion + } else { diff --git a/SolarPower/Controllers/UserController.cs b/SolarPower/Controllers/UserController.cs index f8227f3..38dc272 100644 --- a/SolarPower/Controllers/UserController.cs +++ b/SolarPower/Controllers/UserController.cs @@ -174,7 +174,6 @@ namespace SolarPower.Controllers { "Password", "UpdatedBy", - "UpdatedAt", "Id" }; @@ -186,6 +185,7 @@ namespace SolarPower.Controllers catch (Exception exception) { apiResult.Code = "9999"; + apiResult.Msg = errorCode.GetString(apiResult.Code); string json = System.Text.Json.JsonSerializer.Serialize(post); Logger.LogError("【" + controllerName + "/" + actionName + "】"); Logger.LogError("【" + controllerName + "/" + actionName + "】" + exception.Message); diff --git a/SolarPower/Views/Company/Index.cshtml b/SolarPower/Views/Company/Index.cshtml index 9fbfe4b..41e15ac 100644 --- a/SolarPower/Views/Company/Index.cshtml +++ b/SolarPower/Views/Company/Index.cshtml @@ -312,7 +312,7 @@ "info": true, "autoWidth": false, "responsive": true, - "order": [[1, "desc"]], + // "order": [[1, "desc"]], "columns": [{ "data": "authCode" }, { @@ -329,9 +329,13 @@ 'className': 'dt-body-center', 'render': function (data, type, full, meta) { var check_html = ""; + var disabled = ""; check_html += '
'; if (full.checkAuth > 0) { - check_html += ' '; + if (data == 'A') { + disabled = "disabled"; + } + check_html += ' '; } else { check_html += ' '; } diff --git a/SolarPower/Views/Login/ForgotPassword.cshtml b/SolarPower/Views/Login/ForgotPassword.cshtml index 5308192..bb0f3b8 100644 --- a/SolarPower/Views/Login/ForgotPassword.cshtml +++ b/SolarPower/Views/Login/ForgotPassword.cshtml @@ -7,58 +7,76 @@ - 後台管理 | 忘記密碼 + 忘記密碼 | 太陽能電站管理系統 + + + + + + + + + + + - - - -