コード例 #1
0
        /// <summary>
        /// 保存授权资源
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Task <bool> SaveSysApiResource(SysApiResourceInput model)
        {
            var isRepeat = _sysApiResourceRepository.GetAllList(w => w.ResourceName == model.ResourceName && w.Id != model.Id).Any();

            if (isRepeat)
            {
                throw new UserFriendlyException("授权资源重复", "您设置的授权资源" + model.ResourceName + "重复!");
            }
            if (model.Id == null)
            {
                SysApiResource modelInput = ObjectMapper.Map <SysApiResource>(model);
                _sysApiResourceRepository.InsertAndGetIdAsync(modelInput);
            }
            else
            {
                SysApiResource data = _sysApiResourceRepository.Get(model.Id.Value);
                SysApiResource m    = ObjectMapper.Map(model, data);
                _sysApiResourceRepository.UpdateAsync(m);
            }
            //移除缓存
            _sysIdentityServerCacheAppService.RemoveResourcesCache();
            _sysIdentityServerCacheAppService.RemoveClientAndAccountCache();
            _sysIdentityServerCacheAppService.RemoveClientCache();
            return(Task.FromResult(true));
        }
コード例 #2
0
        public async Task <JsonResult> SaveSysApiResource([FromBody] SysApiResourceInput model)
        {
            var flag = await _sysApiResourceAppService.SaveSysApiResource(model);

            return(Json(flag));
        }