fix: send companyId as a string in backend property filters
The services-system and services-counter property maps are String-valued; a numeric companyId failed the cast there and the scoped lists came back empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
8f80f52c04
commit
bb39e6b805
6 files changed
+11
-11
No files matched your search
+1
-1
@@ -64,7 +64,7 @@ public class AdminEventLeadService {
|
||||
Map<String, Object> property = new LinkedHashMap<>();
|
||||
property.put("name", "");
|
||||
property.put("enabled", "Y");
|
||||
property.put("companyId", scope.scope(caller(), companyId));
|
||||
property.put("companyId", java.util.Objects.toString(scope.scope(caller(), companyId), null)); // backend property maps are String-valued
|
||||
Map<String, Object> request = Map.of("property", property,
|
||||
"pageableRest", Map.of("number", 0, "size", EVENT_PAGE, "sorts", List.of(Map.of("direction", "DESC", "property", "dateStart"))));
|
||||
AdminEventService.EventPage p = restTemplateUtil.postForEntity(
|
||||
|
||||
+2
-2
@@ -52,7 +52,7 @@ public class AdminEventService {
|
||||
|
||||
public Map<String, Object> list(String q, String enabled, int page, int size, String sortBy, String sortDir, Long companyId) {
|
||||
Map<String, Object> property = new LinkedHashMap<>();
|
||||
property.put("companyId", scope.scope(caller(), companyId));
|
||||
property.put("companyId", java.util.Objects.toString(scope.scope(caller(), companyId), null)); // backend property maps are String-valued
|
||||
property.put("name", q == null ? "" : q.trim());
|
||||
property.put("enabled", "Y".equals(enabled) || "N".equals(enabled) ? enabled : "");
|
||||
Map<String, Object> sort = Map.of("direction", "desc".equalsIgnoreCase(sortDir) ? "DESC" : "ASC",
|
||||
@@ -114,7 +114,7 @@ public class AdminEventService {
|
||||
public List<Map<String, Object>> salespersonOptions(Long companyId) {
|
||||
Long company = scope.scope(caller(), companyId);
|
||||
if (company == null) return List.of();
|
||||
Map<String, Object> request = Map.of("property", Map.of("type", "A", "companyId", company),
|
||||
Map<String, Object> request = Map.of("property", Map.of("type", "A", "companyId", String.valueOf(company)),
|
||||
"pageableRest", Map.of("number", 0, "size", 10000, "sorts", List.of(Map.of("direction", "ASC", "property", "id"))));
|
||||
Map<String, Object> body = restTemplateUtil.postForEntity(
|
||||
url(RestApiSystemServiceConstants.API_REST_SYSTEM_USER_FIND_BY_PROPERTY_AND_PAGEABLE), MAP, request).getBody();
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public class AdminUserService {
|
||||
Long company = scope.scope(caller(), companyId);
|
||||
Map<String, Object> property = new HashMap<>();
|
||||
property.put("type", "A");
|
||||
if (company != null) property.put("companyId", company);
|
||||
if (company != null) property.put("companyId", String.valueOf(company)); // backend property maps are String-valued
|
||||
Map<String, Object> request = Map.of("property", property,
|
||||
"pageableRest", Map.of("number", 0, "size", 10000, "sorts", List.of(Map.of("direction", "ASC", "property", "id"))));
|
||||
ResponseEntity<Map<String, Object>> ent = restTemplateUtil.postForEntity(
|
||||
|
||||
+2
-2
@@ -172,13 +172,13 @@ class AdminEventLeadServiceCompanyScopeTest {
|
||||
@Test
|
||||
void events_staffIgnoresRequestedCompany() {
|
||||
caller(5L, false);
|
||||
assertThat(eventsCompany(9L)).isEqualTo(5L);
|
||||
assertThat(eventsCompany(9L)).isEqualTo("5");
|
||||
}
|
||||
|
||||
@Test
|
||||
void events_superPassesRequestedOrAll() {
|
||||
caller(null, true);
|
||||
assertThat(eventsCompany(7L)).isEqualTo(7L);
|
||||
assertThat(eventsCompany(7L)).isEqualTo("7");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+3
-3
@@ -126,13 +126,13 @@ class AdminEventServiceCompanyScopeTest {
|
||||
@Test
|
||||
void list_staffIgnoresRequestedCompany() {
|
||||
caller(5L, false);
|
||||
assertThat(listedCompany(9L)).isEqualTo(5L);
|
||||
assertThat(listedCompany(9L)).isEqualTo("5");
|
||||
}
|
||||
|
||||
@Test
|
||||
void list_superPassesRequestedCompany() {
|
||||
caller(null, true);
|
||||
assertThat(listedCompany(7L)).isEqualTo(7L);
|
||||
assertThat(listedCompany(7L)).isEqualTo("7");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -217,7 +217,7 @@ class AdminEventServiceCompanyScopeTest {
|
||||
service.salespersonOptions(9L);
|
||||
ArgumentCaptor<Object> body = ArgumentCaptor.forClass(Object.class);
|
||||
verify(rest).postForEntity(eq(USERS), any(ParameterizedTypeReference.class), body.capture());
|
||||
assertThat((Map<String, Object>) ((Map<String, Object>) body.getValue()).get("property")).containsEntry("companyId", 5L);
|
||||
assertThat((Map<String, Object>) ((Map<String, Object>) body.getValue()).get("property")).containsEntry("companyId", "5");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+2
-2
@@ -159,7 +159,7 @@ class AdminUserServiceCompanyScopeTest {
|
||||
void list_staffAskedForOwnCompanyWhateverWasRequested() {
|
||||
stubPage(row(1, "ann@ins", 7L));
|
||||
service.list(null, null, 0, 20, null, null, 9L);
|
||||
assertThat(sentProperty()).containsEntry("companyId", 7L).containsEntry("type", "A");
|
||||
assertThat(sentProperty()).containsEntry("companyId", "7").containsEntry("type", "A");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -175,7 +175,7 @@ class AdminUserServiceCompanyScopeTest {
|
||||
superAdmin();
|
||||
stubPage(row(1, "ann@ins", 9L));
|
||||
service.list(null, null, 0, 20, null, null, 9L);
|
||||
assertThat(sentProperty()).containsEntry("companyId", 9L);
|
||||
assertThat(sentProperty()).containsEntry("companyId", "9");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in new issue
Block a user