Fix history not loading
This commit is contained in:
parent
97e5d202bb
commit
23367b6dea
|
|
@ -14,6 +14,7 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {
|
|||
public ResponseEntity<ApiErrorDto> handleException(Exception ex) {
|
||||
ApiErrorDto error = new ApiErrorDto();
|
||||
error.reason("Error: " + ex.getMessage());
|
||||
logger.error(ex.getMessage(), ex);
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,17 +90,24 @@ public class HistoryApiController implements HistoryApi {
|
|||
|
||||
private ResponseEntity<PunishmentHistoryDto> mapPunishmentHistory(PunishmentHistoryDto punishmentHistory, CompletableFuture<List<HistoryRecord>> historyRecords) {
|
||||
historyRecords.join().forEach(historyRecord -> {
|
||||
PunishmentHistoryInnerDto.TypeEnum type = switch (historyRecord.getType().toLowerCase()) {
|
||||
case "ban" -> PunishmentHistoryInnerDto.TypeEnum.BAN;
|
||||
case "mute" -> PunishmentHistoryInnerDto.TypeEnum.MUTE;
|
||||
case "warn" -> PunishmentHistoryInnerDto.TypeEnum.WARN;
|
||||
case "kick" -> PunishmentHistoryInnerDto.TypeEnum.KICK;
|
||||
default -> throw new IllegalStateException("Unexpected value: " + historyRecord.getType());
|
||||
};
|
||||
PunishmentHistoryInnerDto innerDto = new PunishmentHistoryInnerDto()
|
||||
.uuid(historyRecord.getUuid())
|
||||
.username(historyRecord.getPunishedName())
|
||||
.reason(PunishmentHistoryInnerDto.ReasonEnum.valueOf(historyRecord.getReason()))
|
||||
.reason(historyRecord.getReason())
|
||||
.punishedByUuid(historyRecord.getBannedByUuid())
|
||||
.punishedBy(historyRecord.getBannedByName())
|
||||
.removedBy(historyRecord.getRemovedByName())
|
||||
.punishmentTime(historyRecord.getTime())
|
||||
.expiryTime(historyRecord.getUntil())
|
||||
.removedReason(historyRecord.getRemovedByReason())
|
||||
.type(historyRecord.getType());
|
||||
.type(type);
|
||||
punishmentHistory.add(innerDto);
|
||||
});
|
||||
return ResponseEntity.ok().body(punishmentHistory);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public interface NameHistoryMapper {
|
|||
FROM all_punishments
|
||||
INNER JOIN user_lookup
|
||||
ON user_lookup.uuid = all_punishments.uuid
|
||||
WHERE all_punishments.${name_column} LIKE #{partialName}
|
||||
WHERE ${name_column} LIKE #{partialName}
|
||||
ORDER BY time DESC
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
|
|
@ -79,7 +79,7 @@ public interface NameHistoryMapper {
|
|||
removed_by_name, time, until, removed_by_reason
|
||||
FROM ${tableName} AS punishment
|
||||
INNER JOIN user_lookup ON user_lookup.uuid = punishment.uuid
|
||||
WHERE punishment.${name_column} LIKE #{partialName}
|
||||
WHERE ${name_column} LIKE #{partialName}
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
""")
|
||||
List<HistoryRecord> getRecentHistory(@Param("tableName") String tableName,
|
||||
|
|
|
|||
|
|
@ -167,10 +167,10 @@ components:
|
|||
reason:
|
||||
type: string
|
||||
description: The reason for the punishment
|
||||
enum: [ ban, mute, kick, warn ]
|
||||
type:
|
||||
type: string
|
||||
description: The type of punishment
|
||||
enum: [ ban, mute, kick, warn ]
|
||||
punishmentTime:
|
||||
type: integer
|
||||
format: int64
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user