Beispiel #1
0
        //PUT: api/User?id=5&u=xx
        public async Task <HandleResult> Put(string id, string u)
        {
            var command = new UnLockedUser(id);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("解锁成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #2
0
        // DELETE: api/Permission/5
        public async Task <HandleResult> Delete(string id)
        {
            var command = new ChangePermission(id, (int)UseFlag.Disabled);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("删除成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #3
0
        // DELETE: api/UserRole/5  detach a userRole, id is userId
        public async Task <HandleResult> Delete(string id, string roleId)
        {
            var command = new DetachUserRole(id, roleId);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("移除成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #4
0
        // PUT: api/UserRole/5 reset user role, id is userId
        public async Task <HandleResult> Put(string id, [FromBody] List <string> roleIds)
        {
            var command = new ResetUserRole(id, roleIds);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("设置成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #5
0
        //更新密钥
        public async Task <HandleResult> Patch(string id)
        {
            var command = new UpdateSafeKey(id);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("密钥已更新"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #6
0
        // PUT: api/AppSystem/5
        public async Task <HandleResult> Put(string id, [FromBody] UpdateAppSystemDto dto)
        {
            var command = new UpdateAppSystem(id, dto.Name, dto.ReMark);
            var result  = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("更新成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #7
0
        // POST: api/AppSystem
        public async Task <HandleResult> Post([FromBody] CreateAppSystemDto dto)
        {
            var command = new CreateAppSystem(
                ObjectId.GenerateNewStringId(),
                GetAccount().AccountId,
                dto.Name,
                dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("创建成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #8
0
        // POST: api/User

        public async Task <HandleResult> Post([FromBody] CreateUserDto dto)
        {
            var command = new CreateUser(
                ObjectId.GenerateNewStringId(),
                ObjectId.GenerateNewStringId(),
                dto.AppSystemId,
                dto.UserName,
                dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("创建成功", command.Code));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #9
0
        // PUT: api/Permission/5  Update permission
        public async Task <HandleResult> Put(string id, [FromBody] UpdatePermissionDto dto)
        {
            var command = new UpdatePermission(id,
                                               dto.Name,
                                               dto.PermissionType,
                                               dto.ParentPermission,
                                               dto.PermissionUrl,
                                               dto.Sort,
                                               dto.Describe,
                                               dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("更新成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #10
0
        // PUT: api/Module/5  update module

        public async Task <HandleResult> Put(string id, [FromBody] UpdateModuleDto dto)
        {
            var command = new UpdateModule(id,
                                           dto.Name,
                                           dto.ParentModule,
                                           dto.ModuleType,
                                           dto.VerifyType,
                                           dto.IsVisible,
                                           dto.LinkUrl,
                                           dto.Sort,
                                           dto.Describe,
                                           dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("更新成功"));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }
Beispiel #11
0
        // POST: api/Permission create permission
        public async Task <HandleResult> Post([FromBody] CreatePermissionDto dto)
        {
            var command = new CreatePermission(
                ObjectId.GenerateNewStringId(),
                dto.AppSystemId,
                ObjectId.GenerateNewStringId(),
                dto.Name,
                dto.PermissionType,
                dto.IsVisible,
                dto.ParentPermission,
                dto.PermissionUrl,
                dto.Sort,
                dto.Describe,
                dto.ReMark);
            var result = await ExecuteCommandAsync(command);

            if (result.IsSuccess())
            {
                return(HandleResult.FromSuccess("创建成功", command.Code));
            }
            return(HandleResult.FromFail(result.GetErrorMessage()));
        }