Spaces:
Sleeping
Sleeping
Commit ·
950fd72
1
Parent(s): e455230
add push notification
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- pom.xml +6 -0
- src/main/java/com/utility/utilitycommonservice/UtilityCommonServiceApplication.java +0 -2
- src/main/java/com/utility/utilitycommonservice/api/controller/bitbucket/BitbucketController.java +1 -1
- src/main/java/com/utility/utilitycommonservice/api/controller/localize/LocalizeController.java +9 -0
- src/main/java/com/utility/utilitycommonservice/api/controller/notification/PushController.java +34 -0
- src/main/java/com/utility/utilitycommonservice/{domain/model/localize → api/model}/KeyValueParameter.java +1 -1
- src/main/java/com/utility/utilitycommonservice/api/model/request/AddLocalizeRequest.java +22 -0
- src/main/java/com/utility/utilitycommonservice/api/model/request/CrudNotificationRequest.java +22 -0
- src/main/java/com/utility/utilitycommonservice/api/model/request/PushNotificationByDomainRequest.java +21 -0
- src/main/java/com/utility/utilitycommonservice/api/model/response/CrudNotificationResponse.java +15 -0
- src/main/java/com/utility/utilitycommonservice/api/model/response/MenuResponse.java +2 -1
- src/main/java/com/utility/utilitycommonservice/common/base/controller/BaseController.java +4 -0
- src/main/java/com/utility/utilitycommonservice/common/base/response/MessageResponse.java +5 -0
- src/main/java/com/utility/utilitycommonservice/common/base/response/builder/MsgResponseBuilder.java +4 -0
- src/main/java/com/utility/utilitycommonservice/common/interceptor/ResponseErrorHandler.java +1 -2
- src/main/java/com/utility/utilitycommonservice/common/redis/RedisUtil.java +4 -0
- src/main/java/com/utility/utilitycommonservice/common/service/SessionService.java +2 -0
- src/main/java/com/utility/utilitycommonservice/common/service/impl/SessionServiceImpl.java +6 -0
- src/main/java/com/utility/utilitycommonservice/common/util/BitbucketBasicAuthGenerator.java +1 -1
- src/main/java/com/utility/utilitycommonservice/dao/entity/PushNotificationLog.java +51 -0
- src/main/java/com/utility/utilitycommonservice/dao/repository/PushNotificationLogRepository.java +18 -0
- src/main/java/com/utility/utilitycommonservice/domain/assembler/CrudAssembler.java +69 -0
- src/main/java/com/utility/utilitycommonservice/{common → domain}/constant/BitbucketServiceConstant.java +1 -1
- src/main/java/com/utility/utilitycommonservice/{common → domain}/constant/LocalizeConstant.java +1 -1
- src/main/java/com/utility/utilitycommonservice/domain/model/bitbucket/output/CreateBranchOutput.java +1 -1
- src/main/java/com/utility/utilitycommonservice/domain/model/clientbe/output/MenuOutput.java +6 -5
- src/main/java/com/utility/utilitycommonservice/domain/model/localize/LocalizeInitModel.java +1 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/Deeplink.java +17 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/InfoModel.java +18 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/Notification.java +50 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/PushNotificationBody.java +16 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/attributes/LogTypeAttribute.java +19 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/enums/CrudType.java +5 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/enums/LogType.java +34 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/input/CrudNotificationInput.java +14 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/input/PushNotificationByDomainInput.java +13 -0
- src/main/java/com/utility/utilitycommonservice/domain/model/notification/output/CrudNotificationOutput.java +22 -0
- src/main/java/com/utility/utilitycommonservice/{common → domain}/properties/BitbucketProperties.java +1 -1
- src/main/java/com/utility/utilitycommonservice/domain/service/clientbe/notification/PushService.java +14 -0
- src/main/java/com/utility/utilitycommonservice/domain/service/clientbe/notification/notificationImpl/PushServiceImpl.java +89 -0
- src/main/java/com/utility/utilitycommonservice/domain/service/localize/impl/LocalizeServiceImpl.java +26 -16
- src/main/java/com/utility/utilitycommonservice/integration/config/firebase/FirebaseConfig.java +45 -0
- src/main/java/com/utility/utilitycommonservice/integration/service/model/request/firebase/SendToTokenClientRequest.java +16 -0
- src/main/java/com/utility/utilitycommonservice/integration/service/model/request/firebase/SendToTopicClientRequest.java +14 -0
- src/main/java/com/utility/utilitycommonservice/integration/service/model/response/{CreateBranchClientResponse.java → bitbucket/CreateBranchClientResponse.java} +1 -1
- src/main/java/com/utility/utilitycommonservice/integration/service/model/response/firebase/SendToTokenClientResponse.java +18 -0
- src/main/java/com/utility/utilitycommonservice/integration/service/model/response/firebase/SendToTopicClientResponse.java +18 -0
- src/main/java/com/utility/utilitycommonservice/integration/service/service/bitbucket/BitbucketClientService.java +1 -1
- src/main/java/com/utility/utilitycommonservice/integration/service/service/{impl/bitbucket → bitbucket/impl}/BitbucketClientServiceImpl.java +3 -3
- src/main/java/com/utility/utilitycommonservice/integration/service/service/firebase/PushClientService.java +12 -0
pom.xml
CHANGED
|
@@ -35,6 +35,12 @@
|
|
| 35 |
<artifactId>spring-boot-starter-data-redis</artifactId>
|
| 36 |
</dependency>
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
<dependency>
|
| 39 |
<groupId>redis.clients</groupId>
|
| 40 |
<artifactId>jedis</artifactId>
|
|
|
|
| 35 |
<artifactId>spring-boot-starter-data-redis</artifactId>
|
| 36 |
</dependency>
|
| 37 |
|
| 38 |
+
<dependency>
|
| 39 |
+
<groupId>com.google.firebase</groupId>
|
| 40 |
+
<artifactId>firebase-admin</artifactId>
|
| 41 |
+
<version>9.2.0</version>
|
| 42 |
+
</dependency>
|
| 43 |
+
|
| 44 |
<dependency>
|
| 45 |
<groupId>redis.clients</groupId>
|
| 46 |
<artifactId>jedis</artifactId>
|
src/main/java/com/utility/utilitycommonservice/UtilityCommonServiceApplication.java
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
package com.utility.utilitycommonservice;
|
| 2 |
|
| 3 |
-
import com.utility.utilitycommonservice.common.properties.BitbucketProperties;
|
| 4 |
import org.springframework.boot.SpringApplication;
|
| 5 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
| 6 |
-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
| 7 |
import org.springframework.cloud.openfeign.EnableFeignClients;
|
| 8 |
|
| 9 |
@SpringBootApplication
|
|
|
|
| 1 |
package com.utility.utilitycommonservice;
|
| 2 |
|
|
|
|
| 3 |
import org.springframework.boot.SpringApplication;
|
| 4 |
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
|
|
| 5 |
import org.springframework.cloud.openfeign.EnableFeignClients;
|
| 6 |
|
| 7 |
@SpringBootApplication
|
src/main/java/com/utility/utilitycommonservice/api/controller/bitbucket/BitbucketController.java
CHANGED
|
@@ -7,7 +7,7 @@ import com.utility.utilitycommonservice.common.base.controller.BaseController;
|
|
| 7 |
import com.utility.utilitycommonservice.common.base.response.MessageResponse;
|
| 8 |
import com.utility.utilitycommonservice.domain.model.bitbucket.input.UploadFileInput;
|
| 9 |
import com.utility.utilitycommonservice.domain.service.bitbucket.BitbucketService;
|
| 10 |
-
import com.utility.utilitycommonservice.integration.service.model.response.CreateBranchClientResponse;
|
| 11 |
import lombok.RequiredArgsConstructor;
|
| 12 |
import org.springframework.web.bind.annotation.*;
|
| 13 |
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
| 7 |
import com.utility.utilitycommonservice.common.base.response.MessageResponse;
|
| 8 |
import com.utility.utilitycommonservice.domain.model.bitbucket.input.UploadFileInput;
|
| 9 |
import com.utility.utilitycommonservice.domain.service.bitbucket.BitbucketService;
|
| 10 |
+
import com.utility.utilitycommonservice.integration.service.model.response.bitbucket.CreateBranchClientResponse;
|
| 11 |
import lombok.RequiredArgsConstructor;
|
| 12 |
import org.springframework.web.bind.annotation.*;
|
| 13 |
import org.springframework.web.multipart.MultipartFile;
|
src/main/java/com/utility/utilitycommonservice/api/controller/localize/LocalizeController.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package com.utility.utilitycommonservice.api.controller.localize;
|
| 2 |
|
|
|
|
| 3 |
import com.utility.utilitycommonservice.api.model.request.RequestByKey;
|
| 4 |
import com.utility.utilitycommonservice.api.model.response.ResponseByKey;
|
| 5 |
import com.utility.utilitycommonservice.common.base.controller.BaseController;
|
|
@@ -11,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|
| 11 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 12 |
import org.springframework.web.bind.annotation.RestController;
|
| 13 |
|
|
|
|
|
|
|
| 14 |
@RestController
|
| 15 |
@RequiredArgsConstructor
|
| 16 |
@RequestMapping("/api/v1/localize")
|
|
@@ -24,4 +27,10 @@ public class LocalizeController extends BaseController {
|
|
| 24 |
return responseSuccess(output.toResponse());
|
| 25 |
}
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.api.controller.localize;
|
| 2 |
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.request.AddLocalizeRequest;
|
| 4 |
import com.utility.utilitycommonservice.api.model.request.RequestByKey;
|
| 5 |
import com.utility.utilitycommonservice.api.model.response.ResponseByKey;
|
| 6 |
import com.utility.utilitycommonservice.common.base.controller.BaseController;
|
|
|
|
| 12 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 13 |
import org.springframework.web.bind.annotation.RestController;
|
| 14 |
|
| 15 |
+
import java.io.IOException;
|
| 16 |
+
|
| 17 |
@RestController
|
| 18 |
@RequiredArgsConstructor
|
| 19 |
@RequestMapping("/api/v1/localize")
|
|
|
|
| 27 |
return responseSuccess(output.toResponse());
|
| 28 |
}
|
| 29 |
|
| 30 |
+
@PostMapping("/addLocalize")
|
| 31 |
+
public MessageResponse<Void> addLocalize(@RequestBody AddLocalizeRequest request) throws IOException {
|
| 32 |
+
localizeService.addLocalize(request.toInput());
|
| 33 |
+
return responseSuccess();
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
}
|
src/main/java/com/utility/utilitycommonservice/api/controller/notification/PushController.java
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.controller.notification;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.request.CrudNotificationRequest;
|
| 4 |
+
import com.utility.utilitycommonservice.api.model.request.PushNotificationByDomainRequest;
|
| 5 |
+
import com.utility.utilitycommonservice.api.model.response.CrudNotificationResponse;
|
| 6 |
+
import com.utility.utilitycommonservice.common.base.controller.BaseController;
|
| 7 |
+
import com.utility.utilitycommonservice.common.base.response.MessageResponse;
|
| 8 |
+
import com.utility.utilitycommonservice.domain.service.clientbe.notification.PushService;
|
| 9 |
+
import lombok.RequiredArgsConstructor;
|
| 10 |
+
import org.springframework.web.bind.annotation.PostMapping;
|
| 11 |
+
import org.springframework.web.bind.annotation.RequestBody;
|
| 12 |
+
import org.springframework.web.bind.annotation.RequestMapping;
|
| 13 |
+
import org.springframework.web.bind.annotation.RestController;
|
| 14 |
+
|
| 15 |
+
@RestController
|
| 16 |
+
@RequiredArgsConstructor
|
| 17 |
+
@RequestMapping("/api/v1/notification")
|
| 18 |
+
public class PushController extends BaseController {
|
| 19 |
+
|
| 20 |
+
private final PushService pushService;
|
| 21 |
+
|
| 22 |
+
@PostMapping("/pushByDomain")
|
| 23 |
+
public MessageResponse<Void> pushNotificationByDomain(@RequestBody PushNotificationByDomainRequest request) {
|
| 24 |
+
pushService.pushNotificationByDomain(request.toInput());
|
| 25 |
+
return responseSuccess();
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
@PostMapping("/crudNotification")
|
| 29 |
+
public MessageResponse<CrudNotificationResponse> crudNotification(@RequestBody CrudNotificationRequest request) {
|
| 30 |
+
var output = pushService.crudNotification(request.toInput());
|
| 31 |
+
return responseSuccess(output.toResponse());
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
}
|
src/main/java/com/utility/utilitycommonservice/{domain/model/localize → api/model}/KeyValueParameter.java
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.
|
| 2 |
|
| 3 |
import lombok.AllArgsConstructor;
|
| 4 |
import lombok.Builder;
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.model;
|
| 2 |
|
| 3 |
import lombok.AllArgsConstructor;
|
| 4 |
import lombok.Builder;
|
src/main/java/com/utility/utilitycommonservice/api/model/request/AddLocalizeRequest.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.model.request;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.localize.input.AddLocalizeInput;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
|
| 7 |
+
@Data
|
| 8 |
+
@Builder
|
| 9 |
+
public class AddLocalizeRequest {
|
| 10 |
+
private String language;
|
| 11 |
+
private String key;
|
| 12 |
+
private String value;
|
| 13 |
+
|
| 14 |
+
public AddLocalizeInput toInput() {
|
| 15 |
+
return AddLocalizeInput.builder()
|
| 16 |
+
.language(language)
|
| 17 |
+
.key(key)
|
| 18 |
+
.value(value)
|
| 19 |
+
.build();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
}
|
src/main/java/com/utility/utilitycommonservice/api/model/request/CrudNotificationRequest.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.model.request;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.CrudType;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.CrudNotificationInput;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
@Builder
|
| 10 |
+
public class CrudNotificationRequest {
|
| 11 |
+
|
| 12 |
+
private CrudType crudType;
|
| 13 |
+
private String uid;
|
| 14 |
+
|
| 15 |
+
public CrudNotificationInput toInput() {
|
| 16 |
+
return CrudNotificationInput.builder()
|
| 17 |
+
.crudType(crudType)
|
| 18 |
+
.uid(uid)
|
| 19 |
+
.build();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
}
|
src/main/java/com/utility/utilitycommonservice/api/model/request/PushNotificationByDomainRequest.java
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.model.request;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.InfoModel;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.PushNotificationByDomainInput;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
@Builder
|
| 10 |
+
public class PushNotificationByDomainRequest {
|
| 11 |
+
private InfoModel infoModel;
|
| 12 |
+
private String domainCode;
|
| 13 |
+
|
| 14 |
+
public PushNotificationByDomainInput toInput() {
|
| 15 |
+
return PushNotificationByDomainInput.builder()
|
| 16 |
+
.infoModel(infoModel)
|
| 17 |
+
.domainCode(domainCode)
|
| 18 |
+
.build();
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
}
|
src/main/java/com/utility/utilitycommonservice/api/model/response/CrudNotificationResponse.java
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.api.model.response;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.Notification;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
|
| 7 |
+
import java.util.List;
|
| 8 |
+
|
| 9 |
+
@Data
|
| 10 |
+
@Builder
|
| 11 |
+
public class CrudNotificationResponse {
|
| 12 |
+
|
| 13 |
+
private List<Notification> notifications;
|
| 14 |
+
|
| 15 |
+
}
|
src/main/java/com/utility/utilitycommonservice/api/model/response/MenuResponse.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package com.utility.utilitycommonservice.api.model.response;
|
| 2 |
|
|
|
|
| 3 |
import com.utility.utilitycommonservice.domain.model.clientbe.MenuModel;
|
| 4 |
import lombok.Builder;
|
| 5 |
import lombok.Data;
|
|
@@ -9,5 +10,5 @@ import java.util.List;
|
|
| 9 |
@Data
|
| 10 |
@Builder
|
| 11 |
public class MenuResponse {
|
| 12 |
-
private List<
|
| 13 |
}
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.api.model.response;
|
| 2 |
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.KeyValueParameter;
|
| 4 |
import com.utility.utilitycommonservice.domain.model.clientbe.MenuModel;
|
| 5 |
import lombok.Builder;
|
| 6 |
import lombok.Data;
|
|
|
|
| 10 |
@Data
|
| 11 |
@Builder
|
| 12 |
public class MenuResponse {
|
| 13 |
+
private List<KeyValueParameter<String,Integer>> menuList;
|
| 14 |
}
|
src/main/java/com/utility/utilitycommonservice/common/base/controller/BaseController.java
CHANGED
|
@@ -22,4 +22,8 @@ public abstract class BaseController {
|
|
| 22 |
return MsgResponseBuilder.build(true,messageBox,data);
|
| 23 |
}
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
}
|
|
|
|
| 22 |
return MsgResponseBuilder.build(true,messageBox,data);
|
| 23 |
}
|
| 24 |
|
| 25 |
+
protected MessageResponse<Void> responseSuccess() {
|
| 26 |
+
return MsgResponseBuilder.build(true);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
}
|
src/main/java/com/utility/utilitycommonservice/common/base/response/MessageResponse.java
CHANGED
|
@@ -39,4 +39,9 @@ public class MessageResponse<T> {
|
|
| 39 |
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 40 |
}
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
}
|
|
|
|
| 39 |
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 40 |
}
|
| 41 |
|
| 42 |
+
public MessageResponse(boolean success){
|
| 43 |
+
this.success = success;
|
| 44 |
+
this.executionDate = ZonedDateTime.now().format(DateTimeFormatter.ISO_LOCAL_DATE);
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
}
|
src/main/java/com/utility/utilitycommonservice/common/base/response/builder/MsgResponseBuilder.java
CHANGED
|
@@ -25,4 +25,8 @@ public class MsgResponseBuilder {
|
|
| 25 |
return new MessageResponse<>(success,data,messageBox);
|
| 26 |
}
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
}
|
|
|
|
| 25 |
return new MessageResponse<>(success,data,messageBox);
|
| 26 |
}
|
| 27 |
|
| 28 |
+
public static <T>MessageResponse<T> build(boolean success) {
|
| 29 |
+
return new MessageResponse<>(success);
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
}
|
src/main/java/com/utility/utilitycommonservice/common/interceptor/ResponseErrorHandler.java
CHANGED
|
@@ -13,12 +13,11 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
| 13 |
import org.springframework.web.bind.annotation.ResponseStatus;
|
| 14 |
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| 15 |
import org.springframework.web.client.HttpClientErrorException;
|
| 16 |
-
import org.springframework.web.method.HandlerMethod;
|
| 17 |
|
| 18 |
import java.util.ArrayList;
|
| 19 |
import java.util.List;
|
| 20 |
|
| 21 |
-
import static com.utility.utilitycommonservice.
|
| 22 |
|
| 23 |
@RestControllerAdvice
|
| 24 |
@RequiredArgsConstructor
|
|
|
|
| 13 |
import org.springframework.web.bind.annotation.ResponseStatus;
|
| 14 |
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
| 15 |
import org.springframework.web.client.HttpClientErrorException;
|
|
|
|
| 16 |
|
| 17 |
import java.util.ArrayList;
|
| 18 |
import java.util.List;
|
| 19 |
|
| 20 |
+
import static com.utility.utilitycommonservice.domain.constant.BitbucketServiceConstant.*;
|
| 21 |
|
| 22 |
@RestControllerAdvice
|
| 23 |
@RequiredArgsConstructor
|
src/main/java/com/utility/utilitycommonservice/common/redis/RedisUtil.java
CHANGED
|
@@ -21,6 +21,10 @@ public class RedisUtil {
|
|
| 21 |
valueOperations.set(key,value,expirationTime,expirationTimeUnit);
|
| 22 |
}
|
| 23 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
public Object getValue(String key) {
|
| 25 |
return valueOperations.get(key);
|
| 26 |
}
|
|
|
|
| 21 |
valueOperations.set(key,value,expirationTime,expirationTimeUnit);
|
| 22 |
}
|
| 23 |
|
| 24 |
+
public void putValue(String key, Object value) {
|
| 25 |
+
valueOperations.set(key,value);
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
public Object getValue(String key) {
|
| 29 |
return valueOperations.get(key);
|
| 30 |
}
|
src/main/java/com/utility/utilitycommonservice/common/service/SessionService.java
CHANGED
|
@@ -6,6 +6,8 @@ public interface SessionService {
|
|
| 6 |
|
| 7 |
<T> T getSession(String sessionKey, Class<T> returnType, boolean... isNullable);
|
| 8 |
|
|
|
|
|
|
|
| 9 |
void removeSession(String sessionKey);
|
| 10 |
|
| 11 |
}
|
|
|
|
| 6 |
|
| 7 |
<T> T getSession(String sessionKey, Class<T> returnType, boolean... isNullable);
|
| 8 |
|
| 9 |
+
<T> void setSession(String sessionKey, T object);
|
| 10 |
+
|
| 11 |
void removeSession(String sessionKey);
|
| 12 |
|
| 13 |
}
|
src/main/java/com/utility/utilitycommonservice/common/service/impl/SessionServiceImpl.java
CHANGED
|
@@ -33,6 +33,12 @@ public class SessionServiceImpl implements SessionService {
|
|
| 33 |
redisUtil.putValue(key,object,Integer.parseInt(expireTime), TimeUnit.MINUTES);
|
| 34 |
}
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
@Override
|
| 37 |
public <T> T getSession(String sessionKey, Class<T> returnType, boolean... isNullable) {
|
| 38 |
Object sessionObject = null;
|
|
|
|
| 33 |
redisUtil.putValue(key,object,Integer.parseInt(expireTime), TimeUnit.MINUTES);
|
| 34 |
}
|
| 35 |
|
| 36 |
+
@Override
|
| 37 |
+
public <T> void setSession(String sessionKey, T object) {
|
| 38 |
+
String key = StringUtils.isEmpty(sessionKey) ? requestHeaderScope.getRequestHeader().getSessionId() : sessionKey;
|
| 39 |
+
redisUtil.putValue(key,object);
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
@Override
|
| 43 |
public <T> T getSession(String sessionKey, Class<T> returnType, boolean... isNullable) {
|
| 44 |
Object sessionObject = null;
|
src/main/java/com/utility/utilitycommonservice/common/util/BitbucketBasicAuthGenerator.java
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
package com.utility.utilitycommonservice.common.util;
|
| 2 |
|
| 3 |
-
import com.utility.utilitycommonservice.
|
| 4 |
import lombok.RequiredArgsConstructor;
|
| 5 |
import org.springframework.stereotype.Component;
|
| 6 |
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.common.util;
|
| 2 |
|
| 3 |
+
import com.utility.utilitycommonservice.domain.properties.BitbucketProperties;
|
| 4 |
import lombok.RequiredArgsConstructor;
|
| 5 |
import org.springframework.stereotype.Component;
|
| 6 |
|
src/main/java/com/utility/utilitycommonservice/dao/entity/PushNotificationLog.java
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.dao.entity;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.Notification;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.attributes.LogTypeAttribute;
|
| 5 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.LogType;
|
| 6 |
+
import jakarta.persistence.Column;
|
| 7 |
+
import jakarta.persistence.Convert;
|
| 8 |
+
import jakarta.persistence.Entity;
|
| 9 |
+
import jakarta.persistence.Id;
|
| 10 |
+
import lombok.AllArgsConstructor;
|
| 11 |
+
import lombok.Builder;
|
| 12 |
+
import lombok.Data;
|
| 13 |
+
import lombok.NoArgsConstructor;
|
| 14 |
+
|
| 15 |
+
import java.time.LocalDate;
|
| 16 |
+
import java.util.ArrayList;
|
| 17 |
+
import java.util.List;
|
| 18 |
+
|
| 19 |
+
@AllArgsConstructor
|
| 20 |
+
@NoArgsConstructor
|
| 21 |
+
@Data
|
| 22 |
+
@Entity
|
| 23 |
+
@Builder
|
| 24 |
+
public class PushNotificationLog {
|
| 25 |
+
|
| 26 |
+
@Id
|
| 27 |
+
private String uid;
|
| 28 |
+
private String messageId;
|
| 29 |
+
private String customerNumber;
|
| 30 |
+
private String domainCode;
|
| 31 |
+
private Boolean isRead; // false - okunmadı, true - okundu
|
| 32 |
+
private Boolean isRemove; // false - sininmedi, true - silindi
|
| 33 |
+
private LocalDate createDate;
|
| 34 |
+
|
| 35 |
+
@Column(name = "text", columnDefinition = "text")
|
| 36 |
+
private String text;
|
| 37 |
+
|
| 38 |
+
@Convert(converter = LogTypeAttribute.class)
|
| 39 |
+
private LogType logType;
|
| 40 |
+
|
| 41 |
+
public static List<Notification> toNotificationList(List<PushNotificationLog> pushNotificationLogs) {
|
| 42 |
+
List<Notification> notifications = new ArrayList<>();
|
| 43 |
+
|
| 44 |
+
pushNotificationLogs.forEach(pushNotificationLog -> {
|
| 45 |
+
Notification notification = Notification.toNotification(pushNotificationLog);
|
| 46 |
+
notifications.add(notification);
|
| 47 |
+
});
|
| 48 |
+
return notifications;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
}
|
src/main/java/com/utility/utilitycommonservice/dao/repository/PushNotificationLogRepository.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.dao.repository;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.dao.entity.PushNotificationLog;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.LogType;
|
| 5 |
+
import org.springframework.data.jpa.repository.JpaRepository;
|
| 6 |
+
import org.springframework.stereotype.Repository;
|
| 7 |
+
|
| 8 |
+
import java.time.LocalDate;
|
| 9 |
+
import java.util.List;
|
| 10 |
+
import java.util.Optional;
|
| 11 |
+
|
| 12 |
+
@Repository
|
| 13 |
+
public interface PushNotificationLogRepository extends JpaRepository<PushNotificationLog, String> {
|
| 14 |
+
List<PushNotificationLog> findAllByCustomerNumberEqualsIgnoreCaseAndLogTypeAndIsRemoveIsFalseAndCreateDateBetween(String customerNumber,
|
| 15 |
+
LogType logType, LocalDate startDate,
|
| 16 |
+
LocalDate endDate);
|
| 17 |
+
Optional<PushNotificationLog> findAllByUidAndIsRemoveIsFalse(String uuid);
|
| 18 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/assembler/CrudAssembler.java
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.assembler;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.common.helper.RequestScopeHelper;
|
| 4 |
+
import com.utility.utilitycommonservice.dao.entity.PushNotificationLog;
|
| 5 |
+
import com.utility.utilitycommonservice.dao.repository.PushNotificationLogRepository;
|
| 6 |
+
import com.utility.utilitycommonservice.domain.model.notification.Notification;
|
| 7 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.CrudType;
|
| 8 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.LogType;
|
| 9 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.CrudNotificationInput;
|
| 10 |
+
import lombok.RequiredArgsConstructor;
|
| 11 |
+
import org.springframework.stereotype.Component;
|
| 12 |
+
|
| 13 |
+
import java.time.LocalDate;
|
| 14 |
+
import java.util.List;
|
| 15 |
+
import java.util.Objects;
|
| 16 |
+
import java.util.Optional;
|
| 17 |
+
|
| 18 |
+
@Component
|
| 19 |
+
@RequiredArgsConstructor
|
| 20 |
+
public class CrudAssembler {
|
| 21 |
+
|
| 22 |
+
private final PushNotificationLogRepository pushNotificationLogRepository;
|
| 23 |
+
|
| 24 |
+
public List<Notification> assemble(CrudNotificationInput input) {
|
| 25 |
+
if (Objects.requireNonNull(input.getCrudType()) == CrudType.LIST) {
|
| 26 |
+
return getNotifications();
|
| 27 |
+
} else if (Objects.requireNonNull(input.getCrudType()) == CrudType.READ) {
|
| 28 |
+
updateReadStatus(input.getUid());
|
| 29 |
+
} else if (Objects.requireNonNull(input.getCrudType()) == CrudType.REMOVE) {
|
| 30 |
+
updateRemoveStatus(input.getUid());
|
| 31 |
+
}
|
| 32 |
+
return List.of();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
private void updateReadStatus(String uid) {
|
| 36 |
+
|
| 37 |
+
Optional<PushNotificationLog> optPushNotificationLog = pushNotificationLogRepository.findAllByUidAndIsRemoveIsFalse(uid);
|
| 38 |
+
if (optPushNotificationLog.isPresent()) {
|
| 39 |
+
PushNotificationLog pushNotificationLog = optPushNotificationLog.get();
|
| 40 |
+
if (Boolean.FALSE.equals(pushNotificationLog.getIsRead())) {
|
| 41 |
+
pushNotificationLog.setIsRead(Boolean.TRUE);
|
| 42 |
+
} else {
|
| 43 |
+
pushNotificationLog.setIsRead(Boolean.FALSE);
|
| 44 |
+
}
|
| 45 |
+
pushNotificationLogRepository.saveAndFlush(pushNotificationLog);
|
| 46 |
+
}
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
private void updateRemoveStatus(String uid) {
|
| 50 |
+
Optional<PushNotificationLog> optPushNotificationLog = pushNotificationLogRepository.findAllByUidAndIsRemoveIsFalse(uid);
|
| 51 |
+
if (optPushNotificationLog.isPresent()) {
|
| 52 |
+
PushNotificationLog pushNotificationLog = optPushNotificationLog.get();
|
| 53 |
+
pushNotificationLog.setIsRemove(Boolean.TRUE);
|
| 54 |
+
pushNotificationLogRepository.saveAndFlush(pushNotificationLog);
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
private List<Notification> getNotifications() {
|
| 59 |
+
|
| 60 |
+
List<PushNotificationLog> pushNotificationLogs = pushNotificationLogRepository.findAllByCustomerNumberEqualsIgnoreCaseAndLogTypeAndIsRemoveIsFalseAndCreateDateBetween(
|
| 61 |
+
RequestScopeHelper.getCustomerNumber(),
|
| 62 |
+
LogType.INFO,
|
| 63 |
+
LocalDate.now().minusMonths(2),
|
| 64 |
+
LocalDate.now());
|
| 65 |
+
|
| 66 |
+
return PushNotificationLog.toNotificationList(pushNotificationLogs);
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
}
|
src/main/java/com/utility/utilitycommonservice/{common → domain}/constant/BitbucketServiceConstant.java
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.
|
| 2 |
|
| 3 |
public class BitbucketServiceConstant {
|
| 4 |
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.constant;
|
| 2 |
|
| 3 |
public class BitbucketServiceConstant {
|
| 4 |
|
src/main/java/com/utility/utilitycommonservice/{common → domain}/constant/LocalizeConstant.java
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.
|
| 2 |
|
| 3 |
|
| 4 |
public class LocalizeConstant {
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.constant;
|
| 2 |
|
| 3 |
|
| 4 |
public class LocalizeConstant {
|
src/main/java/com/utility/utilitycommonservice/domain/model/bitbucket/output/CreateBranchOutput.java
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.bitbucket.output;
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.integration.service.model.Target;
|
| 4 |
-
import com.utility.utilitycommonservice.integration.service.model.response.CreateBranchClientResponse;
|
| 5 |
import lombok.Builder;
|
| 6 |
import lombok.Data;
|
| 7 |
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.bitbucket.output;
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.integration.service.model.Target;
|
| 4 |
+
import com.utility.utilitycommonservice.integration.service.model.response.bitbucket.CreateBranchClientResponse;
|
| 5 |
import lombok.Builder;
|
| 6 |
import lombok.Data;
|
| 7 |
|
src/main/java/com/utility/utilitycommonservice/domain/model/clientbe/output/MenuOutput.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.clientbe.output;
|
| 2 |
|
|
|
|
| 3 |
import com.utility.utilitycommonservice.api.model.response.MenuResponse;
|
| 4 |
import com.utility.utilitycommonservice.dao.entity.Menu;
|
| 5 |
import com.utility.utilitycommonservice.domain.model.clientbe.MenuModel;
|
|
@@ -17,7 +18,7 @@ import java.util.List;
|
|
| 17 |
@NoArgsConstructor
|
| 18 |
public class MenuOutput {
|
| 19 |
|
| 20 |
-
private List<
|
| 21 |
|
| 22 |
public MenuResponse toResponse() {
|
| 23 |
return MenuResponse.builder()
|
|
@@ -27,11 +28,11 @@ public class MenuOutput {
|
|
| 27 |
|
| 28 |
public static MenuOutput toOutput(List<Menu> menuList) {
|
| 29 |
|
| 30 |
-
List<
|
| 31 |
menuList.forEach(menu -> {
|
| 32 |
-
|
| 33 |
-
.
|
| 34 |
-
.
|
| 35 |
.build();
|
| 36 |
menuModels.add(menuModel);
|
| 37 |
});
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.clientbe.output;
|
| 2 |
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.KeyValueParameter;
|
| 4 |
import com.utility.utilitycommonservice.api.model.response.MenuResponse;
|
| 5 |
import com.utility.utilitycommonservice.dao.entity.Menu;
|
| 6 |
import com.utility.utilitycommonservice.domain.model.clientbe.MenuModel;
|
|
|
|
| 18 |
@NoArgsConstructor
|
| 19 |
public class MenuOutput {
|
| 20 |
|
| 21 |
+
private List<KeyValueParameter<String,Integer>> menuList;
|
| 22 |
|
| 23 |
public MenuResponse toResponse() {
|
| 24 |
return MenuResponse.builder()
|
|
|
|
| 28 |
|
| 29 |
public static MenuOutput toOutput(List<Menu> menuList) {
|
| 30 |
|
| 31 |
+
List<KeyValueParameter<String,Integer>> menuModels = new ArrayList<>();
|
| 32 |
menuList.forEach(menu -> {
|
| 33 |
+
KeyValueParameter<String,Integer> menuModel = KeyValueParameter.<String,Integer>builder()
|
| 34 |
+
.key(menu.getName())
|
| 35 |
+
.value(menu.getNavigationCode())
|
| 36 |
.build();
|
| 37 |
menuModels.add(menuModel);
|
| 38 |
});
|
src/main/java/com/utility/utilitycommonservice/domain/model/localize/LocalizeInitModel.java
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.localize;
|
| 2 |
|
|
|
|
| 3 |
import com.utility.utilitycommonservice.common.base.model.BaseModel;
|
| 4 |
import lombok.Builder;
|
| 5 |
import lombok.Data;
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.domain.model.localize;
|
| 2 |
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.KeyValueParameter;
|
| 4 |
import com.utility.utilitycommonservice.common.base.model.BaseModel;
|
| 5 |
import lombok.Builder;
|
| 6 |
import lombok.Data;
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/Deeplink.java
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
import lombok.NoArgsConstructor;
|
| 7 |
+
|
| 8 |
+
import java.util.List;
|
| 9 |
+
|
| 10 |
+
@Data
|
| 11 |
+
@Builder
|
| 12 |
+
@AllArgsConstructor
|
| 13 |
+
@NoArgsConstructor
|
| 14 |
+
public class Deeplink {
|
| 15 |
+
private List<String> parameters; // ilerde parametre gerekirse
|
| 16 |
+
private String navigationCode; // code için (web ve mobile ortak çalışacak)
|
| 17 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/InfoModel.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
import lombok.NoArgsConstructor;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
@Builder
|
| 10 |
+
@AllArgsConstructor
|
| 11 |
+
@NoArgsConstructor
|
| 12 |
+
public class InfoModel {
|
| 13 |
+
|
| 14 |
+
private String title;
|
| 15 |
+
private String text;
|
| 16 |
+
private String imageUrl;
|
| 17 |
+
private Deeplink deeplink;
|
| 18 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/Notification.java
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 5 |
+
import com.utility.utilitycommonservice.dao.entity.PushNotificationLog;
|
| 6 |
+
import lombok.Builder;
|
| 7 |
+
import lombok.Data;
|
| 8 |
+
import lombok.extern.slf4j.Slf4j;
|
| 9 |
+
|
| 10 |
+
import java.util.Objects;
|
| 11 |
+
|
| 12 |
+
@Data
|
| 13 |
+
@Builder
|
| 14 |
+
@Slf4j
|
| 15 |
+
public class Notification {
|
| 16 |
+
|
| 17 |
+
private String uid;
|
| 18 |
+
private String title;
|
| 19 |
+
private String body;
|
| 20 |
+
private String imageUrl;
|
| 21 |
+
private String url;
|
| 22 |
+
private String topic;
|
| 23 |
+
private Boolean isRead;
|
| 24 |
+
|
| 25 |
+
public static Notification toNotification(PushNotificationLog pushNotificationLog) {
|
| 26 |
+
ObjectMapper mapper = new ObjectMapper();
|
| 27 |
+
InfoModel infoModel = null;
|
| 28 |
+
|
| 29 |
+
try {
|
| 30 |
+
infoModel = mapper.readValue(pushNotificationLog.getText(), InfoModel.class);
|
| 31 |
+
} catch (JsonProcessingException e) {
|
| 32 |
+
log.error("a process error occurrence: {}", e.getMessage());
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
if (!Objects.isNull(infoModel)) {
|
| 36 |
+
return Notification.builder()
|
| 37 |
+
.uid(pushNotificationLog.getUid())
|
| 38 |
+
.title(infoModel.getTitle())
|
| 39 |
+
.body(infoModel.getText())
|
| 40 |
+
.imageUrl(infoModel.getImageUrl())
|
| 41 |
+
.url(infoModel.getDeeplink().getNavigationCode())
|
| 42 |
+
.topic(pushNotificationLog.getDomainCode())
|
| 43 |
+
.isRead(pushNotificationLog.getIsRead())
|
| 44 |
+
.build();
|
| 45 |
+
}
|
| 46 |
+
return Notification.builder()
|
| 47 |
+
.build();
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/PushNotificationBody.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification;
|
| 2 |
+
|
| 3 |
+
import lombok.AllArgsConstructor;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
import lombok.NoArgsConstructor;
|
| 7 |
+
|
| 8 |
+
@Data
|
| 9 |
+
@Builder
|
| 10 |
+
@AllArgsConstructor
|
| 11 |
+
@NoArgsConstructor
|
| 12 |
+
public class PushNotificationBody {
|
| 13 |
+
private String text;
|
| 14 |
+
private Boolean isRead;
|
| 15 |
+
|
| 16 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/attributes/LogTypeAttribute.java
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.attributes;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.LogType;
|
| 4 |
+
import jakarta.persistence.AttributeConverter;
|
| 5 |
+
import jakarta.persistence.Converter;
|
| 6 |
+
|
| 7 |
+
@Converter(autoApply = true)
|
| 8 |
+
public class LogTypeAttribute implements AttributeConverter<LogType,String> {
|
| 9 |
+
|
| 10 |
+
@Override
|
| 11 |
+
public String convertToDatabaseColumn(LogType logType) {
|
| 12 |
+
return LogType.fromCode(logType);
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
@Override
|
| 16 |
+
public LogType convertToEntityAttribute(String s) {
|
| 17 |
+
return LogType.fromType(s);
|
| 18 |
+
}
|
| 19 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/enums/CrudType.java
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.enums;
|
| 2 |
+
|
| 3 |
+
public enum CrudType {
|
| 4 |
+
READ,REMOVE,LIST
|
| 5 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/enums/LogType.java
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.enums;
|
| 2 |
+
|
| 3 |
+
public enum LogType {
|
| 4 |
+
INFO,ERROR,NONE;
|
| 5 |
+
|
| 6 |
+
public static String fromCode(LogType logType) {
|
| 7 |
+
switch (logType) {
|
| 8 |
+
case INFO -> {
|
| 9 |
+
return "Info";
|
| 10 |
+
}
|
| 11 |
+
case ERROR -> {
|
| 12 |
+
return "Error";
|
| 13 |
+
}
|
| 14 |
+
default -> {
|
| 15 |
+
return "";
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
public static LogType fromType(String logType) {
|
| 21 |
+
switch (logType) {
|
| 22 |
+
case "Info" -> {
|
| 23 |
+
return INFO;
|
| 24 |
+
}
|
| 25 |
+
case "Error" -> {
|
| 26 |
+
return ERROR;
|
| 27 |
+
}
|
| 28 |
+
default -> {
|
| 29 |
+
return NONE;
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/input/CrudNotificationInput.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.input;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.CrudType;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
|
| 7 |
+
@Data
|
| 8 |
+
@Builder
|
| 9 |
+
public class CrudNotificationInput {
|
| 10 |
+
|
| 11 |
+
private CrudType crudType;
|
| 12 |
+
private String uid;
|
| 13 |
+
|
| 14 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/input/PushNotificationByDomainInput.java
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.input;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.InfoModel;
|
| 4 |
+
import lombok.Builder;
|
| 5 |
+
import lombok.Data;
|
| 6 |
+
|
| 7 |
+
@Data
|
| 8 |
+
@Builder
|
| 9 |
+
public class PushNotificationByDomainInput {
|
| 10 |
+
private InfoModel infoModel;
|
| 11 |
+
private String domainCode; // campaign, ai vs.
|
| 12 |
+
|
| 13 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/model/notification/output/CrudNotificationOutput.java
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.model.notification.output;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.api.model.response.CrudNotificationResponse;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.Notification;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
|
| 8 |
+
import java.util.List;
|
| 9 |
+
|
| 10 |
+
@Data
|
| 11 |
+
@Builder
|
| 12 |
+
public class CrudNotificationOutput {
|
| 13 |
+
|
| 14 |
+
private List<Notification> notifications;
|
| 15 |
+
|
| 16 |
+
public CrudNotificationResponse toResponse() {
|
| 17 |
+
return CrudNotificationResponse.builder()
|
| 18 |
+
.notifications(notifications)
|
| 19 |
+
.build();
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
}
|
src/main/java/com/utility/utilitycommonservice/{common → domain}/properties/BitbucketProperties.java
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.
|
| 2 |
|
| 3 |
import lombok.Data;
|
| 4 |
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.properties;
|
| 2 |
|
| 3 |
import lombok.Data;
|
| 4 |
import org.springframework.boot.context.properties.ConfigurationProperties;
|
src/main/java/com/utility/utilitycommonservice/domain/service/clientbe/notification/PushService.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.service.clientbe.notification;
|
| 2 |
+
|
| 3 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.CrudNotificationInput;
|
| 4 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.PushNotificationByDomainInput;
|
| 5 |
+
import com.utility.utilitycommonservice.domain.model.notification.output.CrudNotificationOutput;
|
| 6 |
+
|
| 7 |
+
public interface PushService {
|
| 8 |
+
void pushNotificationByDomain(PushNotificationByDomainInput input);
|
| 9 |
+
|
| 10 |
+
// okundu-silindi-listele
|
| 11 |
+
CrudNotificationOutput crudNotification(CrudNotificationInput input);
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/service/clientbe/notification/notificationImpl/PushServiceImpl.java
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.domain.service.clientbe.notification.notificationImpl;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
+
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 5 |
+
import com.utility.utilitycommonservice.common.helper.RequestScopeHelper;
|
| 6 |
+
import com.utility.utilitycommonservice.dao.entity.PushNotificationLog;
|
| 7 |
+
import com.utility.utilitycommonservice.dao.repository.PushNotificationLogRepository;
|
| 8 |
+
import com.utility.utilitycommonservice.domain.assembler.CrudAssembler;
|
| 9 |
+
import com.utility.utilitycommonservice.domain.model.notification.PushNotificationBody;
|
| 10 |
+
import com.utility.utilitycommonservice.domain.model.notification.enums.LogType;
|
| 11 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.CrudNotificationInput;
|
| 12 |
+
import com.utility.utilitycommonservice.domain.model.notification.input.PushNotificationByDomainInput;
|
| 13 |
+
import com.utility.utilitycommonservice.domain.model.notification.output.CrudNotificationOutput;
|
| 14 |
+
import com.utility.utilitycommonservice.domain.service.clientbe.notification.PushService;
|
| 15 |
+
import com.utility.utilitycommonservice.integration.service.model.request.firebase.SendToTopicClientRequest;
|
| 16 |
+
import com.utility.utilitycommonservice.integration.service.service.firebase.PushClientService;
|
| 17 |
+
import lombok.RequiredArgsConstructor;
|
| 18 |
+
import lombok.extern.slf4j.Slf4j;
|
| 19 |
+
import org.springframework.stereotype.Service;
|
| 20 |
+
|
| 21 |
+
import java.time.LocalDate;
|
| 22 |
+
import java.util.UUID;
|
| 23 |
+
|
| 24 |
+
@Service
|
| 25 |
+
@RequiredArgsConstructor
|
| 26 |
+
@Slf4j
|
| 27 |
+
public class PushServiceImpl implements PushService {
|
| 28 |
+
|
| 29 |
+
private final PushClientService clientService;
|
| 30 |
+
private final PushNotificationLogRepository pushNotificationLogRepository;
|
| 31 |
+
private final CrudAssembler crudAssembler;
|
| 32 |
+
private final ObjectMapper mapper = new ObjectMapper();
|
| 33 |
+
|
| 34 |
+
@Override
|
| 35 |
+
public void pushNotificationByDomain(PushNotificationByDomainInput input) {
|
| 36 |
+
|
| 37 |
+
try {
|
| 38 |
+
var pnBody = PushNotificationBody.builder()
|
| 39 |
+
.text(input.getInfoModel().getText())
|
| 40 |
+
.isRead(false)
|
| 41 |
+
.build();
|
| 42 |
+
String jsonBody = mapper.writeValueAsString(pnBody);
|
| 43 |
+
var clientResponse = clientService.sendToTopic(SendToTopicClientRequest.builder()
|
| 44 |
+
.title(input.getInfoModel().getTitle())
|
| 45 |
+
.body(jsonBody)
|
| 46 |
+
.imageUrl(input.getInfoModel().getImageUrl())
|
| 47 |
+
.url(input.getInfoModel().getDeeplink().getNavigationCode())
|
| 48 |
+
.topic(input.getDomainCode())
|
| 49 |
+
.build());
|
| 50 |
+
saveLog(input, LogType.INFO, clientResponse.getMessageId());
|
| 51 |
+
|
| 52 |
+
} catch (Exception e) {
|
| 53 |
+
log.error("An error occurrence: {}", e.getMessage());
|
| 54 |
+
saveLog(input, LogType.ERROR, null);
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
@Override
|
| 60 |
+
public CrudNotificationOutput crudNotification(CrudNotificationInput input) {
|
| 61 |
+
var notifications = crudAssembler.assemble(input);
|
| 62 |
+
return CrudNotificationOutput.builder()
|
| 63 |
+
.notifications(notifications)
|
| 64 |
+
.build();
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
private void saveLog(PushNotificationByDomainInput input, LogType logType, String messageId) {
|
| 68 |
+
|
| 69 |
+
try {
|
| 70 |
+
String jsonBody = mapper.writeValueAsString(input.getInfoModel());
|
| 71 |
+
PushNotificationLog pushNotificationLog = PushNotificationLog.builder()
|
| 72 |
+
.uid(UUID.randomUUID().toString())
|
| 73 |
+
.messageId(messageId)
|
| 74 |
+
.logType(logType)
|
| 75 |
+
.text(jsonBody)
|
| 76 |
+
.domainCode(input.getDomainCode())
|
| 77 |
+
.isRead(false)
|
| 78 |
+
.isRemove(false)
|
| 79 |
+
.customerNumber(RequestScopeHelper.getCustomerNumber())
|
| 80 |
+
.createDate(LocalDate.now())
|
| 81 |
+
.build();
|
| 82 |
+
pushNotificationLogRepository.save(pushNotificationLog);
|
| 83 |
+
|
| 84 |
+
}catch (JsonProcessingException e) {
|
| 85 |
+
log.error("a process error occurrence: {}", e.getMessage());
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
}
|
src/main/java/com/utility/utilitycommonservice/domain/service/localize/impl/LocalizeServiceImpl.java
CHANGED
|
@@ -2,7 +2,7 @@ package com.utility.utilitycommonservice.domain.service.localize.impl;
|
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.common.helper.RequestScopeHelper;
|
| 4 |
import com.utility.utilitycommonservice.common.service.SessionService;
|
| 5 |
-
import com.utility.utilitycommonservice.
|
| 6 |
import com.utility.utilitycommonservice.domain.model.localize.LocalizeInitModel;
|
| 7 |
import com.utility.utilitycommonservice.domain.model.localize.LocalizeInitSession;
|
| 8 |
import com.utility.utilitycommonservice.domain.model.localize.input.AddLocalizeInput;
|
|
@@ -14,13 +14,11 @@ import lombok.RequiredArgsConstructor;
|
|
| 14 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.stereotype.Service;
|
| 16 |
|
| 17 |
-
import java.io.
|
| 18 |
-
import java.io.IOException;
|
| 19 |
-
import java.io.InputStreamReader;
|
| 20 |
import java.nio.charset.StandardCharsets;
|
| 21 |
import java.util.*;
|
| 22 |
|
| 23 |
-
import static com.utility.utilitycommonservice.
|
| 24 |
|
| 25 |
@Service
|
| 26 |
@RequiredArgsConstructor
|
|
@@ -61,7 +59,7 @@ public class LocalizeServiceImpl implements LocalizeService {
|
|
| 61 |
.tr(tr).en(en).build())
|
| 62 |
.build();
|
| 63 |
|
| 64 |
-
sessionService.setSession(LOCALIZE_INIT_SESSION,
|
| 65 |
|
| 66 |
}
|
| 67 |
|
|
@@ -77,19 +75,11 @@ public class LocalizeServiceImpl implements LocalizeService {
|
|
| 77 |
|
| 78 |
if (RequestScopeHelper.getLanguage().equals("tr")) {
|
| 79 |
List<KeyValueParameter<String,String>> parameters = initModel.getTr();
|
| 80 |
-
|
| 81 |
-
.filter(p -> p.getKey().equals(input.getKey())).findFirst();
|
| 82 |
-
if (optional.isPresent()) {
|
| 83 |
-
keyValueParameter = optional.get();
|
| 84 |
-
}
|
| 85 |
|
| 86 |
} else if (RequestScopeHelper.getLanguage().equals("en")) {
|
| 87 |
List<KeyValueParameter<String,String>> parameters = initModel.getEn();
|
| 88 |
-
|
| 89 |
-
.filter(p -> p.getKey().equals(input.getKey())).findFirst();
|
| 90 |
-
if (optional.isPresent()) {
|
| 91 |
-
keyValueParameter = optional.get();
|
| 92 |
-
}
|
| 93 |
}
|
| 94 |
|
| 95 |
return OutputByKey.builder()
|
|
@@ -100,7 +90,27 @@ public class LocalizeServiceImpl implements LocalizeService {
|
|
| 100 |
|
| 101 |
@Override
|
| 102 |
public void addLocalize(AddLocalizeInput input) throws IOException {
|
|
|
|
|
|
|
| 103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
|
| 106 |
private Properties loadProperties(String lang) throws IOException {
|
|
|
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.common.helper.RequestScopeHelper;
|
| 4 |
import com.utility.utilitycommonservice.common.service.SessionService;
|
| 5 |
+
import com.utility.utilitycommonservice.api.model.KeyValueParameter;
|
| 6 |
import com.utility.utilitycommonservice.domain.model.localize.LocalizeInitModel;
|
| 7 |
import com.utility.utilitycommonservice.domain.model.localize.LocalizeInitSession;
|
| 8 |
import com.utility.utilitycommonservice.domain.model.localize.input.AddLocalizeInput;
|
|
|
|
| 14 |
import org.springframework.beans.factory.annotation.Value;
|
| 15 |
import org.springframework.stereotype.Service;
|
| 16 |
|
| 17 |
+
import java.io.*;
|
|
|
|
|
|
|
| 18 |
import java.nio.charset.StandardCharsets;
|
| 19 |
import java.util.*;
|
| 20 |
|
| 21 |
+
import static com.utility.utilitycommonservice.domain.constant.LocalizeConstant.LOCALIZE_INIT_SESSION;
|
| 22 |
|
| 23 |
@Service
|
| 24 |
@RequiredArgsConstructor
|
|
|
|
| 59 |
.tr(tr).en(en).build())
|
| 60 |
.build();
|
| 61 |
|
| 62 |
+
sessionService.setSession(LOCALIZE_INIT_SESSION, session);
|
| 63 |
|
| 64 |
}
|
| 65 |
|
|
|
|
| 75 |
|
| 76 |
if (RequestScopeHelper.getLanguage().equals("tr")) {
|
| 77 |
List<KeyValueParameter<String,String>> parameters = initModel.getTr();
|
| 78 |
+
keyValueParameter = getKeyValueParameter(parameters, input.getKey());
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
} else if (RequestScopeHelper.getLanguage().equals("en")) {
|
| 81 |
List<KeyValueParameter<String,String>> parameters = initModel.getEn();
|
| 82 |
+
keyValueParameter = getKeyValueParameter(parameters, input.getKey());
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
|
| 85 |
return OutputByKey.builder()
|
|
|
|
| 90 |
|
| 91 |
@Override
|
| 92 |
public void addLocalize(AddLocalizeInput input) throws IOException {
|
| 93 |
+
Properties props = loadProperties(input.getLanguage());
|
| 94 |
+
props.setProperty(input.getKey(), input.getValue());
|
| 95 |
|
| 96 |
+
try (OutputStreamWriter writer = new OutputStreamWriter(
|
| 97 |
+
new FileOutputStream(basePath + input.getLanguage() + ".properties"),
|
| 98 |
+
StandardCharsets.UTF_8)) {
|
| 99 |
+
props.store(writer, "Updated by MessageService");
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
private KeyValueParameter<String,String> getKeyValueParameter(List<KeyValueParameter<String, String>> parameters,
|
| 104 |
+
String key) {
|
| 105 |
+
|
| 106 |
+
KeyValueParameter<String,String> keyValueParameter = null;
|
| 107 |
+
|
| 108 |
+
Optional<KeyValueParameter<String,String>> optional = parameters.stream()
|
| 109 |
+
.filter(p -> p.getKey().equals(key)).findFirst();
|
| 110 |
+
if (optional.isPresent()) {
|
| 111 |
+
keyValueParameter = optional.get();
|
| 112 |
+
}
|
| 113 |
+
return keyValueParameter;
|
| 114 |
}
|
| 115 |
|
| 116 |
private Properties loadProperties(String lang) throws IOException {
|
src/main/java/com/utility/utilitycommonservice/integration/config/firebase/FirebaseConfig.java
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.config.firebase;
|
| 2 |
+
|
| 3 |
+
import com.google.auth.oauth2.GoogleCredentials;
|
| 4 |
+
import com.google.firebase.FirebaseApp;
|
| 5 |
+
import com.google.firebase.FirebaseOptions;
|
| 6 |
+
import io.micrometer.common.util.StringUtils;
|
| 7 |
+
import jakarta.annotation.PostConstruct;
|
| 8 |
+
import org.springframework.beans.factory.annotation.Value;
|
| 9 |
+
import org.springframework.stereotype.Component;
|
| 10 |
+
|
| 11 |
+
import java.io.ByteArrayInputStream;
|
| 12 |
+
import java.io.FileInputStream;
|
| 13 |
+
import java.io.IOException;
|
| 14 |
+
import java.util.Base64;
|
| 15 |
+
|
| 16 |
+
@Component
|
| 17 |
+
public class FirebaseConfig {
|
| 18 |
+
|
| 19 |
+
@Value("${push.firebase.credentials.credentials-base64}")
|
| 20 |
+
private String credentialsBase64;
|
| 21 |
+
|
| 22 |
+
@PostConstruct
|
| 23 |
+
public void init() throws IOException {
|
| 24 |
+
FirebaseOptions options = FirebaseOptions.builder()
|
| 25 |
+
.setCredentials(resolveCredentials())
|
| 26 |
+
.build();
|
| 27 |
+
|
| 28 |
+
if (FirebaseApp.getApps().isEmpty()) {
|
| 29 |
+
FirebaseApp.initializeApp(options);
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
private GoogleCredentials resolveCredentials() throws IOException {
|
| 34 |
+
if (StringUtils.isNotBlank(credentialsBase64)) {
|
| 35 |
+
byte[] json = Base64.getDecoder().decode(credentialsBase64);
|
| 36 |
+
return GoogleCredentials.fromStream(new ByteArrayInputStream(json));
|
| 37 |
+
}
|
| 38 |
+
throw new IllegalStateException(
|
| 39 |
+
"Firebase credentials not provided. " +
|
| 40 |
+
"Provide firebase.credentials-base64 or firebase.credentials-json, " +
|
| 41 |
+
"or set client-email and private-key."
|
| 42 |
+
);
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
}
|
src/main/java/com/utility/utilitycommonservice/integration/service/model/request/firebase/SendToTokenClientRequest.java
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.model.request.firebase;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class SendToTokenClientRequest {
|
| 9 |
+
|
| 10 |
+
private String token;
|
| 11 |
+
private String title;
|
| 12 |
+
private String body;
|
| 13 |
+
private String imageUrl;
|
| 14 |
+
private String url;
|
| 15 |
+
|
| 16 |
+
}
|
src/main/java/com/utility/utilitycommonservice/integration/service/model/request/firebase/SendToTopicClientRequest.java
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.model.request.firebase;
|
| 2 |
+
|
| 3 |
+
import lombok.Builder;
|
| 4 |
+
import lombok.Data;
|
| 5 |
+
|
| 6 |
+
@Data
|
| 7 |
+
@Builder
|
| 8 |
+
public class SendToTopicClientRequest {
|
| 9 |
+
private String topic;
|
| 10 |
+
private String title;
|
| 11 |
+
private String body;
|
| 12 |
+
private String imageUrl;
|
| 13 |
+
private String url;
|
| 14 |
+
}
|
src/main/java/com/utility/utilitycommonservice/integration/service/model/response/{CreateBranchClientResponse.java → bitbucket/CreateBranchClientResponse.java}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.integration.service.model.response;
|
| 2 |
|
| 3 |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
| 4 |
import com.utility.utilitycommonservice.domain.model.bitbucket.output.CreateBranchOutput;
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.model.response.bitbucket;
|
| 2 |
|
| 3 |
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
| 4 |
import com.utility.utilitycommonservice.domain.model.bitbucket.output.CreateBranchOutput;
|
src/main/java/com/utility/utilitycommonservice/integration/service/model/response/firebase/SendToTokenClientResponse.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.model.response.firebase;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
import lombok.NoArgsConstructor;
|
| 8 |
+
|
| 9 |
+
@Data
|
| 10 |
+
@Builder
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
@JsonIgnoreProperties(ignoreUnknown = true)
|
| 14 |
+
public class SendToTokenClientResponse {
|
| 15 |
+
|
| 16 |
+
private String messageId;
|
| 17 |
+
|
| 18 |
+
}
|
src/main/java/com/utility/utilitycommonservice/integration/service/model/response/firebase/SendToTopicClientResponse.java
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.model.response.firebase;
|
| 2 |
+
|
| 3 |
+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
| 4 |
+
import lombok.AllArgsConstructor;
|
| 5 |
+
import lombok.Builder;
|
| 6 |
+
import lombok.Data;
|
| 7 |
+
import lombok.NoArgsConstructor;
|
| 8 |
+
|
| 9 |
+
@Data
|
| 10 |
+
@Builder
|
| 11 |
+
@AllArgsConstructor
|
| 12 |
+
@NoArgsConstructor
|
| 13 |
+
@JsonIgnoreProperties(ignoreUnknown = true)
|
| 14 |
+
public class SendToTopicClientResponse {
|
| 15 |
+
|
| 16 |
+
private String messageId;
|
| 17 |
+
|
| 18 |
+
}
|
src/main/java/com/utility/utilitycommonservice/integration/service/service/bitbucket/BitbucketClientService.java
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
package com.utility.utilitycommonservice.integration.service.service.bitbucket;
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.integration.service.model.request.bitbucket.*;
|
| 4 |
-
import com.utility.utilitycommonservice.integration.service.model.response.CreateBranchClientResponse;
|
| 5 |
|
| 6 |
public interface BitbucketClientService {
|
| 7 |
|
|
|
|
| 1 |
package com.utility.utilitycommonservice.integration.service.service.bitbucket;
|
| 2 |
|
| 3 |
import com.utility.utilitycommonservice.integration.service.model.request.bitbucket.*;
|
| 4 |
+
import com.utility.utilitycommonservice.integration.service.model.response.bitbucket.CreateBranchClientResponse;
|
| 5 |
|
| 6 |
public interface BitbucketClientService {
|
| 7 |
|
src/main/java/com/utility/utilitycommonservice/integration/service/service/{impl/bitbucket → bitbucket/impl}/BitbucketClientServiceImpl.java
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
package com.utility.utilitycommonservice.integration.service.service.
|
| 2 |
|
| 3 |
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 5 |
-
import com.utility.utilitycommonservice.
|
| 6 |
import com.utility.utilitycommonservice.integration.service.model.MultipartInputStreamFileResource;
|
| 7 |
import com.utility.utilitycommonservice.integration.service.model.request.bitbucket.*;
|
| 8 |
-
import com.utility.utilitycommonservice.integration.service.model.response.CreateBranchClientResponse;
|
| 9 |
import com.utility.utilitycommonservice.integration.service.service.bitbucket.BitbucketClientService;
|
| 10 |
import lombok.RequiredArgsConstructor;
|
| 11 |
import org.springframework.http.HttpEntity;
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.service.bitbucket.impl;
|
| 2 |
|
| 3 |
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 5 |
+
import com.utility.utilitycommonservice.domain.properties.BitbucketProperties;
|
| 6 |
import com.utility.utilitycommonservice.integration.service.model.MultipartInputStreamFileResource;
|
| 7 |
import com.utility.utilitycommonservice.integration.service.model.request.bitbucket.*;
|
| 8 |
+
import com.utility.utilitycommonservice.integration.service.model.response.bitbucket.CreateBranchClientResponse;
|
| 9 |
import com.utility.utilitycommonservice.integration.service.service.bitbucket.BitbucketClientService;
|
| 10 |
import lombok.RequiredArgsConstructor;
|
| 11 |
import org.springframework.http.HttpEntity;
|
src/main/java/com/utility/utilitycommonservice/integration/service/service/firebase/PushClientService.java
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package com.utility.utilitycommonservice.integration.service.service.firebase;
|
| 2 |
+
|
| 3 |
+
import com.google.firebase.messaging.FirebaseMessagingException;
|
| 4 |
+
import com.utility.utilitycommonservice.integration.service.model.request.firebase.SendToTokenClientRequest;
|
| 5 |
+
import com.utility.utilitycommonservice.integration.service.model.request.firebase.SendToTopicClientRequest;
|
| 6 |
+
import com.utility.utilitycommonservice.integration.service.model.response.firebase.SendToTokenClientResponse;
|
| 7 |
+
import com.utility.utilitycommonservice.integration.service.model.response.firebase.SendToTopicClientResponse;
|
| 8 |
+
|
| 9 |
+
public interface PushClientService {
|
| 10 |
+
SendToTokenClientResponse sendToToken(SendToTokenClientRequest request) throws FirebaseMessagingException;
|
| 11 |
+
SendToTopicClientResponse sendToTopic(SendToTopicClientRequest request) throws FirebaseMessagingException;
|
| 12 |
+
}
|