-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[FEAT] entity 생성
- Loading branch information
Showing
11 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/main/java/danpoong/soenter/domain/enterprise/EnterpriseController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<List<Enterprise>> getEnterprisesByRegion(@PathVariable("region") Region region) { | ||
return enterpriseService.getEnterprisesByRegion(region); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/danpoong/soenter/domain/enterprise/EnterpriseService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<List<Enterprise>> getEnterprisesByRegion(Region region) { | ||
try { | ||
List<Enterprise> enterprises = enterpriseRepository.findAllByRegion(region); | ||
return ApiResponse.onSuccess(enterprises); | ||
} catch (Exception e) { | ||
return ApiResponse.onFailure("500", "지역별 기업 정보를 가져오는 데 실패했습니다.", null); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
src/main/java/danpoong/soenter/domain/enterprise/entity/Enterprise.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} | ||
|
6 changes: 6 additions & 0 deletions
6
src/main/java/danpoong/soenter/domain/enterprise/entity/Region.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package danpoong.soenter.domain.enterprise.entity; | ||
|
||
public enum Region { | ||
경기, | ||
// todo: 나중에 서울 강원 다 추가하면 될듯 | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/java/danpoong/soenter/domain/enterprise/entity/Type.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package danpoong.soenter.domain.enterprise.entity; | ||
|
||
public enum Type { | ||
사회서비스제공형, | ||
일자리제공형, | ||
지역사회공헌형, | ||
기타 | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/danpoong/soenter/domain/enterprise/entity/Visit.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package danpoong.soenter.domain.enterprise.entity; | ||
|
||
import danpoong.soenter.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; | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/danpoong/soenter/domain/enterprise/repository/EnterpriseRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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<Enterprise, Long> { | ||
List<Enterprise> findAllByRegion(Region region); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/danpoong/soenter/domain/likes/entity/Likes.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package 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; | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/danpoong/soenter/domain/review/entity/Review.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package danpoong.soenter.domain.review.entity; | ||
|
||
import danpoong.soenter.domain.enterprise.entity.Enterprise; | ||
import danpoong.soenter.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> tagList; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/danpoong/soenter/domain/review/entity/TagList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/danpoong/soenter/domain/user/entity/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
|
||
} |