-
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 #28 from 9oormthonUniv-seoultech/develop
Develop to Main #2
- Loading branch information
Showing
104 changed files
with
2,392 additions
and
43 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 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ |
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,31 @@ | ||
dependencies { | ||
|
||
implementation project(':core') | ||
implementation project(':domain') | ||
implementation project(':outbound') | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
implementation 'org.springframework.boot:spring-boot-starter-security' | ||
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
|
||
runtimeOnly 'com.mysql:mysql-connector-j' | ||
|
||
testImplementation 'io.rest-assured:rest-assured' | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-batch' // batch | ||
testImplementation 'org.springframework.batch:spring-batch-test' | ||
|
||
} | ||
|
||
bootJar { | ||
enabled = false | ||
} | ||
|
||
jar { | ||
enabled = true | ||
} | ||
|
||
tasks.register("prepareKotlinBuildScriptModel") {} |
Binary file not shown.
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,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
17 changes: 17 additions & 0 deletions
17
batch/src/main/java/com/pocket/batch/BatchApplication.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,17 @@ | ||
package com.pocket.batch; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.autoconfigure.domain.EntityScan; | ||
import org.springframework.context.annotation.ComponentScan; | ||
|
||
@SpringBootApplication | ||
@EntityScan(basePackages = "com.pocket") | ||
@ComponentScan(basePackages = "com.pocket") | ||
public class BatchApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(BatchApplication.class, args); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
batch/src/main/java/com/pocket/batch/config/BatchConfig.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,20 @@ | ||
package com.pocket.batch.config; | ||
|
||
import org.springframework.batch.core.configuration.JobRegistry; | ||
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing; | ||
import org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@EnableBatchProcessing | ||
@Configuration | ||
public class BatchConfig { | ||
|
||
@Bean | ||
public JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor(JobRegistry jobRegistry) { | ||
JobRegistryBeanPostProcessor jobRegistryBeanPostProcessor = new JobRegistryBeanPostProcessor(); | ||
jobRegistryBeanPostProcessor.setJobRegistry(jobRegistry); | ||
return jobRegistryBeanPostProcessor; | ||
|
||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
batch/src/main/java/com/pocket/batch/controller/JobLauncherController.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,31 @@ | ||
package com.pocket.batch.controller; | ||
|
||
import org.springframework.batch.core.ExitStatus; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.configuration.JobRegistry; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("job") | ||
public class JobLauncherController { | ||
|
||
private final JobLauncher jobLauncher; | ||
|
||
private final JobRegistry jobRegistry; | ||
|
||
public JobLauncherController(JobLauncher jobLauncher, JobRegistry jobRegistry) { | ||
this.jobLauncher = jobLauncher; | ||
this.jobRegistry = jobRegistry; | ||
} | ||
|
||
@PostMapping("/launcher") | ||
public ExitStatus launchJob(@RequestBody JobLauncherRequest request) throws Exception { | ||
Job job = jobRegistry.getJob(request.getName()); | ||
return this.jobLauncher.run(job, request.getJobParameters()).getExitStatus(); | ||
|
||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
batch/src/main/java/com/pocket/batch/controller/JobLauncherRequest.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,26 @@ | ||
package com.pocket.batch.controller; | ||
|
||
import lombok.Getter; | ||
import lombok.Setter; | ||
import lombok.ToString; | ||
import org.springframework.batch.core.JobParameters; | ||
import org.springframework.batch.core.JobParametersBuilder; | ||
|
||
import java.util.Properties; | ||
|
||
@Getter | ||
@Setter | ||
@ToString | ||
public class JobLauncherRequest { | ||
private String name; | ||
private Properties jobParameters; | ||
|
||
public JobParameters getJobParameters() { | ||
JobParametersBuilder builder = new JobParametersBuilder(); | ||
for (String key : jobParameters.stringPropertyNames()) { | ||
String value = jobParameters.getProperty(key); | ||
builder.addString(key, value); | ||
} | ||
return builder.toJobParameters(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
batch/src/main/java/com/pocket/batch/dto/KakaoDocument.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,19 @@ | ||
package com.pocket.batch.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class KakaoDocument { | ||
|
||
private String place_name; | ||
private String road_address_name; | ||
private String x; | ||
private String y; | ||
private String category_name; | ||
} |
16 changes: 16 additions & 0 deletions
16
batch/src/main/java/com/pocket/batch/dto/KakaoLocalResponse.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,16 @@ | ||
package com.pocket.batch.dto; | ||
|
||
import java.util.List; | ||
|
||
public class KakaoLocalResponse { | ||
|
||
private List<KakaoDocument> documents; | ||
|
||
public List<KakaoDocument> getDocuments() { | ||
return documents; | ||
} | ||
|
||
public void setDocuments(List<KakaoDocument> documents) { | ||
this.documents = documents; | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
batch/src/main/java/com/pocket/batch/job/AddPlacesJobConfig.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,51 @@ | ||
package com.pocket.batch.job; | ||
|
||
import com.pocket.batch.step.AddPlacesProcessor; | ||
import com.pocket.batch.step.AddPlacesReader; | ||
import com.pocket.batch.step.AddPlacesWriter; | ||
import com.pocket.domain.dto.photobooth.PhotoBoothFindResponseDto; | ||
import com.pocket.outbound.entity.JpaPhotoBooth; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.core.Job; | ||
import org.springframework.batch.core.Step; | ||
import org.springframework.batch.core.job.builder.JobBuilder; | ||
import org.springframework.batch.core.repository.JobRepository; | ||
import org.springframework.batch.core.step.builder.StepBuilder; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
public class AddPlacesJobConfig { | ||
|
||
private final JobRepository jobRepository; | ||
private final PlatformTransactionManager transactionManager; | ||
private final AddPlacesReader addPlacesReader; | ||
private final AddPlacesProcessor addPlacesProcessor; | ||
private final AddPlacesWriter addPlacesWriter; | ||
|
||
@Value("${batch.kakao.chunk-size}") | ||
private int chunkSize; | ||
|
||
@Bean | ||
public Job addPlacesJob() { | ||
return new JobBuilder("addPlacesJob", jobRepository) | ||
.start(addPlacesStep()) | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public Step addPlacesStep() { | ||
return new StepBuilder("addPlacesStep", jobRepository) | ||
// 제네릭 타입을 List 대신 PhotoBoothFindResponseDto와 JpaPhotoBooth로 변경 | ||
.<PhotoBoothFindResponseDto, JpaPhotoBooth>chunk(chunkSize, transactionManager) | ||
.reader(addPlacesReader) | ||
.processor(addPlacesProcessor) | ||
.writer(addPlacesWriter) | ||
.allowStartIfComplete(true) | ||
.build(); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
batch/src/main/java/com/pocket/batch/step/AddPlacesProcessor.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,29 @@ | ||
package com.pocket.batch.step; | ||
|
||
import com.pocket.domain.dto.photobooth.PhotoBoothFindResponseDto; | ||
import com.pocket.domain.entity.photobooth.PhotoBooth; | ||
import com.pocket.outbound.entity.JpaPhotoBooth; | ||
import org.springframework.batch.item.ItemProcessor; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class AddPlacesProcessor implements ItemProcessor<PhotoBoothFindResponseDto, JpaPhotoBooth> { | ||
|
||
@Override | ||
public JpaPhotoBooth process(PhotoBoothFindResponseDto dto) throws Exception { | ||
// DTO를 사용하여 PhotoBooth 객체 생성 | ||
PhotoBooth photoBooth = PhotoBooth.create( | ||
dto.name(), | ||
dto.road(), | ||
dto.x(), | ||
dto.y(), | ||
dto.photoBoothBrand() | ||
); | ||
|
||
// JpaPhotoBooth 객체 생성 및 PhotoBooth 설정 | ||
JpaPhotoBooth jpaPhotoBooth = new JpaPhotoBooth(); | ||
jpaPhotoBooth.setPhotoBooth(photoBooth); | ||
|
||
return jpaPhotoBooth; // 변환된 객체 반환 | ||
} | ||
} |
Oops, something went wrong.