Created CRUD for ApplicationEvaluation Entity
This commit is contained in:
@@ -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;
|
||||
@@ -308,4 +309,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 {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -95,9 +95,15 @@ public class Validator {
|
||||
return userService.validateUser(userId);
|
||||
}
|
||||
|
||||
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 UserEntity validatePreInstructor(HttpServletRequest request, Long userId) {
|
||||
UserEntity user = validateUser(request);
|
||||
if(Boolean.FALSE.equals(RoleStatusEnum.ROLE_PRE_INSTRUCTOR.getValue().equals(user.getRoleEntity().getRoleType()))||Boolean.FALSE.equals(user.getId().equals(userId))) {
|
||||
throw new ForbiddenAccessException(Status.FORBIDDEN, Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
|
||||
}
|
||||
return userService.validateUser(userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user