Add user account management methods and update user-related mappers
This commit is contained in:
@@ -40,5 +40,9 @@ public class UserController {
|
||||
.filter(Boolean::booleanValue)
|
||||
.then();
|
||||
}
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public Mono<User> update(@PathVariable Long id, @Valid @RequestBody User user) {
|
||||
return userService.update(id, user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.gameplatform.server.controller.admin;
|
||||
|
||||
import com.gameplatform.server.model.dto.account.*;
|
||||
import com.gameplatform.server.model.dto.common.PageResult;
|
||||
import com.gameplatform.server.service.account.AccountService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/accounts")
|
||||
public class AccountController {
|
||||
private final AccountService accountService;
|
||||
|
||||
public AccountController(AccountService accountService) {
|
||||
this.accountService = accountService;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public Mono<PageResult<AccountResponse>> list(
|
||||
@RequestParam(value = "userType", required = false) String userType,
|
||||
@RequestParam(value = "status", required = false) String status,
|
||||
@RequestParam(value = "role", required = false) String role,
|
||||
@RequestParam(value = "keyword", required = false) String keyword,
|
||||
@RequestParam(value = "page", required = false) Integer page,
|
||||
@RequestParam(value = "size", required = false) Integer size
|
||||
) {
|
||||
return accountService.list(userType, status, role, keyword, page, size);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
public Mono<AccountResponse> create(@Valid @RequestBody AccountCreateRequest req) {
|
||||
return accountService.create(req);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Mono<AccountResponse> detail(@PathVariable Long id) {
|
||||
return accountService.get(id);
|
||||
}
|
||||
|
||||
@PatchMapping("/{id}")
|
||||
public Mono<AccountResponse> update(@PathVariable Long id, @Valid @RequestBody AccountUpdateRequest req) {
|
||||
return accountService.update(id, req);
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/enable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> enable(@PathVariable Long id) {
|
||||
return accountService.setStatus(id, "ENABLED").then();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/disable")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> disable(@PathVariable Long id) {
|
||||
return accountService.setStatus(id, "DISABLED").then();
|
||||
}
|
||||
|
||||
@PostMapping("/{id}/reset-password")
|
||||
@ResponseStatus(HttpStatus.NO_CONTENT)
|
||||
public Mono<Void> resetPassword(@PathVariable Long id, @Valid @RequestBody ResetPasswordRequest req) {
|
||||
return accountService.resetPassword(id, req.getNewPassword(), Boolean.TRUE.equals(req.getForceLogout()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user