diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 8ff53d01..f527e51d 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,17 +1,14 @@ -## PR 타입(하나 이상의 PR 타입을 선택해주세요) +### PR 타입(하나 이상의 PR 타입을 선택해주세요) - [ ] 기능 추가 - [ ] 기능 삭제 - [ ] 버그 수정 - [ ] 의존성, 환경 변수, 빌드 관련 코드 업데이트 -## 반영 브랜치 +### 반영 브랜치 ex) feat/login -> develop -## 변경 사항 +### 변경 사항 ex) 로그인 시, 구글 소셜 로그인 기능을 추가했습니다. -## 이슈 -- - -## 테스트 결과 +### 테스트 결과 ex) 베이스 브랜치에 포함되기 위한 코드는 모두 정상적으로 동작해야 합니다. 결과물에 대한 스크린샷, GIF, 혹은 라이브 데모가 가능하도록 샘플API를 첨부할 수도 있습니다. diff --git a/build.gradle b/build.gradle index f26ab39e..d805d8b0 100644 --- a/build.gradle +++ b/build.gradle @@ -34,8 +34,6 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2' //Swagger 의존성 추가 implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE' // AWS 서비스 의존성 추가 - implementation 'org.springframework.boot:spring-boot-starter-validation' // validation - compileOnly 'org.projectlombok:lombok' runtimeOnly 'com.microsoft.sqlserver:mssql-jdbc' annotationProcessor 'org.projectlombok:lombok' diff --git a/src/main/java/gaji/service/ServiceApplication.java b/src/main/java/gaji/service/ServiceApplication.java index d7953bcc..179d0625 100644 --- a/src/main/java/gaji/service/ServiceApplication.java +++ b/src/main/java/gaji/service/ServiceApplication.java @@ -9,7 +9,7 @@ import java.util.TimeZone; @EnableJpaAuditing -@SpringBootApplication +@SpringBootApplication(exclude={DataSourceAutoConfiguration.class}) public class ServiceApplication { public static void main(String[] args) { diff --git a/src/main/java/gaji/service/config/AmazonConfig.java b/src/main/java/gaji/service/config/AmazonConfig.java index 5a6d3ba5..52074c1f 100644 --- a/src/main/java/gaji/service/config/AmazonConfig.java +++ b/src/main/java/gaji/service/config/AmazonConfig.java @@ -28,19 +28,19 @@ public class AmazonConfig { @Value("${cloud.aws.region.static}") private String region; - @Value("${cloud.aws.s3.bucket}") + @Value("${cloud.aws.s3.bucket") private String bucket; - @Value("${cloud.aws.s3.path.blog}") + @Value("${cloud.aws.s3.path.blog") private String blogPath; - @Value("${cloud.aws.s3.path.project}") + @Value("${cloud.aws.s3.path.project") private String projectPath; - @Value("${cloud.aws.s3.path.question}") + @Value("${cloud.aws.s3.path.question") private String questionPath; - @Value("${cloud.aws.s3.path.study}") + @Value("${cloud.aws.s3.path.study") private String studyPath; @PostConstruct diff --git a/src/main/java/gaji/service/domain/Report.java b/src/main/java/gaji/service/domain/Report.java index 0eac33f3..37296af3 100644 --- a/src/main/java/gaji/service/domain/Report.java +++ b/src/main/java/gaji/service/domain/Report.java @@ -2,6 +2,7 @@ import gaji.service.domain.enums.ReportPostEnum; import gaji.service.domain.enums.ReportPostTypeEnum; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/alram/Alarm.java b/src/main/java/gaji/service/domain/alram/Alarm.java index 3ab81195..9f863b53 100644 --- a/src/main/java/gaji/service/domain/alram/Alarm.java +++ b/src/main/java/gaji/service/domain/alram/Alarm.java @@ -1,6 +1,6 @@ package gaji.service.domain.alram; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.IsConfirmed; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/alram/UserAlarm.java b/src/main/java/gaji/service/domain/alram/UserAlarm.java index e62cfdf3..402820bb 100644 --- a/src/main/java/gaji/service/domain/alram/UserAlarm.java +++ b/src/main/java/gaji/service/domain/alram/UserAlarm.java @@ -1,6 +1,5 @@ package gaji.service.domain.alram; -import gaji.service.domain.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/common/entity/BaseEntity.java b/src/main/java/gaji/service/domain/common/BaseEntity.java similarity index 81% rename from src/main/java/gaji/service/domain/common/entity/BaseEntity.java rename to src/main/java/gaji/service/domain/common/BaseEntity.java index 7ef257e0..5ff7d209 100644 --- a/src/main/java/gaji/service/domain/common/entity/BaseEntity.java +++ b/src/main/java/gaji/service/domain/common/BaseEntity.java @@ -1,4 +1,4 @@ -package gaji.service.domain.common.entity; +package gaji.service.domain.common; import jakarta.persistence.Column; import org.springframework.data.annotation.CreatedDate; @@ -6,7 +6,7 @@ import java.time.LocalDateTime; -public abstract class BaseEntity { +public class BaseEntity { @CreatedDate @Column(updatable = false) private LocalDateTime createdAt; diff --git a/src/main/java/gaji/service/domain/common/converter/HashtagConverter.java b/src/main/java/gaji/service/domain/common/converter/HashtagConverter.java deleted file mode 100644 index 7267c099..00000000 --- a/src/main/java/gaji/service/domain/common/converter/HashtagConverter.java +++ /dev/null @@ -1,41 +0,0 @@ -package gaji.service.domain.common.converter; - -import gaji.service.domain.common.entity.Hashtag; -import gaji.service.domain.common.entity.SelectHashtag; -import gaji.service.domain.common.service.HashtagQueryService; -import gaji.service.domain.enums.PostTypeEnum; -import lombok.RequiredArgsConstructor; - -import java.util.List; -import java.util.stream.Collectors; - - -public class HashtagConverter { - - public static Hashtag toHashtag(String name) { - return Hashtag.builder() - .name(name) - .build(); - - } - - public static List toHashtagList(List hashtagList) { - return hashtagList.stream() - .map(hashtag -> - Hashtag.builder() - .name(hashtag) - .build() - ).collect(Collectors.toList()); - } - - public static List toSelectHashtagList(List hashtagList, Long entityId, PostTypeEnum type) { - return hashtagList.stream() - .map(hashtag -> - SelectHashtag.builder() - .hashtag(hashtag) - .entityId(entityId) - .type(type) - .build() - ).collect(Collectors.toList()); - } -} diff --git a/src/main/java/gaji/service/domain/common/repository/HashtagRepository.java b/src/main/java/gaji/service/domain/common/repository/HashtagRepository.java deleted file mode 100644 index 6ab7ec60..00000000 --- a/src/main/java/gaji/service/domain/common/repository/HashtagRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package gaji.service.domain.common.repository; - -import gaji.service.domain.common.entity.Hashtag; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface HashtagRepository extends JpaRepository { - Hashtag findByName(String name); - boolean existsByName(String name); -} diff --git a/src/main/java/gaji/service/domain/common/repository/SelectHashtagRepository.java b/src/main/java/gaji/service/domain/common/repository/SelectHashtagRepository.java deleted file mode 100644 index da830a90..00000000 --- a/src/main/java/gaji/service/domain/common/repository/SelectHashtagRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package gaji.service.domain.common.repository; - -import gaji.service.domain.common.entity.SelectHashtag; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface SelectHashtagRepository extends JpaRepository { -} diff --git a/src/main/java/gaji/service/domain/common/service/HashtagQueryService.java b/src/main/java/gaji/service/domain/common/service/HashtagQueryService.java deleted file mode 100644 index 42b17233..00000000 --- a/src/main/java/gaji/service/domain/common/service/HashtagQueryService.java +++ /dev/null @@ -1,7 +0,0 @@ -package gaji.service.domain.common.service; - - -public interface HashtagQueryService { - - boolean ExistHashtagByName(String name); -} diff --git a/src/main/java/gaji/service/domain/common/service/HashtagQueryServiceImpl.java b/src/main/java/gaji/service/domain/common/service/HashtagQueryServiceImpl.java deleted file mode 100644 index d5434d4f..00000000 --- a/src/main/java/gaji/service/domain/common/service/HashtagQueryServiceImpl.java +++ /dev/null @@ -1,17 +0,0 @@ -package gaji.service.domain.common.service; - -import gaji.service.domain.common.repository.HashtagRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; - -@Service -@RequiredArgsConstructor -public class HashtagQueryServiceImpl implements HashtagQueryService { - - private final HashtagRepository hashtagRepository; - - @Override - public boolean ExistHashtagByName(String name) { - return hashtagRepository.existsByName(name); - } -} diff --git a/src/main/java/gaji/service/domain/enums/PostStatusEnum.java b/src/main/java/gaji/service/domain/enums/PostStatusEnum.java index efa4b512..8168fa0e 100644 --- a/src/main/java/gaji/service/domain/enums/PostStatusEnum.java +++ b/src/main/java/gaji/service/domain/enums/PostStatusEnum.java @@ -1,35 +1,5 @@ package gaji.service.domain.enums; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -@Getter -@Slf4j public enum PostStatusEnum { - RECRUITING("모집중"), - RECRUITMENT_COMPLETED("모집완료"), - NEED_RESOLUTION("해결필요"), - RESOLVED("해결완료"), - DELETED("삭제됨"), - POSTING("게시중"); - - @JsonValue - private final String value; - - PostStatusEnum(String value) { - this.value = value; - } - - @JsonCreator // Json -> Object, 역직렬화 수행하는 메서드 - public static PostStatusEnum from(String param) { - for (PostStatusEnum postStatusEnum : PostStatusEnum.values()) { - if (postStatusEnum.getValue().equals(param)) { - return postStatusEnum; - } - } - log.error("PostStatusEnum.from() exception occur param: {}", param); - return null; - } + RECRUITING, RECRUITMENT_COMPLETED, NEED_RESOLUTION, RESOLVED, DELETED } diff --git a/src/main/java/gaji/service/domain/enums/PostTypeEnum.java b/src/main/java/gaji/service/domain/enums/PostTypeEnum.java index 2f0887b4..1c03761f 100644 --- a/src/main/java/gaji/service/domain/enums/PostTypeEnum.java +++ b/src/main/java/gaji/service/domain/enums/PostTypeEnum.java @@ -1,33 +1,6 @@ package gaji.service.domain.enums; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; -import lombok.Getter; -import lombok.extern.slf4j.Slf4j; - -@Getter -@Slf4j public enum PostTypeEnum { - BLOG("블로그"), - PROJECT_RECRUITMENT("프로젝트 모집"), - QUESTION("질문"); - - @JsonValue - private final String value; - - PostTypeEnum(String value) { - this.value = value; - } - - @JsonCreator // Json -> Object, 역직렬화 수행하는 메서드 - public static PostTypeEnum from(String param) { - for (PostTypeEnum postTypeEnum : PostTypeEnum.values()) { - if (postTypeEnum.getValue().equals(param)) { - return postTypeEnum; - } - } - log.error("PostTypeEnum.from() exception occur param: {}", param); - return null; - } + BLOG, PROJECT_RECRUITMENT, RECRUITMENT } diff --git a/src/main/java/gaji/service/domain/message/converter/MessageBodyConverter.java b/src/main/java/gaji/service/domain/message/converter/MessageBodyConverter.java new file mode 100644 index 00000000..b492f781 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/converter/MessageBodyConverter.java @@ -0,0 +1,12 @@ +package gaji.service.domain.message.converter; + +import gaji.service.domain.message.entity.MessageBody; +import gaji.service.domain.message.web.dto.MessageRequestDTO; + +public class MessageBodyConverter { + public static MessageBody toMessageBody(MessageRequestDTO.CreateMessageDTO messageRequestDTO){ + return MessageBody.builder() + .body(messageRequestDTO.getBody()) + .build(); + } +} diff --git a/src/main/java/gaji/service/domain/message/converter/MessageConverter.java b/src/main/java/gaji/service/domain/message/converter/MessageConverter.java new file mode 100644 index 00000000..e18d3b60 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/converter/MessageConverter.java @@ -0,0 +1,41 @@ +package gaji.service.domain.message.converter; + +import gaji.service.domain.message.entity.Message; +import gaji.service.domain.message.enums.MessageTypeEnum; +import gaji.service.domain.message.web.dto.MessageRequestDTO; +import gaji.service.domain.message.web.dto.MessageResponseDTO; +import gaji.service.domain.user.entity.User; + +import java.time.LocalDateTime; +import java.util.List; +import java.util.stream.Collectors; + +public class MessageConverter { + public static MessageResponseDTO.CreateResultDTO toCreateResultDTO(List messageList){ + List messageIds = messageList.stream() + .map(Message::getId) + .collect(Collectors.toList()); + + return MessageResponseDTO.CreateResultDTO.builder() + .messageIds(messageIds) + .build(); + } + + public static Message toSendMessage(User mine, User other){ + return Message.builder() + .mine(mine) + .other(other) + .type(MessageTypeEnum.Send) + .sendDate(LocalDateTime.now()) + .build(); + } + + public static Message toReceiveMessage(User mine, User other){ + return Message.builder() + .mine(other) + .other(mine) + .type(MessageTypeEnum.Receive) + .sendDate(LocalDateTime.now()). + build(); + } +} diff --git a/src/main/java/gaji/service/domain/message/Message.java b/src/main/java/gaji/service/domain/message/entity/Message.java similarity index 54% rename from src/main/java/gaji/service/domain/message/Message.java rename to src/main/java/gaji/service/domain/message/entity/Message.java index 6d52044b..95e01d59 100644 --- a/src/main/java/gaji/service/domain/message/Message.java +++ b/src/main/java/gaji/service/domain/message/entity/Message.java @@ -1,8 +1,10 @@ -package gaji.service.domain.message; +package gaji.service.domain.message.entity; -import gaji.service.domain.User; +import gaji.service.domain.message.enums.MessageTypeEnum; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -21,20 +23,31 @@ public class Message { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "my_id", referencedColumnName = "user_id") - private User sender; + private User self; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "other_id", referencedColumnName = "user_id") - private User receiver; + private User other; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "message_body_id") private MessageBody messageBody; - private Boolean type; + private MessageTypeEnum type; private LocalDateTime readDate; private LocalDateTime sendDate; - + @Builder + public Message(User mine, User other, MessageTypeEnum type, LocalDateTime sendDate) { + this.self = mine; + this.other = other; + this.type = type; + this.sendDate = sendDate; + } + + public void setMessageBody(MessageBody messageBody) { + this.messageBody = messageBody; + messageBody.getMessageList().add(this); + } } diff --git a/src/main/java/gaji/service/domain/message/MessageBody.java b/src/main/java/gaji/service/domain/message/entity/MessageBody.java similarity index 72% rename from src/main/java/gaji/service/domain/message/MessageBody.java rename to src/main/java/gaji/service/domain/message/entity/MessageBody.java index dcb49218..867844dd 100644 --- a/src/main/java/gaji/service/domain/message/MessageBody.java +++ b/src/main/java/gaji/service/domain/message/entity/MessageBody.java @@ -1,7 +1,9 @@ -package gaji.service.domain.message; +package gaji.service.domain.message.entity; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; +import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -21,4 +23,8 @@ public class MessageBody { private String body; + @Builder + public MessageBody(String body) { + this.body = body; + } } diff --git a/src/main/java/gaji/service/domain/message/enums/MessageTypeEnum.java b/src/main/java/gaji/service/domain/message/enums/MessageTypeEnum.java new file mode 100644 index 00000000..5cba7220 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/enums/MessageTypeEnum.java @@ -0,0 +1,5 @@ +package gaji.service.domain.message.enums; + +public enum MessageTypeEnum { + Send, Receive +} diff --git a/src/main/java/gaji/service/domain/message/repository/MessageBodyRepository.java b/src/main/java/gaji/service/domain/message/repository/MessageBodyRepository.java new file mode 100644 index 00000000..dc7f1986 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/repository/MessageBodyRepository.java @@ -0,0 +1,7 @@ +package gaji.service.domain.message.repository; + +import gaji.service.domain.message.entity.MessageBody; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MessageBodyRepository extends JpaRepository { +} diff --git a/src/main/java/gaji/service/domain/message/repository/MessageRepository.java b/src/main/java/gaji/service/domain/message/repository/MessageRepository.java new file mode 100644 index 00000000..c0d8fb18 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/repository/MessageRepository.java @@ -0,0 +1,7 @@ +package gaji.service.domain.message.repository; + +import gaji.service.domain.message.entity.Message; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface MessageRepository extends JpaRepository { +} diff --git a/src/main/java/gaji/service/domain/message/service/MessageCommandService.java b/src/main/java/gaji/service/domain/message/service/MessageCommandService.java new file mode 100644 index 00000000..f517066d --- /dev/null +++ b/src/main/java/gaji/service/domain/message/service/MessageCommandService.java @@ -0,0 +1,10 @@ +package gaji.service.domain.message.service; + +import gaji.service.domain.message.entity.Message; +import gaji.service.domain.message.web.dto.MessageRequestDTO; + +import java.util.List; + +public interface MessageCommandService { + public List createMessage(Long myId, Long otherId, MessageRequestDTO.CreateMessageDTO request); +} diff --git a/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java b/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java new file mode 100644 index 00000000..9d331f66 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/service/MessageCommandServiceImpl.java @@ -0,0 +1,54 @@ +package gaji.service.domain.message.service; + +import gaji.service.domain.message.converter.MessageBodyConverter; +import gaji.service.domain.message.entity.Message; +import gaji.service.domain.message.converter.MessageConverter; +import gaji.service.domain.message.entity.MessageBody; +import gaji.service.domain.message.repository.MessageBodyRepository; +import gaji.service.domain.message.repository.MessageRepository; +import gaji.service.domain.message.web.dto.MessageRequestDTO; +import gaji.service.domain.user.code.UserErrorStatus; +import gaji.service.domain.user.entity.User; +import gaji.service.domain.user.repository.UserRepository; +import gaji.service.global.exception.RestApiException; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class MessageCommandServiceImpl implements MessageCommandService{ + + private final UserRepository userRepository; + private final MessageRepository messageRepository; + private final MessageBodyRepository messageBodyRepository; + + + @Override + @Transactional + public List createMessage(Long myId, Long otherId, MessageRequestDTO.CreateMessageDTO request) { + + User mine = userRepository.findById(myId) + .orElseThrow(()-> new RestApiException(UserErrorStatus._USER_NOT_FOUND)); + User other = userRepository.findById(otherId) + .orElseThrow(()-> new RestApiException(UserErrorStatus._USER_NOT_FOUND)); + + Message sendMessage = MessageConverter.toSendMessage(mine,other); + Message receiveMessage = MessageConverter.toReceiveMessage(mine, other); + + MessageBody messageBody = MessageBodyConverter.toMessageBody(request); + + //연관관계 매핑을 위해 setter 사용 + sendMessage.setMessageBody(messageBody); + receiveMessage.setMessageBody(messageBody); + + messageRepository.save(sendMessage); + messageRepository.save(receiveMessage); + messageBodyRepository.save(messageBody); + + return Arrays.asList(sendMessage, receiveMessage); + } +} diff --git a/src/main/java/gaji/service/domain/message/service/MessageQueryService.java b/src/main/java/gaji/service/domain/message/service/MessageQueryService.java new file mode 100644 index 00000000..fe109cf1 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/service/MessageQueryService.java @@ -0,0 +1,4 @@ +package gaji.service.domain.message.service; + +public interface MessageQueryService { +} diff --git a/src/main/java/gaji/service/domain/message/service/MessageQueryServiceImpl.java b/src/main/java/gaji/service/domain/message/service/MessageQueryServiceImpl.java new file mode 100644 index 00000000..a63733ec --- /dev/null +++ b/src/main/java/gaji/service/domain/message/service/MessageQueryServiceImpl.java @@ -0,0 +1,7 @@ +package gaji.service.domain.message.service; + +import org.springframework.stereotype.Service; + +@Service +public class MessageQueryServiceImpl implements MessageQueryService{ +} diff --git a/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java b/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java new file mode 100644 index 00000000..bd49ffea --- /dev/null +++ b/src/main/java/gaji/service/domain/message/web/controller/MessageRestController.java @@ -0,0 +1,32 @@ +package gaji.service.domain.message.web.controller; + +import gaji.service.domain.message.entity.Message; +import gaji.service.domain.message.converter.MessageConverter; +import gaji.service.domain.message.service.MessageCommandService; +import gaji.service.domain.message.service.MessageQueryService; +import gaji.service.domain.message.web.dto.MessageRequestDTO; +import gaji.service.domain.message.web.dto.MessageResponseDTO; +import gaji.service.global.base.BaseResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@RequestMapping("/api/messages") +@RequiredArgsConstructor +public class MessageRestController { + private final MessageCommandService messageCommandService; + private final MessageQueryService messageQueryService; + + @PostMapping("/{otherId}") + public BaseResponse create(Long myId/*하드 코딩용 추후 수정.*/, + //@RequestHeader("Authorization") String token, + @PathVariable Long otherId, + @RequestBody @Valid MessageRequestDTO.CreateMessageDTO request) { + //Long myId = getUserIdFromToken(token); + List messageList = messageCommandService.createMessage(myId, otherId, request); + return BaseResponse.onSuccess(MessageConverter.toCreateResultDTO(messageList)); + } +} diff --git a/src/main/java/gaji/service/domain/message/web/dto/MessageRequestDTO.java b/src/main/java/gaji/service/domain/message/web/dto/MessageRequestDTO.java new file mode 100644 index 00000000..506351e4 --- /dev/null +++ b/src/main/java/gaji/service/domain/message/web/dto/MessageRequestDTO.java @@ -0,0 +1,15 @@ +package gaji.service.domain.message.web.dto; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +public class MessageRequestDTO { + + @Getter + @RequiredArgsConstructor + public static class CreateMessageDTO{ + @NotBlank(message = "쪽지 내용을 입력해주세요.") + private String body; + } +} diff --git a/src/main/java/gaji/service/domain/post/web/dto/PostResponseDTO.java b/src/main/java/gaji/service/domain/message/web/dto/MessageResponseDTO.java similarity index 52% rename from src/main/java/gaji/service/domain/post/web/dto/PostResponseDTO.java rename to src/main/java/gaji/service/domain/message/web/dto/MessageResponseDTO.java index 127918a8..e723b07a 100644 --- a/src/main/java/gaji/service/domain/post/web/dto/PostResponseDTO.java +++ b/src/main/java/gaji/service/domain/message/web/dto/MessageResponseDTO.java @@ -1,18 +1,19 @@ -package gaji.service.domain.post.web.dto; +package gaji.service.domain.message.web.dto; import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.List; -public class PostResponseDTO { +public class MessageResponseDTO { @Builder @Getter @NoArgsConstructor @AllArgsConstructor - public static class CreatePostDTO { - Long postId; + public static class CreateResultDTO{ + List messageIds; } } diff --git a/src/main/java/gaji/service/domain/post/annotation/ExistPostType.java b/src/main/java/gaji/service/domain/post/annotation/ExistPostType.java deleted file mode 100644 index ad053834..00000000 --- a/src/main/java/gaji/service/domain/post/annotation/ExistPostType.java +++ /dev/null @@ -1,17 +0,0 @@ -package gaji.service.domain.post.annotation; - -import gaji.service.domain.post.validation.PostTypeExistValidator; -import jakarta.validation.Constraint; -import jakarta.validation.Payload; - -import java.lang.annotation.*; - -@Documented -@Constraint(validatedBy = PostTypeExistValidator.class) -@Target( { ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER }) -@Retention(RetentionPolicy.RUNTIME) -public @interface ExistPostType { - String message() default "해당하는 게시글 유형이 존재하지 않습니다."; - Class[] groups() default {}; - Class[] payload() default {}; -} diff --git a/src/main/java/gaji/service/domain/post/converter/PostConverter.java b/src/main/java/gaji/service/domain/post/converter/PostConverter.java index 4c763544..2cc83db3 100644 --- a/src/main/java/gaji/service/domain/post/converter/PostConverter.java +++ b/src/main/java/gaji/service/domain/post/converter/PostConverter.java @@ -1,10 +1,10 @@ package gaji.service.domain.post.converter; -import gaji.service.domain.User; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; import gaji.service.domain.post.entity.Post; import gaji.service.domain.post.web.dto.PostRequestDTO; +import gaji.service.domain.user.entity.User; public class PostConverter { diff --git a/src/main/java/gaji/service/domain/post/repository/PostRepository.java b/src/main/java/gaji/service/domain/post/repository/PostRepository.java deleted file mode 100644 index 424ffe4c..00000000 --- a/src/main/java/gaji/service/domain/post/repository/PostRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package gaji.service.domain.post.repository; - -import gaji.service.domain.post.entity.Post; -import org.springframework.data.jpa.repository.JpaRepository; - -public interface PostRepository extends JpaRepository { -} diff --git a/src/main/java/gaji/service/domain/post/service/PostCommandService.java b/src/main/java/gaji/service/domain/post/service/PostCommandService.java deleted file mode 100644 index d3166853..00000000 --- a/src/main/java/gaji/service/domain/post/service/PostCommandService.java +++ /dev/null @@ -1,10 +0,0 @@ -package gaji.service.domain.post.service; - -import gaji.service.domain.post.entity.Post; -import gaji.service.domain.post.web.dto.PostRequestDTO; - -public interface PostCommandService { - - Post uploadPost(Long userId, PostRequestDTO.UploadPostDTO request); - -} diff --git a/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java b/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java index 44305126..458ff5c4 100644 --- a/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java +++ b/src/main/java/gaji/service/domain/post/service/PostCommandServiceImpl.java @@ -1,6 +1,5 @@ package gaji.service.domain.post.service; -import gaji.service.domain.User; import gaji.service.domain.common.converter.HashtagConverter; import gaji.service.domain.common.entity.Hashtag; import gaji.service.domain.common.entity.SelectHashtag; @@ -11,6 +10,7 @@ import gaji.service.domain.post.entity.Post; import gaji.service.domain.post.repository.PostRepository; import gaji.service.domain.post.web.dto.PostRequestDTO; +import gaji.service.domain.user.entity.User; import gaji.service.domain.user.repository.UserRepository; import gaji.service.global.exception.RestApiException; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java b/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java deleted file mode 100644 index 38e0bef4..00000000 --- a/src/main/java/gaji/service/domain/post/validation/PostTypeExistValidator.java +++ /dev/null @@ -1,29 +0,0 @@ -package gaji.service.domain.post.validation; - -import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.post.annotation.ExistPostType; -import gaji.service.domain.post.code.PostErrorStatus; -import jakarta.validation.ConstraintValidator; -import jakarta.validation.ConstraintValidatorContext; -import org.springframework.stereotype.Component; - -@Component -public class PostTypeExistValidator implements ConstraintValidator { - - @Override - public void initialize(ExistPostType constraintAnnotation) { - ConstraintValidator.super.initialize(constraintAnnotation); - } - - @Override - public boolean isValid(PostTypeEnum value, ConstraintValidatorContext context) { - boolean isValid = value == PostTypeEnum.BLOG || value == PostTypeEnum.PROJECT_RECRUITMENT || value == PostTypeEnum.QUESTION; - - if (!isValid) { - context.disableDefaultConstraintViolation(); - context.buildConstraintViolationWithTemplate(PostErrorStatus._POST_TYPE_NOT_FOUND.getMessage()).addConstraintViolation(); - } - - return isValid; - } -} diff --git a/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java b/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java deleted file mode 100644 index 948599d4..00000000 --- a/src/main/java/gaji/service/domain/post/web/controller/PostRestController.java +++ /dev/null @@ -1,31 +0,0 @@ -package gaji.service.domain.post.web.controller; - -import gaji.service.domain.post.entity.Post; -import gaji.service.domain.post.service.PostCommandService; -import gaji.service.domain.post.web.dto.PostRequestDTO; -import gaji.service.global.base.BaseResponse; -import io.swagger.v3.oas.annotations.Operation; -import jakarta.validation.Valid; -import lombok.RequiredArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@RequiredArgsConstructor -@RequestMapping("/api/community-posts") -public class PostRestController { - - private final PostCommandService postCommandService; - - @PostMapping - @Operation(summary = "커뮤니티 게시글 업로드 API",description = "커뮤니티의 게시글을 업로드하는 API입니다. 게시글 유형과 제목, 본문 내용을 검증합니다.") - public BaseResponse uploadPost(Long userId, @RequestBody @Valid PostRequestDTO.UploadPostDTO request) { - Post newPost = postCommandService.uploadPost(userId, request); - return BaseResponse.onSuccess(newPost.getId()); - } - - -} diff --git a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java b/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java deleted file mode 100644 index f9006951..00000000 --- a/src/main/java/gaji/service/domain/post/web/dto/PostRequestDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -package gaji.service.domain.post.web.dto; - -import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.post.annotation.ExistPostType; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotBlank; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.util.ArrayList; -import java.util.List; - -public class PostRequestDTO { - - @Schema(description = "커뮤니티 게시글 저장 DTO") - @Getter - @RequiredArgsConstructor - public static class UploadPostDTO { - @Schema(description = "게시글 제목") - @NotBlank(message = "게시글 제목을 입력해주세요.") - private final String title; - - @Schema(description = "게시글 본문") - @NotBlank(message = "게시글 본문을 입력해주세요.") - private final String body; - - @Schema(description = "게시글 유형(프로젝트 모집, 질문, 블로그)") - @ExistPostType - private final PostTypeEnum type; - - @Schema(description = "해시태그 리스트") - private final List hashtagList = new ArrayList<>(); - } -} diff --git a/src/main/java/gaji/service/domain/post/entity/Comment.java b/src/main/java/gaji/service/domain/psot/Comment.java similarity index 92% rename from src/main/java/gaji/service/domain/post/entity/Comment.java rename to src/main/java/gaji/service/domain/psot/Comment.java index 2d933365..a375f0c3 100644 --- a/src/main/java/gaji/service/domain/post/entity/Comment.java +++ b/src/main/java/gaji/service/domain/psot/Comment.java @@ -1,6 +1,6 @@ -package gaji.service.domain.post.entity; +package gaji.service.domain.psot; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.CommentStatus; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/post/entity/Post.java b/src/main/java/gaji/service/domain/psot/Post.java similarity index 69% rename from src/main/java/gaji/service/domain/post/entity/Post.java rename to src/main/java/gaji/service/domain/psot/Post.java index 85ea0e12..8b4893e8 100644 --- a/src/main/java/gaji/service/domain/post/entity/Post.java +++ b/src/main/java/gaji/service/domain/psot/Post.java @@ -1,11 +1,10 @@ -package gaji.service.domain.post.entity; +package gaji.service.domain.psot; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.PostStatusEnum; import gaji.service.domain.enums.PostTypeEnum; import jakarta.persistence.*; import lombok.AccessLevel; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -44,21 +43,4 @@ public class Post { @Enumerated(EnumType.STRING) private PostStatusEnum status; - - @Builder - public Post(User user, String title, String body, PostTypeEnum type, PostStatusEnum status) { - this.user = user; - this.title = title; - this.body = body; - this.type = type; - this.status = status; - } - - // 엔티티 생성 시 초기값 설정 - @PrePersist - public void prePersist() { - this.views = 0; - this.likes = 0; - this.bookmarks = 0; - } } diff --git a/src/main/java/gaji/service/domain/post/entity/PostBookmark.java b/src/main/java/gaji/service/domain/psot/PostBookmark.java similarity index 86% rename from src/main/java/gaji/service/domain/post/entity/PostBookmark.java rename to src/main/java/gaji/service/domain/psot/PostBookmark.java index 5180c3a4..3e233e50 100644 --- a/src/main/java/gaji/service/domain/post/entity/PostBookmark.java +++ b/src/main/java/gaji/service/domain/psot/PostBookmark.java @@ -1,6 +1,6 @@ -package gaji.service.domain.post.entity; +package gaji.service.domain.psot; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/post/entity/PostFile.java b/src/main/java/gaji/service/domain/psot/PostFile.java similarity index 86% rename from src/main/java/gaji/service/domain/post/entity/PostFile.java rename to src/main/java/gaji/service/domain/psot/PostFile.java index 6f4ba260..a56ed4a2 100644 --- a/src/main/java/gaji/service/domain/post/entity/PostFile.java +++ b/src/main/java/gaji/service/domain/psot/PostFile.java @@ -1,6 +1,6 @@ -package gaji.service.domain.post.entity; +package gaji.service.domain.psot; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/post/entity/PostLikes.java b/src/main/java/gaji/service/domain/psot/PostLikes.java similarity index 86% rename from src/main/java/gaji/service/domain/post/entity/PostLikes.java rename to src/main/java/gaji/service/domain/psot/PostLikes.java index 667b3aa3..fced5139 100644 --- a/src/main/java/gaji/service/domain/post/entity/PostLikes.java +++ b/src/main/java/gaji/service/domain/psot/PostLikes.java @@ -1,6 +1,6 @@ -package gaji.service.domain.post.entity; +package gaji.service.domain.psot; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/recruite/Category.java b/src/main/java/gaji/service/domain/recruite/Category.java index 1abe3841..2d6eb55c 100644 --- a/src/main/java/gaji/service/domain/recruite/Category.java +++ b/src/main/java/gaji/service/domain/recruite/Category.java @@ -21,4 +21,4 @@ public class Category { @Column(length = 30) private String name; -} \ No newline at end of file +} diff --git a/src/main/java/gaji/service/domain/common/entity/Hashtag.java b/src/main/java/gaji/service/domain/recruite/Hashtag.java similarity index 53% rename from src/main/java/gaji/service/domain/common/entity/Hashtag.java rename to src/main/java/gaji/service/domain/recruite/Hashtag.java index 398e1d3b..fd615456 100644 --- a/src/main/java/gaji/service/domain/common/entity/Hashtag.java +++ b/src/main/java/gaji/service/domain/recruite/Hashtag.java @@ -1,16 +1,10 @@ -package gaji.service.domain.common.entity; +package gaji.service.domain.recruite; -import gaji.service.domain.enums.PostTypeEnum; -import gaji.service.domain.recruite.SelectCategory; import jakarta.persistence.*; import lombok.AccessLevel; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.ArrayList; -import java.util.List; - @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @@ -22,8 +16,4 @@ public class Hashtag { @Column(length = 30) private String name; - @Builder - public Hashtag(String name) { - this.name = name; - } } diff --git a/src/main/java/gaji/service/domain/recruite/RecruitPost.java b/src/main/java/gaji/service/domain/recruite/RecruitPost.java index 8f5a68f7..c6b01bfa 100644 --- a/src/main/java/gaji/service/domain/recruite/RecruitPost.java +++ b/src/main/java/gaji/service/domain/recruite/RecruitPost.java @@ -1,10 +1,10 @@ package gaji.service.domain.recruite; -import gaji.service.domain.User; import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.common.entity.SelectHashtag; import gaji.service.domain.enums.RecruitePostTypeEnum; import gaji.service.domain.room.Room; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/recruite/RecruitPostBookmark.java b/src/main/java/gaji/service/domain/recruite/RecruitPostBookmark.java index d128f452..0485ef78 100644 --- a/src/main/java/gaji/service/domain/recruite/RecruitPostBookmark.java +++ b/src/main/java/gaji/service/domain/recruite/RecruitPostBookmark.java @@ -1,6 +1,6 @@ package gaji.service.domain.recruite; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/recruite/RecruitPostLikes.java b/src/main/java/gaji/service/domain/recruite/RecruitPostLikes.java index 16f91cfa..8e27dbab 100644 --- a/src/main/java/gaji/service/domain/recruite/RecruitPostLikes.java +++ b/src/main/java/gaji/service/domain/recruite/RecruitPostLikes.java @@ -1,6 +1,6 @@ package gaji.service.domain.recruite; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/recruite/SearchKeyword.java b/src/main/java/gaji/service/domain/recruite/SearchKeyword.java index 913a02f5..3b637efa 100644 --- a/src/main/java/gaji/service/domain/recruite/SearchKeyword.java +++ b/src/main/java/gaji/service/domain/recruite/SearchKeyword.java @@ -1,6 +1,6 @@ package gaji.service.domain.recruite; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/common/entity/SelectHashtag.java b/src/main/java/gaji/service/domain/recruite/SelectHashtag.java similarity index 50% rename from src/main/java/gaji/service/domain/common/entity/SelectHashtag.java rename to src/main/java/gaji/service/domain/recruite/SelectHashtag.java index 4299b07b..e9a2e693 100644 --- a/src/main/java/gaji/service/domain/common/entity/SelectHashtag.java +++ b/src/main/java/gaji/service/domain/recruite/SelectHashtag.java @@ -1,9 +1,7 @@ -package gaji.service.domain.common.entity; +package gaji.service.domain.recruite; -import gaji.service.domain.enums.PostTypeEnum; import jakarta.persistence.*; import lombok.AccessLevel; -import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; @@ -15,19 +13,12 @@ public class SelectHashtag { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "post_id") + private RecruitPost recruitPost; + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "hashtag_id") private Hashtag hashtag; - private Long entityId; - - @Enumerated(EnumType.STRING) - private PostTypeEnum type; - - @Builder - public SelectHashtag(Hashtag hashtag, Long entityId, PostTypeEnum type) { - this.hashtag = hashtag; - this.entityId = entityId; - this.type = type; - } } diff --git a/src/main/java/gaji/service/domain/room/Event.java b/src/main/java/gaji/service/domain/room/Event.java index c6f383dd..625c1ffb 100644 --- a/src/main/java/gaji/service/domain/room/Event.java +++ b/src/main/java/gaji/service/domain/room/Event.java @@ -1,6 +1,6 @@ package gaji.service.domain.room; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.myRepeat.MyRepeat; import gaji.service.domain.myRepeat.RepeatException; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/room/VoiceChatUser.java b/src/main/java/gaji/service/domain/room/VoiceChatUser.java index cad8ddce..c5b44470 100644 --- a/src/main/java/gaji/service/domain/room/VoiceChatUser.java +++ b/src/main/java/gaji/service/domain/room/VoiceChatUser.java @@ -1,6 +1,6 @@ package gaji.service.domain.room; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomComment.java b/src/main/java/gaji/service/domain/roomPost/RoomComment.java index fdf20c12..38273c64 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomComment.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomComment.java @@ -1,9 +1,7 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; -import gaji.service.domain.enums.RoomAlarmTypeEnum; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.UserAlarmTypeEnum; -import gaji.service.domain.studyMate.StudyMate; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomCommentLikes.java b/src/main/java/gaji/service/domain/roomPost/RoomCommentLikes.java index 8cef1a00..9a1b892c 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomCommentLikes.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomCommentLikes.java @@ -1,7 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; -import gaji.service.domain.studyMate.StudyMate; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomPost.java b/src/main/java/gaji/service/domain/roomPost/RoomPost.java index 8af0dc00..cae40819 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomPost.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomPost.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.PostStatusEnum; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomPostBookmark.java b/src/main/java/gaji/service/domain/roomPost/RoomPostBookmark.java index a8662b02..28f860d9 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomPostBookmark.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomPostBookmark.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomPostFile.java b/src/main/java/gaji/service/domain/roomPost/RoomPostFile.java index 766e80f2..aa1328cb 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomPostFile.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomPostFile.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomPostLikes.java b/src/main/java/gaji/service/domain/roomPost/RoomPostLikes.java index 656bebe3..58fc86c3 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomPostLikes.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomPostLikes.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/roomPost/RoomPostReport.java b/src/main/java/gaji/service/domain/roomPost/RoomPostReport.java index 2e9ae6b3..5fcf5640 100644 --- a/src/main/java/gaji/service/domain/roomPost/RoomPostReport.java +++ b/src/main/java/gaji/service/domain/roomPost/RoomPostReport.java @@ -1,6 +1,6 @@ package gaji.service.domain.roomPost; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.ReportPostTypeEnum; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/src/main/java/gaji/service/domain/studyMate/ChatMessage.java b/src/main/java/gaji/service/domain/studyMate/ChatMessage.java index b7cbfe93..913602d4 100644 --- a/src/main/java/gaji/service/domain/studyMate/ChatMessage.java +++ b/src/main/java/gaji/service/domain/studyMate/ChatMessage.java @@ -1,6 +1,6 @@ package gaji.service.domain.studyMate; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/studyMate/ChatUser.java b/src/main/java/gaji/service/domain/studyMate/ChatUser.java index 5f679949..08590887 100644 --- a/src/main/java/gaji/service/domain/studyMate/ChatUser.java +++ b/src/main/java/gaji/service/domain/studyMate/ChatUser.java @@ -1,6 +1,6 @@ package gaji.service.domain.studyMate; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/studyMate/StudyApplicant.java b/src/main/java/gaji/service/domain/studyMate/StudyApplicant.java index 3791c1cb..7c2dd50d 100644 --- a/src/main/java/gaji/service/domain/studyMate/StudyApplicant.java +++ b/src/main/java/gaji/service/domain/studyMate/StudyApplicant.java @@ -1,6 +1,6 @@ package gaji.service.domain.studyMate; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.ApplicantStatus; import gaji.service.domain.room.Room; import jakarta.persistence.*; diff --git a/src/main/java/gaji/service/domain/studyMate/StudyMate.java b/src/main/java/gaji/service/domain/studyMate/StudyMate.java index 799f61c8..4b06d1c3 100644 --- a/src/main/java/gaji/service/domain/studyMate/StudyMate.java +++ b/src/main/java/gaji/service/domain/studyMate/StudyMate.java @@ -1,8 +1,7 @@ package gaji.service.domain.studyMate; -import gaji.service.domain.User; -import gaji.service.domain.roomPost.RoomComment; +import gaji.service.domain.user.entity.User; import gaji.service.domain.enums.Role; import gaji.service.domain.room.Room; import jakarta.persistence.*; @@ -10,9 +9,6 @@ import lombok.Getter; import lombok.NoArgsConstructor; -import java.util.ArrayList; -import java.util.List; - @Entity @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) diff --git a/src/main/java/gaji/service/domain/studyMate/UserAssignment.java b/src/main/java/gaji/service/domain/studyMate/UserAssignment.java index eb15cfae..c69bd41d 100644 --- a/src/main/java/gaji/service/domain/studyMate/UserAssignment.java +++ b/src/main/java/gaji/service/domain/studyMate/UserAssignment.java @@ -1,6 +1,6 @@ package gaji.service.domain.studyMate; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/term/TermAgree.java b/src/main/java/gaji/service/domain/term/TermAgree.java index 8759fce1..68b1c7cf 100644 --- a/src/main/java/gaji/service/domain/term/TermAgree.java +++ b/src/main/java/gaji/service/domain/term/TermAgree.java @@ -1,6 +1,6 @@ package gaji.service.domain.term; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; diff --git a/src/main/java/gaji/service/domain/token.java b/src/main/java/gaji/service/domain/token.java index d231cc1a..86594e4c 100644 --- a/src/main/java/gaji/service/domain/token.java +++ b/src/main/java/gaji/service/domain/token.java @@ -1,12 +1,12 @@ package gaji.service.domain; import gaji.service.domain.enums.IsRevoked; +import gaji.service.domain.user.entity.User; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; -import java.time.LocalDate; import java.time.LocalDateTime; @Entity diff --git a/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java b/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java similarity index 70% rename from src/main/java/gaji/service/domain/post/code/PostErrorStatus.java rename to src/main/java/gaji/service/domain/user/code/UserErrorStatus.java index 7b4b06dd..638d835b 100644 --- a/src/main/java/gaji/service/domain/post/code/PostErrorStatus.java +++ b/src/main/java/gaji/service/domain/user/code/UserErrorStatus.java @@ -1,4 +1,4 @@ -package gaji.service.domain.post.code; +package gaji.service.domain.user.code; import gaji.service.global.exception.code.BaseCodeDto; import gaji.service.global.exception.code.BaseErrorCodeInterface; @@ -6,13 +6,11 @@ import lombok.Getter; import org.springframework.http.HttpStatus; - @Getter @AllArgsConstructor -public enum PostErrorStatus implements BaseErrorCodeInterface { +public enum UserErrorStatus implements BaseErrorCodeInterface { - _POST_TYPE_NOT_FOUND(HttpStatus.BAD_REQUEST, "POST_4001", "존재하지 않는 게시글 유형입니다."), - _USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "USER_4001", "존재하지 않는 회원입니다."), // user 도메인을 건드리지 않기 위해 생성한 임시 에러코드 + _USER_NOT_FOUND(HttpStatus.BAD_REQUEST, "USER_4001", "존재하지 않는 회원입니다."), ; private final HttpStatus httpStatus; diff --git a/src/main/java/gaji/service/domain/user/converter/UserConverter.java b/src/main/java/gaji/service/domain/user/converter/UserConverter.java new file mode 100644 index 00000000..393d8582 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/converter/UserConverter.java @@ -0,0 +1,4 @@ +package gaji.service.domain.user.converter; + +public class UserConverter { +} diff --git a/src/main/java/gaji/service/domain/User.java b/src/main/java/gaji/service/domain/user/entity/User.java similarity index 95% rename from src/main/java/gaji/service/domain/User.java rename to src/main/java/gaji/service/domain/user/entity/User.java index f23ad847..08cf0f58 100644 --- a/src/main/java/gaji/service/domain/User.java +++ b/src/main/java/gaji/service/domain/user/entity/User.java @@ -1,12 +1,13 @@ -package gaji.service.domain; +package gaji.service.domain.user.entity; +import gaji.service.domain.Report; import gaji.service.domain.alram.Alarm; import gaji.service.domain.common.entity.BaseEntity; import gaji.service.domain.enums.Gender; import gaji.service.domain.enums.Role; import gaji.service.domain.enums.SocialType; import gaji.service.domain.enums.UserActive; -import gaji.service.domain.message.Message; +import gaji.service.domain.message.entity.Message; import gaji.service.domain.post.entity.*; import gaji.service.domain.recruite.*; import gaji.service.domain.room.Event; @@ -66,10 +67,10 @@ public class User extends BaseEntity { @OneToMany(mappedBy = "user",cascade = CascadeType.ALL ) private List recruitPostBookmarkList = new ArrayList<>(); - @OneToMany(mappedBy = "sender") + @OneToMany(mappedBy = "self") private List sentMessages = new ArrayList<>(); - @OneToMany(mappedBy = "receiver") + @OneToMany(mappedBy = "other") private List receivedMessages = new ArrayList<>(); @OneToMany(mappedBy = "user") diff --git a/src/main/java/gaji/service/domain/user/repository/UserRepository.java b/src/main/java/gaji/service/domain/user/repository/UserRepository.java index a13426fb..7d1d3be0 100644 --- a/src/main/java/gaji/service/domain/user/repository/UserRepository.java +++ b/src/main/java/gaji/service/domain/user/repository/UserRepository.java @@ -1,7 +1,10 @@ package gaji.service.domain.user.repository; -import gaji.service.domain.User; +import gaji.service.domain.user.entity.User; import org.springframework.data.jpa.repository.JpaRepository; +import java.util.Optional; + public interface UserRepository extends JpaRepository { + Optional findById(Long id); } diff --git a/src/main/java/gaji/service/domain/user/service/UserCommandService.java b/src/main/java/gaji/service/domain/user/service/UserCommandService.java new file mode 100644 index 00000000..fb379dc3 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/service/UserCommandService.java @@ -0,0 +1,4 @@ +package gaji.service.domain.user.service; + +public interface UserCommandService { +} diff --git a/src/main/java/gaji/service/domain/user/service/UserCommandServiceImpl.java b/src/main/java/gaji/service/domain/user/service/UserCommandServiceImpl.java new file mode 100644 index 00000000..32fc08a4 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/service/UserCommandServiceImpl.java @@ -0,0 +1,8 @@ +package gaji.service.domain.user.service; + +import org.springframework.stereotype.Service; + +@Service +public class UserCommandServiceImpl implements UserCommandService{ + +} diff --git a/src/main/java/gaji/service/domain/user/service/UserQueryService.java b/src/main/java/gaji/service/domain/user/service/UserQueryService.java new file mode 100644 index 00000000..6e503a92 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/service/UserQueryService.java @@ -0,0 +1,4 @@ +package gaji.service.domain.user.service; + +public interface UserQueryService { +} diff --git a/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java b/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java new file mode 100644 index 00000000..1dc40949 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/service/UserQueryServiceImpl.java @@ -0,0 +1,7 @@ +package gaji.service.domain.user.service; + +import org.springframework.stereotype.Service; + +@Service +public class UserQueryServiceImpl implements UserQueryService { +} diff --git a/src/main/java/gaji/service/domain/user/web/controller/UserRestController.java b/src/main/java/gaji/service/domain/user/web/controller/UserRestController.java new file mode 100644 index 00000000..c866a100 --- /dev/null +++ b/src/main/java/gaji/service/domain/user/web/controller/UserRestController.java @@ -0,0 +1,22 @@ +package gaji.service.domain.user.web.controller; + +import gaji.service.domain.user.converter.UserConverter; +import gaji.service.domain.user.entity.User; +import gaji.service.domain.user.service.UserCommandService; +import gaji.service.domain.user.service.UserQueryService; +import gaji.service.domain.user.web.dto.UserResponseDTO; +import gaji.service.global.base.BaseResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/users") +@RequiredArgsConstructor +public class UserRestController { + private final UserCommandService userCommandService; + private final UserQueryService userQueryService; +} + diff --git a/src/main/java/gaji/service/domain/user/web/dto/UserResponseDTO.java b/src/main/java/gaji/service/domain/user/web/dto/UserResponseDTO.java new file mode 100644 index 00000000..a31a197e --- /dev/null +++ b/src/main/java/gaji/service/domain/user/web/dto/UserResponseDTO.java @@ -0,0 +1,14 @@ +package gaji.service.domain.user.web.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +public class UserResponseDTO { +} + + +