From 41b329cc7f7527ad607c0fc1c8442eab04f9f9a6 Mon Sep 17 00:00:00 2001 From: upagge Date: Thu, 12 Mar 2020 16:46:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B2=D0=B0=D1=8F=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20=D0=BD=D0=BE=D1=82=D0=B8=D1=84?= =?UTF-8?q?=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80=D0=B8=20?= =?UTF-8?q?=D1=83=D0=BF=D0=BE=D0=BC=D0=B8=D0=BD=D0=B0=D0=BD=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tsc/bitbucketbot/config/AppConfig.java | 2 +- .../bitbucketbot/config/BitbucketConfig.java | 1 + .../domain/entity/PullRequest.java | 6 ++++ .../dto/bitbucket/ProjectJson.java | 10 +++++++ .../dto/bitbucket/RepositoryJson.java | 2 ++ .../tsc/bitbucketbot/dto/bitbucket/Sheet.java | 4 +++ .../service/PullRequestsService.java | 4 +++ .../converter/PullRequestJsonConverter.java | 2 ++ .../service/impl/PullRequestsServiceImpl.java | 8 ++++++ src/main/resources/application.yaml | 1 + src/main/resources/liquibase/change-log.xml | 1 + .../resources/liquibase/change-set/v1.3.0.xml | 28 +++++++++++++++++++ 12 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/tsc/bitbucketbot/dto/bitbucket/ProjectJson.java create mode 100644 src/main/resources/liquibase/change-set/v1.3.0.xml diff --git a/src/main/java/com/tsc/bitbucketbot/config/AppConfig.java b/src/main/java/com/tsc/bitbucketbot/config/AppConfig.java index f978d82..1dd0ae6 100644 --- a/src/main/java/com/tsc/bitbucketbot/config/AppConfig.java +++ b/src/main/java/com/tsc/bitbucketbot/config/AppConfig.java @@ -13,7 +13,7 @@ public class AppConfig { @Bean public TaskScheduler taskScheduler() { ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); - taskScheduler.setPoolSize(5); + taskScheduler.setPoolSize(6); return taskScheduler; } diff --git a/src/main/java/com/tsc/bitbucketbot/config/BitbucketConfig.java b/src/main/java/com/tsc/bitbucketbot/config/BitbucketConfig.java index 32a173e..90ba88d 100644 --- a/src/main/java/com/tsc/bitbucketbot/config/BitbucketConfig.java +++ b/src/main/java/com/tsc/bitbucketbot/config/BitbucketConfig.java @@ -17,5 +17,6 @@ public class BitbucketConfig { private String token; private String urlPullRequestOpen; private String urlPullRequestClose; + private String urlPullRequestComment; } diff --git a/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java b/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java index 4462b52..834c098 100644 --- a/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java +++ b/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java @@ -50,6 +50,12 @@ public class PullRequest { @Column(name = "repository_id") private Long repositoryId; + @Column(name = "project_key") + private String projectKey; + + @Column(name = "repository_slug") + private String repositorySlug; + @Column(name = "version") private Integer version; diff --git a/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/ProjectJson.java b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/ProjectJson.java new file mode 100644 index 0000000..08337ea --- /dev/null +++ b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/ProjectJson.java @@ -0,0 +1,10 @@ +package com.tsc.bitbucketbot.dto.bitbucket; + +import lombok.Data; + +@Data +public class ProjectJson { + + private String key; + +} diff --git a/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/RepositoryJson.java b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/RepositoryJson.java index 1f81498..3817e39 100644 --- a/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/RepositoryJson.java +++ b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/RepositoryJson.java @@ -11,5 +11,7 @@ import lombok.Data; public class RepositoryJson { private Long id; + private String slug; + private ProjectJson project; } diff --git a/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/Sheet.java b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/Sheet.java index f440ca4..5bb3e5d 100644 --- a/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/Sheet.java +++ b/src/main/java/com/tsc/bitbucketbot/dto/bitbucket/Sheet.java @@ -18,4 +18,8 @@ public abstract class Sheet { private List values; private Integer nextPageStart; + public boolean hasContent() { + return values != null && !values.isEmpty(); + } + } diff --git a/src/main/java/com/tsc/bitbucketbot/service/PullRequestsService.java b/src/main/java/com/tsc/bitbucketbot/service/PullRequestsService.java index aedb15c..9173549 100644 --- a/src/main/java/com/tsc/bitbucketbot/service/PullRequestsService.java +++ b/src/main/java/com/tsc/bitbucketbot/service/PullRequestsService.java @@ -1,8 +1,10 @@ package com.tsc.bitbucketbot.service; +import com.tsc.bitbucketbot.domain.Pagination; import com.tsc.bitbucketbot.domain.ReviewerStatus; import com.tsc.bitbucketbot.domain.entity.PullRequest; import lombok.NonNull; +import org.springframework.data.domain.Page; import java.util.Collection; import java.util.List; @@ -37,4 +39,6 @@ public interface PullRequestsService { Set getAllId(); + Page getAll(@NonNull Pagination pagination); + } diff --git a/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java b/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java index eebc845..e9e708a 100644 --- a/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java +++ b/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java @@ -42,6 +42,8 @@ public class PullRequestJsonConverter implements Converter getAll(@NonNull Pagination pagination) { + return pullRequestsRepository.findAll(PageRequest.of(pagination.getPage(), pagination.getSize())); + } + } diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 2ad64c1..932c4cc 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -23,5 +23,6 @@ bitbucketbot: token: Nzg5NjUyNDQwMzk2OlA+6naQz02+GxOG0Q9li/jnsn7E url-pull-request-open: http://localhost:7990/rest/api/1.0/dashboard/pull-requests?limit=150&state=OPEN url-pull-request-close: http://localhost:7990/rest/api/1.0/dashboard/pull-requests?limit=150&closedSince=86400 + url-pull-request-comment: http://localhost:7990/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/comments/{commentId} server: port: 8018 diff --git a/src/main/resources/liquibase/change-log.xml b/src/main/resources/liquibase/change-log.xml index a84e0ec..db0a65f 100644 --- a/src/main/resources/liquibase/change-log.xml +++ b/src/main/resources/liquibase/change-log.xml @@ -5,5 +5,6 @@ + \ No newline at end of file diff --git a/src/main/resources/liquibase/change-set/v1.3.0.xml b/src/main/resources/liquibase/change-set/v1.3.0.xml new file mode 100644 index 0000000..eddfc13 --- /dev/null +++ b/src/main/resources/liquibase/change-set/v1.3.0.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file