-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev-be' into feat/70-cors-config
- Loading branch information
Showing
19 changed files
with
387 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
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
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
60 changes: 60 additions & 0 deletions
60
backend/bang-ggood/src/main/java/com/bang_ggood/category/domain/CategoryPriority.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,60 @@ | ||
package com.bang_ggood.category.domain; | ||
|
||
import com.bang_ggood.BaseEntity; | ||
import com.bang_ggood.user.domain.User; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.FetchType; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.ManyToOne; | ||
import java.util.Objects; | ||
|
||
@Entity | ||
public class CategoryPriority extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private Integer categoryId; | ||
|
||
@ManyToOne(fetch = FetchType.LAZY) | ||
private User user; | ||
|
||
protected CategoryPriority() { | ||
} | ||
|
||
public CategoryPriority(Integer categoryId, User user) { | ||
this.categoryId = categoryId; | ||
this.user = user; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
CategoryPriority that = (CategoryPriority) o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CategoryPriority{" + | ||
"id=" + id + | ||
", categoryId=" + categoryId + | ||
", user=" + user + | ||
'}'; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...d/bang-ggood/src/main/java/com/bang_ggood/category/dto/CategoryPriorityCreateRequest.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 com.bang_ggood.category.dto; | ||
|
||
import java.util.List; | ||
|
||
public record CategoryPriorityCreateRequest(List<Integer> categoryIds) { | ||
} |
7 changes: 7 additions & 0 deletions
7
...ng-ggood/src/main/java/com/bang_ggood/category/repository/CategoryPriorityRepository.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,7 @@ | ||
package com.bang_ggood.category.repository; | ||
|
||
import com.bang_ggood.category.domain.CategoryPriority; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface CategoryPriorityRepository extends JpaRepository<CategoryPriority, Long> { | ||
} |
56 changes: 56 additions & 0 deletions
56
backend/bang-ggood/src/main/java/com/bang_ggood/category/service/CategoryService.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
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
54 changes: 54 additions & 0 deletions
54
backend/bang-ggood/src/main/java/com/bang_ggood/user/domain/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,54 @@ | ||
package com.bang_ggood.user.domain; | ||
|
||
import com.bang_ggood.BaseEntity; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import jakarta.persistence.Table; | ||
import java.util.Objects; | ||
|
||
@Table(name = "users") | ||
@Entity | ||
public class User extends BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private Long id; | ||
|
||
@Column(nullable = false) | ||
private String name; | ||
|
||
protected User() { | ||
} | ||
|
||
public User(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) { | ||
return true; | ||
} | ||
if (o == null || getClass() != o.getClass()) { | ||
return false; | ||
} | ||
User user = (User) o; | ||
return Objects.equals(id, user.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "User{" + | ||
"id=" + id + | ||
", name='" + name + '\'' + | ||
'}'; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
backend/bang-ggood/src/main/java/com/bang_ggood/user/repository/UserRepository.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,13 @@ | ||
package com.bang_ggood.user.repository; | ||
|
||
import com.bang_ggood.exception.BangggoodException; | ||
import com.bang_ggood.exception.ExceptionCode; | ||
import com.bang_ggood.user.domain.User; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
|
||
public interface UserRepository extends JpaRepository<User, Long> { | ||
|
||
default User getUserById(Long id) { | ||
return findById(id).orElseThrow(() -> new BangggoodException(ExceptionCode.USER_NOT_FOUND)); | ||
} | ||
} |
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,2 @@ | ||
INSERT INTO users(id, name, created_at, modified_at) | ||
VALUES (1, '방방이', '2024-07-22 07:56:42', '2024-07-22 07:56:42'); |
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,19 @@ | ||
CREATE TABLE users | ||
( | ||
id bigint generated by default as identity, | ||
name varchar(255) not null, | ||
created_at TIMESTAMP not null, | ||
modified_at TIMESTAMP not null, | ||
primary key (id) | ||
); | ||
|
||
CREATE TABLE category_priority | ||
( | ||
id bigint generated by default as identity, | ||
category_id tinyint not null, | ||
user_id bigint not null, | ||
created_at TIMESTAMP not null, | ||
modified_at TIMESTAMP not null, | ||
primary key (id), | ||
foreign key (user_id) references users | ||
); |
11 changes: 11 additions & 0 deletions
11
backend/bang-ggood/src/test/java/com/bang_ggood/IntegrationTestSupport.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 com.bang_ggood; | ||
|
||
|
||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; | ||
import org.springframework.test.context.ActiveProfiles; | ||
|
||
@ActiveProfiles("test") | ||
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) | ||
public abstract class IntegrationTestSupport { | ||
} |
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
Oops, something went wrong.