-
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 #47 from ssu-student-union/feat/26-csv
[feat] : #26 CSV Batch 처리 및 온보딩 수정
- Loading branch information
Showing
38 changed files
with
707 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ out/ | |
|
||
### Yml ### | ||
**/src/main/resources/application.yml | ||
**/src/main/resources/** | ||
|
||
|
||
.DS_Store | ||
|
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
51 changes: 51 additions & 0 deletions
51
src/main/generated/ussum/homepage/infra/jpa/csv_user/entity/QStudentCsvEntity.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 ussum.homepage.infra.jpa.csv_user.entity; | ||
|
||
import static com.querydsl.core.types.PathMetadataFactory.*; | ||
|
||
import com.querydsl.core.types.dsl.*; | ||
|
||
import com.querydsl.core.types.PathMetadata; | ||
import javax.annotation.processing.Generated; | ||
import com.querydsl.core.types.Path; | ||
|
||
|
||
/** | ||
* QStudentCsvEntity is a Querydsl query type for StudentCsvEntity | ||
*/ | ||
@Generated("com.querydsl.codegen.DefaultEntitySerializer") | ||
public class QStudentCsvEntity extends EntityPathBase<StudentCsvEntity> { | ||
|
||
private static final long serialVersionUID = 1910442335L; | ||
|
||
public static final QStudentCsvEntity studentCsvEntity = new QStudentCsvEntity("studentCsvEntity"); | ||
|
||
public final StringPath groupName = createString("groupName"); | ||
|
||
public final StringPath major = createString("major"); | ||
|
||
public final NumberPath<Long> STID = createNumber("STID", Long.class); | ||
|
||
public final StringPath studentEmail = createString("studentEmail"); | ||
|
||
public final StringPath studentGroup = createString("studentGroup"); | ||
|
||
public final NumberPath<Long> studentId = createNumber("studentId", Long.class); | ||
|
||
public final StringPath studentName = createString("studentName"); | ||
|
||
public final StringPath studentStatus = createString("studentStatus"); | ||
|
||
public QStudentCsvEntity(String variable) { | ||
super(StudentCsvEntity.class, forVariable(variable)); | ||
} | ||
|
||
public QStudentCsvEntity(Path<? extends StudentCsvEntity> path) { | ||
super(path.getType(), path.getMetadata()); | ||
} | ||
|
||
public QStudentCsvEntity(PathMetadata metadata) { | ||
super(StudentCsvEntity.class, metadata); | ||
} | ||
|
||
} | ||
|
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
30 changes: 30 additions & 0 deletions
30
src/main/java/ussum/homepage/application/admin/controller/AdminController.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,30 @@ | ||
package ussum.homepage.application.admin.controller; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import ussum.homepage.application.admin.service.AdminService; | ||
import ussum.homepage.global.ApiResponse; | ||
|
||
@RequiredArgsConstructor | ||
@RequestMapping("/admin") | ||
@RestController | ||
public class AdminController { | ||
private final AdminService adminService; | ||
|
||
@PostMapping("/s3-csv") | ||
public ResponseEntity<ApiResponse<?>> csvToS3(@RequestParam MultipartFile file) { | ||
adminService.uploadCsvToS3(file); | ||
return ApiResponse.success(null); | ||
} | ||
|
||
@PostMapping("csv-project") | ||
public ResponseEntity<ApiResponse<?>> s3ToProject(@RequestParam("file") String fileName) { | ||
adminService.uploadCsvFromS3ToProject(fileName); | ||
return ApiResponse.success(null); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/ussum/homepage/application/admin/service/AdminService.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,27 @@ | ||
package ussum.homepage.application.admin.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
import ussum.homepage.infra.csvBatch.JobLauncherRunner; | ||
import ussum.homepage.infra.utils.S3utils; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class AdminService { | ||
private final S3utils s3utils; | ||
private final JobLauncherRunner runner; | ||
|
||
public void uploadCsvToS3(MultipartFile file) { | ||
s3utils.uploadFile(file); | ||
} | ||
|
||
public void uploadCsvFromS3ToProject(String fileName) { | ||
s3utils.getFileToProject(fileName); | ||
runner.runJob(); // batch job 실행 | ||
|
||
// runJob이후 resources/csv 경로에 학생목록.csv파일이 생성됨, 코드로 삭제해야하나? | ||
} | ||
} |
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
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
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
18 changes: 18 additions & 0 deletions
18
...main/java/ussum/homepage/application/user/service/dto/response/CsvOnBoardingResponse.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,18 @@ | ||
package ussum.homepage.application.user.service.dto.response; | ||
|
||
import lombok.Builder; | ||
|
||
@Builder | ||
public record CsvOnBoardingResponse( | ||
boolean name, | ||
boolean groupName, | ||
boolean major | ||
) { | ||
public static CsvOnBoardingResponse of(boolean name, boolean groupName, boolean major) { | ||
return CsvOnBoardingResponse.builder() | ||
.name(name) | ||
.groupName(groupName) | ||
.major(major) | ||
.build(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/ussum/homepage/application/user/service/dto/response/OnBoardingResponse.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,21 @@ | ||
package ussum.homepage.application.user.service.dto.response; | ||
|
||
import lombok.Builder; | ||
import ussum.homepage.application.user.service.dto.request.OnBoardingRequest; | ||
|
||
@Builder | ||
public record OnBoardingResponse( | ||
boolean name, | ||
boolean studentId, | ||
boolean groupName, | ||
boolean major | ||
) { | ||
public static OnBoardingResponse of(boolean name, boolean studentId, boolean groupName, boolean major) { | ||
return OnBoardingResponse.builder() | ||
.name(name) | ||
.studentId(studentId) | ||
.groupName(groupName) | ||
.major(major) | ||
.build(); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/ussum/homepage/domain/csv_user/StudentCsv.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,30 @@ | ||
package ussum.homepage.domain.csv_user; | ||
|
||
import lombok.*; | ||
|
||
/* | ||
원래는 record로 dto를 관리하지만, | ||
기본 생성자에서 문제가 발생하여 class 사용 | ||
*/ | ||
@Getter | ||
@Setter | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor(access = AccessLevel.PRIVATE) | ||
public class StudentCsv { | ||
private Long STID; | ||
private Long studentId; | ||
private String studentName; | ||
private String groupName; | ||
private String major; | ||
private String studentStatus; | ||
private String studentGroup; // 학생그룹의 의미 | ||
// 전화번호? | ||
private String studentEmail; | ||
|
||
public static StudentCsv of(Long STID, Long studentId, String studentName, String groupName, | ||
String major, String studentStatus, String studentGroup, String studentEmail) { | ||
return new StudentCsv(STID, studentId, studentName, groupName, | ||
major, studentStatus, studentGroup, studentEmail); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/ussum/homepage/domain/csv_user/StudentCsvRepository.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,11 @@ | ||
package ussum.homepage.domain.csv_user; | ||
|
||
import org.springframework.batch.item.Chunk; | ||
import ussum.homepage.infra.jpa.csv_user.entity.StudentCsvEntity; | ||
|
||
import java.util.Optional; | ||
|
||
public interface StudentCsvRepository { | ||
void saveAll(Chunk<StudentCsvEntity> students); | ||
Optional<StudentCsv> findByStudentId(Long studentId); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/ussum/homepage/domain/csv_user/service/StudentCsvModifier.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,12 @@ | ||
package ussum.homepage.domain.csv_user.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import ussum.homepage.domain.csv_user.StudentCsvRepository; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class StudentCsvModifier { | ||
private final StudentCsvRepository studentCsvRepository; | ||
|
||
} |
Oops, something went wrong.