//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())); }
// 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())); }
// 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())); }
// 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())); }
//更新密钥 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())); }
// 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())); }
// 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())); }
// 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())); }
// 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())); }
// 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())); }
// 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())); }