-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from Nexters/main
merge to master
- Loading branch information
Showing
86 changed files
with
3,347 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: spurt build check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
push_to_registry: | ||
name: Push to aws container registry | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'corretto' | ||
|
||
- name: make application.yml | ||
if: github.event.pull_request.base.ref == 'main' | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "${{ secrets.YML_PROD }}" > ./application.yml | ||
shell: bash | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Setup Gradle | ||
uses: gradle/gradle-build-action@v2 | ||
with: | ||
arguments: build | ||
cache-read-only: ${{ github.ref != 'refs/heads/master' }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,3 +36,5 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
application.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/main/java/com/sirius/spurt/common/config/RestTemplateConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.sirius.spurt.common.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@Configuration | ||
public class RestTemplateConfig { | ||
|
||
@Bean | ||
public RestTemplate restTemplate() { | ||
return new RestTemplate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/main/java/com/sirius/spurt/common/validator/ExperienceValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.sirius.spurt.common.validator; | ||
|
||
import static com.sirius.spurt.common.meta.ResultCode.EXPERIENCE_THREE_SECONDS; | ||
import static com.sirius.spurt.common.meta.ResultCode.NOT_EXPERIENCE_OWNER; | ||
import static com.sirius.spurt.common.meta.ResultCode.NO_CONTENT; | ||
|
||
import com.sirius.spurt.common.exception.GlobalException; | ||
import com.sirius.spurt.store.repository.database.entity.ExperienceEntity; | ||
import java.sql.Timestamp; | ||
import java.util.List; | ||
import org.springframework.util.CollectionUtils; | ||
|
||
public class ExperienceValidator { | ||
private static long EXPERIENCE_DUPLICATE_TIME = 3000L; | ||
|
||
public static void validateNoContent(ExperienceEntity experienceEntity) { | ||
if (!isExistExperience(experienceEntity)) { | ||
throw new GlobalException(NO_CONTENT); | ||
} | ||
} | ||
|
||
public static void validateNoContents(List<ExperienceEntity> experienceEntities) { | ||
if (CollectionUtils.isEmpty(experienceEntities)) { | ||
throw new GlobalException(NO_CONTENT); | ||
} | ||
} | ||
|
||
public static void validate(ExperienceEntity experienceEntity) { | ||
if (!isExistExperience(experienceEntity)) { | ||
throw new GlobalException(NOT_EXPERIENCE_OWNER); | ||
} | ||
} | ||
|
||
public static void validateTimestamp(ExperienceEntity experienceEntity) { | ||
if (!isExistExperience(experienceEntity)) { | ||
return; | ||
} | ||
|
||
if (isWithin3SecondsDifference(experienceEntity.getCreateTimestamp())) { | ||
throw new GlobalException(EXPERIENCE_THREE_SECONDS); | ||
} | ||
} | ||
|
||
private static boolean isExistExperience(ExperienceEntity experienceEntity) { | ||
return experienceEntity != null; | ||
} | ||
|
||
private static boolean isWithin3SecondsDifference(Timestamp timestamp) { | ||
return new Timestamp(System.currentTimeMillis()).getTime() - timestamp.getTime() | ||
< EXPERIENCE_DUPLICATE_TIME; | ||
} | ||
} |
Oops, something went wrong.