From 717686200014628f976bfa0d5caefa635ad2e75e Mon Sep 17 00:00:00 2001 From: rivkode Date: Mon, 29 Apr 2024 17:23:24 +0900 Subject: [PATCH 01/44] =?UTF-8?q?#79=20feat=20:=20RawLibrary=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/domain/RawLibrary.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java new file mode 100644 index 00000000..b6d12d36 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java @@ -0,0 +1,80 @@ +package com.seoultech.synergybe.domain.library.domain; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class RawLibrary { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "library_seq") // 도서관 일련번호 + private String librarySeq; + + @Column(name = "name") // 도서관 명 + private String name; + + @Column(name = "gu_code") // 구 코드 + private String guCode; + + @Column(name = "gu_code_value") // 구 명 + private String guCodeValue; + + @Column(name = "address") // 주소 + private String address; + + @Column(name = "tel_number") // 전화번호 + private String telNumber; + + @Column(name = "hompage_url") // 홈페이지 url + private String hompageUrl; + + @Column(name = "op_time") // 운영시간 + private String opTime; + + @Column(name = "close_date") // 정기 휴관일 + private String closeDate; + + @Column(name = "se_name") // 도서관 구분명 + private String seName; + + @Column(name = "latitude") // 위도 + private Double latitude; + + @Column(name = "longitude") // 경도 + private Double longitude; + + @Builder + public RawLibrary( + String librarySeq, + String name, + String guCode, + String guCodeValue, + String address, + String telNumber, + String hompageUrl, + String opTime, + String closeDate, + String seName, + Double latitude, + Double longitude + ) { + this.librarySeq = librarySeq; + this.name = name; + this.guCode = guCode; + this.guCodeValue = guCodeValue; + this.address = address; + this.telNumber = telNumber; + this.hompageUrl = hompageUrl; + this.opTime = opTime; + this.closeDate = closeDate; + this.seName = seName; + this.latitude = latitude; + this.longitude = longitude; + } +} From 3db5d05247ed882ece3b4ce40e21125c48d8fea0 Mon Sep 17 00:00:00 2001 From: rivkode Date: Mon, 29 Apr 2024 17:23:31 +0900 Subject: [PATCH 02/44] =?UTF-8?q?#79=20feat=20:=20Library=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=EC=84=A4=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/library/domain/Library.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java new file mode 100644 index 00000000..58a6fe74 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java @@ -0,0 +1,16 @@ +package com.seoultech.synergybe.domain.library.domain; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity +@Getter +@NoArgsConstructor +public class Library { + @Id + @Column(name = "library_id") + private String id; +} From 24b2d76ad0c6d7928053fbc49051fd3d9de430b2 Mon Sep 17 00:00:00 2001 From: rivkode Date: Mon, 29 Apr 2024 17:23:49 +0900 Subject: [PATCH 03/44] =?UTF-8?q?#79=20feat=20:=20LibraryRepository=20RawL?= =?UTF-8?q?ibraryRepository=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/repository/LibraryRepository.java | 7 +++++++ .../domain/library/repository/RawLibraryRepository.java | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java new file mode 100644 index 00000000..12846417 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java @@ -0,0 +1,7 @@ +package com.seoultech.synergybe.domain.library.repository; + +import com.seoultech.synergybe.domain.library.domain.Library; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface LibraryRepository extends JpaRepository { +} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java new file mode 100644 index 00000000..2fdce352 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java @@ -0,0 +1,7 @@ +package com.seoultech.synergybe.domain.library.repository; + +import com.seoultech.synergybe.domain.library.domain.RawLibrary; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RawLibraryRepository extends JpaRepository { +} From 951ba5c239ec06505e010ffc354179c4ed0efce5 Mon Sep 17 00:00:00 2001 From: rivkode Date: Mon, 29 Apr 2024 17:24:03 +0900 Subject: [PATCH 04/44] =?UTF-8?q?#79=20feat=20:=20Library=20Id=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=EA=B8=B0=20Prefix=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seoultech/synergybe/domain/common/idgenerator/IdPrefix.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java b/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java index b39057cc..a314b3ee 100644 --- a/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java +++ b/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java @@ -16,6 +16,7 @@ public enum IdPrefix { PROJECT_USER("project_user"), RATE("rate"), SCHEDULE("schedule"), + LIBRARY("library"), TICKET("ticket"), TICKET_USER("ticket_user"); From 613b9c195df1a47f7faf363099f644d13fa4de9f Mon Sep 17 00:00:00 2001 From: rivkode Date: Mon, 29 Apr 2024 17:29:36 +0900 Subject: [PATCH 05/44] =?UTF-8?q?#79=20feat=20:=20Library=20=EC=8A=A4?= =?UTF-8?q?=EC=BC=80=EC=A4=84=EB=9F=AC=20=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/RawLibraryScheduler.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java new file mode 100644 index 00000000..435c70d2 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java @@ -0,0 +1,19 @@ +package com.seoultech.synergybe.domain.library; + +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; + +@Component +@RequiredArgsConstructor +@Transactional +public class RawLibraryScheduler { + private final RestTemplate restTemplate; + + @Scheduled(cron = "0 0 4 * * 0") + public void updateRawLibrary() { + + } +} From 029fec9c8cef6d242ceb49efa057aa514e3f693f Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:19:27 +0900 Subject: [PATCH 06/44] =?UTF-8?q?#79=20remove=20:=20RawLibraryRepository?= =?UTF-8?q?=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/repository/LibraryRepository.java | 7 ------- .../domain/library/repository/RawLibraryRepository.java | 7 ------- 2 files changed, 14 deletions(-) delete mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java delete mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java deleted file mode 100644 index 12846417..00000000 --- a/src/main/java/com/seoultech/synergybe/domain/library/repository/LibraryRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.seoultech.synergybe.domain.library.repository; - -import com.seoultech.synergybe.domain.library.domain.Library; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface LibraryRepository extends JpaRepository { -} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java deleted file mode 100644 index 2fdce352..00000000 --- a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawLibraryRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.seoultech.synergybe.domain.library.repository; - -import com.seoultech.synergybe.domain.library.domain.RawLibrary; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface RawLibraryRepository extends JpaRepository { -} From 32f1afd7ec65c348020d3e3a30ce44b635eab026 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:19:52 +0900 Subject: [PATCH 07/44] =?UTF-8?q?#79=20feat=20:=20smallLibraryRepository?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/repository/RawSmallLibraryRepository.java | 4 ++++ .../domain/library/repository/SmallLibraryRepository.java | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/SmallLibraryRepository.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java new file mode 100644 index 00000000..00f588ce --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java @@ -0,0 +1,4 @@ +package com.seoultech.synergybe.domain.library.repository; + +public interface RawSmallLibraryRepository { +} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/SmallLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/SmallLibraryRepository.java new file mode 100644 index 00000000..e0c1032a --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/SmallLibraryRepository.java @@ -0,0 +1,7 @@ +package com.seoultech.synergybe.domain.library.repository; + +import com.seoultech.synergybe.domain.library.domain.SmallLibrary; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface SmallLibraryRepository extends JpaRepository { +} From 56a443dd2974c8bac6e6984726e04b301e6f4836 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:20:02 +0900 Subject: [PATCH 08/44] =?UTF-8?q?#79=20feat=20:=20publicLibraryRepository?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/repository/PublicLibraryRepository.java | 7 +++++++ .../library/repository/RawPublicLibraryRepository.java | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/PublicLibraryRepository.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/repository/RawPublicLibraryRepository.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/PublicLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/PublicLibraryRepository.java new file mode 100644 index 00000000..8033925f --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/PublicLibraryRepository.java @@ -0,0 +1,7 @@ +package com.seoultech.synergybe.domain.library.repository; + +import com.seoultech.synergybe.domain.library.domain.PublicLibrary; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface PublicLibraryRepository extends JpaRepository { +} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawPublicLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawPublicLibraryRepository.java new file mode 100644 index 00000000..fbef4a91 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawPublicLibraryRepository.java @@ -0,0 +1,7 @@ +package com.seoultech.synergybe.domain.library.repository; + +import com.seoultech.synergybe.domain.library.domain.RawPublicLibrary; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RawPublicLibraryRepository extends JpaRepository { +} From 423ca9ab6163abc6ef1df36e11041362ad350b00 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:20:55 +0900 Subject: [PATCH 09/44] =?UTF-8?q?#79=20fix=20:=20PublicLibrary=20entity=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/domain/Library.java | 16 ----- .../domain/library/domain/PublicLibrary.java | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 16 deletions(-) delete mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java deleted file mode 100644 index 58a6fe74..00000000 --- a/src/main/java/com/seoultech/synergybe/domain/library/domain/Library.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.seoultech.synergybe.domain.library.domain; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Id; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Entity -@Getter -@NoArgsConstructor -public class Library { - @Id - @Column(name = "library_id") - private String id; -} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java new file mode 100644 index 00000000..a5b0bd6f --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java @@ -0,0 +1,60 @@ +package com.seoultech.synergybe.domain.library.domain; + +import com.seoultech.synergybe.domain.library.vo.LibraryLocation; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.geo.Point; + +@Entity +@Getter +@NoArgsConstructor +public class PublicLibrary { + @Id + @Column(name = "library_id") + private String id; + + @Column(name = "name") + private String name; + + @Column(name = "address") + private String address; + + @Column(name = "tel_number") + private String telNumber; + + @Column(name = "homepage_url") + private String homepageUrl; + + @Column(name = "op_time") + private String opTime; + + @Column(name = "close_date") // 정기 휴관일 + private String closeDate; + + @Embedded + private LibraryLocation location; + + @Builder + public PublicLibrary( + String name, + String address, + String telNumber, + String homepageUrl, + String opTime, + String closeDate, + Point location + ) { + this.name = name; + this.address = address; + this.telNumber = telNumber; + this.homepageUrl = homepageUrl; + this.opTime = opTime; + this.closeDate = closeDate; + this.location = new LibraryLocation(location); + } +} From 73282cd3340d8e74aa6b1e7f0531a6075f893adf Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:21:03 +0900 Subject: [PATCH 10/44] =?UTF-8?q?#79=20fix=20:=20SmallLibrary=20entity=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/domain/SmallLibrary.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java new file mode 100644 index 00000000..a74756d1 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java @@ -0,0 +1,55 @@ +package com.seoultech.synergybe.domain.library.domain; + +import com.seoultech.synergybe.domain.library.vo.LibraryLocation; +import jakarta.persistence.Column; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.geo.Point; + +@Entity +@Getter +@NoArgsConstructor +public class SmallLibrary { + @Id + @Column(name = "library_id") + private String id; + + private String name; + + private String address; + + private String telNumber; + + private String homepageUrl; + + private String opTime; + + @Column(name = "close_date") // 정기 휴관일 + private String closeDate; + + @Embedded + private LibraryLocation location; + + @Builder + public SmallLibrary( + String name, + String address, + String telNumber, + String homepageUrl, + String opTime, + String closeDate, + Point location + ) { + this.name = name; + this.address = address; + this.telNumber = telNumber; + this.homepageUrl = homepageUrl; + this.opTime = opTime; + this.closeDate = closeDate; + this.location = new LibraryLocation(location); + } +} From 7be24c05e36c40081afeb1c2872ba50f04a7cc03 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:21:11 +0900 Subject: [PATCH 11/44] =?UTF-8?q?#79=20fix=20:=20RawSmallLibrary=20entity?= =?UTF-8?q?=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/domain/RawSmallLibrary.java | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/domain/RawSmallLibrary.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/RawSmallLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawSmallLibrary.java new file mode 100644 index 00000000..f7555804 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawSmallLibrary.java @@ -0,0 +1,80 @@ +package com.seoultech.synergybe.domain.library.domain; + +import jakarta.persistence.*; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@Entity(name = "raw_small_library") +@Getter +@NoArgsConstructor +public class RawSmallLibrary { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(name = "library_seq") // 도서관 일련번호 + private String smallLibrarySeq; + + @Column(name = "name") // 도서관 명 + private String name; + + @Column(name = "gu_code") // 구 코드 + private String guCode; + + @Column(name = "gu_code_value") // 구 명 + private String guCodeValue; + + @Column(name = "address") // 주소 + private String address; + + @Column(name = "tel_number") // 전화번호 + private String telNumber; + + @Column(name = "hompage_url") // 홈페이지 url + private String hompageUrl; + + @Column(name = "op_time") // 운영시간 + private String opTime; + + @Column(name = "close_date") // 정기 휴관일 + private String closeDate; + + @Column(name = "se_name") // 도서관 구분명 + private String seName; + + @Column(name = "latitude") // 위도 + private Double latitude; + + @Column(name = "longitude") // 경도 + private Double longitude; + + @Builder + public RawSmallLibrary( + String smallLibrarySeq, + String name, + String guCode, + String guCodeValue, + String address, + String telNumber, + String hompageUrl, + String opTime, + String closeDate, + String seName, + Double latitude, + Double longitude + ) { + this.smallLibrarySeq = smallLibrarySeq; + this.name = name; + this.guCode = guCode; + this.guCodeValue = guCodeValue; + this.address = address; + this.telNumber = telNumber; + this.hompageUrl = hompageUrl; + this.opTime = opTime; + this.closeDate = closeDate; + this.seName = seName; + this.latitude = latitude; + this.longitude = longitude; + } +} From b79cf29bdfa06d90844f6ba4d71a28f6a46f4d5f Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:21:28 +0900 Subject: [PATCH 12/44] =?UTF-8?q?#79=20fix=20:=20library=20->=20public=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{RawLibrary.java => RawPublicLibrary.java} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename src/main/java/com/seoultech/synergybe/domain/library/domain/{RawLibrary.java => RawPublicLibrary.java} (86%) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawPublicLibrary.java similarity index 86% rename from src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java rename to src/main/java/com/seoultech/synergybe/domain/library/domain/RawPublicLibrary.java index b6d12d36..7f09abeb 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/domain/RawLibrary.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/RawPublicLibrary.java @@ -5,16 +5,16 @@ import lombok.Getter; import lombok.NoArgsConstructor; -@Entity +@Entity(name = "raw_public_library") @Getter @NoArgsConstructor -public class RawLibrary { +public class RawPublicLibrary { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @Column(name = "library_seq") // 도서관 일련번호 - private String librarySeq; + @Column(name = "public_library_seq") // 도서관 일련번호 + private String publicLibrarySeq; @Column(name = "name") // 도서관 명 private String name; @@ -50,8 +50,8 @@ public class RawLibrary { private Double longitude; @Builder - public RawLibrary( - String librarySeq, + public RawPublicLibrary( + String publicLibrarySeq, String name, String guCode, String guCodeValue, @@ -64,7 +64,7 @@ public RawLibrary( Double latitude, Double longitude ) { - this.librarySeq = librarySeq; + this.publicLibrarySeq = publicLibrarySeq; this.name = name; this.guCode = guCode; this.guCodeValue = guCodeValue; From b55340e64720f67803d317e2d0ea5b3d9ab2a8a2 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:21:37 +0900 Subject: [PATCH 13/44] =?UTF-8?q?#79=20fix=20:=20api=20key=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/RawLibraryScheduler.java | 19 ------------- .../scheduler/RawLibraryScheduler.java | 28 +++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) delete mode 100644 src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java deleted file mode 100644 index 435c70d2..00000000 --- a/src/main/java/com/seoultech/synergybe/domain/library/RawLibraryScheduler.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.seoultech.synergybe.domain.library; - -import lombok.RequiredArgsConstructor; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.client.RestTemplate; - -@Component -@RequiredArgsConstructor -@Transactional -public class RawLibraryScheduler { - private final RestTemplate restTemplate; - - @Scheduled(cron = "0 0 4 * * 0") - public void updateRawLibrary() { - - } -} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java new file mode 100644 index 00000000..98ae0bd1 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java @@ -0,0 +1,28 @@ +package com.seoultech.synergybe.domain.library.scheduler; + +import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; + +@Component +@RequiredArgsConstructor +@Transactional +public class RawLibraryScheduler { + private final RestTemplate restTemplate; + private final RawPublicLibraryRepository rawPublicLibraryRepository; + + @Value("library.api.key") + private String libraryApiKey; + private Long dataCount; + private final Long BATCH_SIZE = 500L; + + // 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. + @Scheduled(cron = "0 0 4 * * 0") + public void updateRawLibrary() { + + } +} From a7803741e62db76368a930e346e88a5ef30800bc Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 11:22:28 +0900 Subject: [PATCH 14/44] =?UTF-8?q?#79=20fix=20:=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=20(public,=20small)=20=EC=9C=84=EC=B9=98=20=EA=B3=B5?= =?UTF-8?q?=ED=86=B5=20=EC=86=8D=EC=84=B1=20=EC=82=AC=EC=9A=A9=EC=9C=BC?= =?UTF-8?q?=EB=A1=9C=20VO=20=EC=A0=95=EC=9D=98=20LibraryLocation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/vo/LibraryLocation.java | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java b/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java new file mode 100644 index 00000000..59dd902f --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java @@ -0,0 +1,48 @@ +package com.seoultech.synergybe.domain.library.vo; + +import com.seoultech.synergybe.domain.project.exception.ProjectBadRequestException; +import jakarta.persistence.Column; +import jakarta.persistence.Embeddable; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.geo.Point; + +import java.util.Objects; + +@Getter +@Embeddable +@NoArgsConstructor(access = AccessLevel.PROTECTED) +public class LibraryLocation { + @Column(name = "location") + private Point location; + + public LibraryLocation(Point value) { + validateNotNull(value); + this.location = value; + } + + private void validateNotNull(Point value) { + if (value == null) { + throw new ProjectBadRequestException("위치 정보는 필수 항목입니다."); + } + } + + public void updateLocation(Point value) { + validateNotNull(value); + this.location = value; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LibraryLocation that = (LibraryLocation) o; + return Objects.equals(location, that.location); + } + + @Override + public int hashCode() { + return Objects.hash(location); + } +} From c7abcb08b7ca10c3a0a493d5126b24bff977d59f Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 17:49:04 +0900 Subject: [PATCH 15/44] =?UTF-8?q?#79=20feat=20:=20object=20mapper=20?= =?UTF-8?q?=EB=B0=94=EC=9D=B8=EB=94=A9=20=EA=B5=AC=ED=98=84=20json=20->=20?= =?UTF-8?q?object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/RawLibraryScheduler.java | 28 ---- .../scheduler/RawPublicLibraryScheduler.java | 153 ++++++++++++++++++ 2 files changed, 153 insertions(+), 28 deletions(-) delete mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java deleted file mode 100644 index 98ae0bd1..00000000 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawLibraryScheduler.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.seoultech.synergybe.domain.library.scheduler; - -import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.web.client.RestTemplate; - -@Component -@RequiredArgsConstructor -@Transactional -public class RawLibraryScheduler { - private final RestTemplate restTemplate; - private final RawPublicLibraryRepository rawPublicLibraryRepository; - - @Value("library.api.key") - private String libraryApiKey; - private Long dataCount; - private final Long BATCH_SIZE = 500L; - - // 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. - @Scheduled(cron = "0 0 4 * * 0") - public void updateRawLibrary() { - - } -} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java new file mode 100644 index 00000000..5dbfa020 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java @@ -0,0 +1,153 @@ +package com.seoultech.synergybe.domain.library.scheduler; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.seoultech.synergybe.domain.library.domain.RawPublicLibrary; +import com.seoultech.synergybe.domain.library.dto.response.SeoulPublicLibraryInfo; +import com.seoultech.synergybe.domain.library.dto.response.SeoulPublicLibraryInfoResponse; +import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.configurationprocessor.json.JSONException; +import org.springframework.boot.configurationprocessor.json.JSONObject; +import org.springframework.http.RequestEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + +import java.util.ArrayList; +import java.util.List; + +@Component +@RequiredArgsConstructor +@Transactional +@Slf4j +public class RawPublicLibraryScheduler { + private final RestTemplate restTemplate; + private final RawPublicLibraryRepository rawPublicLibraryRepository; + + @Value("${library.api.key}") + private String libraryApiKey; + private int dataCount; + private final int BATCH_SIZE = 500; + + + /** + * 크론 스케줄링 + * 첫 번째 필드: 초 (0-59) + * 두 번째 필드: 분 (0-59) + * 세 번째 필드: 시간 (0-23) + * 네 번째 필드: 일 (1-31) + * 다섯 번째 필드: 월 (1-12) + * 여섯 번째 필드: 요일 (0-6, 일요일부터 토요일까지, 일요일=0 또는 7) + * 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. + */ +// @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") + @Scheduled(fixedDelay = 10000) + public void updateRawLibrary() throws JSONException, JsonProcessingException { + log.info("================시작"); + countTotalData(); + updatePublicLibrary(); + log.info("=================끝"); + } + + private void countTotalData() throws JSONException { + UriComponents uriComponents = UriComponentsBuilder + .newInstance() + .scheme("http") + .host("openapi.seoul.go.kr") + .port(8088) + .path("/{libraryAPI}/json/SeoulPublicLibraryInfo/{start}/{end}") + .buildAndExpand(libraryApiKey, 1, 10); + + log.info("uri : " + uriComponents); + RequestEntity requestEntity = RequestEntity.get(uriComponents.toUri()).build(); + ResponseEntity responseEntity = restTemplate.exchange(requestEntity, String.class); + + log.info(responseEntity.getBody()); + dataCount = new JSONObject(responseEntity.getBody()) + .getJSONObject("SeoulPublicLibraryInfo") + .getInt("list_total_count"); + log.info("dataCount : " + dataCount); + } + + public void updatePublicLibrary() throws JsonProcessingException, JSONException { + List libraries = getPublicLibraryFromOpenApi(); + + // stream api로 + List rawPublicLibraries = libraries.stream() + .map(library -> RawPublicLibrary.builder() + .publicLibrarySeq(library.getLBRRY_SEQ_NO()) + .name(library.getLBRRY_NAME()) + .guCode(library.getGU_CODE()) + .guCodeValue(library.getCODE_VALUE()) + .address(library.getADRES()) + .telNumber(library.getTEL_NO()) + .hompageUrl(library.getHMPG_URL()) + .opTime(library.getOP_TIME()) + .closeDate(library.getFDRM_CLOSE_DATE()) + .seName(library.getLBRRY_SE_NAME()) + .latitude(Double.valueOf(library.getXCNTS())) + .longitude(Double.valueOf(library.getYDNTS())) + .build()) + .toList(); + + rawPublicLibraryRepository.saveAll(rawPublicLibraries); + + + } + + + private List getPublicLibraryFromOpenApi() throws JsonProcessingException, JSONException { + int start; + List rawLibraries = new ArrayList<>(); + for (start = 1; start <= dataCount; start += BATCH_SIZE) { + + UriComponents uriComponents = UriComponentsBuilder + .newInstance() + .scheme("http") + .host("openapi.seoul.go.kr") + .port(8088) + .path("/{libraryAPI}/json/SeoulPublicLibraryInfo/{start}/{end}") + .buildAndExpand(libraryApiKey, 1, 10); + + RequestEntity requestEntity = RequestEntity.get(uriComponents.toUri()).build(); + ResponseEntity responseEntity = restTemplate.exchange(requestEntity, String.class); + + log.info("RawLibrary ======================"); + log.info("responseENtity : " + responseEntity.getBody()); + + // JSON 문자열을 Java 객체로 변환 + ObjectMapper objectMapper = new ObjectMapper(); + + // 내가 필요한 데이터들만 파싱하기 위해 설정 + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + try { + SeoulPublicLibraryInfoResponse seoulPublicLibraryInfoResponse = objectMapper.readValue(responseEntity.getBody() , SeoulPublicLibraryInfoResponse.class); + log.info(String.valueOf(seoulPublicLibraryInfoResponse.getSeoulPublicLibraryInfo().getListTotalCount())); + log.info(String.valueOf(seoulPublicLibraryInfoResponse.getSeoulPublicLibraryInfo().getRow().get(0).getHMPG_URL())); + log.info(String.valueOf(seoulPublicLibraryInfoResponse.getSeoulPublicLibraryInfo().getRESULT().getCODE())); + + rawLibraries.addAll(seoulPublicLibraryInfoResponse.getSeoulPublicLibraryInfo().getRow()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + log.info("RawLibrary 변환중 ======================"); + + // 가져온 데이터 사용 예시 +// List libraryInfos = libraryInfoResponse.getSeoulPublicLibraryInfo().getRawLibrary(); +// rawLibraries.addAll(libraryInfos); + + } + + return rawLibraries; + } +} From f53d148cf06f193ef85e160264d256e91c0fd3c7 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 17:49:31 +0900 Subject: [PATCH 16/44] =?UTF-8?q?#79=20feat=20:=20object=20mapper=20?= =?UTF-8?q?=EA=B0=9D=EC=B2=B4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SeoulPublicLibraryInfo.java | 78 +++++++++++++++++++ .../SeoulPublicLibraryInfoResponse.java | 14 ++++ 2 files changed, 92 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfoResponse.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java new file mode 100644 index 00000000..9aa93ed8 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java @@ -0,0 +1,78 @@ +package com.seoultech.synergybe.domain.library.dto.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +@Getter +@NoArgsConstructor +@AllArgsConstructor +public class SeoulPublicLibraryInfo { + @JsonProperty("list_total_count") + private int listTotalCount; + + @JsonProperty("RESULT") + private Result RESULT; + + @JsonProperty("row") + private List row; + + @Getter + @NoArgsConstructor + @AllArgsConstructor + public static class Result { + @JsonProperty("CODE") + private String CODE; + + @JsonProperty("MESSAGE") + private String MESSAGE; + } + + @Getter + @NoArgsConstructor + @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) + @AllArgsConstructor + public static class RawLibrary { + @JsonProperty("LBRRY_SEQ_NO") + private String LBRRY_SEQ_NO; + + @JsonProperty("LBRRY_NAME") + private String LBRRY_NAME; + + @JsonProperty("GU_CODE") + private String GU_CODE; + + @JsonProperty("CODE_VALUE") + private String CODE_VALUE; + + @JsonProperty("ADRES") + private String ADRES; + + @JsonProperty("TEL_NO") + private String TEL_NO; + + @JsonProperty("HMPG_URL") + private String HMPG_URL; + + @JsonProperty("OP_TIME") + private String OP_TIME; + + @JsonProperty("FDRM_CLOSE_DATE") + private String FDRM_CLOSE_DATE; + + @JsonProperty("LBRRY_SE_NAME") + private String LBRRY_SE_NAME; + + @JsonProperty("XCNTS") + private String XCNTS; + + @JsonProperty("YDNTS") + private String YDNTS; + } +} \ No newline at end of file diff --git a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfoResponse.java b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfoResponse.java new file mode 100644 index 00000000..d32d1d69 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfoResponse.java @@ -0,0 +1,14 @@ +package com.seoultech.synergybe.domain.library.dto.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class SeoulPublicLibraryInfoResponse { + @JsonProperty("SeoulPublicLibraryInfo") + private SeoulPublicLibraryInfo seoulPublicLibraryInfo; +} From e64c3c679247b498cebb2cf88123c43b0de3d1de Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 17:50:04 +0900 Subject: [PATCH 17/44] =?UTF-8?q?#79=20feat=20:=20enableScheduling=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/seoultech/synergybe/SynergyBeApplication.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/SynergyBeApplication.java b/src/main/java/com/seoultech/synergybe/SynergyBeApplication.java index 0a8620f5..5286a242 100644 --- a/src/main/java/com/seoultech/synergybe/SynergyBeApplication.java +++ b/src/main/java/com/seoultech/synergybe/SynergyBeApplication.java @@ -2,12 +2,10 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.properties.ConfigurationPropertiesScan; -import org.springframework.cache.annotation.EnableCaching; -import org.springframework.data.jpa.repository.config.EnableJpaAuditing; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication +@EnableScheduling public class SynergyBeApplication { public static void main(String[] args) { SpringApplication.run(SynergyBeApplication.class, args); From bb53f07086c82ae7af757f307f3ceeb611f6a1c7 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 17:50:24 +0900 Subject: [PATCH 18/44] =?UTF-8?q?#79=20fix=20:=20local=20=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C=20=ED=99=98=EA=B2=BD=20=EB=A6=AC=EB=93=9C=EB=AF=B8=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 75b9f0ab..e76cf0a9 100644 --- a/README.md +++ b/README.md @@ -72,16 +72,22 @@ ## Setup Dev Environment (Local) +> Java 17이 설치되어있다고 가정합니다 +
1. synergy_be 프로젝트를 `git clone` 명령어를 통해 클론 받습니다. - git clone https://github.com/TeamSynergyy/synergy_be.git -2. app_network 이름의 네트워크를 `docker network create app_network` 명령어로 생성합니다. -3. `docker-compose.yml` 파일을 루트 디렉토리에 생성합니다. +2. 클론받은 스프링 프로젝트 실행파일 (*.jar) 을 생성합니다. + - 루트 위치에서 권한 부여를 위해 `chmod +x gradlew` 명령어 실행 + - `./gradlew build -x test` 명령어 실행 +3. app_network 이름의 네트워크를 `docker network create app_network` 명령어로 생성합니다. +4. `docker-compose.yml` 파일을 루트 디렉토리에 생성합니다. - `docker-compose.yml` 파일은 보안상 개인적으로 전달합니다. -4. `docker-compose build` 명령어로 docker 이미지를 생성합니다. -5. `docker-compose up -d` 명령어로 docker-compose 를 통해 docker 이미지를 실행 (컨테이너화) 합니다. -6. host 는 `localhost` 이며 `localhost` url을 통해 프론트 로컬 개발환경을 구성합니다. + - mac일 경우 docker-compose.yml의 mysql, mongo 에 `platform: linux/amd64` 추가 필요 +5. `docker-compose build` 명령어로 docker 이미지를 생성합니다. +6. `docker-compose up -d` 명령어로 docker-compose 를 통해 docker 이미지를 실행 (컨테이너화) 합니다. +7. host 는 `localhost` 이며 `localhost` url을 통해 프론트 로컬 개발환경을 구성합니다.
@@ -89,10 +95,11 @@ 위 로컬 개발환경 구성 순서는 아래와 같이 진행됩니다. 1. 프로젝트 clone -2. docker network 생성 -3. docker-compose.yml 파일 생성 -4. docker image 빌드 -5. docker image 실행 +2. 프로젝트 빌드 +3. docker network 생성 +4. docker-compose.yml 파일 생성 +5. docker image 빌드 +6. docker image 실행 ```
From b3dda87b26e133c5ddb9d7eb4248028dcc6cc980 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 2 May 2024 17:51:24 +0900 Subject: [PATCH 19/44] =?UTF-8?q?#79=20fix=20:=20json=20->=20object=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/dto/response/SeoulPublicLibraryInfo.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java index 9aa93ed8..2e53238e 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulPublicLibraryInfo.java @@ -3,16 +3,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import java.util.List; @Getter @NoArgsConstructor -@AllArgsConstructor public class SeoulPublicLibraryInfo { @JsonProperty("list_total_count") private int listTotalCount; @@ -25,7 +22,6 @@ public class SeoulPublicLibraryInfo { @Getter @NoArgsConstructor - @AllArgsConstructor public static class Result { @JsonProperty("CODE") private String CODE; @@ -37,7 +33,6 @@ public static class Result { @Getter @NoArgsConstructor @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) - @AllArgsConstructor public static class RawLibrary { @JsonProperty("LBRRY_SEQ_NO") private String LBRRY_SEQ_NO; From eb8e1bc3d35084c56e8132c250c206514ca09c22 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:12:30 +0900 Subject: [PATCH 20/44] =?UTF-8?q?#94=20feat=20:=20RawPublicLibrary=20->=20?= =?UTF-8?q?PublicLibrary=20=EB=B3=80=ED=99=98=20=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=A4=84=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/PublicLibraryScheduler.java | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java new file mode 100644 index 00000000..723da10e --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java @@ -0,0 +1,42 @@ +package com.seoultech.synergybe.domain.library.scheduler; + +import com.seoultech.synergybe.domain.library.domain.PublicLibrary; +import com.seoultech.synergybe.domain.library.domain.RawPublicLibrary; +import com.seoultech.synergybe.domain.library.repository.PublicLibraryRepository; +import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Slf4j +@Component +@RequiredArgsConstructor +public class PublicLibraryScheduler { + private final PublicLibraryRepository publicLibraryRepository; + private final RawPublicLibraryRepository rawPublicLibraryRepository; + + // @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") + @Scheduled(fixedDelay = 20000) + public void updatePublicLibrary() { + log.info("update Public Library"); + + List rawPublicLibraryList = rawPublicLibraryRepository.findAll(); + + List publicLibraries = rawPublicLibraryList.stream().map( + rawPublicLibrary -> PublicLibrary.builder() + .name(rawPublicLibrary.getName()) + .address(rawPublicLibrary.getAddress()) + .telNumber(rawPublicLibrary.getTelNumber()) + .homepageUrl(rawPublicLibrary.getHompageUrl()) + .opTime(rawPublicLibrary.getOpTime()) + .closeDate(rawPublicLibrary.getCloseDate()) + .build() + ).toList(); + + // 약 120개로 데이터가 크지 않은점을 고려 + publicLibraryRepository.saveAll(publicLibraries); + } +} From 0b0a9c99eaccaa5c3dcd743a727d9f7a84d76b40 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:12:46 +0900 Subject: [PATCH 21/44] =?UTF-8?q?#94=20feat=20:=20=EC=9E=91=EC=9D=80?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20=EC=8A=A4=EC=BC=80=EC=A4=84?= =?UTF-8?q?=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/scheduler/RawSmallLibraryScheduler.java | 13 +++++++++++++ .../library/scheduler/SmallLibraryScheduler.java | 4 ++++ 2 files changed, 17 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java new file mode 100644 index 00000000..fee7ae77 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java @@ -0,0 +1,13 @@ +package com.seoultech.synergybe.domain.library.scheduler; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +@Component +@RequiredArgsConstructor +@Transactional +@Slf4j +public class RawSmallLibraryScheduler { +} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java new file mode 100644 index 00000000..2b35d5ab --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java @@ -0,0 +1,4 @@ +package com.seoultech.synergybe.domain.library.scheduler; + +public class SmallLibraryScheduler { +} From 110a29942ede914b970568339f3864db50488527 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:28:38 +0900 Subject: [PATCH 22/44] =?UTF-8?q?#79=20feat=20:=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=20BadRequest=20=EC=98=88=EC=99=B8=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/exception/LibraryBadRequestException.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/exception/LibraryBadRequestException.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/exception/LibraryBadRequestException.java b/src/main/java/com/seoultech/synergybe/domain/library/exception/LibraryBadRequestException.java new file mode 100644 index 00000000..572c6819 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/exception/LibraryBadRequestException.java @@ -0,0 +1,11 @@ +package com.seoultech.synergybe.domain.library.exception; + +import com.seoultech.synergybe.system.exception.BadRequestException; + +import static com.seoultech.synergybe.system.exception.ErrorCode.BAD_REQUEST; + +public class LibraryBadRequestException extends BadRequestException { + public LibraryBadRequestException(String message) { + super(BAD_REQUEST, message); + } +} From d128a0c33c8471e3ef271588a943d62df55b9ce2 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:28:56 +0900 Subject: [PATCH 23/44] =?UTF-8?q?#79=20feat=20:=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=20BadRequest=20=EC=98=88=EC=99=B8=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/library/vo/LibraryLocation.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java b/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java index 59dd902f..3d96add2 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/vo/LibraryLocation.java @@ -1,6 +1,6 @@ package com.seoultech.synergybe.domain.library.vo; -import com.seoultech.synergybe.domain.project.exception.ProjectBadRequestException; +import com.seoultech.synergybe.domain.library.exception.LibraryBadRequestException; import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import lombok.AccessLevel; @@ -24,7 +24,7 @@ public LibraryLocation(Point value) { private void validateNotNull(Point value) { if (value == null) { - throw new ProjectBadRequestException("위치 정보는 필수 항목입니다."); + throw new LibraryBadRequestException("위치 정보는 필수 항목입니다."); } } From 354060dbe4174792031c43d07c2d1c85b97c64df Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:29:11 +0900 Subject: [PATCH 24/44] =?UTF-8?q?#79=20feat=20:=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=20=EC=83=9D=EC=84=B1=EC=8B=9C=20IdGenerator=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/library/domain/PublicLibrary.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java index a5b0bd6f..2551f15d 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/PublicLibrary.java @@ -41,6 +41,7 @@ public class PublicLibrary { @Builder public PublicLibrary( + String id, String name, String address, String telNumber, @@ -49,6 +50,7 @@ public PublicLibrary( String closeDate, Point location ) { + this.id = id; this.name = name; this.address = address; this.telNumber = telNumber; From 5a15fb4d39fa95c8ecfa0df09b7c64264a59e334 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:29:30 +0900 Subject: [PATCH 25/44] =?UTF-8?q?#79=20feat=20:=20=EB=8F=84=EC=84=9C?= =?UTF-8?q?=EA=B4=80=20=EC=83=9D=EC=84=B1=EC=8B=9C=20IdGenerator=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../library/scheduler/PublicLibraryScheduler.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java index 723da10e..d37f0242 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java @@ -1,11 +1,14 @@ package com.seoultech.synergybe.domain.library.scheduler; +import com.seoultech.synergybe.domain.common.idgenerator.IdGenerator; +import com.seoultech.synergybe.domain.common.idgenerator.IdPrefix; import com.seoultech.synergybe.domain.library.domain.PublicLibrary; import com.seoultech.synergybe.domain.library.domain.RawPublicLibrary; import com.seoultech.synergybe.domain.library.repository.PublicLibraryRepository; import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.geo.Point; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -17,9 +20,10 @@ public class PublicLibraryScheduler { private final PublicLibraryRepository publicLibraryRepository; private final RawPublicLibraryRepository rawPublicLibraryRepository; + private final IdGenerator idGenerator; - // @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") - @Scheduled(fixedDelay = 20000) + @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") +// @Scheduled(fixedDelay = 20000) public void updatePublicLibrary() { log.info("update Public Library"); @@ -27,12 +31,14 @@ public void updatePublicLibrary() { List publicLibraries = rawPublicLibraryList.stream().map( rawPublicLibrary -> PublicLibrary.builder() + .id(idGenerator.generateId(IdPrefix.LIBRARY)) .name(rawPublicLibrary.getName()) .address(rawPublicLibrary.getAddress()) .telNumber(rawPublicLibrary.getTelNumber()) .homepageUrl(rawPublicLibrary.getHompageUrl()) .opTime(rawPublicLibrary.getOpTime()) .closeDate(rawPublicLibrary.getCloseDate()) + .location(new Point(rawPublicLibrary.getLatitude(), rawPublicLibrary.getLatitude())) .build() ).toList(); From 646fec6e158fc6d90bf77341b70dcfcf033e93e9 Mon Sep 17 00:00:00 2001 From: rivkode Date: Wed, 8 May 2024 17:29:44 +0900 Subject: [PATCH 26/44] =?UTF-8?q?#79=20fix=20:=20=EC=8A=A4=EC=BC=80?= =?UTF-8?q?=EC=A4=84=EB=9F=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/scheduler/RawPublicLibraryScheduler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java index 5dbfa020..f35c91fa 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java @@ -48,8 +48,8 @@ public class RawPublicLibraryScheduler { * 여섯 번째 필드: 요일 (0-6, 일요일부터 토요일까지, 일요일=0 또는 7) * 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. */ -// @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") - @Scheduled(fixedDelay = 10000) + @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") +// @Scheduled(fixedDelay = 10000) public void updateRawLibrary() throws JSONException, JsonProcessingException { log.info("================시작"); countTotalData(); From 92c54784df024a8cd1094c027f23cf8bbe0b14fc Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 10:10:23 +0900 Subject: [PATCH 27/44] =?UTF-8?q?#94=20fix=20:=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EA=B2=80=EC=A6=9D=20=EC=B6=94=EA=B0=80=20/=20=EC=B1=84?= =?UTF-8?q?=ED=8C=85=20=EC=A0=84=EC=86=A1=EC=8B=9C=20=EC=A0=80=EC=9E=A5?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=B1=85=EC=9E=84=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/chat/handler/ChatHandler.java | 65 ++++++++++++------- 1 file changed, 41 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java index 345c3357..94bde91d 100644 --- a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java +++ b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java @@ -4,6 +4,8 @@ import com.seoultech.synergybe.domain.chat.domain.ChatType; import com.seoultech.synergybe.domain.chat.dto.request.ChatMessageRequest; import com.seoultech.synergybe.domain.chat.service.ChatMessageService; +import com.seoultech.synergybe.domain.user.User; +import com.seoultech.synergybe.domain.user.service.UserService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; @@ -20,35 +22,42 @@ @Component //@RequiredArgsConstructor public class ChatHandler extends TextWebSocketHandler { -// private static List webSocketSessions = new ArrayList<>(); private WebSocketSessionMap webSocketSessionMap; // 채팅방별 세션리스트 모음 private ObjectMapper objectMapper; private ChatMessageService chatMessageService; + private UserService userService; // 채팅 핸들러 생성 - public ChatHandler(ObjectMapper objectMapper, ChatMessageService chatMessageService) { + public ChatHandler(ObjectMapper objectMapper, ChatMessageService chatMessageService, UserService userService) { this.webSocketSessionMap = new WebSocketSessionMap(); this.objectMapper = objectMapper; this.chatMessageService = chatMessageService; + this.userService = userService; } @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { -// webSocketSessions.add(session); - Long chatRoomId = webSocketSessionMap.getKeyFromSession(session); - - // 여기서 request를 어떻게 알지 ? - if (chatRoomId == null) { - // 채팅방 생성 -// chatRoomService.createRoom(); - } - - -// log.info("session add : " + session.getId()); } + // todo + // 좀 더 책임을 나누자 + + /** + * 전체 로직 + * - TextMessage에서 payLoad를 가져옴 + * - payLoad 값을 통해 objectMapper를 사용하여 ChatMessageRequest Dto 로 변환 + * - payLoad에 담긴 userId를 통해 user 검증 + * - payLoad에 담긴 chatRoomId를 통해 websocketList 탐색 + * - 만약 없으면 생성 + * - chatType이 ENTER일 경우 session 에 add + * - chatType이 TEXT일 경우 sendMessage(), saveMessage() 호출 + * - websocket connection을 close할 경우 해당 session을 websocket List에서 remove + * @param session + * @param message + * @throws Exception + */ @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { String payLoad = message.getPayload(); @@ -58,6 +67,10 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) ChatMessageRequest chatMessageRequest = objectMapper.readValue(payLoad, ChatMessageRequest.class); log.info("session {}", chatMessageRequest.toString()); + // 유저 검증 + userService.getUser(chatMessageRequest.userId()); + + // payload에 chatroomId 가져옴 Long chatRoomId = chatMessageRequest.chatRoomId(); @@ -80,18 +93,27 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) // 만약 입장하는 경우라면 (Type이 Enter 라면) if (chatMessageRequest.chatType().equals(ChatType.ENTER)) { + // afterConnectionEstablished -> 이 메소들 사용해서 session add는 안되는지 다시 고민 // afterConnectionEstablished(session); + log.info("before add session List size : {}", webSocketSessionList.getWebSocketSessions().size()); // 현재 들어온 세션을 해당 채팅방 세션리스트에 추가 webSocketSessionList.getWebSocketSessions().add(session); - log.info("session add / session Id : {}", session.getId()); + log.info("session add | session Id : {}", session.getId()); } // 만약 텍스트를 보낸다면 if (chatMessageRequest.chatType().equals(ChatType.TEXT)) { + log.info("websocket Session List size : {}",webSocketSessionList.getWebSocketSessions().size()); + // 채팅 전송 - sendAndSaveMessageToChatRoom(chatMessageRequest, webSocketSessionList); - } + sendMessageToChatRoom(chatMessageRequest, webSocketSessionList); + // 한사람에 대해서만 저장을 해야함 + saveMessage(chatMessageRequest); + } else if (chatMessageRequest.chatType().equals(ChatType.IMAGE)) { + // todo + // 이미지 혹은 영상 처리 + } } @@ -100,8 +122,6 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { Long chatRoomId = webSocketSessionMap.getKeyFromSession(session); - - // 얘가 호출되니까 여기서 removeClosedSession을 호출해야지 // 그런데 roomId로 해당하는 채팅방의 채팅세션리스트들을 가져와야하는데 ? // 그 내용을 넣어줄 수 있을까 ? @@ -110,21 +130,18 @@ public void afterConnectionClosed(WebSocketSession session, CloseStatus status) List webSocketSessions = getSessionListByChatRoomId(chatRoomId); webSocketSessions.remove(session); - log.info("session remove / session Id : {}", session.getId()); + log.info("session remove | session Id : {}", session.getId()); + log.info("after connection closed session List size : {}",webSocketSessions.size()); } private List getSessionListByChatRoomId(Long chatRoomId) { return webSocketSessionMap.getWebsocketListHashMap().get(chatRoomId).getWebSocketSessions(); } - private void sendAndSaveMessageToChatRoom(ChatMessageRequest chatMessageRequest, WebSocketSessionList webSocketSessionList) { + private void sendMessageToChatRoom(ChatMessageRequest chatMessageRequest, WebSocketSessionList webSocketSessionList) { for (WebSocketSession session : webSocketSessionList.getWebSocketSessions()) { sendMessage(session, chatMessageRequest.message()); - saveMessage(chatMessageRequest); } - -// webSocketSessionList.getWebSocketSessions().parallelStream().forEach(sess -> sendMessage(sess, chatMessageRequest.message())); - } private void saveMessage(ChatMessageRequest chatMessageRequest) { From 22b8b41b45a59509d745b9aa076311a0473340d4 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 10:11:13 +0900 Subject: [PATCH 28/44] =?UTF-8?q?#94=20remove=20:=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/seoultech/synergybe/domain/chat/handler/ChatHandler.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java index 94bde91d..779f0370 100644 --- a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java +++ b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java @@ -20,7 +20,6 @@ @Slf4j @Component -//@RequiredArgsConstructor public class ChatHandler extends TextWebSocketHandler { private WebSocketSessionMap webSocketSessionMap; // 채팅방별 세션리스트 모음 private ObjectMapper objectMapper; From 954969bdfa16b1446d1b7cd9b2de9d2030e383bd Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 15:54:22 +0900 Subject: [PATCH 29/44] #79 fix : README.md update --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e76cf0a9..ee6d97f5 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,16 @@ **(프로젝트, 게시글, 팀원을 추천하는 기능을 통해 원활한 프로젝트 진행을 지원합니다)** +
## Infra Architecture logo + +
+ + ## Skills
@@ -70,6 +75,8 @@
+
+ ## Setup Dev Environment (Local) > Java 17이 설치되어있다고 가정합니다 @@ -126,9 +133,12 @@ docker pull jonghuni/synergy_be - 프로젝트 신청, 수락, 거절 - 프로젝트 평가 +
## Directory +
+
파일 구조 보기 @@ -295,19 +305,27 @@ src - 로그인(첫 소셜로그인시 자동 회원가입) - 회원 정보 변경 +
+ ### API Lists - login (users/auth/login) - 로그인, 회원가입을 수행합니다. 로그인 성공시 token을 발급하며 이후 요청에 대해서 해당 토큰으로 인증을 진행합니다. - updateMyInfo (users/me/info) - 회원 정보를 변경합니다. +
+ #### Using stack - Spring Boot, Java 11, Spring Data JPA, Mysql, Lombok, Gradle, JWT +
+ ### Sequence Diagram Example (회원 가입, JWT 토큰 인증 프로세스) logo +
+ ## Recommend Service 사용자가 가진 활동들을 바탕으로 사용자에게 알맞는 컨텐츠(게시글, 프로젝트, 유저)를 추천해주는 기능을 제공하는 서비스입니다. @@ -316,6 +334,8 @@ src - 추천 기능이 동작하는 FastAPI 서버를 docker Image화 하여 docker 컨테이너 위에서 실행 (메인서버 또한 Image화 하여 컨테이너위에서 실행) - DB와 메인 서버로부터 데이터와 API 요청을 받아 모델학습 및 추천을 수행 +
+ ### API List - getRecommendProjects (projects/recommend) @@ -325,10 +345,16 @@ src - getSimilarUsers (users/recommend) - 유저 활동을 바탕으로 적합한 유저를 추천합니다. +
+ ### Sequence Diagram Example (컨텐츠 추천 프로세스) +
+ logo +
+ ## Project Service 사용자가 팀원을 구성하며 팀 프로젝트를 진행하며 공지시항, 일정, 티켓 관리, 평가 등의 @@ -336,18 +362,41 @@ src - 티켓 관리 기능의 경우 티켓을 칸반보드로 관리하는 기능으로 각 Status별로 나누어 티켓들을 올바른 위치로 이동하게끔 구현 +
+ ### API List - changePositionTicket (tickets/change/{ticketId}) - 티켓 위치 변경 기능을 제공합니다. +
+ ### Sequence Diagram Example (프로젝트 팀원 참가 신청 프로세스) logo +
+ ### Sequence Diagram Example (티켓 위치 변경 프로세스) logo +
+
+ +## 고민 흔적 + +- [좋은 객체 ID 만들기 블로그 - click](https://velog.io/@rivkode/ID-%EC%83%9D%EC%84%B1%EA%B8%B0-%EA%B5%AC%ED%98%84%EC%9D%84-%ED%95%B4%EB%B3%B4%EC%95%84%EC%9A%94-2%ED%83%84) + - 좋은 객체 ID를 만들기 위해 아래 4가지 사항을 고려하여 만들기 위해 노력하였습니다. + - 고유성 + - 식별 가능성 + - 보안성 + - 생성 시간순 정렬 + - 관련 PR + - [ID 생성기 구현](https://github.com/TeamSynergyy/synergy_be/pull/70) +- [WebSocket 을 이해하며 채팅서비스를 구현해보아요 | MySQL, MongoDB](https://velog.io/@rivkode/WebSocket-%EC%9D%84-%EC%9D%B4%ED%95%B4%ED%95%98%EB%A9%B0-%EC%B1%84%ED%8C%85%EC%84%9C%EB%B9%84%EC%8A%A4%EB%A5%BC-%EA%B5%AC%ED%98%84%ED%95%B4%EB%B3%B4%EC%95%84%EC%9A%94-MySQL-MongoDB) + - 채팅 서비스를 구현하기 위해 아래 사항들을 고려해보았습니다. + - 웹소켓 프로토콜 이해 + - 실시간성 보장
@@ -383,17 +432,6 @@ https://github.com/TeamSynergyy/synergy_be/assets/109144975/46ca7bdf-9372-49b0-9 https://github.com/TeamSynergyy/synergy_be/assets/109144975/ada92a51-bc5e-41a8-b0aa-cfef4a11d66b -## 고민 흔적 - -- [좋은 객체 ID 만들기 블로그 - click](https://velog.io/@rivkode/ID-%EC%83%9D%EC%84%B1%EA%B8%B0-%EA%B5%AC%ED%98%84%EC%9D%84-%ED%95%B4%EB%B3%B4%EC%95%84%EC%9A%94-2%ED%83%84) - - 좋은 객체 ID를 만들기 위해 아래 4가지 사항을 고려하여 만들기 위해 노력하였습니다. - - 고유성 - - 식별 가능성 - - 보안성 - - 생성 시간순 정렬 - - 관련 PR - - [ID 생성기 구현](https://github.com/TeamSynergyy/synergy_be/pull/70) - ## 발표 PPT From 9f390433c89201206e86e12d686105449fa7040e Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 15:54:42 +0900 Subject: [PATCH 30/44] =?UTF-8?q?#79=20feat=20:=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20=EC=9A=94=EC=B2=AD=20WebSocket=20=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/exception/WebSocketBadRequestException.java | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/chat/exception/WebSocketBadRequestException.java diff --git a/src/main/java/com/seoultech/synergybe/domain/chat/exception/WebSocketBadRequestException.java b/src/main/java/com/seoultech/synergybe/domain/chat/exception/WebSocketBadRequestException.java new file mode 100644 index 00000000..f6668c52 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/chat/exception/WebSocketBadRequestException.java @@ -0,0 +1,10 @@ +package com.seoultech.synergybe.domain.chat.exception; + +import com.seoultech.synergybe.system.exception.BadRequestException; +import com.seoultech.synergybe.system.exception.ErrorCode; + +public class WebSocketBadRequestException extends BadRequestException { + public WebSocketBadRequestException(ErrorCode errorCode, String message) { + super(errorCode, message); + } +} From 5e5f23a03e9d937f94a7a3af343f2e06c4336dfd Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 15:54:47 +0900 Subject: [PATCH 31/44] =?UTF-8?q?#79=20feat=20:=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20=EC=9A=94=EC=B2=AD=20WebSocket=20=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/chat/handler/WebSocketSessionMap.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/chat/handler/WebSocketSessionMap.java b/src/main/java/com/seoultech/synergybe/domain/chat/handler/WebSocketSessionMap.java index da40e922..9628f7c5 100644 --- a/src/main/java/com/seoultech/synergybe/domain/chat/handler/WebSocketSessionMap.java +++ b/src/main/java/com/seoultech/synergybe/domain/chat/handler/WebSocketSessionMap.java @@ -1,5 +1,7 @@ package com.seoultech.synergybe.domain.chat.handler; +import com.seoultech.synergybe.domain.chat.exception.WebSocketBadRequestException; +import com.seoultech.synergybe.system.exception.ErrorCode; import lombok.Getter; import org.springframework.stereotype.Component; import org.springframework.web.socket.WebSocketSession; @@ -24,6 +26,6 @@ public Long getKeyFromSession(WebSocketSession session) { return entry.getKey(); } } - return null; // 세션을 찾지 못한 경우 + throw new WebSocketBadRequestException(ErrorCode.BAD_REQUEST, "채팅방 세션을 찾을 수 없습니다."); } } From ee493ae66df4475016bda3397dddf7ac5df11a42 Mon Sep 17 00:00:00 2001 From: rivkode Date: Thu, 9 May 2024 15:55:01 +0900 Subject: [PATCH 32/44] =?UTF-8?q?#79=20feat=20:=20=EC=9E=98=EB=AA=BB?= =?UTF-8?q?=EB=90=9C=20=EC=9A=94=EC=B2=AD=20WebSocket=20=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/chat/handler/ChatHandler.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java index 779f0370..a31fef00 100644 --- a/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java +++ b/src/main/java/com/seoultech/synergybe/domain/chat/handler/ChatHandler.java @@ -3,9 +3,11 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.seoultech.synergybe.domain.chat.domain.ChatType; import com.seoultech.synergybe.domain.chat.dto.request.ChatMessageRequest; +import com.seoultech.synergybe.domain.chat.exception.WebSocketBadRequestException; import com.seoultech.synergybe.domain.chat.service.ChatMessageService; import com.seoultech.synergybe.domain.user.User; import com.seoultech.synergybe.domain.user.service.UserService; +import com.seoultech.synergybe.system.exception.ErrorCode; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; import org.springframework.web.socket.CloseStatus; @@ -67,7 +69,10 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) log.info("session {}", chatMessageRequest.toString()); // 유저 검증 - userService.getUser(chatMessageRequest.userId()); + User user = userService.getUser(chatMessageRequest.userId()); + if (user == null) { + throw new WebSocketBadRequestException(ErrorCode.BAD_REQUEST, "유효하지 않은 유저의 메세지 요청입니다."); + } // payload에 chatroomId 가져옴 @@ -98,10 +103,8 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) // 현재 들어온 세션을 해당 채팅방 세션리스트에 추가 webSocketSessionList.getWebSocketSessions().add(session); log.info("session add | session Id : {}", session.getId()); - } - // 만약 텍스트를 보낸다면 - if (chatMessageRequest.chatType().equals(ChatType.TEXT)) { + } else if (chatMessageRequest.chatType().equals(ChatType.TEXT)) { log.info("websocket Session List size : {}",webSocketSessionList.getWebSocketSessions().size()); // 채팅 전송 @@ -109,6 +112,7 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message) // 한사람에 대해서만 저장을 해야함 saveMessage(chatMessageRequest); + } else if (chatMessageRequest.chatType().equals(ChatType.IMAGE)) { // todo // 이미지 혹은 영상 처리 From ba55a709775a80942e4b8ef1911a0297cbc0c4f2 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 13:25:26 +0900 Subject: [PATCH 33/44] =?UTF-8?q?#96=20fix=20:=20gradle=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=EC=9C=BC=EB=A1=9C=20=EC=97=90=EB=9F=AC=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0=20configuration-processor=20->=20json:json:20231013?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 37c358f0..43835955 100644 --- a/build.gradle +++ b/build.gradle @@ -30,13 +30,10 @@ dependencies { // implementation 'org.springframework.boot:spring-boot-starter-data-redis' //security -// implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' implementation 'org.springframework.boot:spring-boot-starter-security' - // 좌표 저장 -// implementation 'org.hibernate', name: 'hibernate-spatial' - - annotationProcessor "org.springframework.boot:spring-boot-configuration-processor" + // json + implementation 'org.json:json:20231013' //lombok compileOnly 'org.projectlombok:lombok' From ed8dc0770ac8ccd3897c865b945b3bffe6f726e1 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 13:25:57 +0900 Subject: [PATCH 34/44] =?UTF-8?q?#79=20remove=20:=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/scheduler/PublicLibraryScheduler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java index d37f0242..a6709b68 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java @@ -22,8 +22,7 @@ public class PublicLibraryScheduler { private final RawPublicLibraryRepository rawPublicLibraryRepository; private final IdGenerator idGenerator; - @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") -// @Scheduled(fixedDelay = 20000) + @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") public void updatePublicLibrary() { log.info("update Public Library"); From 666dc160f9cb5373a14b78f1b4ef4a833a2a8e19 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 13:26:48 +0900 Subject: [PATCH 35/44] =?UTF-8?q?#96=20fix=20:=20import=20=EC=88=98?= =?UTF-8?q?=EC=A0=95=20/=20gradle=20=EC=88=98=EC=A0=95=EC=9C=BC=EB=A1=9C?= =?UTF-8?q?=20=EC=97=90=EB=9F=AC=20=ED=95=B4=EA=B2=B0=20configuration-proc?= =?UTF-8?q?essor=20->=20json:json:20231013?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/RawPublicLibraryScheduler.java | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java index f35c91fa..56f5cc72 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java @@ -9,9 +9,9 @@ import com.seoultech.synergybe.domain.library.repository.RawPublicLibraryRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.json.JSONException; +import org.json.JSONObject; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.configurationprocessor.json.JSONException; -import org.springframework.boot.configurationprocessor.json.JSONObject; import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Scheduled; @@ -49,15 +49,14 @@ public class RawPublicLibraryScheduler { * 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. */ @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") -// @Scheduled(fixedDelay = 10000) - public void updateRawLibrary() throws JSONException, JsonProcessingException { + public void updateRawLibrary() throws JsonProcessingException { log.info("================시작"); countTotalData(); updatePublicLibrary(); log.info("=================끝"); } - private void countTotalData() throws JSONException { + private void countTotalData() { UriComponents uriComponents = UriComponentsBuilder .newInstance() .scheme("http") @@ -71,13 +70,18 @@ private void countTotalData() throws JSONException { ResponseEntity responseEntity = restTemplate.exchange(requestEntity, String.class); log.info(responseEntity.getBody()); - dataCount = new JSONObject(responseEntity.getBody()) - .getJSONObject("SeoulPublicLibraryInfo") - .getInt("list_total_count"); + try { + dataCount = new JSONObject(responseEntity.getBody()) + .getJSONObject("SeoulPublicLibraryInfo") + .getInt("list_total_count"); + } catch (JSONException jsonException) { + log.error("JSONException {}", jsonException.toString()); + } + log.info("dataCount : " + dataCount); } - public void updatePublicLibrary() throws JsonProcessingException, JSONException { + public void updatePublicLibrary() { List libraries = getPublicLibraryFromOpenApi(); // stream api로 @@ -104,7 +108,7 @@ public void updatePublicLibrary() throws JsonProcessingException, JSONException } - private List getPublicLibraryFromOpenApi() throws JsonProcessingException, JSONException { + private List getPublicLibraryFromOpenApi() { int start; List rawLibraries = new ArrayList<>(); for (start = 1; start <= dataCount; start += BATCH_SIZE) { From 3a812eb4e79c3b270ff0a6d43c37ac6d098d2274 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 13:35:18 +0900 Subject: [PATCH 36/44] =?UTF-8?q?#79=20fix=20:=20GetUserAccountResponse=20?= =?UTF-8?q?=EC=86=8D=EC=84=B1=EC=9C=BC=EB=A1=9C=20userId=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/dto/response/GetUserAccountResponse.java | 4 +++- .../seoultech/synergybe/domain/user/service/UserService.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/user/dto/response/GetUserAccountResponse.java b/src/main/java/com/seoultech/synergybe/domain/user/dto/response/GetUserAccountResponse.java index 1435320f..251cd1eb 100644 --- a/src/main/java/com/seoultech/synergybe/domain/user/dto/response/GetUserAccountResponse.java +++ b/src/main/java/com/seoultech/synergybe/domain/user/dto/response/GetUserAccountResponse.java @@ -5,13 +5,15 @@ @Builder public record GetUserAccountResponse( + String userId, String email, String name, String major, Double temperature ) { @QueryProjection - public GetUserAccountResponse(String email, String name, String major, Double temperature) { + public GetUserAccountResponse(String userId, String email, String name, String major, Double temperature) { + this.userId = userId; this.email = email; this.name = name; this.major = major; diff --git a/src/main/java/com/seoultech/synergybe/domain/user/service/UserService.java b/src/main/java/com/seoultech/synergybe/domain/user/service/UserService.java index 49ffd969..7487f56b 100644 --- a/src/main/java/com/seoultech/synergybe/domain/user/service/UserService.java +++ b/src/main/java/com/seoultech/synergybe/domain/user/service/UserService.java @@ -79,6 +79,7 @@ public GetUserAccountResponse getUserInfo(String userId) { User user = getUser(userId); return GetUserAccountResponse.builder() + .userId(user.getId()) .email(user.getEmail().getEmail()) .major(user.getMajor().getMajor()) .name(user.getName().getName()) From b8f0052e342eba528978f8d8e743267f2179a24b Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:00:18 +0900 Subject: [PATCH 37/44] =?UTF-8?q?#79=20fix=20:=20=EC=9E=91=EC=9D=80=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20=EC=9D=91=EB=8B=B5=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/response/SeoulSmallLibraryInfo.java | 73 +++++++++++++++++++ .../response/SeoulSmallLibraryResponse.java | 14 ++++ 2 files changed, 87 insertions(+) create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryInfo.java create mode 100644 src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryResponse.java diff --git a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryInfo.java b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryInfo.java new file mode 100644 index 00000000..5f4025c4 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryInfo.java @@ -0,0 +1,73 @@ +package com.seoultech.synergybe.domain.library.dto.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.PropertyNamingStrategy; +import com.fasterxml.jackson.databind.annotation.JsonNaming; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.util.List; + +@Getter +@NoArgsConstructor +public class SeoulSmallLibraryInfo { + @JsonProperty("list_total_count") + private int listTotalCount; + + @JsonProperty("RESULT") + private SeoulPublicLibraryInfo.Result RESULT; + + @JsonProperty("row") + private List row; + + @Getter + @NoArgsConstructor + public static class Result { + @JsonProperty("CODE") + private String CODE; + + @JsonProperty("MESSAGE") + private String MESSAGE; + } + + @Getter + @NoArgsConstructor + @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) + public static class RawLibrary { + @JsonProperty("LBRRY_SEQ_NO") + private String LBRRY_SEQ_NO; + + @JsonProperty("LBRRY_NAME") + private String LBRRY_NAME; + + @JsonProperty("GU_CODE") + private String GU_CODE; + + @JsonProperty("CODE_VALUE") + private String CODE_VALUE; + + @JsonProperty("ADRES") + private String ADRES; + + @JsonProperty("TEL_NO") + private String TEL_NO; + + @JsonProperty("HMPG_URL") + private String HMPG_URL; + + @JsonProperty("OP_TIME") + private String OP_TIME; + + @JsonProperty("FDRM_CLOSE_DATE") + private String FDRM_CLOSE_DATE; + + @JsonProperty("LBRRY_SE_NAME") + private String LBRRY_SE_NAME; + + @JsonProperty("XCNTS") + private String XCNTS; + + @JsonProperty("YDNTS") + private String YDNTS; + } +} diff --git a/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryResponse.java b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryResponse.java new file mode 100644 index 00000000..08ef4855 --- /dev/null +++ b/src/main/java/com/seoultech/synergybe/domain/library/dto/response/SeoulSmallLibraryResponse.java @@ -0,0 +1,14 @@ +package com.seoultech.synergybe.domain.library.dto.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class SeoulSmallLibraryResponse { + @JsonProperty("SeoulSmallLibraryInfo") + private SeoulSmallLibraryInfo seoulSmallLibraryInfo; +} From 9fba809e5466e333cefb7f5ff26d75014f45c0d0 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:00:33 +0900 Subject: [PATCH 38/44] =?UTF-8?q?#79=20fix=20:=20=EC=9E=91=EC=9D=80=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20Jpa=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/repository/RawSmallLibraryRepository.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java index 00f588ce..a0d00b7b 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/repository/RawSmallLibraryRepository.java @@ -1,4 +1,7 @@ package com.seoultech.synergybe.domain.library.repository; -public interface RawSmallLibraryRepository { +import com.seoultech.synergybe.domain.library.domain.RawSmallLibrary; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface RawSmallLibraryRepository extends JpaRepository { } From 81cd8b76c2c484edecfd60e575ae0bdd8ea76eda Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:01:24 +0900 Subject: [PATCH 39/44] =?UTF-8?q?#79=20fix=20:=20=EA=B3=B5=EA=B3=B5=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20batch=20size=20=EB=B3=84=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/PublicLibraryScheduler.java | 2 +- .../scheduler/RawPublicLibraryScheduler.java | 24 ++++++++----------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java index a6709b68..735e224d 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java @@ -22,7 +22,7 @@ public class PublicLibraryScheduler { private final RawPublicLibraryRepository rawPublicLibraryRepository; private final IdGenerator idGenerator; - @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") + @Scheduled(cron = "0 0 4 * * 6", zone = "Asia/Seoul") public void updatePublicLibrary() { log.info("update Public Library"); diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java index 56f5cc72..2092f77d 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawPublicLibraryScheduler.java @@ -48,15 +48,15 @@ public class RawPublicLibraryScheduler { * 여섯 번째 필드: 요일 (0-6, 일요일부터 토요일까지, 일요일=0 또는 7) * 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. */ - @Scheduled(cron = "0 31 15 * * 4", zone = "Asia/Seoul") - public void updateRawLibrary() throws JsonProcessingException { + @Scheduled(cron = "0 0 4 * * 6", zone = "Asia/Seoul") + public void updateRawPublicLibrary() { log.info("================시작"); - countTotalData(); - updatePublicLibrary(); + countRawPublicLibraryTotalData(); + savePublicLibraryFromOpenApi(); log.info("=================끝"); } - private void countTotalData() { + private void countRawPublicLibraryTotalData() { UriComponents uriComponents = UriComponentsBuilder .newInstance() .scheme("http") @@ -81,8 +81,8 @@ private void countTotalData() { log.info("dataCount : " + dataCount); } - public void updatePublicLibrary() { - List libraries = getPublicLibraryFromOpenApi(); + public void insertRawPublicLibrary(List libraries) { +// List libraries = getPublicLibraryFromOpenApi(); // stream api로 List rawPublicLibraries = libraries.stream() @@ -108,7 +108,7 @@ public void updatePublicLibrary() { } - private List getPublicLibraryFromOpenApi() { + private void savePublicLibraryFromOpenApi() { int start; List rawLibraries = new ArrayList<>(); for (start = 1; start <= dataCount; start += BATCH_SIZE) { @@ -146,12 +146,8 @@ private List getPublicLibraryFromOpenApi() { log.info("RawLibrary 변환중 ======================"); - // 가져온 데이터 사용 예시 -// List libraryInfos = libraryInfoResponse.getSeoulPublicLibraryInfo().getRawLibrary(); -// rawLibraries.addAll(libraryInfos); - + // batch size로 저장 + insertRawPublicLibrary(rawLibraries); } - - return rawLibraries; } } From 2841bb1a12f339bbeb314b44695702017fcdb372 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:01:31 +0900 Subject: [PATCH 40/44] =?UTF-8?q?#79=20fix=20:=20=EC=9E=91=EC=9D=80=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20batch=20size=20=EB=B3=84=20?= =?UTF-8?q?=EC=A0=80=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/RawSmallLibraryScheduler.java | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java index fee7ae77..f89e0763 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/RawSmallLibraryScheduler.java @@ -1,13 +1,143 @@ package com.seoultech.synergybe.domain.library.scheduler; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.seoultech.synergybe.domain.library.domain.RawSmallLibrary; +import com.seoultech.synergybe.domain.library.dto.response.SeoulSmallLibraryInfo; +import com.seoultech.synergybe.domain.library.dto.response.SeoulSmallLibraryResponse; +import com.seoultech.synergybe.domain.library.repository.RawSmallLibraryRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.json.JSONException; +import org.json.JSONObject; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.http.RequestEntity; +import org.springframework.http.ResponseEntity; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponents; +import org.springframework.web.util.UriComponentsBuilder; + +import java.util.ArrayList; +import java.util.List; @Component @RequiredArgsConstructor @Transactional @Slf4j public class RawSmallLibraryScheduler { + private final RestTemplate restTemplate; + private final RawSmallLibraryRepository rawSmallLibraryRepository; + + @Value("${library.api.key}") + private String libraryApiKey; + + private int dataCount; + + private final int BATCH_SIZE = 500; + + /** + * 크론 스케줄링 + * 첫 번째 필드: 초 (0-59) + * 두 번째 필드: 분 (0-59) + * 세 번째 필드: 시간 (0-23) + * 네 번째 필드: 일 (1-31) + * 다섯 번째 필드: 월 (1-12) + * 여섯 번째 필드: 요일 (0-6, 일요일부터 토요일까지, 일요일=0 또는 7) + * 데이터 총 개수를 가져와서 dataCount에 넣어줍니다. + */ + @Scheduled(cron = "0 0 4 * * 6", zone = "Asia/Seoul") + public void updateRawSmallLibrary() { + log.info("================시작"); + countRawSmallLibraryTotalData(); + saveSmallLibraryFromOpenApi(); + log.info("=================끝"); + } + + private void countRawSmallLibraryTotalData() { + UriComponents uriComponents = UriComponentsBuilder + .newInstance() + .scheme("http") + .host("openapi.seoul.go.kr") + .port(8088) + .path("/{libraryAPI}/json/SeoulSmallLibraryInfo/{start}/{end}") + .buildAndExpand(libraryApiKey, 1, 10); + + log.info("uri : " + uriComponents); + RequestEntity requestEntity = RequestEntity.get(uriComponents.toUri()).build(); + ResponseEntity responseEntity = restTemplate.exchange(requestEntity, String.class); + log.info(responseEntity.getBody()); + try { + dataCount = new JSONObject(responseEntity.getBody()) + .getJSONObject("SeoulSmallLibraryInfo") + .getInt("list_total_count"); + } catch (JSONException jsonException) { + log.error("JSONException {}", jsonException.toString()); + } + + log.info("dataCount : " + dataCount); + } + + private void insertRawSmallLibrary(List libraries) { +// List libraries = getSmallLibraryFromOpenApi(); + + // stream api + List rawSmallLibraries = libraries.stream() + .map(library -> RawSmallLibrary.builder() + .smallLibrarySeq(library.getLBRRY_SEQ_NO()) + .name(library.getLBRRY_NAME()) + .guCode(library.getGU_CODE()) + .guCodeValue(library.getCODE_VALUE()) + .address(library.getADRES()) + .telNumber(library.getTEL_NO()) + .hompageUrl(library.getHMPG_URL()) + .opTime(library.getOP_TIME()) + .closeDate(library.getFDRM_CLOSE_DATE()) + .seName(library.getLBRRY_SE_NAME()) + .latitude(Double.valueOf(library.getXCNTS())) + .longitude(Double.valueOf(library.getYDNTS())) + .build()) + .toList(); + + rawSmallLibraryRepository.saveAll(rawSmallLibraries); + } + + private void saveSmallLibraryFromOpenApi() { + int start; + List rawLibraries = new ArrayList<>(); + + for (start = 1; start <= dataCount; start += BATCH_SIZE) { + UriComponents uriComponents = UriComponentsBuilder + .newInstance() + .scheme("http") + .host("openapi.seoul.go.kr") + .port(8088) + .path("/{libraryAPI}/json/SeoulSmallLibraryInfo/{start}/{end}") + .buildAndExpand(libraryApiKey, 1, 10); + + RequestEntity requestEntity = RequestEntity.get(uriComponents.toUri()).build(); + ResponseEntity responseEntity = restTemplate.exchange(requestEntity, String.class); + log.info(responseEntity.getBody()); + + ObjectMapper objectMapper = new ObjectMapper(); + + // 내가 필요한 데이터들만 파싱하기 위해 설정 + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + + try { + SeoulSmallLibraryResponse seoulSmallLibraryResponse = objectMapper.readValue(responseEntity.getBody(), SeoulSmallLibraryResponse.class); + + rawLibraries.addAll(seoulSmallLibraryResponse.getSeoulSmallLibraryInfo().getRow()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + log.info("RawSmallLibrary 변환중 ====="); + + // batch size 로 저장 + insertRawSmallLibrary(rawLibraries); + } + } } From bc96935ca7e1b5e00afb67fda469c866f05cd0ef Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:07:20 +0900 Subject: [PATCH 41/44] =?UTF-8?q?#79=20fix=20:=20LIBRARY=20->=20SMALL=20/?= =?UTF-8?q?=20PUBLIC=20=EA=B5=AC=EB=B6=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../synergybe/domain/common/idgenerator/IdPrefix.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java b/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java index a314b3ee..44aefdb5 100644 --- a/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java +++ b/src/main/java/com/seoultech/synergybe/domain/common/idgenerator/IdPrefix.java @@ -16,7 +16,8 @@ public enum IdPrefix { PROJECT_USER("project_user"), RATE("rate"), SCHEDULE("schedule"), - LIBRARY("library"), + PUBLIC_LIBRARY("public_library"), + SMALL_LIBRARY("small_library"), TICKET("ticket"), TICKET_USER("ticket_user"); From ec3cf716f7450e2134f9dbc91c3fc78ba7f14a4d Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:07:34 +0900 Subject: [PATCH 42/44] =?UTF-8?q?#79=20fix=20:=20LIBRARY=20->=20PUBLIC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/library/scheduler/PublicLibraryScheduler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java index 735e224d..f777f445 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/PublicLibraryScheduler.java @@ -30,7 +30,7 @@ public void updatePublicLibrary() { List publicLibraries = rawPublicLibraryList.stream().map( rawPublicLibrary -> PublicLibrary.builder() - .id(idGenerator.generateId(IdPrefix.LIBRARY)) + .id(idGenerator.generateId(IdPrefix.PUBLIC_LIBRARY)) .name(rawPublicLibrary.getName()) .address(rawPublicLibrary.getAddress()) .telNumber(rawPublicLibrary.getTelNumber()) From e7e65f342f2cbeaedc476a814b094c120fea2cb1 Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:07:53 +0900 Subject: [PATCH 43/44] =?UTF-8?q?#79=20fix=20:=20builder=20=EC=97=90=20id?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seoultech/synergybe/domain/library/domain/SmallLibrary.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java b/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java index a74756d1..75e72902 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/domain/SmallLibrary.java @@ -36,6 +36,7 @@ public class SmallLibrary { @Builder public SmallLibrary( + String id, String name, String address, String telNumber, @@ -44,6 +45,7 @@ public SmallLibrary( String closeDate, Point location ) { + this.id = id; this.name = name; this.address = address; this.telNumber = telNumber; From b42c3c5000e83ccc6fbca093be54a03c71ad8a1c Mon Sep 17 00:00:00 2001 From: rivkode Date: Fri, 10 May 2024 14:08:08 +0900 Subject: [PATCH 44/44] =?UTF-8?q?#79=20fix=20:=20=EC=9E=91=EC=9D=80=20?= =?UTF-8?q?=EB=8F=84=EC=84=9C=EA=B4=80=20=EC=A0=80=EC=9E=A5=20=EC=8A=A4?= =?UTF-8?q?=EC=BC=80=EC=A4=84=EB=9F=AC=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scheduler/SmallLibraryScheduler.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java index 2b35d5ab..c01b5abf 100644 --- a/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java +++ b/src/main/java/com/seoultech/synergybe/domain/library/scheduler/SmallLibraryScheduler.java @@ -1,4 +1,49 @@ package com.seoultech.synergybe.domain.library.scheduler; +import com.seoultech.synergybe.domain.common.idgenerator.IdGenerator; +import com.seoultech.synergybe.domain.common.idgenerator.IdPrefix; +import com.seoultech.synergybe.domain.library.domain.RawSmallLibrary; +import com.seoultech.synergybe.domain.library.domain.SmallLibrary; +import com.seoultech.synergybe.domain.library.repository.RawSmallLibraryRepository; +import com.seoultech.synergybe.domain.library.repository.SmallLibraryRepository; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.data.geo.Point; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Slf4j +@Component +@RequiredArgsConstructor public class SmallLibraryScheduler { + private final SmallLibraryRepository smallLibraryRepository; + private final RawSmallLibraryRepository rawSmallLibraryRepository; + private final IdGenerator idGenerator; + + @Scheduled(cron = "0 0 4 * * 6", zone = "Asia/Seoul") + public void updateSmallLibrary() { + log.info("update Small Library"); + + List rawSmallLibraryList = rawSmallLibraryRepository.findAll(); + + List smallLibraries = rawSmallLibraryList.stream().map( + rawSmallLibrary -> SmallLibrary.builder() + .id(idGenerator.generateId(IdPrefix.SMALL_LIBRARY)) + .name(rawSmallLibrary.getName()) + .address(rawSmallLibrary.getAddress()) + .telNumber(rawSmallLibrary.getTelNumber()) + .homepageUrl(rawSmallLibrary.getHompageUrl()) + .opTime(rawSmallLibrary.getOpTime()) + .closeDate(rawSmallLibrary.getCloseDate()) + .location(new Point(rawSmallLibrary.getLatitude(), rawSmallLibrary.getLongitude())) + .build() + ).toList(); + + // 약 1000개로 데이터가 크지 않은점을 고려 + + smallLibraryRepository.saveAll(smallLibraries); + } + }