From 42a14ec06719cfa31168b7daee0a6cc6b49e81bd Mon Sep 17 00:00:00 2001 From: haeun1107 Date: Mon, 18 Nov 2024 12:08:39 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat:=20entity=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../enterprise/EnterpriseController.java | 25 ++++++++ .../domain/enterprise/EnterpriseService.java | 28 ++++++++ .../domain/enterprise/entity/Enterprise.java | 64 +++++++++++++++++++ .../domain/enterprise/entity/Region.java | 6 ++ .../domain/enterprise/entity/Type.java | 8 +++ .../domain/enterprise/entity/Visit.java | 30 +++++++++ .../repository/EnterpriseRepository.java | 11 ++++ .../soenter/domain/likes/entity/Likes.java | 27 ++++++++ .../soenter/domain/review/entity/Review.java | 44 +++++++++++++ .../soenter/domain/review/entity/TagList.java | 23 +++++++ .../soenter/domain/user/entity/User.java | 32 ++++++++++ 11 files changed, 298 insertions(+) create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/EnterpriseController.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/EnterpriseService.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/entity/Enterprise.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/entity/Region.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/entity/Type.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java create mode 100644 src/main/java/danpoong/soenter/domain/enterprise/repository/EnterpriseRepository.java create mode 100644 src/main/java/danpoong/soenter/domain/likes/entity/Likes.java create mode 100644 src/main/java/danpoong/soenter/domain/review/entity/Review.java create mode 100644 src/main/java/danpoong/soenter/domain/review/entity/TagList.java create mode 100644 src/main/java/danpoong/soenter/domain/user/entity/User.java diff --git a/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseController.java b/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseController.java new file mode 100644 index 0000000..4a5ddd9 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseController.java @@ -0,0 +1,25 @@ +package danpoong.soenter.domain.enterprise; + +import danpoong.soenter.base.ApiResponse; +import danpoong.soenter.domain.enterprise.entity.Enterprise; +import danpoong.soenter.domain.enterprise.entity.Region; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/enterprises") +public class EnterpriseController { + + private final EnterpriseService enterpriseService; + + @GetMapping("/{region}") + public ApiResponse> getEnterprisesByRegion(@PathVariable("region") Region region) { + return enterpriseService.getEnterprisesByRegion(region); + } +} \ No newline at end of file diff --git a/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseService.java b/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseService.java new file mode 100644 index 0000000..5aad460 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/EnterpriseService.java @@ -0,0 +1,28 @@ +package danpoong.soenter.domain.enterprise; + +import danpoong.soenter.base.ApiResponse; +import danpoong.soenter.domain.enterprise.entity.Enterprise; +import danpoong.soenter.domain.enterprise.entity.Region; +import danpoong.soenter.domain.enterprise.repository.EnterpriseRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@RequiredArgsConstructor +@Transactional +public class EnterpriseService { + + private final EnterpriseRepository enterpriseRepository; + + public ApiResponse> getEnterprisesByRegion(Region region) { + try { + List enterprises = enterpriseRepository.findAllByRegion(region); + return ApiResponse.onSuccess(enterprises); + } catch (Exception e) { + return ApiResponse.onFailure("500", "지역별 기업 정보를 가져오는 데 실패했습니다.", null); + } + } +} \ No newline at end of file diff --git a/src/main/java/danpoong/soenter/domain/enterprise/entity/Enterprise.java b/src/main/java/danpoong/soenter/domain/enterprise/entity/Enterprise.java new file mode 100644 index 0000000..9e71556 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/entity/Enterprise.java @@ -0,0 +1,64 @@ +package danpoong.soenter.domain.enterprise.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "enterprise") +public class Enterprise { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long enterpriseId; + + @Enumerated(EnumType.STRING) + @Column + private Region region; + + @Column + private Boolean is_cooperative; + + @Column + private String certificationNumber; + + @Column(nullable = false) + private String name; + + @Column + private String businessRegistrationNumber; + + @Column + private String socialPurpose; + + @Column + private String type; + + @Column + private String representativeName; + + @Column + private String representativePhone; + + @Column + private String city; + + @Column + private String district; + + @Column + private double latitude; + + @Column + private double longitude; + + @Column + private String website; + + @Column + private Integer certificationYear; +} + diff --git a/src/main/java/danpoong/soenter/domain/enterprise/entity/Region.java b/src/main/java/danpoong/soenter/domain/enterprise/entity/Region.java new file mode 100644 index 0000000..88e1cd7 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/entity/Region.java @@ -0,0 +1,6 @@ +package danpoong.soenter.domain.enterprise.entity; + +public enum Region { + 경기, + // todo: 나중에 서울 강원 다 추가하면 될듯 +} diff --git a/src/main/java/danpoong/soenter/domain/enterprise/entity/Type.java b/src/main/java/danpoong/soenter/domain/enterprise/entity/Type.java new file mode 100644 index 0000000..756692e --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/entity/Type.java @@ -0,0 +1,8 @@ +package danpoong.soenter.domain.enterprise.entity; + +public enum Type { + 사회서비스제공형, + 일자리제공형, + 지역사회공헌형, + 기타 +} diff --git a/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java b/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java new file mode 100644 index 0000000..1748890 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java @@ -0,0 +1,30 @@ +package danpoong.soenter.domain.enterprise.entity; + +import goorm.ssoenter.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.*; + +import java.time.LocalDate; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "visit") +public class Visit { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long visitId; + + @ManyToOne + @JoinColumn(name = "userId", nullable = false) + private User user; + + @ManyToOne + @JoinColumn(name = "enterpriseId", nullable = false) + private Enterprise enterprise; + + private LocalDate visitDate; +} diff --git a/src/main/java/danpoong/soenter/domain/enterprise/repository/EnterpriseRepository.java b/src/main/java/danpoong/soenter/domain/enterprise/repository/EnterpriseRepository.java new file mode 100644 index 0000000..37296b7 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/enterprise/repository/EnterpriseRepository.java @@ -0,0 +1,11 @@ +package danpoong.soenter.domain.enterprise.repository; + +import danpoong.soenter.domain.enterprise.entity.Enterprise; +import danpoong.soenter.domain.enterprise.entity.Region; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +public interface EnterpriseRepository extends JpaRepository { + List findAllByRegion(Region region); +} diff --git a/src/main/java/danpoong/soenter/domain/likes/entity/Likes.java b/src/main/java/danpoong/soenter/domain/likes/entity/Likes.java new file mode 100644 index 0000000..6b85236 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/likes/entity/Likes.java @@ -0,0 +1,27 @@ +package danpoong.soenter.domain.likes.entity; + +import danpoong.soenter.domain.enterprise.entity.Enterprise; +import danpoong.soenter.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "likes") +public class Likes { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long likeId; + + @ManyToOne + @JoinColumn(name = "userId", nullable = false) + private User user; + + @ManyToOne + @JoinColumn(name = "enterpriseId", nullable = false) + private Enterprise enterprise; + +} diff --git a/src/main/java/danpoong/soenter/domain/review/entity/Review.java b/src/main/java/danpoong/soenter/domain/review/entity/Review.java new file mode 100644 index 0000000..62d07de --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/review/entity/Review.java @@ -0,0 +1,44 @@ +package danpoong.soenter.domain.review.entity; + +import goorm.ssoenter.domain.enterprise.entity.Enterprise; +import goorm.ssoenter.domain.user.entity.User; +import jakarta.persistence.*; +import lombok.*; + +import java.time.LocalDate; +import java.util.List; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "review") +public class Review { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long reviewId; + + @ManyToOne + @JoinColumn(name = "userId", nullable = false) + private User user; + + @ManyToOne + @JoinColumn(name = "enterpriseId", nullable = false) + private Enterprise enterprise; + + @Column + private String title; + + @Column + private String content; + + @Column + private Integer tagNum; + + @Column + private LocalDate createAt; + + @OneToMany(mappedBy = "review", cascade = CascadeType.ALL, orphanRemoval = true) + private List tagList; +} diff --git a/src/main/java/danpoong/soenter/domain/review/entity/TagList.java b/src/main/java/danpoong/soenter/domain/review/entity/TagList.java new file mode 100644 index 0000000..32451db --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/review/entity/TagList.java @@ -0,0 +1,23 @@ +package danpoong.soenter.domain.review.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "tagList") +public class TagList { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long tagId; + + @ManyToOne + @JoinColumn(name = "reviewId", nullable = false) + private Review review; + + @Column + private Integer tagNum; +} diff --git a/src/main/java/danpoong/soenter/domain/user/entity/User.java b/src/main/java/danpoong/soenter/domain/user/entity/User.java new file mode 100644 index 0000000..f758da5 --- /dev/null +++ b/src/main/java/danpoong/soenter/domain/user/entity/User.java @@ -0,0 +1,32 @@ +package danpoong.soenter.domain.user.entity; + +import jakarta.persistence.*; +import lombok.*; + +@Entity +@Getter +@Builder +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor +@Table(name = "users") +public class User { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long userId; + + @Column(nullable = false) + private String name; + + @Column(nullable = false) + private String email; + + private String password; + + @Column + private String socialType; + + @Column + private String socialId; // 로그인한 소셜 타입의 식별자 값 (일반 로그인 : null) + +} From d02829e3665857752f567d4fc0d6d9027d7b98c9 Mon Sep 17 00:00:00 2001 From: haeun1107 Date: Mon, 18 Nov 2024 12:15:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix:=20import=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/danpoong/soenter/domain/enterprise/entity/Visit.java | 2 +- .../java/danpoong/soenter/domain/review/entity/Review.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java b/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java index 1748890..9967ecf 100644 --- a/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java +++ b/src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java @@ -1,6 +1,6 @@ package danpoong.soenter.domain.enterprise.entity; -import goorm.ssoenter.domain.user.entity.User; +import danpoong.soenter.domain.user.entity.User; import jakarta.persistence.*; import lombok.*; diff --git a/src/main/java/danpoong/soenter/domain/review/entity/Review.java b/src/main/java/danpoong/soenter/domain/review/entity/Review.java index 62d07de..3887226 100644 --- a/src/main/java/danpoong/soenter/domain/review/entity/Review.java +++ b/src/main/java/danpoong/soenter/domain/review/entity/Review.java @@ -1,7 +1,7 @@ package danpoong.soenter.domain.review.entity; -import goorm.ssoenter.domain.enterprise.entity.Enterprise; -import goorm.ssoenter.domain.user.entity.User; +import danpoong.soenter.domain.enterprise.entity.Enterprise; +import danpoong.soenter.domain.user.entity.User; import jakarta.persistence.*; import lombok.*;