Exemplo n.º 1
0
        /// <summary>
        /// 设置角色接口权限
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task <SetRoleApiOutput> SetRoleApi(SetRoleApiInput input)
        {
            // 用户角色操作
            List <RoleApiInfo> roleApiList = new List <RoleApiInfo>();

            foreach (var id in input.ApiIdList)
            {
                // 防止重复数据
                if (!roleApiList.Exists(it => it.ApiId == id))
                {
                    roleApiList.Add(new RoleApiInfo
                    {
                        ApiId  = id,
                        RoleId = input.RoleId
                    });
                }
            }
            // 删除用户当前角色
            await _dbContext.Deleteable <RoleApiInfo>().Where(f => f.RoleId == input.RoleId).ExecuteCommandAsync();

            // 添加用户角色
            if (roleApiList.Count > 0)
            {
                await _dbContext.Insertable(roleApiList).ExecuteCommandAsync();
            }

            return(new SetRoleApiOutput {
            });
        }
Exemplo n.º 2
0
 public async Task <SetRoleApiOutput> SetRoleApi(SetRoleApiInput input)
 {
     return(await _roleBusiness.SetRoleApi(input));
 }