Merge branch 'develop' of https://github.com/Kitzanos/GEPAFIN-BE into develop

This commit is contained in:
nisha
2024-10-28 18:13:18 +05:30
69 changed files with 3445 additions and 137 deletions

View File

@@ -108,4 +108,12 @@ public class DateTimeUtil {
return null;
}
}
public static String formatCreatedDate(LocalDateTime createdDate) {
if (createdDate == null) {
return "";
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy");
return createdDate.format(formatter);
}
}

View File

@@ -1,5 +1,6 @@
package net.gepafin.tendermanagement.util;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
@@ -316,6 +317,23 @@ public class Utils {
return new StringTokenizer(header, ",").nextToken().trim();
}
public static <T> List<T> convertJsonToList(String json, TypeReference<List<T>> typeRef) {
ObjectMapper objectMapper = new ObjectMapper();
try {
return objectMapper.readValue(json, typeRef);
} catch (IOException e) {
e.printStackTrace();
return Collections.emptyList();
}
}
public static String convertObjectToJson(Object obj) {
try {
if(obj == null){return null;}
return new ObjectMapper().writeValueAsString(obj);
} catch (JsonProcessingException e) {
log.error("Failed to convert object to JSON: {}", e.getMessage(), e);
throw new RuntimeException("Failed to convert object to JSON", e);}}
public static String replaceSpacesWithUnderscores(String content) {
if (content == null) {

View File

@@ -135,11 +135,10 @@ public class Validator {
return requestedUser;
}
private Long getUserIdFromToken(HttpServletRequest request) {
public Long getUserIdFromToken(HttpServletRequest request) {
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
return Long.parseLong(userInfo.get("userId").toString());
}
public CallEntity validateUserWithCall(UserEntity user, Long callId) {
CallEntity callEntity = callService.validateCall(callId);
if(Boolean.FALSE.equals(user.getHub().getId().equals(callEntity.getHub().getId()))) {