Exemplo n.º 1
0
        /// <summary>
        /// 用户授权角色
        /// </summary>
        public async Task <bool> ToRole(ToRoleInput input)
        {
            if (input.Status)
            {
                await _dbContext.Insertable(new Permissions
                {
                    RoleId     = input.RoleId,
                    UserId     = input.UserId,
                    MenuId     = input.MenuId,
                    BtnFunId   = input.BtnFunId,
                    Types      = input.Types,
                    CreateTime = DateTime.Now
                }).ExecuteCommandAsync();
            }
            else
            {
                switch (input.Types)
                {
                case 2:
                    await _dbContext.Deleteable <Permissions>()
                    .Where(m => m.UserId == input.UserId && m.RoleId == input.RoleId && m.Types == 2)
                    .ExecuteCommandAsync();

                    break;

                case 3:
                    await _dbContext.Deleteable <Permissions>()
                    .Where(m => m.BtnFunId == input.BtnFunId && m.RoleId == input.RoleId && m.MenuId == input.MenuId && m.Types == 3)
                    .ExecuteCommandAsync();

                    break;
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        public async Task <ObjectResult> AdminToRoleAsync([FromBody] ToRoleInput input)
        {
            var result = await _perBusiness.ToRole(input);

            return(Ok(result));
        }