/// <summary> /// 添加权限 /// </summary> /// <param name="permissionitems"></param> /// <returns></returns> public virtual async Task <ResponseMessage> InsertJurisdiction(PermissionitemRequest permissionitems) { var response = new ResponseMessage(); if (permissionitems == null) { throw new Exception(nameof(permissionitems)); } try { var newPermissionitems = _Mapper.Map <Permissionitems>(permissionitems); if (await _IJurisdictionStore.isExist(permissionitems.Id)) { newPermissionitems.Groups = newPermissionitems.Groups; newPermissionitems.Name = newPermissionitems.Name; await _IJurisdictionStore.UpdateJurisdiction(newPermissionitems); return(response); } newPermissionitems.Id = newPermissionitems.Id; newPermissionitems.Groups = newPermissionitems.Groups; newPermissionitems.Name = newPermissionitems.Name; await _IJurisdictionStore.InsertJurisdiction(newPermissionitems); } catch (Exception el) { throw new Exception(nameof(el.Message)); } return(response); }
public async Task <ResponseMessage> AddJurisdiction(PermissionitemRequest permissionRequest) { var users = DataBaseUser.TokenModel; _Logger.LogInformation($"用户{users?.UserName ?? ""},其ID:({users?.Id ?? ""}) 添加组织:\r\n" + (permissionRequest != null ? JsonHelpers.ToJSON(permissionRequest) : "")); var response = new ResponseMessage(); if (permissionRequest == null) { _Logger.LogInformation($"用户:{users.UserName}添加权限,请求的参数为空。"); response.Code = ResponseCodeDefines.NotAllow; response.Message = "请求参数为空"; } try { return(await _JurisdictionManager.InsertJurisdiction(permissionRequest)); } catch (Exception el) { _Logger.LogError($"用户:{users.UserName }添加组织报错{ el.Message}\t\n"); response.Code = ResponseCodeDefines.NotAllow; response.Message = $"添加用户信息失败,请联系管理员."; } return(response); }