Add party name retrieval: implemented PartyMapper for database queries, updated ChatService with new getPartyName method, and extended /chat/party/{id}/name API endpoint.
This commit is contained in:
@@ -40,4 +40,17 @@ public class ChatController implements ChatApi {
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<String> getPartyName(String id) {
|
||||
int partyId;
|
||||
try {
|
||||
partyId = Integer.parseInt(id);
|
||||
} catch (NumberFormatException e) {
|
||||
return ResponseEntity.badRequest().build();
|
||||
}
|
||||
return chatService.getPartyName(partyId)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@ package com.alttd.altitudeweb.services.chat;
|
||||
|
||||
import com.alttd.altitudeweb.controllers.chat.ChatMessage;
|
||||
import com.alttd.altitudeweb.controllers.chat.ChatMessageMapper;
|
||||
import com.alttd.altitudeweb.controllers.chat.ChatMessageType;
|
||||
import com.alttd.altitudeweb.database.Databases;
|
||||
import com.alttd.altitudeweb.database.chat.ChatLogMapper;
|
||||
import com.alttd.altitudeweb.database.chat.NicknameMapper;
|
||||
import com.alttd.altitudeweb.database.chat.PartyMapper;
|
||||
import com.alttd.altitudeweb.database.luckperms.UUIDUsernameMapper;
|
||||
import com.alttd.altitudeweb.model.PermissionClaimDto;
|
||||
import com.alttd.altitudeweb.model.PlayerNameDto;
|
||||
@@ -163,4 +163,9 @@ public class ChatService {
|
||||
return Optional.of(playerNameDto);
|
||||
}
|
||||
|
||||
public Optional<String> getPartyName(int id) {
|
||||
return Connection.getConnection(Databases.CHAT)
|
||||
.runQueryWithResult(sqlSession -> sqlSession.getMapper(PartyMapper.class).getPartyName(id));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user