Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions alex/week0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

### 전체 ERD
![Main](./main.png)

### user
![User](./user.png)

### review
![review](./review.png)

### store
![store](./store.png)

### mission
![mission](./mission.png)

Binary file added alex/week0/main.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alex/week0/mission.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alex/week0/review.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alex/week0/store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added alex/week0/user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions alex/week1/sql_query.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
## 1 ##
INSERT INTO review (user_id, store_id, star, content)
VALUES (1, 1, 5, '음 너무 맛있어요...');
######

## 2 ##
SELECT u.id, u.name, u.email, u.phone_num, u.point
FROM user AS u
WHERE u.id = :user_id
######

## 3 ##
SELECT
m.point,
m.contnet
FROM user_mission AS um
JOIN mission AS m
ON um.mission_id = m.id
WHERE um.user_id = :user_id
AND um.is_complete = True
ORDER BY um.cmplete_at DESC
LIMIT 15;
######

## 4 ##
SELECT
m.content
s.name
fc.name
m.deadline
m.point
FROM user_mission AS um
JOIN mssion AS m
ON um.mission_id = m.id
JOIN store AS s
ON m.store_id = s.id
JOIN food_category AS fc
ON s.category_id = fc.id
WHERE
um.is_complete = false AND
s.addr = '안암동' AND
um.user_id = :user_id
ORDER BY um.complete_at DESC
LIMIT 15;
######
16 changes: 16 additions & 0 deletions alex/week4/com/exmaple/umc/agreement/Agreement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.umc.agreement;

import com.example.umc.common.BaseTime;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="agreement")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class Agreement extends BaseTime {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable=false, length=1000)
private String content;
}
24 changes: 24 additions & 0 deletions alex/week4/com/exmaple/umc/agreement/UserAgreement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.umc.agreement;

import com.example.umc.user.User;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;

@Entity
@Table(name="user_agreement",
uniqueConstraints = @UniqueConstraint(name="uq_user_agreement", columnNames={"user_id","agreement_id"}))
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class UserAgreement {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="user_id", nullable=false)
private User user;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="agreement_id", nullable=false)
private Agreement agreement;

@Column(nullable=false) private Boolean isAgreed;
private LocalDateTime agreedAt;
}
19 changes: 19 additions & 0 deletions alex/week4/com/exmaple/umc/common/BaseTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.umc.common;

import jakarta.persistence.*;
import lombok.Getter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;
import java.time.LocalDateTime;

@MappedSuperclass
@Getter
public abstract class BaseTime {
@CreationTimestamp
@Column(name = "created_at", nullable = false, updatable = false)
private LocalDateTime createdAt;

@UpdateTimestamp
@Column(name = "updated_at", nullable = false)
private LocalDateTime updatedAt;
}
41 changes: 41 additions & 0 deletions alex/week4/com/exmaple/umc/mission/Mission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.example.umc.mission;

import com.example.umc.common.BaseTime;
import com.example.umc.store.Store;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDate;
import java.util.List;

@Entity
@Table(
name = "mission",
indexes = {
@Index(name = "idx_mission_store", columnList = "store_id")
}
)
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class Mission extends BaseTime {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "store_id", nullable = false)
private Store store;

@Column(nullable = false, length = 255)
private String content;

@Column(nullable = false)
private LocalDate deadline;

@Column(nullable = false)
private Long point;

@Column(nullable = false)
private Boolean dbStatus = true;

@OneToMany(mappedBy = "mission", cascade = CascadeType.ALL, orphanRemoval = true)
private List<UserMission> assignments;
}
43 changes: 43 additions & 0 deletions alex/week4/com/exmaple/umc/mission/UserMission.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.umc.mission;

import com.example.umc.user.User;
import jakarta.persistence.*;
import lombok.*;
import java.time.LocalDateTime;

@Entity
@Table(
name = "user_mission",
uniqueConstraints = {
@UniqueConstraint(name = "uq_user_mission", columnNames = {"user_id", "mission_id"})
},
indexes = {
@Index(name = "idx_um_user", columnList = "user_id"),
@Index(name = "idx_um_mission", columnList = "mission_id")
}
)
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class UserMission {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "mission_id", nullable = false)
private Mission mission;

@Column(name = "is_complete", nullable = false)
private Boolean isComplete = false;

@Column(name = "complete_at")
private LocalDateTime completeAt;

public void completeNow() {
this.isComplete = true;
this.completeAt = LocalDateTime.now();
}
}
32 changes: 32 additions & 0 deletions alex/week4/com/exmaple/umc/review/Review.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.example.umc.review;

import com.example.umc.common.BaseTime;
import com.example.umc.store.Store;
import com.example.umc.user.User;
import jakarta.persistence.*;
import lombok.*;
import java.util.List;

@Entity
@Table(name="review")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class Review extends BaseTime {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="user_id", nullable=false)
private User user;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="store_id", nullable=false)
private Store store;

@Column(nullable=false) private Integer star;
@Column(nullable=false, length=1000) private String content;
@Column(nullable=false) private Boolean dbStatus;

@OneToMany(mappedBy="review", cascade=CascadeType.ALL, orphanRemoval=true)
private List<ReviewImage> images;

@OneToOne(mappedBy="review", cascade=CascadeType.ALL, orphanRemoval=true, fetch=FetchType.LAZY)
private ReviewReply reply;
}
18 changes: 18 additions & 0 deletions alex/week4/com/exmaple/umc/review/ReviewImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.umc.review;

import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="review_image")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class ReviewImage {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="review_id", nullable=false)
private Review review;

@Column(name="image_url", nullable=false, length=500)
private String imageUrl;
}
19 changes: 19 additions & 0 deletions alex/week4/com/exmaple/umc/review/ReviewReply.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.example.umc.review;

import com.example.umc.common.BaseTime;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="review_reply")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class ReviewReply extends BaseTime {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@OneToOne(fetch=FetchType.LAZY) @JoinColumn(name="review_id", nullable=false, unique=true)
private Review review;

@Column(nullable=false, length=1000)
private String content;
}
25 changes: 25 additions & 0 deletions alex/week4/com/exmaple/umc/store/Store.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.example.umc.store;

import com.example.umc.common.BaseTime;
import com.example.umc.user.FoodCategory;
import jakarta.persistence.*;
import lombok.*;
import java.util.List;

@Entity
@Table(name="store")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class Store extends BaseTime {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="category_id", nullable=false)
private FoodCategory category;

@Column(nullable=false, length=100) private String name;
@Column(nullable=false, length=255) private String addr;
@Column(nullable=false) private Boolean dbStatus;

@OneToMany(mappedBy="store", cascade=CascadeType.ALL, orphanRemoval=true)
private List<StoreImage> images;
}
18 changes: 18 additions & 0 deletions alex/week4/com/exmaple/umc/store/StoreImage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.example.umc.store;

import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="store_image")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class StoreImage {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@ManyToOne(fetch=FetchType.LAZY) @JoinColumn(name="store_id", nullable=false)
private Store store;

@Column(name="image_url", nullable=false, length=500)
private String imageUrl;
}
16 changes: 16 additions & 0 deletions alex/week4/com/exmaple/umc/user/FoodCategory.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.umc.user;

import com.example.umc.common.BaseTime;
import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="food_category")
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class FoodCategory extends BaseTime {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(nullable=false, length=50, unique=true)
private String name;
}
5 changes: 5 additions & 0 deletions alex/week4/com/exmaple/umc/user/SocialType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.example.umc.domain.user;
public enum SocialType { KAKAO, NAVER, GOOGLE, APPLE }

package com.example.umc.domain.review;
public enum DbStatus { DISABLED, ENABLED }
Loading