From 7e5a8a7426eb33960c2a5ed751d93592d941157a Mon Sep 17 00:00:00 2001 From: dev02 Date: Tue, 17 Oct 2023 11:17:21 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=BE=8C=E7=AB=AF]=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BD=BF=E7=94=A8=E8=80=85=E8=A8=AD=E5=82=99?= =?UTF-8?q?api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiControllers/UserController.cs | 53 ++++++++++++++----- FrontendWebApi/Models/User.cs | 1 + 2 files changed, 41 insertions(+), 13 deletions(-) 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; } }