Exemple #1
0
        public async Task <IResultModel> PlatformPermissionBind(RolePlatformPermissionBindModel model)
        {
            if (model.Platform == Platform.Web)
            {
                return(ResultModel.Failed("不支持Web平台"));
            }

            using var uow = _dbContext.NewUnitOfWork();
            //先清除已有绑定关系,再重新插入新的
            var result = await _platformPermissionRepository.Clear(model.RoleId, model.Platform);

            if (result)
            {
                if (model.Permissions != null && model.Permissions.Any())
                {
                    var list = model.Permissions.Select(m => new RolePlatformPermissionEntity
                    {
                        RoleId         = model.RoleId,
                        Platform       = model.Platform,
                        PermissionCode = m
                    }).ToList();

                    if (await _platformPermissionRepository.AddAsync(list))
                    {
                        uow.Commit();
                        await ClearAccountPermissionCache(model.RoleId);

                        return(ResultModel.Success());
                    }
                }
                else
                {
                    uow.Commit();
                    await ClearAccountPermissionCache(model.RoleId);

                    return(ResultModel.Success());
                }
            }

            return(ResultModel.Failed());
        }
Exemple #2
0
 public Task <IResultModel> PlatformPermissionBind(RolePlatformPermissionBindModel model)
 {
     return(_service.PlatformPermissionBind(model));
 }