초기소스
This commit is contained in:
47
src/main/java/com/wb/domainserver/response/ApiResponse.java
Normal file
47
src/main/java/com/wb/domainserver/response/ApiResponse.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import com.wb.domainserver.exception.WnbtRestException;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* [공통] API Response 결과의 반환 값을 관리
|
||||
*/
|
||||
public final class ApiResponse<T> {
|
||||
|
||||
private final Optional<T> t;
|
||||
|
||||
private ApiResponse(T t) {
|
||||
this.t = Optional.ofNullable(t);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse of(T t) {
|
||||
return new ApiResponse(t);
|
||||
}
|
||||
public static <T> ApiResponse of() {
|
||||
return new ApiResponse(null);
|
||||
}
|
||||
|
||||
public ResponseEntity<T> ok() {
|
||||
return t.map(value -> ResponseEntity.status(HttpStatus.OK).body(value))
|
||||
.orElseGet(()->ResponseEntity.noContent().build());
|
||||
}
|
||||
|
||||
public ResponseEntity<T> ifPresentOrElse(HttpStatus exists, HttpStatus notExists) {
|
||||
return t.map(value -> new ResponseEntity<>(value, exists))
|
||||
.orElseGet(() -> new ResponseEntity<>(notExists));
|
||||
}
|
||||
|
||||
public ResponseEntity<T> ifPresentOrElse(Object result) {
|
||||
return t.map(value -> new ResponseEntity<>(value, HttpStatus.OK))
|
||||
.orElseGet(() -> (ResponseEntity<T>) new ResponseEntity<>(result, HttpStatus.OK));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import com.wb.domainserver.domain.gcone.common.service.BOCommonService;
|
||||
import com.wb.domainserver.domain.gcone.login.mapper.LoginMapper;
|
||||
import com.wb.domainserver.domain.gcone.login.service.LoginService;
|
||||
import com.wb.domainserver.domain.gcone.login.vo.LoginUser;
|
||||
import com.wb.domainserver.domain.gcone.mbr.mbr.mapper.BOMbrMapper;
|
||||
import com.wb.domainserver.domain.gcone.mbr.mbr.vo.BOMbrVO;
|
||||
import com.wb.domainserver.domain.sopmal.oauth.mapper.UserMapper;
|
||||
import com.wb.domainserver.security.handler.CustomLogoutSuccessHandler;
|
||||
import com.wb.domainserver.util.dataaccess.DataMap;
|
||||
import com.wb.domainserver.util.string.StringUtil;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
|
||||
import org.springframework.security.oauth2.core.OAuth2Error;
|
||||
import org.springframework.security.oauth2.core.user.OAuth2User;
|
||||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||
@Autowired
|
||||
private LoginService service;
|
||||
@Autowired
|
||||
private LoginMapper mapper;
|
||||
@Autowired
|
||||
private BOMbrMapper mbrMapper;
|
||||
@Autowired
|
||||
private BOCommonService boCommonService;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public void onAuthenticationSuccess(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Authentication authentication) throws IOException, ServletException {
|
||||
authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
|
||||
//변수 초기화
|
||||
LoginUser loginUser = new LoginUser(); //회원정보 vo
|
||||
Map<String,Object> map =new HashMap<>(); //인증 response 값
|
||||
String provider = null; //kakao or naver
|
||||
String extrlIntrlckDvCd = null; //provider 구분 코드
|
||||
String id = null;
|
||||
//회원정보
|
||||
String email = null;
|
||||
String sex = null;
|
||||
String brthDe = null;
|
||||
String mbtlnb = null;
|
||||
String name = null;
|
||||
|
||||
//인증 정보 (로그인 유저 정보, 공급주체 가져오기)
|
||||
if (authentication != null && authentication.getPrincipal() instanceof OAuth2User) {
|
||||
OAuth2User oauth2User = (OAuth2User) authentication.getPrincipal();
|
||||
map = oauth2User.getAttributes();
|
||||
log.debug("map {}", map);
|
||||
//로그인 유저 정보
|
||||
loginUser = (LoginUser) map.get("loginUser");
|
||||
//kakao인지 naver인지
|
||||
provider = (String) map.get("provider");
|
||||
}
|
||||
|
||||
//행위 목적이 연동인지 로그인인지 확인 후 세션 삭제
|
||||
String mode = (String) request.getSession().getAttribute("mode");
|
||||
request.getSession().removeAttribute("mode");
|
||||
String redirectUrl = "";
|
||||
|
||||
//연동처리
|
||||
if ("link".equals(mode)) {
|
||||
DataMap tokenUserInfo = (DataMap) request.getSession().getAttribute("userInfo");
|
||||
request.getSession().removeAttribute("tokenUserInfo");
|
||||
//연동처리
|
||||
//카카오일경우
|
||||
if ("kakao".equals(provider)) {
|
||||
Map<String, Object> kakaoAccount = (Map<String, Object>) map.get("kakao_account");
|
||||
//값 세팅
|
||||
email = (String) kakaoAccount.get("email");
|
||||
sex = (String) kakaoAccount.get("gender");
|
||||
sex = sex.equals("female") ? "F" : "M";
|
||||
brthDe = null;
|
||||
mbtlnb = StringUtil.formatKoreanPhoneNumber((String) kakaoAccount.get("phone_number"));
|
||||
name = (String) kakaoAccount.get("name");
|
||||
Long tempId = (Long) map.get("id");
|
||||
id = tempId.toString();
|
||||
extrlIntrlckDvCd = "01";
|
||||
//네이버일경우
|
||||
} else if ("naver".equals(provider)) {
|
||||
Map<String, Object> naverAccount = (Map<String, Object>) map.get("response");
|
||||
email = (String) naverAccount.get("email");
|
||||
sex = (String) naverAccount.get("gender");
|
||||
brthDe = (String) naverAccount.get("birthyear")+naverAccount.get("birthday");
|
||||
brthDe = brthDe.replace("-","");
|
||||
mbtlnb = StringUtil.formatKoreanPhoneNumber((String) naverAccount.get("mobile"));
|
||||
name = (String) naverAccount.get("name");
|
||||
id = (String) naverAccount.get("id");
|
||||
extrlIntrlckDvCd = "02";
|
||||
}
|
||||
|
||||
//oauth 정보와 맞는지 확인
|
||||
String decMbtlnb = mbrMapper.decodeMbtlnb((String) tokenUserInfo.get("mbtlnb"),boCommonService.selectSecretkey());
|
||||
if (!tokenUserInfo.get("mbrNm").equals(name) || !decMbtlnb.equals(mbtlnb)) {
|
||||
if (!decMbtlnb.equals(mbtlnb)) { //핸드폰번호안맞을시
|
||||
throw new OAuth2AuthenticationException(new OAuth2Error("not collect mbrInfo"), "sns 회원정보와 맞지 않습니다. 로그아웃 후 다시 연동해주세요.");
|
||||
} else {
|
||||
throw new OAuth2AuthenticationException(new OAuth2Error("not collect mbrInfo"), "sns 회원정보와 맞지 않습니다.");
|
||||
}
|
||||
}
|
||||
|
||||
//값 set, 외부 연동 insert
|
||||
BOMbrVO mbr = new BOMbrVO();
|
||||
//token에서 회원정보 빼옴
|
||||
mbr.setSopmalCd(tokenUserInfo.get("sopmalCd").toString());
|
||||
mbr.setMbrInnb(tokenUserInfo.get("mbrInnb").toString());
|
||||
mbr.setMbrDvCd(tokenUserInfo.get("mbrDvCd").toString());
|
||||
mbr.setMbrNm(tokenUserInfo.get("mbrNm").toString());
|
||||
|
||||
|
||||
//oauth 식별정보
|
||||
mbr.setExtrlIntrlckId(id);
|
||||
//naver,kakao에서 빼온 정보
|
||||
mbr.setExtrlIntrlckDvCd(extrlIntrlckDvCd);
|
||||
mbr.setEmail(email);
|
||||
mbr.setSex(sex);
|
||||
mbr.setBrthDe(brthDe);
|
||||
//시크릿키
|
||||
mbr.setSecretKey(boCommonService.selectSecretkey());
|
||||
//외부 연동 insert
|
||||
mbrMapper.insertBOExtrlMember(mbr);
|
||||
|
||||
redirectUrl = "/sopmal/mpage/mbr/selectMbrInfoUpdtForm"; //회원 정보 수정 페이지
|
||||
response.sendRedirect(redirectUrl);
|
||||
//로그인
|
||||
}else {
|
||||
if (loginUser != null) { //로그인 처리
|
||||
//최종 로그인 일시 업데이트
|
||||
mapper.updateMbrLastLoginDt(loginUser);
|
||||
|
||||
//로그인 처리
|
||||
service.createLoginToken(loginUser, request, response);
|
||||
|
||||
//처리 후 로그인페이지로 이동
|
||||
redirectUrl = "/sopmal/login";
|
||||
response.sendRedirect(redirectUrl);
|
||||
}else{ //인증 로그아웃 처리
|
||||
CustomLogoutSuccessHandler logout = new CustomLogoutSuccessHandler();
|
||||
logout.onLogoutSuccess(request,response,authentication);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UploadFileResponse {
|
||||
|
||||
private String fileId;
|
||||
private String fileName;
|
||||
private String fileDownloadUri;
|
||||
private String fileType;
|
||||
private String filePath;
|
||||
private long fileSize;
|
||||
|
||||
public UploadFileResponse() {
|
||||
|
||||
}
|
||||
public UploadFileResponse(String fileId, String fileName, String fileDownloadUri, String fileType, String filePath, long fileSize) {
|
||||
this.fileId = fileId;
|
||||
this.fileName = fileName;
|
||||
this.fileDownloadUri = fileDownloadUri;
|
||||
this.fileType = fileType;
|
||||
this.filePath = filePath;
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
}
|
||||
15
src/main/java/com/wb/domainserver/response/WnbtResponse.java
Normal file
15
src/main/java/com/wb/domainserver/response/WnbtResponse.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
public class WnbtResponse {
|
||||
private int statusCode;
|
||||
private String requestUrl;
|
||||
private com.wb.domainserver.response.WnbtResponseBody resBody;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import com.wb.domainserver.exception.WnbtException;
|
||||
import com.wb.domainserver.exception.WnbtRestException;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class WnbtResponseBody {
|
||||
private String resultCode;
|
||||
private String message;
|
||||
private Object result;
|
||||
|
||||
public WnbtResponseBody(Object result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public WnbtResponseBody(WnbtException ex){
|
||||
this.resultCode = Optional.ofNullable(ex.getCode()).orElse("FAIL");
|
||||
this.message = ex.getMessage();
|
||||
}
|
||||
|
||||
public WnbtResponseBody(WnbtRestException ex){
|
||||
this.resultCode = Optional.ofNullable(ex.getCode()).orElse("FAIL");
|
||||
this.message = ex.getMessage();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
package com.wb.domainserver.response;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.wb.domainserver. exception.code.ErrCode;
|
||||
import com.wb.domainserver.exception.WnbtException;
|
||||
import com.wb.domainserver.exception.WnbtWebClientException;
|
||||
import com.wb.domainserver.util.communicate.BoResultMapConverter;
|
||||
import com.wb.domainserver.util.communicate.ReplyFromResrc;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class WnbtWebClientResponseHandler {
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
public WnbtWebClientResponseHandler(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
public void handleResponse(Mono<ReplyFromResrc> monoResponse,
|
||||
ModelMap model,
|
||||
String modelAttributeName) {
|
||||
try {
|
||||
ReplyFromResrc result = monoResponse.block(Duration.ofSeconds(30));
|
||||
if (result != null && !result.isEmpty()) {
|
||||
Map<String, Object> resultMap = BoResultMapConverter.convert(objectMapper, result.getReply());
|
||||
model.addAttribute(modelAttributeName, resultMap);
|
||||
} else {
|
||||
model.addAttribute(modelAttributeName, new HashMap<>());
|
||||
}
|
||||
} catch (IllegalStateException ise){
|
||||
log.error("Error occurred while fetching data", ise);
|
||||
throw new WnbtException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
model.addAttribute(modelAttributeName, new HashMap<>());
|
||||
model.addAttribute("error", "데이터를 가져오는 중 오류가 발생했습니다.");
|
||||
throw new WnbtException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> ResponseEntity<WnbtResponse> handleResponse(Mono<T> monoResponse,
|
||||
Function<T, Object> responseMapper) {
|
||||
try {
|
||||
T result = monoResponse.toFuture().get(30, TimeUnit.SECONDS);
|
||||
Object mappedResult = responseMapper.apply(result);
|
||||
WnbtResponse response = WnbtResponse.builder()
|
||||
.resBody(new com.wb.domainserver.response.WnbtResponseBody(mappedResult))
|
||||
.build();
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
public <T, R> ResponseEntity<R> handleCustomResponse(Mono<T> monoResponse,
|
||||
Function<T, ResponseEntity<R>> responseMapper) {
|
||||
try {
|
||||
T result = monoResponse.toFuture().get(30, TimeUnit.SECONDS);
|
||||
return responseMapper.apply(result);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
public <T, R> ResponseEntity<R> handleMapResponse(Mono<ReplyFromResrc> monoResponse,
|
||||
Function<Map<String, Object>, ResponseEntity<R>> responseMapper) {
|
||||
try {
|
||||
ReplyFromResrc result = monoResponse.toFuture().get(30, TimeUnit.SECONDS);
|
||||
if (result.isEmpty()) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
Map<String, Object> resultMap = convertToMap(result.getReply());
|
||||
return responseMapper.apply(resultMap);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<String, Object> handleResponseAsMap(Mono<ReplyFromResrc> monoResponse) {
|
||||
try {
|
||||
ReplyFromResrc result = monoResponse.toFuture().get(30, TimeUnit.SECONDS);
|
||||
if (result.isEmpty()) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
return convertToMap(result.getReply());
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> convertToMap(String jsonString) {
|
||||
return BoResultMapConverter.convert(new ObjectMapper(), jsonString);
|
||||
}
|
||||
|
||||
public <T> ResponseEntity<WnbtResponse> handleMultipleResponses(
|
||||
List<Mono<T>> monoResponses,
|
||||
List<String> resultKeys,
|
||||
Function<T, Object> responseMapper) {
|
||||
|
||||
try {
|
||||
List<CompletableFuture<T>> futures = monoResponses.stream()
|
||||
.map(Mono::toFuture)
|
||||
.toList();
|
||||
|
||||
CompletableFuture<Void> allOf = CompletableFuture.allOf(
|
||||
futures.toArray(new CompletableFuture[0]));
|
||||
|
||||
CompletableFuture<Map<String, Object>> result = allOf.thenApply(v -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
T response = futures.get(i).join();
|
||||
resultMap.put(resultKeys.get(i), responseMapper.apply(response));
|
||||
}
|
||||
return resultMap;
|
||||
});
|
||||
|
||||
Map<String, Object> mappedResult = result.get(30, TimeUnit.SECONDS);
|
||||
WnbtResponse response = WnbtResponse.builder()
|
||||
.resBody(new com.wb.domainserver.response.WnbtResponseBody(mappedResult))
|
||||
.build();
|
||||
return ResponseEntity.ok(response);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
public <T>ResponseEntity<Map<String, Object>> handleMapMultipleResponses(
|
||||
List<Mono<T>> monoResponses,
|
||||
List<String> resultKeys,
|
||||
Function<T, Object> responseMapper) {
|
||||
|
||||
try {
|
||||
List<CompletableFuture<T>> futures = monoResponses.stream()
|
||||
.map(Mono::toFuture)
|
||||
.toList();
|
||||
|
||||
CompletableFuture<Void> allOf = CompletableFuture.allOf(
|
||||
futures.toArray(new CompletableFuture[0]));
|
||||
|
||||
CompletableFuture<Map<String, Object>> result = allOf.thenApply(v -> {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
T response = futures.get(i).join();
|
||||
resultMap.put(resultKeys.get(i), responseMapper.apply(response));
|
||||
}
|
||||
return resultMap;
|
||||
});
|
||||
|
||||
Map<String, Object> mappedResult = result.get(30, TimeUnit.SECONDS);
|
||||
return ResponseEntity.ok(mappedResult);
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
throw new WnbtWebClientException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (TimeoutException e) {
|
||||
log.error("Request timed out", e);
|
||||
Map<String, Object> errorMap = new HashMap<>();
|
||||
errorMap.put("error", "Request timed out");
|
||||
throw new WnbtWebClientException(ErrCode.REQUEST_TIMEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleMultipleResponses(
|
||||
List<Mono<ReplyFromResrc>> monoResponses,
|
||||
ModelMap model,
|
||||
List<String> modelAttributeNames) {
|
||||
|
||||
try {
|
||||
List<CompletableFuture<ReplyFromResrc>> futures = monoResponses.stream()
|
||||
.map(mono -> mono.toFuture())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
CompletableFuture<Void> allOf = CompletableFuture.allOf(
|
||||
futures.toArray(new CompletableFuture[0]));
|
||||
|
||||
allOf.thenApply(v -> {
|
||||
for (int i = 0; i < futures.size(); i++) {
|
||||
ReplyFromResrc result = futures.get(i).join();
|
||||
if (result != null && !result.isEmpty()) {
|
||||
Map<String, Object> resultMap = BoResultMapConverter.convert(objectMapper, result.getReply());
|
||||
model.addAttribute(modelAttributeNames.get(i), resultMap);
|
||||
} else {
|
||||
model.addAttribute(modelAttributeNames.get(i), new HashMap<>());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}).get(30, TimeUnit.SECONDS);
|
||||
}catch (IllegalStateException ise){
|
||||
log.error("Error occurred while fetching data", ise);
|
||||
throw new WnbtException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
} catch (Exception e) {
|
||||
log.error("Error occurred while fetching data", e);
|
||||
for (String attributeName : modelAttributeNames) {
|
||||
model.addAttribute(attributeName, new HashMap<>());
|
||||
}
|
||||
model.addAttribute("error", "데이터를 가져오는 중 오류가 발생했습니다.");
|
||||
|
||||
throw new WnbtException(ErrCode.INTERNAL_SEVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user