Skip to content

Commit e59962b

Browse files
Merge pull request #36 from OpenElementsLabs/feat/106-spring-services-0.16-upgrade
Upgrade to spring-services 0.16.0 (#33)
2 parents ce01ffa + 7df1730 commit e59962b

21 files changed

Lines changed: 365 additions & 642 deletions

backend/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<dependency>
103103
<groupId>com.open-elements</groupId>
104104
<artifactId>spring-services</artifactId>
105-
<version>0.15.0</version>
105+
<version>0.16.0</version>
106106
</dependency>
107107

108108
<!-- HEIC decoding via libheif. Multi-Release JAR — activates under JDK 21+. -->

backend/src/main/java/com/openelements/crm/company/CompanyDto.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.openelements.crm.company;
22

3+
import com.openelements.spring.base.data.NameSupplier;
34
import com.openelements.spring.base.data.WithId;
45
import io.swagger.v3.oas.annotations.media.Schema;
56

@@ -33,4 +34,14 @@ public record CompanyDto(
3334
@Schema(description = "Last update timestamp", requiredMode = Schema.RequiredMode.REQUIRED) Instant updatedAt
3435
) implements WithId {
3536

37+
/**
38+
* Display name used by the spring-services audit log ({@code @NameSupplier}).
39+
* Returns the company name, or an empty string if absent.
40+
*
41+
* @return the audit-log display name
42+
*/
43+
@NameSupplier
44+
public String displayName() {
45+
return name == null ? "" : name;
46+
}
3647
}

backend/src/main/java/com/openelements/crm/company/CompanyService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ private void recordCommentAudit(final UUID companyId, final AuditAction action)
257257
final AuditLogEntity entry = new AuditLogEntity();
258258
entry.setEntityType(COMMENT_ENTITY_TYPE);
259259
entry.setEntityId(companyId);
260+
// spring-services 0.16 makes AuditLogEntity.name NOT NULL. This is a
261+
// hand-rolled audit row (not the library's @NameSupplier path), so set
262+
// a meaningful name ourselves: the owning company's name.
263+
entry.setName(companyRepository.findById(companyId)
264+
.map(CompanyEntity::getName)
265+
.filter(n -> n != null && !n.isBlank())
266+
.orElse("UNKNOWN"));
260267
entry.setAction(action);
261268
entry.setUser(userService.getCurrentUserEntity());
262269
auditLogRepository.save(entry);

backend/src/main/java/com/openelements/crm/contact/ContactController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public void delete(@Parameter(description = "The contact ID") @PathVariable fina
189189
@ApiResponse(responseCode = "400", description = "Invalid file format or size")
190190
@ApiResponse(responseCode = "404", description = "Contact not found")
191191
public void uploadPhoto(@Parameter(description = "The contact ID") @PathVariable final UUID id,
192-
@Parameter(description = "The photo image file (JPEG, PNG, WebP, or HEIC; max 2 MB)") @RequestParam("file") final MultipartFile file) {
192+
@Parameter(description = "The photo image file (JPEG, PNG, WebP, or HEIC; max 20 MB)") @RequestParam("file") final MultipartFile file) {
193193
try {
194194
contactService.uploadPhoto(id, file.getBytes(), file.getContentType());
195195
} catch (final java.io.IOException e) {

backend/src/main/java/com/openelements/crm/contact/ContactDto.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.openelements.crm.contact;
22

3+
import com.openelements.spring.base.data.NameSupplier;
34
import com.openelements.spring.base.data.WithId;
45
import io.swagger.v3.oas.annotations.media.Schema;
56

@@ -33,4 +34,17 @@ public record ContactDto(
3334
@Schema(description = "Last update timestamp", requiredMode = Schema.RequiredMode.REQUIRED) Instant updatedAt
3435
) implements WithId {
3536

37+
/**
38+
* Display name used by the spring-services audit log ({@code @NameSupplier}).
39+
* Returns {@code "firstName lastName"} (trimmed); the title is intentionally
40+
* not included.
41+
*
42+
* @return the audit-log display name
43+
*/
44+
@NameSupplier
45+
public String displayName() {
46+
final String f = firstName == null ? "" : firstName;
47+
final String l = lastName == null ? "" : lastName;
48+
return (f + " " + l).trim();
49+
}
3650
}

backend/src/main/java/com/openelements/crm/contact/ContactPhotoTranscoder.java

Lines changed: 0 additions & 315 deletions
This file was deleted.

0 commit comments

Comments
 (0)