Skip to content

Commit

Permalink
feat: 촬영지 데이터셋 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
JONG-KYEONG committed Aug 13, 2024
1 parent ba21f84 commit 15ea743
Show file tree
Hide file tree
Showing 31 changed files with 138 additions and 16 deletions.
Binary file modified server/.gradle/8.8/checksums/checksums.lock
Binary file not shown.
Binary file modified server/.gradle/8.8/checksums/md5-checksums.bin
Binary file not shown.
Binary file modified server/.gradle/8.8/checksums/sha1-checksums.bin
Binary file not shown.
Binary file modified server/.gradle/8.8/executionHistory/executionHistory.bin
Binary file not shown.
Binary file modified server/.gradle/8.8/executionHistory/executionHistory.lock
Binary file not shown.
Binary file modified server/.gradle/8.8/fileHashes/fileHashes.bin
Binary file not shown.
Binary file modified server/.gradle/8.8/fileHashes/fileHashes.lock
Binary file not shown.
Binary file modified server/.gradle/8.8/fileHashes/resourceHashesCache.bin
Binary file not shown.
Binary file modified server/.gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
Binary file modified server/.gradle/file-system.probe
Binary file not shown.
2 changes: 2 additions & 0 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ dependencies {
implementation group: 'io.jsonwebtoken', name: 'jjwt-api', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.2'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-jackson', version: '0.11.2'

implementation 'com.opencsv:opencsv:5.7.1'
}

tasks.named('test') {
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
37 changes: 21 additions & 16 deletions server/build/resources/main/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,26 @@
#app.cors.allowedOrigins=http://localhost:3000,http://localhost:8080,https://port-0-hackathon-be-lyqylohp8957ca6e.sel5.cloudtype.app/
#app.oauth2.authorizedRedirectUris=http://localhost:3000/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect

#Spring Data JPA
spring.datasource.url=jdbc:mysql://localhost:3306/hackathon?createDatabaseIfNotExist=true
spring.datasource.url=jdbc:mariadb://svc.sel5.cloudtype.app:31837/hackathon?characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=0322
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.password=0322!
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver

spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.ddl-auto=create

app.auth.tokenSecret=04ca023b39512e46d0c2cf4b48d5aac61d34302994c87ed4eff225dcf3b0a218739f3897051a057f9b846a69ea2927a587044164b7bae5e1306219d50b588cb1
app.auth.tokenExpirationMsec = 864000000
app.cors.allowedOrigins=https://glog-beta.vercel.app,http://localhost:3000,http://localhost:8080
app.oauth2.authorizedRedirectUris=https://glog-beta.vercel.app/oauth2/redirect,http://localhost:3000/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
app.GitHub.gitHubToken=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

#AWS
cloud.aws.credentials.accessKey=AKIA6ODUZVK7N2P6RB6C
cloud.aws.credentials.secretKey=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
cloud.aws.s3.bucket=glog-image-bucket
cloud.aws.region.static=ap-northeast-2
cloud.aws.stack.auto=false

# spring boot 2.5.x to use script
spring.sql.init.mode=always
Expand All @@ -81,15 +93,8 @@ spring.security.oauth2.client.registration.github.client-secret=40bbeeda1c6175ec
spring.security.oauth2.client.registration.github.redirect-uri=http://localhost:8080/oauth2/callback/github
spring.security.oauth2.client.registration.github.scope=user:email,read:user

app.auth.tokenSecret=04ca023b39512e46d0c2cf4b48d5aac61d34302994c87ed4eff225dcf3b0a218739f3897051a057f9b846a69ea2927a587044164b7bae5e1306219d50b588cb1
app.auth.tokenExpirationMsec = 864000000
app.cors.allowedOrigins=https://glog-beta.vercel.app,http://localhost:3000,http://localhost:8080
app.oauth2.authorizedRedirectUris=https://glog-beta.vercel.app/oauth2/redirect,http://localhost:3000/oauth2/redirect,myandroidapp://oauth2/redirect,myiosapp://oauth2/redirect
app.GitHub.gitHubToken=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
# ?? ??? ?? ?? ?? (10MB? ??)
spring.servlet.multipart.max-file-size=10MB

#AWS
cloud.aws.credentials.accessKey=AKIA6ODUZVK7N2P6RB6C
cloud.aws.credentials.secretKey=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
cloud.aws.s3.bucket=glog-image-bucket
cloud.aws.region.static=ap-northeast-2
cloud.aws.stack.auto=false
# ?? ??? ?? ?? ?? (10MB? ??)
spring.servlet.multipart.max-request-size=10MB
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.
Binary file modified server/build/tmp/compileJava/previous-compilation-data.bin
Binary file not shown.
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();
}
}
}
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();
}
}
}
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;
}
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> {
}

0 comments on commit 15ea743

Please sign in to comment.