feat(frontend): replace all name concatenation with displayName
- Add displayName default method to PersonSummaryDTO - Update native SQL queries to include title, person_type columns - Add getInitials() utility to personFormat.ts - Update abbreviateName/abbreviateCompact for nullable firstName - Replace firstName+lastName concatenation with displayName in all person-displaying components and server load files - Regenerate API types with displayName on Person and PersonSummaryDTO Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,11 +9,21 @@ import java.util.UUID;
|
||||
*/
|
||||
public interface PersonSummaryDTO {
|
||||
UUID getId();
|
||||
String getTitle();
|
||||
String getFirstName();
|
||||
String getLastName();
|
||||
String getPersonType();
|
||||
String getAlias();
|
||||
Integer getBirthYear();
|
||||
Integer getDeathYear();
|
||||
String getNotes();
|
||||
long getDocumentCount();
|
||||
|
||||
default String getDisplayName() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (getTitle() != null) sb.append(getTitle()).append(" ");
|
||||
if (getFirstName() != null) sb.append(getFirstName()).append(" ");
|
||||
sb.append(getLastName());
|
||||
return sb.toString().trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ public interface PersonRepository extends JpaRepository<Person, UUID> {
|
||||
// --- PersonSummaryDTO with document count ---
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.id, p.first_name AS firstName, p.last_name AS lastName,
|
||||
SELECT p.id, p.title, p.first_name AS firstName, p.last_name AS lastName,
|
||||
p.person_type AS personType,
|
||||
p.alias, p.birth_year AS birthYear, p.death_year AS deathYear, p.notes,
|
||||
(SELECT COUNT(*) FROM documents d WHERE d.sender_id = p.id)
|
||||
+ (SELECT COUNT(*) FROM document_receivers dr WHERE dr.person_id = p.id) AS documentCount
|
||||
@@ -46,7 +47,8 @@ public interface PersonRepository extends JpaRepository<Person, UUID> {
|
||||
List<PersonSummaryDTO> findAllWithDocumentCount();
|
||||
|
||||
@Query(value = """
|
||||
SELECT p.id, p.first_name AS firstName, p.last_name AS lastName,
|
||||
SELECT p.id, p.title, p.first_name AS firstName, p.last_name AS lastName,
|
||||
p.person_type AS personType,
|
||||
p.alias, p.birth_year AS birthYear, p.death_year AS deathYear, p.notes,
|
||||
(SELECT COUNT(*) FROM documents d WHERE d.sender_id = p.id)
|
||||
+ (SELECT COUNT(*) FROM document_receivers dr WHERE dr.person_id = p.id) AS documentCount
|
||||
@@ -56,7 +58,7 @@ public interface PersonRepository extends JpaRepository<Person, UUID> {
|
||||
OR LOWER(CONCAT(p.last_name,' ',COALESCE(p.first_name,''))) LIKE LOWER(CONCAT('%',:query,'%'))
|
||||
OR LOWER(p.alias) LIKE LOWER(CONCAT('%',:query,'%'))
|
||||
OR LOWER(a.last_name) LIKE LOWER(CONCAT('%',:query,'%'))
|
||||
GROUP BY p.id, p.first_name, p.last_name, p.alias, p.birth_year, p.death_year, p.notes
|
||||
GROUP BY p.id, p.title, p.first_name, p.last_name, p.person_type, p.alias, p.birth_year, p.death_year, p.notes
|
||||
ORDER BY p.last_name ASC, p.first_name ASC
|
||||
""",
|
||||
nativeQuery = true)
|
||||
|
||||
@@ -73,8 +73,10 @@ class PersonControllerTest {
|
||||
private PersonSummaryDTO mockPersonSummary(String firstName, String lastName) {
|
||||
return new PersonSummaryDTO() {
|
||||
public java.util.UUID getId() { return UUID.randomUUID(); }
|
||||
public String getTitle() { return null; }
|
||||
public String getFirstName() { return firstName; }
|
||||
public String getLastName() { return lastName; }
|
||||
public String getPersonType() { return "PERSON"; }
|
||||
public String getAlias() { return null; }
|
||||
public Integer getBirthYear() { return null; }
|
||||
public Integer getDeathYear() { return null; }
|
||||
|
||||
Reference in New Issue
Block a user