Skip to content

Commit

Permalink
Merge pull request #13 from cbnu-sequence/feat/#12-ckyeon
Browse files Browse the repository at this point in the history
Create default entities - ckyeon
  • Loading branch information
ckyeon authored Sep 14, 2023
2 parents 09485a0 + 7481d43 commit 9f36282
Show file tree
Hide file tree
Showing 30 changed files with 445 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import io.swagger.v3.oas.annotations.servers.Server;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

@SpringBootApplication
@EnableJpaAuditing
@OpenAPIDefinition(servers = {@Server(url = "/")})
public class AnonymousApplication {

Expand Down
24 changes: 24 additions & 0 deletions src/main/java/com/sequence/anonymous/common/BaseEntity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.sequence.anonymous.common;

import jakarta.persistence.Column;
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Getter
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public class BaseEntity {

@CreatedDate
@Column(updatable = false)
private LocalDateTime createdAt;

@LastModifiedDate
private LocalDateTime updatedAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sequence.anonymous.matchpost.application;

import com.sequence.anonymous.matchpost.domain.repository.ChatRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class ChatService {

private final ChatRepository chatRepository;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sequence.anonymous.matchpost.application;

import com.sequence.anonymous.matchpost.domain.repository.MatchPostRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class MatchPostService {

private final MatchPostRepository matchPostRepository;
}
35 changes: 35 additions & 0 deletions src/main/java/com/sequence/anonymous/matchpost/domain/Chat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.sequence.anonymous.matchpost.domain;

import com.google.common.base.Preconditions;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import lombok.Getter;

import java.util.UUID;

@Getter
@Entity
public class Chat {

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

private UUID identifier;

protected Chat() {
}

public Chat(UUID identifier) {
this(null, identifier);
}

private Chat(Long id, UUID identifier) {
Preconditions.checkArgument(identifier != null, "identifier must be provided.");

this.id = id;
this.identifier = identifier;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.sequence.anonymous.matchpost.domain;

import com.google.common.base.Preconditions;
import com.sequence.anonymous.common.BaseEntity;
import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;

@Getter
@Entity
public class MatchPost extends BaseEntity {

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

@Column(length = 50)
@NotNull
private String title;

@Column(length = 50)
@NotNull
private String introduce;

@Column(length = 50)
@NotNull
private String appeal;

@Enumerated(EnumType.STRING)
@Column(length = 10)
@NotNull
private Status status;

protected MatchPost() {
}

public MatchPost(String title, String introduce, String appeal) {
this(null, title, introduce, appeal, Status.RECRUIT);
}

private MatchPost(Long id, String title, String introduce, String appeal, Status status) {
Preconditions.checkArgument(title != null, "title must be provided.");
Preconditions.checkArgument(introduce != null, "introduce must be provided.");
Preconditions.checkArgument(appeal != null, "appeal must be provided.");
Preconditions.checkArgument(status != null, "status must be provided.");

Preconditions.checkArgument(title.isEmpty(), "title must not be empty.");

this.id = id;
this.title = title;
this.introduce = introduce;
this.appeal = appeal;
this.status = status;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sequence.anonymous.matchpost.domain;

public enum Status {
RECRUIT,
DONE
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sequence.anonymous.matchpost.domain.repository;

import com.sequence.anonymous.matchpost.domain.Chat;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface ChatRepository extends JpaRepository<Chat, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.sequence.anonymous.matchpost.domain.repository;

import com.sequence.anonymous.matchpost.domain.MatchPost;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface MatchPostRepository extends JpaRepository<MatchPost, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sequence.anonymous.matchpost.presentation;

import com.sequence.anonymous.matchpost.application.ChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/chats")
public class ChatController {

private final ChatService chatService;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.sequence.anonymous.matchpost.presentation;

import com.sequence.anonymous.matchpost.application.MatchPostService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequiredArgsConstructor
@RestController
@RequestMapping("/match-posts")
public class MatchPostController {

private final MatchPostService matchPostService;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sequence.anonymous.security;

import com.google.common.base.Preconditions;
import com.sequence.anonymous.user.domain.Role;
import com.sequence.anonymous.user.domain.user.Role;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.sequence.anonymous.security.userinfo.GithubOAuth2UserInfo;
import com.sequence.anonymous.security.userinfo.GoogleOAuth2UserInfo;
import com.sequence.anonymous.security.userinfo.KakaoOAuth2UserInfo;
import com.sequence.anonymous.user.domain.OAuth2Provider;
import com.sequence.anonymous.user.domain.user.OAuth2Provider;
import java.util.Map;

public class CustomOAuth2UserInfoFactory {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sequence.anonymous.security;

import com.sequence.anonymous.user.domain.Role;
import com.sequence.anonymous.user.domain.user.Role;
import java.util.Map;
import org.springframework.security.oauth2.core.oidc.OidcIdToken;
import org.springframework.security.oauth2.core.oidc.OidcUserInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.sequence.anonymous.security.CustomOAuth2User;
import com.sequence.anonymous.security.CustomOAuth2UserInfoFactory;
import com.sequence.anonymous.security.userinfo.CustomOAuth2UserInfo;
import com.sequence.anonymous.user.domain.OAuth2Provider;
import com.sequence.anonymous.user.domain.User;
import com.sequence.anonymous.user.domain.user.OAuth2Provider;
import com.sequence.anonymous.user.domain.user.User;
import com.sequence.anonymous.user.domain.repository.UserRepository;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.sequence.anonymous.security.CustomOAuth2UserInfoFactory;
import com.sequence.anonymous.security.CustomOidcUser;
import com.sequence.anonymous.security.userinfo.CustomOAuth2UserInfo;
import com.sequence.anonymous.user.domain.OAuth2Provider;
import com.sequence.anonymous.user.domain.User;
import com.sequence.anonymous.user.domain.user.OAuth2Provider;
import com.sequence.anonymous.user.domain.user.User;
import com.sequence.anonymous.user.domain.repository.UserRepository;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sequence.anonymous.user.application;

import com.sequence.anonymous.user.domain.repository.TagRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class TagService {

private final TagRepository tagRepository;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.sequence.anonymous.user.application;

import com.sequence.anonymous.user.domain.repository.UserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class UserService {

private final UserRepository userRepository;
}
54 changes: 0 additions & 54 deletions src/main/java/com/sequence/anonymous/user/domain/User.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.sequence.anonymous.user.domain.repository;

import com.sequence.anonymous.user.domain.tag.Tag;
import org.springframework.data.jpa.repository.JpaRepository;

public interface TagRepository extends JpaRepository<Tag, Long> {
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.sequence.anonymous.user.domain.repository;

import com.sequence.anonymous.user.domain.User;
import com.sequence.anonymous.user.domain.user.User;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/com/sequence/anonymous/user/domain/tag/Tag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.sequence.anonymous.user.domain.tag;

import jakarta.persistence.*;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;

@Getter
@Entity
public class Tag {

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

@Column(unique = true, insertable = false, updatable = false, length = 10)
@NotNull
private String name;

protected Tag() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.sequence.anonymous.user.domain.user;

public enum Gender {
FEMALE,
MALE
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sequence.anonymous.user.domain;
package com.sequence.anonymous.user.domain.user;

import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.sequence.anonymous.user.domain;
package com.sequence.anonymous.user.domain.user;

public enum Role {
ROLE_USER("USER"),
Expand Down
Loading

0 comments on commit 9f36282

Please sign in to comment.