|  |  |  | 
|---|
|  |  |  | using WIDESEA_Model.Models.System; | 
|---|
|  |  |  | using WIDESEA_SystemRepository; | 
|---|
|  |  |  | using WIDESEA_Core.Helper; | 
|---|
|  |  |  | using WIDESEA_Core.HostedService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | namespace WIDESEA_SystemService | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override WebResponseContent AddData(SaveModel saveModel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string authorityScope = saveModel.MainData["authorityScope"].ToString(); | 
|---|
|  |  |  | string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? ""; | 
|---|
|  |  |  | Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>(); | 
|---|
|  |  |  | if (BaseDal.QueryFirst(x => x.RoleName == role.RoleName) != null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public override WebResponseContent UpdateData(SaveModel saveModel) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | string authorityScope = saveModel.MainData["authorityScope"].ToString(); | 
|---|
|  |  |  | string authorityScope = saveModel.MainData["authorityScope"].ToString() ?? ""; | 
|---|
|  |  |  | Sys_Role role = saveModel.MainData.DicToModel<Sys_Role>(); | 
|---|
|  |  |  | if (BaseDal.QueryFirst(x => x.RoleId == role.RoleId) == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | 
|---|
|  |  |  | BaseDal.Db.Insertable(roleDataPermissions).ExecuteCommand(); | 
|---|
|  |  |  | BaseDal.Db.Deleteable(oldDatas).ExecuteCommand(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | PermissionDataHostService.UserRoles = PermissionDataHostService.GetUserRoles(Db); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<int> GetAllChildrenRoleId(int roleId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return GetAllChildren(roleId).Select(x => x.Id).ToList(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<RoleNodes> GetAllChildren(int roleId) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (roleId <= 0) return new List<RoleNodes>() { }; | 
|---|