Spaces:
Sleeping
Sleeping
Merged in feature/sarvenDev (pull request #4)
Browse files- src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java +24 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/MessageModel.java +15 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java +21 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBox.java +26 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBoxAction.java +24 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageResponse.java +42 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/builder/MsgResponseBuilder.java +28 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionType.java +9 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionUiStyle.java +10 -0
- src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageType.java +7 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java +13 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionTypeConstants.java +18 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionUiConstants.java +15 -0
- src/main/java/com/artandscience/webbff/webbff/common/constants/MessageTypeConstants.java +9 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/BusinessException.java +23 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BaseErrorType.java +8 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BusinessErrorType.java +21 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/SessionErrorType.java +22 -0
- src/main/java/com/artandscience/webbff/webbff/common/exception/enums/UnhandledErrorType.java +22 -0
- src/main/java/com/artandscience/webbff/webbff/common/scope/RequestHeaderScope.java +20 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/ExternalAttributeService.java +10 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/MessageBoxService.java +12 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/ExternalAttributeServiceImpl.java +55 -0
- src/main/java/com/artandscience/webbff/webbff/common/service/impl/MessageBoxServiceImpl.java +98 -0
- src/main/java/com/artandscience/webbff/webbff/dao/entity/ErrorMessageBox.java +51 -0
- src/main/java/com/artandscience/webbff/webbff/dao/entity/ErrorMessageBoxAction.java +69 -0
- src/main/java/com/artandscience/webbff/webbff/dao/repository/ErrorMessageBoxRepository.java +9 -0
src/main/java/com/artandscience/webbff/webbff/common/base/controller/BaseController.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.controller;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.builder.MsgResponseBuilder;
|
| 7 |
+
|
| 8 |
+
import java.util.List;
|
| 9 |
+
|
| 10 |
+
public abstract class BaseController {
|
| 11 |
+
|
| 12 |
+
protected MessageResponse<Void> responseFail(List<MessageBox> messageBox) {
|
| 13 |
+
return MsgResponseBuilder.build(false,messageBox);
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
protected <T> MessageResponse<T> responseSuccess(T data) {
|
| 17 |
+
return MsgResponseBuilder.build(true,data);
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
protected <T> MessageResponse<T> responseSuccess(T data, List<MessageBox> messageBox) {
|
| 21 |
+
return MsgResponseBuilder.build(true,messageBox,data);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/MessageModel.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.model;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class MessageModel {
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String type;
|
| 12 |
+
private final String message;
|
| 13 |
+
private final String handlerMethodName;
|
| 14 |
+
|
| 15 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/model/RequestHeader.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.model;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class RequestHeader {
|
| 9 |
+
|
| 10 |
+
private String sessionId;
|
| 11 |
+
private String correlationId;
|
| 12 |
+
private String deviceAppVersion;
|
| 13 |
+
private String deviceAppName;
|
| 14 |
+
private String language;
|
| 15 |
+
private String role;
|
| 16 |
+
private String wafUsername;
|
| 17 |
+
private String wafPassword;
|
| 18 |
+
private String diamondUsername;
|
| 19 |
+
private String diamondPassword;
|
| 20 |
+
|
| 21 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBox.java
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageType;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
|
| 8 |
+
import java.io.Serial;
|
| 9 |
+
import java.io.Serializable;
|
| 10 |
+
import java.util.List;
|
| 11 |
+
|
| 12 |
+
@Builder
|
| 13 |
+
@Data
|
| 14 |
+
@AllArgsConstructor
|
| 15 |
+
public class MessageBox implements Serializable {
|
| 16 |
+
|
| 17 |
+
@Serial
|
| 18 |
+
private static final long serialVersionUID = -5828974365524339512L;
|
| 19 |
+
private String title;
|
| 20 |
+
private String subtitle;
|
| 21 |
+
private MessageType messageType;
|
| 22 |
+
private String message;
|
| 23 |
+
private String messageCode;
|
| 24 |
+
private List<MessageBoxAction> messageBoxAction;
|
| 25 |
+
|
| 26 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageBoxAction.java
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionType;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionUiStyle;
|
| 5 |
+
import lombok.AllArgsConstructor;
|
| 6 |
+
import lombok.Builder;
|
| 7 |
+
import lombok.Data;
|
| 8 |
+
|
| 9 |
+
import java.io.Serial;
|
| 10 |
+
import java.io.Serializable;
|
| 11 |
+
|
| 12 |
+
@Builder
|
| 13 |
+
@Data
|
| 14 |
+
@AllArgsConstructor
|
| 15 |
+
public class MessageBoxAction implements Serializable {
|
| 16 |
+
@Serial
|
| 17 |
+
private static final long serialVersionUID = -5828974365524339512L;
|
| 18 |
+
|
| 19 |
+
private MessageBoxActionType actionType;
|
| 20 |
+
private MessageBoxActionUiStyle uiStyle;
|
| 21 |
+
private String text;
|
| 22 |
+
private int orderNo;
|
| 23 |
+
|
| 24 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/MessageResponse.java
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Getter;
|
| 5 |
+
import lombok.NoArgsConstructor;
|
| 6 |
+
import lombok.Setter;
|
| 7 |
+
|
| 8 |
+
import java.time.ZonedDateTime;
|
| 9 |
+
import java.time.format.DateTimeFormatter;
|
| 10 |
+
import java.util.List;
|
| 11 |
+
|
| 12 |
+
@Getter
|
| 13 |
+
@Setter
|
| 14 |
+
@NoArgsConstructor
|
| 15 |
+
@AllArgsConstructor
|
| 16 |
+
public class MessageResponse<T> {
|
| 17 |
+
|
| 18 |
+
private Boolean success;
|
| 19 |
+
private String executionDate;
|
| 20 |
+
private T data;
|
| 21 |
+
private List<MessageBox> messageBoxes;
|
| 22 |
+
|
| 23 |
+
public MessageResponse(boolean success, T data){
|
| 24 |
+
this.success = success;
|
| 25 |
+
this.data = data;
|
| 26 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
public MessageResponse(boolean success, T data, List<MessageBox> messageBoxes){
|
| 30 |
+
this.success = success;
|
| 31 |
+
this.data = data;
|
| 32 |
+
this.messageBoxes = messageBoxes;
|
| 33 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
public MessageResponse(boolean success, List<MessageBox> messageBoxes){
|
| 37 |
+
this.success = success;
|
| 38 |
+
this.messageBoxes = messageBoxes;
|
| 39 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/builder/MsgResponseBuilder.java
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.builder;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageResponse;
|
| 6 |
+
|
| 7 |
+
import java.util.List;
|
| 8 |
+
|
| 9 |
+
public class MsgResponseBuilder {
|
| 10 |
+
|
| 11 |
+
private MsgResponseBuilder() {}
|
| 12 |
+
|
| 13 |
+
public static <T> MessageResponse<T> build(boolean success,
|
| 14 |
+
List<MessageBox> messageBox) {
|
| 15 |
+
return new MessageResponse<>(success, messageBox);
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
public static <T>MessageResponse<T> build(boolean success,
|
| 19 |
+
T data) {
|
| 20 |
+
return new MessageResponse<>(success, data);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public static <T>MessageResponse<T> build(boolean success, List<MessageBox> messageBox,
|
| 24 |
+
T data) {
|
| 25 |
+
return new MessageResponse<>(success,data,messageBox);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionType.java
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageBoxActionType implements Serializable {
|
| 6 |
+
|
| 7 |
+
RETRY, POPUPTO, ACTION_HANDLER, DEEPLINK, NONE
|
| 8 |
+
|
| 9 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageBoxActionUiStyle.java
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageBoxActionUiStyle implements Serializable {
|
| 6 |
+
|
| 7 |
+
BUTTON,
|
| 8 |
+
TEXT
|
| 9 |
+
|
| 10 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/base/response/enums/MessageType.java
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.base.response.enums;
|
| 2 |
+
|
| 3 |
+
import java.io.Serializable;
|
| 4 |
+
|
| 5 |
+
public enum MessageType implements Serializable {
|
| 6 |
+
INFORMATION,WARNING,ERROR,NONE
|
| 7 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/HeaderConstant.java
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
public class HeaderConstant {
|
| 4 |
+
|
| 5 |
+
private HeaderConstant() {}
|
| 6 |
+
|
| 7 |
+
public static String HEADER_LANGUAGE = "x-language";
|
| 8 |
+
public static String HEADER_DEVICE_APP_NAME = "x-device-app-name";
|
| 9 |
+
public static String HEADER_DEVICE_APP_VERSION = "x-device-app-version";
|
| 10 |
+
public static String HEADER_SESSION_ID = "x-session-id";
|
| 11 |
+
public static String HEADER_CORRELATION_ID = "x-correlation-id";
|
| 12 |
+
|
| 13 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionTypeConstants.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class MessageBoxActionTypeConstants {
|
| 7 |
+
|
| 8 |
+
public static final String RETRY = "R";
|
| 9 |
+
public static final String POPUPTO = "P";
|
| 10 |
+
public static final String ACTION_HANDLER = "A";
|
| 11 |
+
public static final String DEEPLINK = "D";
|
| 12 |
+
public static final String NONE = "N";
|
| 13 |
+
|
| 14 |
+
private MessageBoxActionTypeConstants() {
|
| 15 |
+
log.error("MessageBoxActionTypeConstants case create instance");
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageBoxActionUiConstants.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
import lombok.extern.slf4j.Slf4j;
|
| 4 |
+
|
| 5 |
+
@Slf4j
|
| 6 |
+
public class MessageBoxActionUiConstants {
|
| 7 |
+
|
| 8 |
+
public static final String BUTTON = "B";
|
| 9 |
+
public static final String TEXT = "T";
|
| 10 |
+
|
| 11 |
+
private MessageBoxActionUiConstants() {
|
| 12 |
+
log.error("MessageBoxActionUiConstants case create instance");
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/constants/MessageTypeConstants.java
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.constants;
|
| 2 |
+
|
| 3 |
+
public abstract class MessageTypeConstants {
|
| 4 |
+
|
| 5 |
+
public static final String INFORMATION = "I";
|
| 6 |
+
public static final String WARNING = "W";
|
| 7 |
+
public static final String ERROR = "E";
|
| 8 |
+
|
| 9 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/BusinessException.java
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.exception.enums.BaseErrorType;
|
| 4 |
+
import lombok.Getter;
|
| 5 |
+
|
| 6 |
+
import java.io.Serial;
|
| 7 |
+
import java.io.Serializable;
|
| 8 |
+
|
| 9 |
+
@Getter
|
| 10 |
+
public class BusinessException extends RuntimeException implements Serializable {
|
| 11 |
+
|
| 12 |
+
@Serial
|
| 13 |
+
private static final long serialVersionUID = -7123456789012345678L;
|
| 14 |
+
|
| 15 |
+
private final String code;
|
| 16 |
+
private final String message;
|
| 17 |
+
|
| 18 |
+
public BusinessException(BaseErrorType baseErrorType) {
|
| 19 |
+
this.code = baseErrorType.getCode();
|
| 20 |
+
this.message = baseErrorType.getMessage();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BaseErrorType.java
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
public interface BaseErrorType {
|
| 4 |
+
|
| 5 |
+
String getCode();
|
| 6 |
+
String getMessage();
|
| 7 |
+
|
| 8 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/BusinessErrorType.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum BusinessErrorType implements BaseErrorType{
|
| 7 |
+
BACKOFFICE_DB_DUPLICATE("DUPLICATE_01","This data is found.");
|
| 8 |
+
|
| 9 |
+
private final String code;
|
| 10 |
+
private final String message;
|
| 11 |
+
|
| 12 |
+
@Override
|
| 13 |
+
public String getCode() {
|
| 14 |
+
return code;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
@Override
|
| 18 |
+
public String getMessage() {
|
| 19 |
+
return message;
|
| 20 |
+
}
|
| 21 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/SessionErrorType.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum SessionErrorType implements BaseErrorType{
|
| 7 |
+
|
| 8 |
+
SESSION_NOT_FOUND("SESSION_001", "Session Not Found");
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String message;
|
| 12 |
+
|
| 13 |
+
@Override
|
| 14 |
+
public String getCode() {
|
| 15 |
+
return code;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
@Override
|
| 19 |
+
public String getMessage() {
|
| 20 |
+
return message;
|
| 21 |
+
}
|
| 22 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/exception/enums/UnhandledErrorType.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.exception.enums;
|
| 2 |
+
|
| 3 |
+
import lombok.RequiredArgsConstructor;
|
| 4 |
+
|
| 5 |
+
@RequiredArgsConstructor
|
| 6 |
+
public enum UnhandledErrorType implements BaseErrorType {
|
| 7 |
+
|
| 8 |
+
UNHANDLED_ERROR_TYPE("GENERIC_001","Generic Exception");
|
| 9 |
+
|
| 10 |
+
private final String code;
|
| 11 |
+
private final String message;
|
| 12 |
+
|
| 13 |
+
@Override
|
| 14 |
+
public String getCode() {
|
| 15 |
+
return this.code;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
@Override
|
| 19 |
+
public String getMessage() {
|
| 20 |
+
return this.message;
|
| 21 |
+
}
|
| 22 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/scope/RequestHeaderScope.java
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.scope;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 4 |
+
import org.springframework.stereotype.Component;
|
| 5 |
+
import org.springframework.web.context.annotation.RequestScope;
|
| 6 |
+
|
| 7 |
+
@Component
|
| 8 |
+
@RequestScope
|
| 9 |
+
public class RequestHeaderScope {
|
| 10 |
+
|
| 11 |
+
private RequestHeader requestHeader;
|
| 12 |
+
|
| 13 |
+
public RequestHeader getRequestHeader() {
|
| 14 |
+
return requestHeader;
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public void setRequestHeader(RequestHeader requestHeader) {
|
| 18 |
+
this.requestHeader = requestHeader;
|
| 19 |
+
}
|
| 20 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/ExternalAttributeService.java
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
|
| 6 |
+
public interface ExternalAttributeService {
|
| 7 |
+
|
| 8 |
+
MessageBox getMessageBox(MessageModel messageModel, String... parameters);
|
| 9 |
+
|
| 10 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/MessageBoxService.java
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBox;
|
| 6 |
+
|
| 7 |
+
public interface MessageBoxService {
|
| 8 |
+
MessageBox getMessageBox(String errorCode);
|
| 9 |
+
void saveMessageBox(ErrorMessageBox errorMessageBox);
|
| 10 |
+
void removeMessageBox(String errorCode);
|
| 11 |
+
void updateMessageBox(ErrorMessageBox errorMessageBox);
|
| 12 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/ExternalAttributeServiceImpl.java
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.model.MessageModel;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.model.RequestHeader;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.scope.RequestHeaderScope;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.service.ExternalAttributeService;
|
| 8 |
+
import com.artandscience.webbff.webbff.common.service.MessageBoxService;
|
| 9 |
+
import lombok.RequiredArgsConstructor;
|
| 10 |
+
import lombok.extern.slf4j.Slf4j;
|
| 11 |
+
import org.springframework.stereotype.Service;
|
| 12 |
+
|
| 13 |
+
@Slf4j
|
| 14 |
+
@Service
|
| 15 |
+
@RequiredArgsConstructor
|
| 16 |
+
public class ExternalAttributeServiceImpl implements ExternalAttributeService {
|
| 17 |
+
|
| 18 |
+
private final RequestHeaderScope requestHeaderScope;
|
| 19 |
+
private final MessageBoxService messageBoxService;
|
| 20 |
+
|
| 21 |
+
@Override
|
| 22 |
+
public MessageBox getMessageBox(MessageModel messageModel, String... parameters) {
|
| 23 |
+
try {
|
| 24 |
+
RequestHeader requestHeader = requestHeaderScope.getRequestHeader();
|
| 25 |
+
String messageKey = messageModel.getCode() + "." + requestHeader.getLanguage();
|
| 26 |
+
var messageBox = messageBoxService.getMessageBox(messageKey);
|
| 27 |
+
if (messageBox == null) {
|
| 28 |
+
if (!messageModel.getCode().contains("DEFAULT_MESSAGE_BOX")) {
|
| 29 |
+
log.error("MessageBoxService errorCode not found." + messageModel.getCode() + messageModel.getCode() + "." + requestHeader.getLanguage());
|
| 30 |
+
}
|
| 31 |
+
return getDefaultMessageBox(requestHeader.getLanguage(), messageModel);
|
| 32 |
+
} else {
|
| 33 |
+
log.info("MessageBoxService returning error message key {}", messageKey);
|
| 34 |
+
}
|
| 35 |
+
if (messageBox.getMessage() != null && parameters != null && parameters.length != 0) {
|
| 36 |
+
var formattedMessage = String.format(messageBox.getMessage(), parameters);
|
| 37 |
+
messageBox.setMessage(formattedMessage);
|
| 38 |
+
return messageBox;
|
| 39 |
+
}
|
| 40 |
+
return messageBox;
|
| 41 |
+
} catch (Exception e) {
|
| 42 |
+
log.error("ExternalAttributeServiceImpl getMessageBox() exception occurred for messageBoxCode: " + messageModel.getCode(), e);
|
| 43 |
+
return getDefaultMessageBox();
|
| 44 |
+
}
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
private MessageBox getDefaultMessageBox() {
|
| 48 |
+
return null; //TODO: yazılacak
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
private MessageBox getDefaultMessageBox(String language, MessageModel messageModel) {
|
| 52 |
+
return null; //TODO: yazılacak.
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/common/service/impl/MessageBoxServiceImpl.java
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.common.service.impl;
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBox;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBoxAction;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageType;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.constants.MessageTypeConstants;
|
| 8 |
+
import com.artandscience.webbff.webbff.common.exception.BusinessException;
|
| 9 |
+
import com.artandscience.webbff.webbff.common.exception.enums.BusinessErrorType;
|
| 10 |
+
import com.artandscience.webbff.webbff.common.service.MessageBoxService;
|
| 11 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBox;
|
| 12 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBoxAction;
|
| 13 |
+
import com.artandscience.webbff.webbff.dao.repository.ErrorMessageBoxRepository;
|
| 14 |
+
import lombok.RequiredArgsConstructor;
|
| 15 |
+
import lombok.extern.slf4j.Slf4j;
|
| 16 |
+
import org.springframework.cache.annotation.CacheEvict;
|
| 17 |
+
import org.springframework.cache.annotation.Cacheable;
|
| 18 |
+
import org.springframework.scheduling.annotation.Scheduled;
|
| 19 |
+
import org.springframework.stereotype.Service;
|
| 20 |
+
|
| 21 |
+
import java.util.Comparator;
|
| 22 |
+
import java.util.Objects;
|
| 23 |
+
import java.util.Optional;
|
| 24 |
+
|
| 25 |
+
@Slf4j
|
| 26 |
+
@Service
|
| 27 |
+
@RequiredArgsConstructor
|
| 28 |
+
public class MessageBoxServiceImpl implements MessageBoxService {
|
| 29 |
+
|
| 30 |
+
private static final String CACHE_NAME_MESSAGE_BOX = "artandsciencewebbff-messageBox";
|
| 31 |
+
private final ErrorMessageBoxRepository errorMessageBoxRepository;
|
| 32 |
+
|
| 33 |
+
@Override
|
| 34 |
+
@Cacheable(cacheNames = CACHE_NAME_MESSAGE_BOX, key = "#errorCode", unless = "#result == null")
|
| 35 |
+
public MessageBox getMessageBox(String errorCode) {
|
| 36 |
+
Optional<ErrorMessageBox> optErrorMessageBox = errorMessageBoxRepository.findById(String.format("%s",errorCode));
|
| 37 |
+
if (optErrorMessageBox.isPresent()) {
|
| 38 |
+
ErrorMessageBox errorMessageBox = optErrorMessageBox.get();
|
| 39 |
+
return MessageBox.builder()
|
| 40 |
+
.messageCode(errorMessageBox.getMessageCode())
|
| 41 |
+
.messageType(getMessageType(errorMessageBox.getMessageType()))
|
| 42 |
+
.message(errorMessageBox.getMessage())
|
| 43 |
+
.title(errorMessageBox.getTitle())
|
| 44 |
+
.messageBoxAction(errorMessageBox.getErrorMessageBoxActions().stream()
|
| 45 |
+
.map(ErrorMessageBoxAction::toMessageBoxAction)
|
| 46 |
+
.sorted(Comparator.comparing(MessageBoxAction::getOrderNo)).toList())
|
| 47 |
+
.build();
|
| 48 |
+
}
|
| 49 |
+
return null;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
@Override
|
| 53 |
+
public void saveMessageBox(ErrorMessageBox errorMessageBox) {
|
| 54 |
+
if (!Objects.isNull(errorMessageBox)) {
|
| 55 |
+
var messageBox = getErrorMessageBox(errorMessageBox.getKey());
|
| 56 |
+
if (!Objects.isNull(messageBox))
|
| 57 |
+
throw new BusinessException(BusinessErrorType.BACKOFFICE_DB_DUPLICATE);
|
| 58 |
+
errorMessageBoxRepository.save(errorMessageBox);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
@Override
|
| 63 |
+
public void removeMessageBox(String errorCode) {
|
| 64 |
+
ErrorMessageBox errorMessageBox = getErrorMessageBox(errorCode);
|
| 65 |
+
if (!Objects.isNull(errorMessageBox)) {
|
| 66 |
+
errorMessageBoxRepository.delete(errorMessageBox);
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
@Override
|
| 71 |
+
public void updateMessageBox(ErrorMessageBox errorMessageBox) {
|
| 72 |
+
ErrorMessageBox messageBox = getErrorMessageBox(errorMessageBox.getKey());
|
| 73 |
+
if (!Objects.isNull(messageBox)) {
|
| 74 |
+
errorMessageBoxRepository.saveAndFlush(errorMessageBox);
|
| 75 |
+
}
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
private ErrorMessageBox getErrorMessageBox(String errorCode) {
|
| 79 |
+
Optional<ErrorMessageBox> optErrorMessageBox = errorMessageBoxRepository.findById(String.format("%s",errorCode));
|
| 80 |
+
return optErrorMessageBox.orElse(null);
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
private MessageType getMessageType(String type) {
|
| 84 |
+
return switch (type) {
|
| 85 |
+
case (MessageTypeConstants.WARNING) -> MessageType.WARNING;
|
| 86 |
+
case (MessageTypeConstants.ERROR) -> MessageType.ERROR;
|
| 87 |
+
case (MessageTypeConstants.INFORMATION) -> MessageType.INFORMATION;
|
| 88 |
+
default -> MessageType.NONE;
|
| 89 |
+
};
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
@Scheduled(fixedDelayString = "${security.messagebox-cache-expire-time}")
|
| 93 |
+
@CacheEvict(value = CACHE_NAME_MESSAGE_BOX, allEntries = true)
|
| 94 |
+
public void clearCache() {
|
| 95 |
+
log.debug("Cache '{}' cleared.", CACHE_NAME_MESSAGE_BOX);
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/dao/entity/ErrorMessageBox.java
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.dao.entity;
|
| 2 |
+
|
| 3 |
+
import jakarta.persistence.*;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
import lombok.NoArgsConstructor;
|
| 7 |
+
|
| 8 |
+
import java.util.ArrayList;
|
| 9 |
+
import java.util.List;
|
| 10 |
+
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
@Data
|
| 14 |
+
@Entity
|
| 15 |
+
@Table(name = "error_message_box", schema = "artandscience")
|
| 16 |
+
public class ErrorMessageBox {
|
| 17 |
+
|
| 18 |
+
@Id
|
| 19 |
+
@Column(name = "\"key\"") // -> public.error_message_box("key")
|
| 20 |
+
private String key;
|
| 21 |
+
|
| 22 |
+
private String title;
|
| 23 |
+
|
| 24 |
+
@Column(name = "message")
|
| 25 |
+
private String message;
|
| 26 |
+
|
| 27 |
+
@Column(name = "message_type")
|
| 28 |
+
private String messageType;
|
| 29 |
+
|
| 30 |
+
@Column(name = "message_code")
|
| 31 |
+
private String messageCode;
|
| 32 |
+
|
| 33 |
+
@OneToMany(
|
| 34 |
+
cascade = CascadeType.ALL, // <-- çocukları da persist/merge et
|
| 35 |
+
orphanRemoval = true, // <-- listeden çıkarılan çocuk için join kaydını siler
|
| 36 |
+
fetch = FetchType.LAZY
|
| 37 |
+
)
|
| 38 |
+
@JoinTable(
|
| 39 |
+
name = "error_message_box_error_message_box_actions",
|
| 40 |
+
schema = "security",
|
| 41 |
+
joinColumns = @JoinColumn(
|
| 42 |
+
name = "error_message_box_key", // join tablodaki FK kolonu
|
| 43 |
+
referencedColumnName = "\"key\"" // ebeveyn PK kolonu (quoted!)
|
| 44 |
+
),
|
| 45 |
+
inverseJoinColumns = @JoinColumn(
|
| 46 |
+
name = "error_message_box_actions_key", // join tablodaki çocuk FK kolonu
|
| 47 |
+
referencedColumnName = "\"key\"" // çocuk PK kolonu (quoted!)
|
| 48 |
+
)
|
| 49 |
+
)
|
| 50 |
+
private List<ErrorMessageBoxAction> errorMessageBoxActions = new ArrayList<>();
|
| 51 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/dao/entity/ErrorMessageBoxAction.java
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.dao.entity;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.common.base.response.MessageBoxAction;
|
| 4 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionType;
|
| 5 |
+
import com.artandscience.webbff.webbff.common.base.response.enums.MessageBoxActionUiStyle;
|
| 6 |
+
import com.artandscience.webbff.webbff.common.constants.MessageBoxActionTypeConstants;
|
| 7 |
+
import com.artandscience.webbff.webbff.common.constants.MessageBoxActionUiConstants;
|
| 8 |
+
import jakarta.persistence.Column;
|
| 9 |
+
import jakarta.persistence.Entity;
|
| 10 |
+
import jakarta.persistence.Id;
|
| 11 |
+
import jakarta.persistence.Table;
|
| 12 |
+
import lombok.AllArgsConstructor;
|
| 13 |
+
import lombok.Data;
|
| 14 |
+
import lombok.NoArgsConstructor;
|
| 15 |
+
|
| 16 |
+
@AllArgsConstructor
|
| 17 |
+
@NoArgsConstructor
|
| 18 |
+
@Data
|
| 19 |
+
@Entity
|
| 20 |
+
@Table(name = "error_message_box_action", schema = "artandscience")
|
| 21 |
+
public class ErrorMessageBoxAction {
|
| 22 |
+
|
| 23 |
+
@Id
|
| 24 |
+
@Column(name = "\"key\"") // -> public.error_message_box_action("key")
|
| 25 |
+
private String key;
|
| 26 |
+
|
| 27 |
+
@Column(name = "message_box_action_type")
|
| 28 |
+
private String messageBoxActionType;
|
| 29 |
+
|
| 30 |
+
@Column(name = "message_box_ui_style")
|
| 31 |
+
private String messageBoxUiStyle;
|
| 32 |
+
|
| 33 |
+
@Column(name = "\"text\"") // -> public.error_message_box_action("text")
|
| 34 |
+
private String text;
|
| 35 |
+
|
| 36 |
+
@Column(name = "deep_link_key")
|
| 37 |
+
private String deepLinkKey;
|
| 38 |
+
|
| 39 |
+
@Column(name = "order_no")
|
| 40 |
+
private Integer orderNo;
|
| 41 |
+
|
| 42 |
+
public static MessageBoxAction toMessageBoxAction(ErrorMessageBoxAction errorMessageBoxAction) {
|
| 43 |
+
return MessageBoxAction.builder()
|
| 44 |
+
.actionType(getMessageBoxActionType(errorMessageBoxAction.getMessageBoxActionType()))
|
| 45 |
+
.text(errorMessageBoxAction.getText())
|
| 46 |
+
.uiStyle(getMessageBoxActionUiStyle(errorMessageBoxAction.getMessageBoxUiStyle()))
|
| 47 |
+
.orderNo(errorMessageBoxAction.getOrderNo())
|
| 48 |
+
.build();
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
private static MessageBoxActionType getMessageBoxActionType(String messageBoxActionType) {
|
| 52 |
+
return switch (messageBoxActionType) {
|
| 53 |
+
case (MessageBoxActionTypeConstants.RETRY) -> MessageBoxActionType.RETRY;
|
| 54 |
+
case (MessageBoxActionTypeConstants.POPUPTO) -> MessageBoxActionType.POPUPTO;
|
| 55 |
+
case (MessageBoxActionTypeConstants.ACTION_HANDLER) -> MessageBoxActionType.ACTION_HANDLER;
|
| 56 |
+
case (MessageBoxActionTypeConstants.DEEPLINK) -> MessageBoxActionType.DEEPLINK;
|
| 57 |
+
default -> MessageBoxActionType.NONE;
|
| 58 |
+
};
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
private static MessageBoxActionUiStyle getMessageBoxActionUiStyle(String messageBoxUiStyle) {
|
| 62 |
+
return switch (messageBoxUiStyle) {
|
| 63 |
+
case (MessageBoxActionUiConstants.BUTTON) -> MessageBoxActionUiStyle.BUTTON;
|
| 64 |
+
case (MessageBoxActionUiConstants.TEXT) -> MessageBoxActionUiStyle.TEXT;
|
| 65 |
+
default -> MessageBoxActionUiStyle.BUTTON;
|
| 66 |
+
};
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
}
|
src/main/java/com/artandscience/webbff/webbff/dao/repository/ErrorMessageBoxRepository.java
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.artandscience.webbff.webbff.dao.repository;
|
| 2 |
+
|
| 3 |
+
import com.artandscience.webbff.webbff.dao.entity.ErrorMessageBox;
|
| 4 |
+
import org.springframework.data.jpa.repository.JpaRepository;
|
| 5 |
+
import org.springframework.stereotype.Repository;
|
| 6 |
+
|
| 7 |
+
@Repository
|
| 8 |
+
public interface ErrorMessageBoxRepository extends JpaRepository<ErrorMessageBox, String> {
|
| 9 |
+
}
|