diff --git a/FrontendWebApi/ApiControllers/UserController.cs b/FrontendWebApi/ApiControllers/UserController.cs index 8b2c6e1..f6e5aa4 100644 --- a/FrontendWebApi/ApiControllers/UserController.cs +++ b/FrontendWebApi/ApiControllers/UserController.cs @@ -596,26 +596,53 @@ namespace FrontendWebApi.ApiControllers } else { - await backendRepository.ExecuteSql($"delete from role_auth where role_guid = '{post.SelectedRoleId}' and AuthCode like '%PF%'"); - if (post.SaveCheckAuth.Count > 0) + if (post.Type.Equals("1")) { - foreach (var item in post.SaveCheckAuth) + await backendRepository.ExecuteSql($"delete from role_auth where role_guid = '{post.SelectedRoleId}' and AuthCode like '%PF%'"); + if (post.SaveCheckAuth.Count > 0) { - #region 新增權限 + foreach (var item in post.SaveCheckAuth) { - Dictionary roleAuth = new Dictionary(); - roleAuth = new Dictionary() - { - { "@role_guid", post.SelectedRoleId}, - { "@AuthCode", item}, - { "@created_by", myUser.userinfo_guid} - }; + #region 新增權限 + { + Dictionary roleAuth = new Dictionary(); + roleAuth = new Dictionary() + { + { "@role_guid", post.SelectedRoleId}, + { "@AuthCode", item}, + { "@created_by", myUser.userinfo_guid} + }; - await backendRepository.AddOneByCustomTable(roleAuth, "role_auth"); + await backendRepository.AddOneByCustomTable(roleAuth, "role_auth"); + } + #endregion } - #endregion } } + else if (post.Type.Equals("2")) + { + await backendRepository.ExecuteSql($"delete from role_auth where role_guid = '{post.SelectedRoleId}' and AuthCode like 'F%'"); + if (post.SaveCheckAuth.Count > 0) + { + foreach (var item in post.SaveCheckAuth) + { + #region 新增權限 + { + Dictionary roleAuth = new Dictionary(); + roleAuth = new Dictionary() + { + { "@role_guid", post.SelectedRoleId}, + { "@AuthCode", item}, + { "@created_by", myUser.userinfo_guid} + }; + + await backendRepository.AddOneByCustomTable(roleAuth, "role_auth"); + } + #endregion + } + } + } + apiResult.Code = "0000"; apiResult.Msg = "儲存成功"; } diff --git a/FrontendWebApi/Models/User.cs b/FrontendWebApi/Models/User.cs index 4437472..23636c2 100644 --- a/FrontendWebApi/Models/User.cs +++ b/FrontendWebApi/Models/User.cs @@ -147,6 +147,7 @@ namespace FrontendWebApi.Models { public string SelectedRoleId { get; set; } public List SaveCheckAuth { get; set; } + public string Type { get; set; } //public FrontEndCheckAuth BackEndCheckAuth { get; set; } }