From 6bb10762f9067661a2aba932ea5e89bb76657941 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 22:03:19 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20CertificationSubject=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/walking/data/entity/member/CertificationSubject.java | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 data/src/main/java/com/walking/data/entity/member/CertificationSubject.java diff --git a/data/src/main/java/com/walking/data/entity/member/CertificationSubject.java b/data/src/main/java/com/walking/data/entity/member/CertificationSubject.java new file mode 100644 index 00000000..a20968ef --- /dev/null +++ b/data/src/main/java/com/walking/data/entity/member/CertificationSubject.java @@ -0,0 +1,5 @@ +package com.walking.data.entity.member; + +public enum CertificationSubject { + KAKAO, +} From 7ecb8feed576ec319e6c7201a501f8f2ba3a680a Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 22:03:55 +0900 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20MemberStatus=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/entity/member/MemberStatus.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 data/src/main/java/com/walking/data/entity/member/MemberStatus.java diff --git a/data/src/main/java/com/walking/data/entity/member/MemberStatus.java b/data/src/main/java/com/walking/data/entity/member/MemberStatus.java new file mode 100644 index 00000000..8e4c4bab --- /dev/null +++ b/data/src/main/java/com/walking/data/entity/member/MemberStatus.java @@ -0,0 +1,18 @@ +package com.walking.data.entity.member; + +import lombok.ToString; + +@ToString +public enum MemberStatus { + REGULAR("정회원"), + ASSOCIATE("준회원"), + SEPARATE("장기미이용 회원"), + WITHDRAWN("탈퇴회원"), + ; + + private final String description; + + MemberStatus(String description) { + this.description = description; + } +} From 71c119723bd54b6ba8f44e24c0d97fbed608800b Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:31:18 +0900 Subject: [PATCH 03/12] =?UTF-8?q?refactor:=20MemberEntity=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/entity/member/MemberEntity.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/data/src/main/java/com/walking/data/entity/member/MemberEntity.java b/data/src/main/java/com/walking/data/entity/member/MemberEntity.java index 01ee41a2..b1346ee9 100644 --- a/data/src/main/java/com/walking/data/entity/member/MemberEntity.java +++ b/data/src/main/java/com/walking/data/entity/member/MemberEntity.java @@ -3,9 +3,12 @@ import com.walking.data.entity.BaseEntity; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EnumType; +import javax.persistence.Enumerated; import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.experimental.SuperBuilder; @@ -20,9 +23,32 @@ @SQLDelete(sql = "UPDATE member SET deleted=true where id=?") public class MemberEntity extends BaseEntity { + /* 소셜 로그인을 통해 가입한 회원의 닉네임 */ + @Column(nullable = false, unique = true, length = 50) + private String nickName; + + /* 소셜 로그인을 통해 가입한 회원의 프로필 이미지 URL */ @Column(nullable = false) - private String memberId; + private String profile; + + /* 소셜 로그인을 통해 가입한 회원의 식별자 */ + @Column(nullable = false, unique = true) + private String certificationId; + /* 소셜 로그인을 통해 가입한 회원의 인증 주체 */ + @SuppressWarnings("FieldMayBeFinal") + @Enumerated(EnumType.STRING) + @Builder.Default @Column(nullable = false) - private String password; + private CertificationSubject certificationSubject = CertificationSubject.KAKAO; + + @SuppressWarnings("FieldMayBeFinal") + @Enumerated(EnumType.STRING) + @Builder.Default + @Column(nullable = false) + private MemberStatus status = MemberStatus.REGULAR; + + @Builder.Default + @Column(nullable = false, columnDefinition = "json") + private String resource = "{}"; } From e2419c183e55e33cdf48236df7aca4e9484bce7d Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:32:33 +0900 Subject: [PATCH 04/12] =?UTF-8?q?refactor:=20PathFavoritesEntity=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit memberFk의 ForeignKey 제한 조건은 설정하지 않았습니다. 위치 컬럼의 SRID를 추가하였습니다. 칼럼별 길이에 관한 제한 조건과 nullable 조건을 추가하였습니다. --- .../data/entity/member/PathFavoritesEntity.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/data/src/main/java/com/walking/data/entity/member/PathFavoritesEntity.java b/data/src/main/java/com/walking/data/entity/member/PathFavoritesEntity.java index 2d0275f6..f027a785 100644 --- a/data/src/main/java/com/walking/data/entity/member/PathFavoritesEntity.java +++ b/data/src/main/java/com/walking/data/entity/member/PathFavoritesEntity.java @@ -21,20 +21,21 @@ public class PathFavoritesEntity extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) - private MemberEntity memberEntity; + @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) + private MemberEntity memberFk; - @Column(columnDefinition = "POINT") + @Column(nullable = false, columnDefinition = "POINT SRID 4326") private Point startPoint; - @Column(columnDefinition = "POINT") + @Column(nullable = false, columnDefinition = "POINT SRID 4326") private Point endPoint; - @Column(columnDefinition = "LINESTRING") + @Column(nullable = false, columnDefinition = "LINESTRING SRID 4326") private LineString path; - @Column(nullable = false) + @Column(nullable = false, length = 50) private String startAlias; - @Column(nullable = false) + @Column(nullable = false, length = 50) private String endAlias; } From eab5fb411f6740c92bddd18edbffe8bb88417952 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:32:56 +0900 Subject: [PATCH 05/12] =?UTF-8?q?refactor:=20PathFavoritesEntity=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit memberFk,trafficFk의 ForeignKey 제한 조건은 설정하지 않았습니다. 칼럼별 길이에 관한 제한 조건과 nullable 조건을 추가하였습니다. --- .../data/entity/member/TrafficFavoritesEntity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/data/src/main/java/com/walking/data/entity/member/TrafficFavoritesEntity.java b/data/src/main/java/com/walking/data/entity/member/TrafficFavoritesEntity.java index f5596a1b..63b22dd8 100644 --- a/data/src/main/java/com/walking/data/entity/member/TrafficFavoritesEntity.java +++ b/data/src/main/java/com/walking/data/entity/member/TrafficFavoritesEntity.java @@ -20,11 +20,13 @@ public class TrafficFavoritesEntity extends BaseEntity { @ManyToOne(fetch = FetchType.LAZY) - private MemberEntity memberEntity; + @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) + private MemberEntity memberFk; @OneToOne(fetch = FetchType.LAZY) - private TrafficEntity trafficEntity; + @JoinColumn(foreignKey = @ForeignKey(value = ConstraintMode.NO_CONSTRAINT)) + private TrafficEntity trafficFk; - @Column(nullable = false) + @Column(nullable = false, length = 50) private String alias; } From 815a07d2f0b28de0257cf54260e6e4f95c2a3741 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:33:29 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20BaseEntity#id=EC=9D=98=20=EC=A0=84?= =?UTF-8?q?=EB=9E=B5=EC=9D=84=20IDENTITY=EB=A1=9C=20=EB=90=98=EB=8F=8C?= =?UTF-8?q?=EB=A6=BD=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 별도의 id 전략이 필요한 경우 객체를 새로 생성하거나 해당 엔티티에서 id를 설정합니다. --- data/src/main/java/com/walking/data/entity/BaseEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/src/main/java/com/walking/data/entity/BaseEntity.java b/data/src/main/java/com/walking/data/entity/BaseEntity.java index a28d879c..1cfe9d66 100644 --- a/data/src/main/java/com/walking/data/entity/BaseEntity.java +++ b/data/src/main/java/com/walking/data/entity/BaseEntity.java @@ -29,7 +29,7 @@ public abstract class BaseEntity { @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE) + @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(nullable = false, updatable = false) From 05a0d7830144b40cf8c7de3a250ba084c1a85887 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:36:13 +0900 Subject: [PATCH 07/12] =?UTF-8?q?refactor:=20TrafficEntity=EB=A5=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BaseEntity를 상속하지 않고 기본 정보를 엔티티 안에서 구현합니다. 위치 컬럼의 SRID를 추가하였습니다. --- .../data/entity/traffic/TrafficEntity.java | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java b/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java index 8afb0378..d2788657 100644 --- a/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java +++ b/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java @@ -1,25 +1,30 @@ package com.walking.data.entity.traffic; -import com.walking.data.entity.BaseEntity; +import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; import javax.persistence.Table; import lombok.AccessLevel; import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; import org.hibernate.annotations.SQLDelete; import org.locationtech.jts.geom.Point; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity -@SuperBuilder(toBuilder = true) +@Builder(toBuilder = true) @Table(name = "traffic") @SQLDelete(sql = "UPDATE traffic SET deleted=true where id=?") -public class TrafficEntity extends BaseEntity { +public class TrafficEntity { @Column(nullable = false, updatable = false) private String detail; @@ -27,6 +32,26 @@ public class TrafficEntity extends BaseEntity { @Column(nullable = false) private String name; - @Column(columnDefinition = "POINT SRID 4326", nullable = false) + @Column(nullable = false, columnDefinition = "POINT SRID 4326") private Point point; + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE) + private Long id; + + @Column(nullable = false, updatable = false) + @CreatedDate + private LocalDateTime createdAt; + + @Column(nullable = false) + @LastModifiedDate + private LocalDateTime updatedAt; + + @Builder.Default + @Column(nullable = false) + private Boolean deleted = false; + + public void delete() { + this.deleted = true; + } } From 0699cf1c44786aebf10da2833012fbca1080ba74 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:44:16 +0900 Subject: [PATCH 08/12] =?UTF-8?q?feat:=20TrafficEntity=EC=9D=98=20SoftDele?= =?UTF-8?q?teListener=20=EA=B5=AC=ED=98=84,=20=EC=A0=81=EC=9A=A9=ED=95=A9?= =?UTF-8?q?=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../listener/TrafficEntitySoftDeleteListener.java | 12 ++++++++++++ .../walking/data/entity/traffic/TrafficEntity.java | 4 ++++ 2 files changed, 16 insertions(+) create mode 100644 data/src/main/java/com/walking/data/entity/support/listener/TrafficEntitySoftDeleteListener.java diff --git a/data/src/main/java/com/walking/data/entity/support/listener/TrafficEntitySoftDeleteListener.java b/data/src/main/java/com/walking/data/entity/support/listener/TrafficEntitySoftDeleteListener.java new file mode 100644 index 00000000..d9539fd3 --- /dev/null +++ b/data/src/main/java/com/walking/data/entity/support/listener/TrafficEntitySoftDeleteListener.java @@ -0,0 +1,12 @@ +package com.walking.data.entity.support.listener; + +import com.walking.data.entity.traffic.TrafficEntity; +import javax.persistence.PreRemove; + +public class TrafficEntitySoftDeleteListener { + + @PreRemove + private void preRemove(TrafficEntity entity) { + entity.delete(); + } +} diff --git a/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java b/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java index d2788657..e6eef41a 100644 --- a/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java +++ b/data/src/main/java/com/walking/data/entity/traffic/TrafficEntity.java @@ -1,8 +1,10 @@ package com.walking.data.entity.traffic; +import com.walking.data.entity.support.listener.TrafficEntitySoftDeleteListener; import java.time.LocalDateTime; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.EntityListeners; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; @@ -16,11 +18,13 @@ import org.locationtech.jts.geom.Point; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Entity +@EntityListeners({AuditingEntityListener.class, TrafficEntitySoftDeleteListener.class}) @Builder(toBuilder = true) @Table(name = "traffic") @SQLDelete(sql = "UPDATE traffic SET deleted=true where id=?") From 5807696121433f094f7a2b1e9a83efbb705cfc25 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:54:10 +0900 Subject: [PATCH 09/12] =?UTF-8?q?rename:=20repository=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=EB=A5=BC=20=EC=9D=B4=EB=8F=99=ED=95=A9=EB=8B=88?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit web 패키지 아래가 아닌 api 패키지 아래로 위치하는 것이 적절하다 판단하였습니다. --- .../api/{web => }/repository/member/MemberRepository.java | 2 +- .../{web => }/repository/member/PathFavoritesRepository.java | 2 +- .../{web => }/repository/member/TrafficFavoritesRepository.java | 2 +- .../api/{web => }/repository/traffic/TrafficRepository.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) rename api/src/main/java/com/walking/api/{web => }/repository/member/MemberRepository.java (84%) rename api/src/main/java/com/walking/api/{web => }/repository/member/PathFavoritesRepository.java (85%) rename api/src/main/java/com/walking/api/{web => }/repository/member/TrafficFavoritesRepository.java (85%) rename api/src/main/java/com/walking/api/{web => }/repository/traffic/TrafficRepository.java (84%) diff --git a/api/src/main/java/com/walking/api/web/repository/member/MemberRepository.java b/api/src/main/java/com/walking/api/repository/member/MemberRepository.java similarity index 84% rename from api/src/main/java/com/walking/api/web/repository/member/MemberRepository.java rename to api/src/main/java/com/walking/api/repository/member/MemberRepository.java index 8d3312df..b69c76d8 100644 --- a/api/src/main/java/com/walking/api/web/repository/member/MemberRepository.java +++ b/api/src/main/java/com/walking/api/repository/member/MemberRepository.java @@ -1,4 +1,4 @@ -package com.walking.api.web.repository.member; +package com.walking.api.repository.member; import com.walking.data.entity.member.MemberEntity; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/api/src/main/java/com/walking/api/web/repository/member/PathFavoritesRepository.java b/api/src/main/java/com/walking/api/repository/member/PathFavoritesRepository.java similarity index 85% rename from api/src/main/java/com/walking/api/web/repository/member/PathFavoritesRepository.java rename to api/src/main/java/com/walking/api/repository/member/PathFavoritesRepository.java index 71131a1b..e4f8c070 100644 --- a/api/src/main/java/com/walking/api/web/repository/member/PathFavoritesRepository.java +++ b/api/src/main/java/com/walking/api/repository/member/PathFavoritesRepository.java @@ -1,4 +1,4 @@ -package com.walking.api.web.repository.member; +package com.walking.api.repository.member; import com.walking.data.entity.member.PathFavoritesEntity; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/api/src/main/java/com/walking/api/web/repository/member/TrafficFavoritesRepository.java b/api/src/main/java/com/walking/api/repository/member/TrafficFavoritesRepository.java similarity index 85% rename from api/src/main/java/com/walking/api/web/repository/member/TrafficFavoritesRepository.java rename to api/src/main/java/com/walking/api/repository/member/TrafficFavoritesRepository.java index 3d59d871..15ea6239 100644 --- a/api/src/main/java/com/walking/api/web/repository/member/TrafficFavoritesRepository.java +++ b/api/src/main/java/com/walking/api/repository/member/TrafficFavoritesRepository.java @@ -1,4 +1,4 @@ -package com.walking.api.web.repository.member; +package com.walking.api.repository.member; import com.walking.data.entity.member.TrafficFavoritesEntity; import org.springframework.data.jpa.repository.JpaRepository; diff --git a/api/src/main/java/com/walking/api/web/repository/traffic/TrafficRepository.java b/api/src/main/java/com/walking/api/repository/traffic/TrafficRepository.java similarity index 84% rename from api/src/main/java/com/walking/api/web/repository/traffic/TrafficRepository.java rename to api/src/main/java/com/walking/api/repository/traffic/TrafficRepository.java index 8c4e3349..93b2781a 100644 --- a/api/src/main/java/com/walking/api/web/repository/traffic/TrafficRepository.java +++ b/api/src/main/java/com/walking/api/repository/traffic/TrafficRepository.java @@ -1,4 +1,4 @@ -package com.walking.api.web.repository.traffic; +package com.walking.api.repository.traffic; import com.walking.data.entity.traffic.TrafficEntity; import org.springframework.data.jpa.repository.JpaRepository; From cbf102c0b42e9a2a3857cdbbee854fc4ec81b04d Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:56:17 +0900 Subject: [PATCH 10/12] =?UTF-8?q?remove:=20RepoTest=EB=A5=BC=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 해당 테스트의 경우 테스트 레포에서 진행하여 삭제합니다. https://github.com/Capstone-Walking/Capstone-Walking-BE-TEST/pull/3 --- .../test/java/com/walking/api/RepoTest.java | 142 ------------------ 1 file changed, 142 deletions(-) delete mode 100644 api/src/test/java/com/walking/api/RepoTest.java diff --git a/api/src/test/java/com/walking/api/RepoTest.java b/api/src/test/java/com/walking/api/RepoTest.java deleted file mode 100644 index f4e258cd..00000000 --- a/api/src/test/java/com/walking/api/RepoTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.walking.api; - -import com.walking.api.web.repository.member.MemberRepository; -import com.walking.api.web.repository.member.PathFavoritesRepository; -import com.walking.api.web.repository.member.TrafficFavoritesRepository; -import com.walking.api.web.repository.traffic.TrafficRepository; -import com.walking.data.entity.member.MemberEntity; -import com.walking.data.entity.member.PathFavoritesEntity; -import com.walking.data.entity.member.TrafficFavoritesEntity; -import com.walking.data.entity.traffic.TrafficEntity; -import java.util.Optional; -import javax.persistence.EntityManager; -import lombok.extern.slf4j.Slf4j; -import org.assertj.core.api.Assertions; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.locationtech.jts.geom.Coordinate; -import org.locationtech.jts.geom.GeometryFactory; -import org.locationtech.jts.geom.LineString; -import org.locationtech.jts.geom.Point; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.test.annotation.Rollback; - -@Slf4j -public class RepoTest extends RepositoryTest { - - @Autowired EntityManager em; - - @Autowired MemberRepository memberRepository; - - @Autowired TrafficRepository trafficRepository; - - @Autowired PathFavoritesRepository pathFavoritesRepository; - @Autowired TrafficFavoritesRepository trafficFavoritesRepository; - - @Nested - class MemberEntityTest { - - @Test - // @Rollback(value = false) - public void saveMember() { - MemberEntity memberEntity = MemberEntity.builder().memberId("124").password("123").build(); - - MemberEntity saved = memberRepository.save(memberEntity); - - Assertions.assertThat(memberEntity.getId()).isEqualTo(saved.getId()); - } - - @Test - // @Rollback(value = false) - public void deleteMember() { - MemberEntity memberEntity = MemberEntity.builder().memberId("123").password("123").build(); - - MemberEntity saved = memberRepository.save(memberEntity); - } - - @Test - // @Rollback(value = false) - public void saveTraffic() { - - GeometryFactory gf = new GeometryFactory(); - Point point = gf.createPoint(new Coordinate(123, 321)); - - TrafficEntity traffic = - TrafficEntity.builder().detail("123-L").name("제법이 집 앞").point(point).build(); - - TrafficEntity savedTraffic = trafficRepository.save(traffic); - - Optional findTraffic = trafficRepository.findById(savedTraffic.getId()); - - Assertions.assertThat(traffic.getId()).isEqualTo(findTraffic.get().getId()); - } - - @Test - @Rollback(value = false) - public void saveTrafficFavorites() { - - GeometryFactory gf = new GeometryFactory(); - Point point = gf.createPoint(new Coordinate(123, 321)); - - MemberEntity memberEntity = MemberEntity.builder().memberId("123").password("123").build(); - - TrafficEntity traffic = - TrafficEntity.builder().detail("123-L").name("제법이 집 앞").point(point).build(); - - em.persist(memberEntity); - em.persist(traffic); - em.flush(); - - TrafficFavoritesEntity trafficFavorites = - TrafficFavoritesEntity.builder() - .memberEntity(memberEntity) - .trafficEntity(traffic) - .alias("123") - .build(); - - TrafficFavoritesEntity save = trafficFavoritesRepository.save(trafficFavorites); - - TrafficFavoritesEntity trafficFavoritesEntity = - trafficFavoritesRepository.findById(save.getId()).get(); - - Assertions.assertThat(save.getId()).isEqualTo(trafficFavoritesEntity.getId()); - } - - @Test - @Rollback(value = false) - public void savePathFavorites() { - - GeometryFactory gf = new GeometryFactory(); - Coordinate[] coordinates = new Coordinate[3]; - for (int i = 0; i < 3; i++) { - coordinates[i] = new Coordinate(i * 10, i * 20); - } - LineString lineString = gf.createLineString(coordinates); - - Point startPoint = gf.createPoint(coordinates[0]); - Point endPoint = gf.createPoint(coordinates[2]); - - MemberEntity memberEntity = MemberEntity.builder().memberId("123").password("123").build(); - - em.persist(memberEntity); - em.flush(); - - PathFavoritesEntity build = - PathFavoritesEntity.builder() - .memberEntity(memberEntity) - .startPoint(startPoint) - .startAlias("시작") - .endPoint(endPoint) - .endAlias("끝") - .path(lineString) - .build(); - - PathFavoritesEntity save = pathFavoritesRepository.save(build); - - PathFavoritesEntity pathFavoritesEntity = - pathFavoritesRepository.findById(save.getId()).get(); - - Assertions.assertThat(save.getId()).isEqualTo(pathFavoritesEntity.getId()); - } - } -} From 4e7b6c137e31c0412d3e4dad259300408d31a5b2 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 21:56:53 +0900 Subject: [PATCH 11/12] =?UTF-8?q?refactor:=20RepositoryTest=EC=9D=98=20?= =?UTF-8?q?=EC=9C=84=EC=B9=98=EB=A5=BC=20=EC=9D=B4=EB=8F=99=ED=95=98?= =?UTF-8?q?=EA=B3=A0=20=EC=B6=94=EC=83=81=20=EA=B0=9D=EC=B2=B4=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/walking/api/{ => repository}/RepositoryTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename api/src/test/java/com/walking/api/{ => repository}/RepositoryTest.java (96%) diff --git a/api/src/test/java/com/walking/api/RepositoryTest.java b/api/src/test/java/com/walking/api/repository/RepositoryTest.java similarity index 96% rename from api/src/test/java/com/walking/api/RepositoryTest.java rename to api/src/test/java/com/walking/api/repository/RepositoryTest.java index e78fc93b..1306d0f3 100644 --- a/api/src/test/java/com/walking/api/RepositoryTest.java +++ b/api/src/test/java/com/walking/api/repository/RepositoryTest.java @@ -1,4 +1,4 @@ -package com.walking.api; +package com.walking.api.repository; import com.fasterxml.jackson.databind.ObjectMapper; import com.walking.api.config.ApiDataSourceConfig; @@ -38,4 +38,4 @@ ObjectMapper.class, }) @DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class) -class RepositoryTest {} +abstract class RepositoryTest {} From 68f99fa3812ea80b25a6f5d8473778d096a1ec3d Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 May 2024 22:30:21 +0900 Subject: [PATCH 12/12] =?UTF-8?q?feat:=20data-local=20=EC=9D=B4=EC=99=B8?= =?UTF-8?q?=EC=9D=98=20=EB=8B=A4=EB=A5=B8=20=ED=94=84=EB=A1=9C=ED=95=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=EB=8F=84=20spatial=20=EB=B0=A9=EC=96=B8?= =?UTF-8?q?=EA=B3=BC=20jdbc=20batch=20=EC=84=A4=EC=A0=95=EC=9D=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=ED=95=A9=EB=8B=88=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/src/main/resources/application-data-dev.yml | 7 ++++++- data/src/main/resources/application-data-local.yml | 5 ++++- data/src/main/resources/application-data-prod.yml | 7 ++++++- data/src/main/resources/application-data.yml | 7 ++++++- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/data/src/main/resources/application-data-dev.yml b/data/src/main/resources/application-data-dev.yml index 20dc88f4..be8c5310 100644 --- a/data/src/main/resources/application-data-dev.yml +++ b/data/src/main/resources/application-data-dev.yml @@ -4,4 +4,9 @@ spring: ddl-auto: validate properties: hibernate: - format_sql: true \ No newline at end of file + format_sql: true + dialect: org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect + order_inserts: true + order_updates: true + jdbc: + batch_size: ${JDBC_BATCH_SIZE:50} \ No newline at end of file diff --git a/data/src/main/resources/application-data-local.yml b/data/src/main/resources/application-data-local.yml index 619d6cca..5bcf57a3 100644 --- a/data/src/main/resources/application-data-local.yml +++ b/data/src/main/resources/application-data-local.yml @@ -6,4 +6,7 @@ spring: hibernate: format_sql: true dialect: org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect - + order_inserts: true + order_updates: true + jdbc: + batch_size: 50 diff --git a/data/src/main/resources/application-data-prod.yml b/data/src/main/resources/application-data-prod.yml index 20dc88f4..be8c5310 100644 --- a/data/src/main/resources/application-data-prod.yml +++ b/data/src/main/resources/application-data-prod.yml @@ -4,4 +4,9 @@ spring: ddl-auto: validate properties: hibernate: - format_sql: true \ No newline at end of file + format_sql: true + dialect: org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect + order_inserts: true + order_updates: true + jdbc: + batch_size: ${JDBC_BATCH_SIZE:50} \ No newline at end of file diff --git a/data/src/main/resources/application-data.yml b/data/src/main/resources/application-data.yml index 20dc88f4..be8c5310 100644 --- a/data/src/main/resources/application-data.yml +++ b/data/src/main/resources/application-data.yml @@ -4,4 +4,9 @@ spring: ddl-auto: validate properties: hibernate: - format_sql: true \ No newline at end of file + format_sql: true + dialect: org.hibernate.spatial.dialect.mysql.MySQL8SpatialDialect + order_inserts: true + order_updates: true + jdbc: + batch_size: ${JDBC_BATCH_SIZE:50} \ No newline at end of file