-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba21f84
commit 15ea743
Showing
31 changed files
with
138 additions
and
16 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Binary file added
BIN
+2.51 KB
server/build/classes/java/main/com/example/hackathon/dataset/application/DataService.class
Binary file not shown.
Binary file added
BIN
+1.95 KB
server/build/classes/java/main/com/example/hackathon/dataset/controller/DataController.class
Binary file not shown.
Binary file added
BIN
+3.21 KB
server/build/classes/java/main/com/example/hackathon/dataset/domain/Data.class
Binary file not shown.
Binary file added
BIN
+368 Bytes
server/build/classes/java/main/com/example/hackathon/dataset/repository/DataRepository.class
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
Binary file added
BIN
+1.76 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/AwsController.class.uniqueId9
Binary file not shown.
Binary file added
BIN
+1.81 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/AwsS3Config.class.uniqueId3
Binary file not shown.
Binary file added
BIN
+5.46 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/AwsUtils.class.uniqueId1
Binary file not shown.
Binary file added
BIN
+903 Bytes
...r/build/tmp/compileJava/compileTransaction/stash-dir/HackathonApplication.class.uniqueId6
Binary file not shown.
Binary file added
BIN
+3.46 KB
...mpileJava/compileTransaction/stash-dir/OAuth2AuthenticationFailureHandler.class.uniqueId4
Binary file not shown.
Binary file added
BIN
+6.69 KB
...mpileJava/compileTransaction/stash-dir/OAuth2AuthenticationSuccessHandler.class.uniqueId0
Binary file not shown.
Binary file added
BIN
+6.45 KB
.../build/tmp/compileJava/compileTransaction/stash-dir/OAuth2UserInfoFactory.class.uniqueId5
Binary file not shown.
Binary file renamed
BIN
+9.96 KB
.../stash-dir/SecurityConfig.class.uniqueId0 → .../stash-dir/SecurityConfig.class.uniqueId8
Binary file not shown.
Binary file added
BIN
+3.92 KB
...ld/tmp/compileJava/compileTransaction/stash-dir/TokenAuthenticationFilter.class.uniqueId2
Binary file not shown.
Binary file added
BIN
+1.76 KB
server/build/tmp/compileJava/compileTransaction/stash-dir/WebMvcConfig.class.uniqueId7
Binary file not shown.
Binary file not shown.
45 changes: 45 additions & 0 deletions
45
server/src/main/java/com/example/hackathon/dataset/application/DataService.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,45 @@ | ||
package com.example.hackathon.dataset.application; | ||
|
||
import com.example.hackathon.dataset.domain.Data; | ||
import com.example.hackathon.dataset.repository.DataRepository; | ||
import com.opencsv.CSVReader; | ||
import lombok.AllArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
import java.io.InputStreamReader; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@Service | ||
@AllArgsConstructor | ||
public class DataService { | ||
private final DataRepository dataRepository; | ||
public void saveCsv(MultipartFile file) { | ||
try (CSVReader reader = new CSVReader(new InputStreamReader(file.getInputStream()))) { | ||
String[] nextLine; | ||
List<Data> entities = new ArrayList<>(); | ||
|
||
while ((nextLine = reader.readNext()) != null) { | ||
Data entity = new Data(); | ||
entity.setMediaType(nextLine[1]); | ||
entity.setTitleName(nextLine[2]); | ||
entity.setPlaceName(nextLine[3]); | ||
entity.setPlaceTypel(nextLine[4]); | ||
entity.setPlaceOverview(nextLine[5]); | ||
entity.setOpenTime(nextLine[6]); | ||
entity.setRestDay(nextLine[8]); | ||
entity.setAddress(nextLine[9]); | ||
entity.setMapY(nextLine[10]); | ||
entity.setMapX(nextLine[11]); | ||
entity.setTel(nextLine[12]); | ||
|
||
entities.add(entity); | ||
} | ||
|
||
dataRepository.saveAll(entities); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
server/src/main/java/com/example/hackathon/dataset/controller/DataController.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 com.example.hackathon.dataset.controller; | ||
|
||
import com.example.hackathon.dataset.application.DataService; | ||
import lombok.AllArgsConstructor; | ||
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; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/csv") | ||
public class DataController { | ||
|
||
private final DataService dataService; | ||
|
||
@PostMapping("/upload") | ||
public String uploadCSV(@RequestParam("file") MultipartFile file) { | ||
try { | ||
dataService.saveCsv(file); | ||
return "File uploaded and data saved successfully!"; | ||
} catch (Exception e) { | ||
return "Failed to upload and save data: " + e.getMessage(); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
server/src/main/java/com/example/hackathon/dataset/domain/Data.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,36 @@ | ||
package com.example.hackathon.dataset.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Getter; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@Entity | ||
public class Data { | ||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
@Column(name = "mediaType") | ||
private String mediaType; | ||
@Column(name = "titleName") | ||
private String titleName; | ||
@Column(name = "placeName") | ||
private String placeName; | ||
@Column(name = "placeTypel") | ||
private String placeTypel; | ||
@Column(name = "placeOverview") | ||
private String placeOverview; | ||
@Column(name = "openTime") | ||
private String openTime; | ||
@Column(name = "restDay") | ||
private String restDay; | ||
@Column(name = "address") | ||
private String address; | ||
@Column(name = "mapY") | ||
private String mapY; | ||
@Column(name = "mapX") | ||
private String mapX; | ||
@Column(name = "tel") | ||
private String tel; | ||
} |
7 changes: 7 additions & 0 deletions
7
server/src/main/java/com/example/hackathon/dataset/repository/DataRepository.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,7 @@ | ||
package com.example.hackathon.dataset.repository; | ||
|
||
import com.example.hackathon.dataset.domain.Data; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface DataRepository extends JpaRepository<Data, Long> { | ||
} |