Exemplo n.º 1
0
        public async Task <AjaxResult> SaveRoleAuth(RoleAuthInputDto roleAuthInputDto)
        {
            var user = HttpContextCore.GetLoginUser(_accessor);

            var db = _dal.GetDatabase();
            await db.UseDbTransactionAsync(async (conn, tran) =>
            {
                await _dal.DeleteAsync <Authorize>(new { ObjectId = roleAuthInputDto.RoleId, ObjectType = 1 }, tran);
                foreach (var auth in roleAuthInputDto.AuthLists)
                {
                    await _dal.AddAsync(new Authorize()
                    {
                        Id          = Guid.NewGuid().ToString("N"),
                        ObjectId    = roleAuthInputDto.RoleId,
                        ObjectType  = 1,
                        ItemId      = auth.ItemId,
                        ItemType    = auth.ItemType,
                        CreatedId   = user.UserId,
                        CreatedBy   = user.UserName,
                        CreatedDate = DateTime.Now
                    }, tran);
                }
            });

            return(Success("保存成功"));
        }