diff --git a/src/main/java/com/dissonance/itit/DissonanceApplication.java b/src/main/java/com/dissonance/itit/DissonanceApplication.java index 8389b10..f06ab60 100644 --- a/src/main/java/com/dissonance/itit/DissonanceApplication.java +++ b/src/main/java/com/dissonance/itit/DissonanceApplication.java @@ -8,8 +8,8 @@ @SpringBootApplication public class DissonanceApplication { - public static void main(String[] args) { - SpringApplication.run(DissonanceApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(DissonanceApplication.class, args); + } } diff --git a/src/main/java/com/dissonance/itit/domain/entity/Report.java b/src/main/java/com/dissonance/itit/bookmark/domain/Bookmark.java similarity index 75% rename from src/main/java/com/dissonance/itit/domain/entity/Report.java rename to src/main/java/com/dissonance/itit/bookmark/domain/Bookmark.java index 2b0f677..b292e01 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/Report.java +++ b/src/main/java/com/dissonance/itit/bookmark/domain/Bookmark.java @@ -1,4 +1,7 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.bookmark.domain; + +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.user.domain.User; import jakarta.persistence.Column; import jakarta.persistence.Entity; @@ -9,7 +12,6 @@ import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; -import jakarta.validation.constraints.Size; import lombok.AccessLevel; import lombok.AllArgsConstructor; import lombok.Builder; @@ -21,8 +23,8 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @NoArgsConstructor(access = AccessLevel.PROTECTED) @Entity -@Table(name = "report") -public class Report { +@Table(name = "bookmark") +public class Bookmark { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") @@ -33,10 +35,6 @@ public class Report { private User user; @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "info_post_id") - private InfoPost infoPost; - - @Size(max = 255) - @Column(name = "content") - private String content; + @JoinColumn(name = "post_id") + private InfoPost post; } \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/client/KakaoInformationFeignClient.java b/src/main/java/com/dissonance/itit/client/KakaoInformationFeignClient.java deleted file mode 100644 index 06a062e..0000000 --- a/src/main/java/com/dissonance/itit/client/KakaoInformationFeignClient.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.dissonance.itit.client; - -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; - -@FeignClient(name = "KakaoInformationFeignClient", - url = "${kakao.api_url.information}") -public interface KakaoInformationFeignClient { - @GetMapping - ResponseEntity call( - @RequestHeader("Content-Type") String contentType, - @RequestHeader("Authorization") String accessToken - ); -} diff --git a/src/main/java/com/dissonance/itit/common/converter/MultipartJackson2HttpMessageConverter.java b/src/main/java/com/dissonance/itit/common/converter/MultipartJackson2HttpMessageConverter.java deleted file mode 100644 index a5587f2..0000000 --- a/src/main/java/com/dissonance/itit/common/converter/MultipartJackson2HttpMessageConverter.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.dissonance.itit.common.converter; - -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.http.MediaType; -import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; -import org.springframework.stereotype.Component; - -import java.lang.reflect.Type; - -@Component -public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter { - /** - * Converter for support http request with header Content-Type: multipart/form-data - */ - public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) { - super(objectMapper, MediaType.APPLICATION_OCTET_STREAM); - } - - @Override - public boolean canWrite(Class clazz, MediaType mediaType) { - return false; - } - - @Override - public boolean canWrite(Type type, Class clazz, MediaType mediaType) { - return false; - } - - @Override - protected boolean canWrite(MediaType mediaType) { - return false; - } -} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/common/exception/CustomException.java b/src/main/java/com/dissonance/itit/common/exception/CustomException.java deleted file mode 100644 index 6074e01..0000000 --- a/src/main/java/com/dissonance/itit/common/exception/CustomException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dissonance.itit.common.exception; - -import lombok.Getter; - -@Getter -public class CustomException extends RuntimeException { - private final ErrorCode errorCode; - - public CustomException(ErrorCode errorCode) { - super(errorCode.getMessage()); - this.errorCode = errorCode; - } -} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/config/S3Config.java b/src/main/java/com/dissonance/itit/config/S3Config.java deleted file mode 100644 index 9c1b892..0000000 --- a/src/main/java/com/dissonance/itit/config/S3Config.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.dissonance.itit.config; - -import com.amazonaws.auth.AWSStaticCredentialsProvider; -import com.amazonaws.auth.BasicAWSCredentials; -import com.amazonaws.services.s3.AmazonS3Client; -import com.amazonaws.services.s3.AmazonS3ClientBuilder; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class S3Config { - @Value("${cloud.aws.credentials.access-key}") - private String accessKey; - - @Value("${cloud.aws.credentials.secret-key}") - private String secretKey; - - @Value("${cloud.aws.region.static}") - private String region; - - @Bean - public AmazonS3Client amazonS3Client() { - BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey); - - return (AmazonS3Client) AmazonS3ClientBuilder.standard() - .withRegion(region) - .withCredentials(new AWSStaticCredentialsProvider(awsCreds)) - .build(); - } -} diff --git a/src/main/java/com/dissonance/itit/domain/entity/Bookmark.java b/src/main/java/com/dissonance/itit/domain/entity/Bookmark.java deleted file mode 100644 index 9175bfe..0000000 --- a/src/main/java/com/dissonance/itit/domain/entity/Bookmark.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.dissonance.itit.domain.entity; - -import jakarta.persistence.*; -import lombok.*; - -@Getter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -@Table(name = "bookmark") -public class Bookmark { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Long id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "user_id") - private User user; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "post_id") - private InfoPost post; -} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/domain/entity/Category.java b/src/main/java/com/dissonance/itit/domain/entity/Category.java deleted file mode 100644 index e91589f..0000000 --- a/src/main/java/com/dissonance/itit/domain/entity/Category.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dissonance.itit.domain.entity; - -import jakarta.persistence.*; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import lombok.*; - -@Getter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -@Table(name = "category") -public class Category { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @ManyToOne(fetch = FetchType.LAZY) - @JoinColumn(name = "parent_id") - private Category parent; - - @Size(max = 30) - @NotNull - @Column(name = "name") - private String name; -} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/domain/entity/FeaturedPost.java b/src/main/java/com/dissonance/itit/domain/entity/FeaturedPost.java deleted file mode 100644 index 8596820..0000000 --- a/src/main/java/com/dissonance/itit/domain/entity/FeaturedPost.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.dissonance.itit.domain.entity; - -import jakarta.persistence.*; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import lombok.*; - -@Getter -@Builder -@AllArgsConstructor(access = AccessLevel.PRIVATE) -@NoArgsConstructor(access = AccessLevel.PROTECTED) -@Entity -@Table(name = "featured_post") -public class FeaturedPost { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "id") - private Integer id; - - @Size(max = 500) - @NotNull - @Column(name = "banner_image_url") - private String bannerImageUrl; - - @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - @JoinColumn(name = "info_post_id") - private InfoPost infoPost; -} diff --git a/src/main/java/com/dissonance/itit/domain/enums/Directory.java b/src/main/java/com/dissonance/itit/domain/enums/Directory.java deleted file mode 100644 index e408e3d..0000000 --- a/src/main/java/com/dissonance/itit/domain/enums/Directory.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.dissonance.itit.domain.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum Directory { - INFORMATION("info-posts"), RECRUITMENT("recruit-posts"); - - private final String name; -} diff --git a/src/main/java/com/dissonance/itit/domain/enums/Role.java b/src/main/java/com/dissonance/itit/domain/enums/Role.java deleted file mode 100644 index 1c8241a..0000000 --- a/src/main/java/com/dissonance/itit/domain/enums/Role.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.dissonance.itit.domain.enums; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum Role { - USER("ROLE_USER"), - ADMIN("ROLE_ADMIN"); - - private final String key; -} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/dto/request/OauthTokenReq.java b/src/main/java/com/dissonance/itit/dto/request/OauthTokenReq.java deleted file mode 100644 index e72fc8a..0000000 --- a/src/main/java/com/dissonance/itit/dto/request/OauthTokenReq.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dissonance.itit.dto.request; - -import jakarta.validation.constraints.NotBlank; - -public record OauthTokenReq( - @NotBlank(message = "access token은 필수 입력입니다.") - String accessToken -) { -} diff --git a/src/main/java/com/dissonance/itit/dto/response/FeaturedPostRes.java b/src/main/java/com/dissonance/itit/dto/response/FeaturedPostRes.java deleted file mode 100644 index 27d3358..0000000 --- a/src/main/java/com/dissonance/itit/dto/response/FeaturedPostRes.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.dissonance.itit.dto.response; - -import com.dissonance.itit.domain.entity.FeaturedPost; -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.Builder; -import lombok.Getter; - -import java.util.List; - -@Getter -@Builder -public class FeaturedPostRes { - @Schema(description = "추천 게시글 id", example = "1") - private final Integer featuredPostId; - @Schema(description = "배너 이미지 url", example = "https://naver.com") - private final String bannerImageUrl; - @Schema(description = "게시글 id", example = "1") - private final Long infoPostId; - - public static List of(List featuredPosts) { - return featuredPosts.stream() - .map(featuredPost -> FeaturedPostRes.builder() - .featuredPostId(featuredPost.getId()) - .bannerImageUrl(featuredPost.getBannerImageUrl()) - .infoPostId(featuredPost.getInfoPost().getId()) - .build()) - .toList(); - } -} diff --git a/src/main/java/com/dissonance/itit/dto/response/GeneratedToken.java b/src/main/java/com/dissonance/itit/dto/response/GeneratedToken.java deleted file mode 100644 index 6d6a445..0000000 --- a/src/main/java/com/dissonance/itit/dto/response/GeneratedToken.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.dissonance.itit.dto.response; - -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@NoArgsConstructor -@Getter -public class GeneratedToken { - private String accessToken; - private String refreshToken; - - @Builder - public GeneratedToken(String accessToken, String refreshToken) { - this.accessToken = accessToken; - this.refreshToken = refreshToken; - } -} diff --git a/src/main/java/com/dissonance/itit/dto/response/LoginUserInfoRes.java b/src/main/java/com/dissonance/itit/dto/response/LoginUserInfoRes.java deleted file mode 100644 index 6811237..0000000 --- a/src/main/java/com/dissonance/itit/dto/response/LoginUserInfoRes.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.dissonance.itit.dto.response; - -import com.dissonance.itit.domain.enums.SocialLoginProvider; - -public record LoginUserInfoRes( - boolean isAdmin, - SocialLoginProvider provider) { -} diff --git a/src/main/java/com/dissonance/itit/common/annotation/CurrentUser.java b/src/main/java/com/dissonance/itit/global/common/annotation/CurrentUser.java similarity index 89% rename from src/main/java/com/dissonance/itit/common/annotation/CurrentUser.java rename to src/main/java/com/dissonance/itit/global/common/annotation/CurrentUser.java index 5532921..db513a1 100644 --- a/src/main/java/com/dissonance/itit/common/annotation/CurrentUser.java +++ b/src/main/java/com/dissonance/itit/global/common/annotation/CurrentUser.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.annotation; +package com.dissonance.itit.global.common.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/com/dissonance/itit/global/common/converter/MultipartJackson2HttpMessageConverter.java b/src/main/java/com/dissonance/itit/global/common/converter/MultipartJackson2HttpMessageConverter.java new file mode 100644 index 0000000..33a0c86 --- /dev/null +++ b/src/main/java/com/dissonance/itit/global/common/converter/MultipartJackson2HttpMessageConverter.java @@ -0,0 +1,34 @@ +package com.dissonance.itit.global.common.converter; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.springframework.http.MediaType; +import org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter; +import org.springframework.stereotype.Component; + +import java.lang.reflect.Type; + +@Component +public class MultipartJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter { + /** + * Converter for support http request with header Content-Type: multipart/form-data + */ + public MultipartJackson2HttpMessageConverter(ObjectMapper objectMapper) { + super(objectMapper, MediaType.APPLICATION_OCTET_STREAM); + } + + @Override + public boolean canWrite(Class clazz, MediaType mediaType) { + return false; + } + + @Override + public boolean canWrite(Type type, Class clazz, MediaType mediaType) { + return false; + } + + @Override + protected boolean canWrite(MediaType mediaType) { + return false; + } +} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/domain/entity/BaseTime.java b/src/main/java/com/dissonance/itit/global/common/entity/BaseTime.java similarity index 73% rename from src/main/java/com/dissonance/itit/domain/entity/BaseTime.java rename to src/main/java/com/dissonance/itit/global/common/entity/BaseTime.java index 6bded3e..0b72536 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/BaseTime.java +++ b/src/main/java/com/dissonance/itit/global/common/entity/BaseTime.java @@ -1,8 +1,9 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.global.common.entity; 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; @@ -13,9 +14,9 @@ @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public class BaseTime { - @CreatedDate - private LocalDateTime createdDate; + @CreatedDate + private LocalDateTime createdDate; - @LastModifiedDate - private LocalDateTime updatedDate; + @LastModifiedDate + private LocalDateTime updatedDate; } diff --git a/src/main/java/com/dissonance/itit/global/common/exception/CustomException.java b/src/main/java/com/dissonance/itit/global/common/exception/CustomException.java new file mode 100644 index 0000000..92c2b91 --- /dev/null +++ b/src/main/java/com/dissonance/itit/global/common/exception/CustomException.java @@ -0,0 +1,13 @@ +package com.dissonance.itit.global.common.exception; + +import lombok.Getter; + +@Getter +public class CustomException extends RuntimeException { + private final ErrorCode errorCode; + + public CustomException(ErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } +} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/common/exception/ErrorCode.java b/src/main/java/com/dissonance/itit/global/common/exception/ErrorCode.java similarity index 86% rename from src/main/java/com/dissonance/itit/common/exception/ErrorCode.java rename to src/main/java/com/dissonance/itit/global/common/exception/ErrorCode.java index 342da3c..dbfd51f 100644 --- a/src/main/java/com/dissonance/itit/common/exception/ErrorCode.java +++ b/src/main/java/com/dissonance/itit/global/common/exception/ErrorCode.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.exception; +package com.dissonance.itit.global.common.exception; import org.springframework.http.HttpStatus; @@ -25,10 +25,6 @@ public enum ErrorCode { IMAGE_NOT_FOUND(HttpStatus.NOT_FOUND, "해당 id의 이미지가 존재하지 않습니다."), NON_EXISTENT_CATEGORY_ID(HttpStatus.NOT_FOUND, "해당 id의 카테고리가 존재하지 않습니다."), NON_EXISTENT_INFO_POST_ID(HttpStatus.NOT_FOUND, "해당 id의 공고 게시글이 존재하지 않습니다."), - REPORTED_INFO_POST_ID(HttpStatus.NOT_FOUND, "해당 id의 게시글은 신고 처리되었습니다."), - - // 409 - ALREADY_REPORTED_POST(HttpStatus.CONFLICT, "이미 신고한 공고입니다."), // 500 IO_EXCEPTION(HttpStatus.INTERNAL_SERVER_ERROR, "파일 입출력 에러"), diff --git a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java b/src/main/java/com/dissonance/itit/global/common/exception/GlobalExceptionHandler.java similarity index 93% rename from src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java rename to src/main/java/com/dissonance/itit/global/common/exception/GlobalExceptionHandler.java index a2c29c3..4e4788e 100644 --- a/src/main/java/com/dissonance/itit/common/exception/GlobalExceptionHandler.java +++ b/src/main/java/com/dissonance/itit/global/common/exception/GlobalExceptionHandler.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.exception; +package com.dissonance.itit.global.common.exception; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -6,7 +6,7 @@ import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.multipart.MaxUploadSizeExceededException; -import com.dissonance.itit.common.util.ApiResponse; +import com.dissonance.itit.global.common.util.ApiResponse; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/dissonance/itit/service/RedisService.java b/src/main/java/com/dissonance/itit/global/common/redis/RedisService.java similarity index 92% rename from src/main/java/com/dissonance/itit/service/RedisService.java rename to src/main/java/com/dissonance/itit/global/common/redis/RedisService.java index f92ba7a..b39c2b6 100644 --- a/src/main/java/com/dissonance/itit/service/RedisService.java +++ b/src/main/java/com/dissonance/itit/global/common/redis/RedisService.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.global.common.redis; import java.util.concurrent.TimeUnit; diff --git a/src/main/java/com/dissonance/itit/common/util/ApiResponse.java b/src/main/java/com/dissonance/itit/global/common/util/ApiResponse.java similarity index 91% rename from src/main/java/com/dissonance/itit/common/util/ApiResponse.java rename to src/main/java/com/dissonance/itit/global/common/util/ApiResponse.java index ca276eb..49f8282 100644 --- a/src/main/java/com/dissonance/itit/common/util/ApiResponse.java +++ b/src/main/java/com/dissonance/itit/global/common/util/ApiResponse.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.util; +package com.dissonance.itit.global.common.util; import org.springframework.http.HttpStatus; diff --git a/src/main/java/com/dissonance/itit/common/util/DateUtil.java b/src/main/java/com/dissonance/itit/global/common/util/DateUtil.java similarity index 83% rename from src/main/java/com/dissonance/itit/common/util/DateUtil.java rename to src/main/java/com/dissonance/itit/global/common/util/DateUtil.java index c913b02..c4e79f4 100644 --- a/src/main/java/com/dissonance/itit/common/util/DateUtil.java +++ b/src/main/java/com/dissonance/itit/global/common/util/DateUtil.java @@ -1,11 +1,11 @@ -package com.dissonance.itit.common.util; +package com.dissonance.itit.global.common.util; import java.time.LocalDate; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeParseException; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; public class DateUtil { public static LocalDate stringToDate(String dateString) { diff --git a/src/main/java/com/dissonance/itit/common/jwt/util/JwtUtil.java b/src/main/java/com/dissonance/itit/global/common/util/JwtUtil.java similarity index 92% rename from src/main/java/com/dissonance/itit/common/jwt/util/JwtUtil.java rename to src/main/java/com/dissonance/itit/global/common/util/JwtUtil.java index bc964e1..2f53c23 100644 --- a/src/main/java/com/dissonance/itit/common/jwt/util/JwtUtil.java +++ b/src/main/java/com/dissonance/itit/global/common/util/JwtUtil.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.common.jwt.util; +package com.dissonance.itit.global.common.util; -import static com.dissonance.itit.domain.enums.JwtTokenExpiration.*; +import static com.dissonance.itit.global.security.enums.JwtTokenExpiration.*; import java.nio.charset.StandardCharsets; import java.util.Base64; @@ -11,10 +11,10 @@ import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; -import com.dissonance.itit.domain.entity.UserDetailsImpl; -import com.dissonance.itit.dto.response.GeneratedToken; -import com.dissonance.itit.service.RedisService; -import com.dissonance.itit.service.UserDetailsServiceImpl; +import com.dissonance.itit.global.common.redis.RedisService; +import com.dissonance.itit.global.security.dto.GeneratedToken; +import com.dissonance.itit.user.domain.UserDetailsImpl; +import com.dissonance.itit.user.service.UserDetailsServiceImpl; import io.jsonwebtoken.Claims; import io.jsonwebtoken.ExpiredJwtException; diff --git a/src/main/java/com/dissonance/itit/config/MariaDBFullTextDialect.java b/src/main/java/com/dissonance/itit/global/config/MariaDBFullTextDialect.java similarity index 95% rename from src/main/java/com/dissonance/itit/config/MariaDBFullTextDialect.java rename to src/main/java/com/dissonance/itit/global/config/MariaDBFullTextDialect.java index 451219e..6141b74 100644 --- a/src/main/java/com/dissonance/itit/config/MariaDBFullTextDialect.java +++ b/src/main/java/com/dissonance/itit/global/config/MariaDBFullTextDialect.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import org.hibernate.boot.model.FunctionContributions; import org.hibernate.dialect.MariaDBDialect; diff --git a/src/main/java/com/dissonance/itit/config/OpenFeignConfig.java b/src/main/java/com/dissonance/itit/global/config/OpenFeignConfig.java similarity index 63% rename from src/main/java/com/dissonance/itit/config/OpenFeignConfig.java rename to src/main/java/com/dissonance/itit/global/config/OpenFeignConfig.java index 3c57572..7d8b1ba 100644 --- a/src/main/java/com/dissonance/itit/config/OpenFeignConfig.java +++ b/src/main/java/com/dissonance/itit/global/config/OpenFeignConfig.java @@ -1,9 +1,9 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration -@EnableFeignClients("com.dissonance.itit.client") +@EnableFeignClients("com.dissonance.itit.oauth.client") public class OpenFeignConfig { } diff --git a/src/main/java/com/dissonance/itit/config/QueryDslConfig.java b/src/main/java/com/dissonance/itit/global/config/QueryDslConfig.java similarity index 58% rename from src/main/java/com/dissonance/itit/config/QueryDslConfig.java rename to src/main/java/com/dissonance/itit/global/config/QueryDslConfig.java index 5ca94cc..d7bf17c 100644 --- a/src/main/java/com/dissonance/itit/config/QueryDslConfig.java +++ b/src/main/java/com/dissonance/itit/global/config/QueryDslConfig.java @@ -1,18 +1,20 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import com.querydsl.jpa.impl.JPAQueryFactory; + import jakarta.persistence.EntityManager; import jakarta.persistence.PersistenceContext; + import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @Configuration public class QueryDslConfig { - @PersistenceContext - private EntityManager entityManager; + @PersistenceContext + private EntityManager entityManager; - @Bean - public JPAQueryFactory jpaQueryFactory() { - return new JPAQueryFactory(entityManager); - } + @Bean + public JPAQueryFactory jpaQueryFactory() { + return new JPAQueryFactory(entityManager); + } } \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/config/RedisConfig.java b/src/main/java/com/dissonance/itit/global/config/RedisConfig.java similarity index 93% rename from src/main/java/com/dissonance/itit/config/RedisConfig.java rename to src/main/java/com/dissonance/itit/global/config/RedisConfig.java index 91b2f0d..141ba19 100644 --- a/src/main/java/com/dissonance/itit/config/RedisConfig.java +++ b/src/main/java/com/dissonance/itit/global/config/RedisConfig.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; diff --git a/src/main/java/com/dissonance/itit/global/config/S3Config.java b/src/main/java/com/dissonance/itit/global/config/S3Config.java new file mode 100644 index 0000000..3f0df70 --- /dev/null +++ b/src/main/java/com/dissonance/itit/global/config/S3Config.java @@ -0,0 +1,32 @@ +package com.dissonance.itit.global.config; + +import com.amazonaws.auth.AWSStaticCredentialsProvider; +import com.amazonaws.auth.BasicAWSCredentials; +import com.amazonaws.services.s3.AmazonS3Client; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class S3Config { + @Value("${cloud.aws.credentials.access-key}") + private String accessKey; + + @Value("${cloud.aws.credentials.secret-key}") + private String secretKey; + + @Value("${cloud.aws.region.static}") + private String region; + + @Bean + public AmazonS3Client amazonS3Client() { + BasicAWSCredentials awsCreds = new BasicAWSCredentials(accessKey, secretKey); + + return (AmazonS3Client)AmazonS3ClientBuilder.standard() + .withRegion(region) + .withCredentials(new AWSStaticCredentialsProvider(awsCreds)) + .build(); + } +} diff --git a/src/main/java/com/dissonance/itit/config/SecurityConfig.java b/src/main/java/com/dissonance/itit/global/config/SecurityConfig.java similarity index 91% rename from src/main/java/com/dissonance/itit/config/SecurityConfig.java rename to src/main/java/com/dissonance/itit/global/config/SecurityConfig.java index 15c87f0..5283463 100644 --- a/src/main/java/com/dissonance/itit/config/SecurityConfig.java +++ b/src/main/java/com/dissonance/itit/global/config/SecurityConfig.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import java.util.List; @@ -16,9 +16,9 @@ import org.springframework.web.cors.CorsConfigurationSource; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; -import com.dissonance.itit.common.jwt.filter.JwtAuthFilter; -import com.dissonance.itit.common.jwt.handler.JwtAccessDeniedHandler; -import com.dissonance.itit.common.jwt.handler.RestAuthenticationEntryPoint; +import com.dissonance.itit.global.security.filter.JwtAuthFilter; +import com.dissonance.itit.global.security.handler.JwtAccessDeniedHandler; +import com.dissonance.itit.global.security.handler.RestAuthenticationEntryPoint; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/config/SwaggerConfig.java b/src/main/java/com/dissonance/itit/global/config/SwaggerConfig.java similarity index 97% rename from src/main/java/com/dissonance/itit/config/SwaggerConfig.java rename to src/main/java/com/dissonance/itit/global/config/SwaggerConfig.java index 351c51d..572d567 100644 --- a/src/main/java/com/dissonance/itit/config/SwaggerConfig.java +++ b/src/main/java/com/dissonance/itit/global/config/SwaggerConfig.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.config; +package com.dissonance.itit.global.config; import java.util.Collections; import java.util.List; diff --git a/src/main/java/com/dissonance/itit/global/security/dto/GeneratedToken.java b/src/main/java/com/dissonance/itit/global/security/dto/GeneratedToken.java new file mode 100644 index 0000000..77da2dc --- /dev/null +++ b/src/main/java/com/dissonance/itit/global/security/dto/GeneratedToken.java @@ -0,0 +1,18 @@ +package com.dissonance.itit.global.security.dto; + +import lombok.Builder; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@Getter +public class GeneratedToken { + private String accessToken; + private String refreshToken; + + @Builder + public GeneratedToken(String accessToken, String refreshToken) { + this.accessToken = accessToken; + this.refreshToken = refreshToken; + } +} diff --git a/src/main/java/com/dissonance/itit/domain/enums/JwtTokenExpiration.java b/src/main/java/com/dissonance/itit/global/security/enums/JwtTokenExpiration.java similarity index 87% rename from src/main/java/com/dissonance/itit/domain/enums/JwtTokenExpiration.java rename to src/main/java/com/dissonance/itit/global/security/enums/JwtTokenExpiration.java index c81c661..305b1f7 100644 --- a/src/main/java/com/dissonance/itit/domain/enums/JwtTokenExpiration.java +++ b/src/main/java/com/dissonance/itit/global/security/enums/JwtTokenExpiration.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.domain.enums; +package com.dissonance.itit.global.security.enums; import lombok.AllArgsConstructor; import lombok.Getter; diff --git a/src/main/java/com/dissonance/itit/common/jwt/filter/JwtAuthFilter.java b/src/main/java/com/dissonance/itit/global/security/filter/JwtAuthFilter.java similarity index 93% rename from src/main/java/com/dissonance/itit/common/jwt/filter/JwtAuthFilter.java rename to src/main/java/com/dissonance/itit/global/security/filter/JwtAuthFilter.java index 8087095..26afc6c 100644 --- a/src/main/java/com/dissonance/itit/common/jwt/filter/JwtAuthFilter.java +++ b/src/main/java/com/dissonance/itit/global/security/filter/JwtAuthFilter.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.jwt.filter; +package com.dissonance.itit.global.security.filter; import java.io.IOException; @@ -8,7 +8,7 @@ import org.springframework.util.StringUtils; import org.springframework.web.filter.OncePerRequestFilter; -import com.dissonance.itit.common.jwt.util.JwtUtil; +import com.dissonance.itit.global.common.util.JwtUtil; import jakarta.servlet.FilterChain; import jakarta.servlet.ServletException; diff --git a/src/main/java/com/dissonance/itit/common/jwt/handler/JwtAccessDeniedHandler.java b/src/main/java/com/dissonance/itit/global/security/handler/JwtAccessDeniedHandler.java similarity index 95% rename from src/main/java/com/dissonance/itit/common/jwt/handler/JwtAccessDeniedHandler.java rename to src/main/java/com/dissonance/itit/global/security/handler/JwtAccessDeniedHandler.java index 994e95e..2545364 100644 --- a/src/main/java/com/dissonance/itit/common/jwt/handler/JwtAccessDeniedHandler.java +++ b/src/main/java/com/dissonance/itit/global/security/handler/JwtAccessDeniedHandler.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.jwt.handler; +package com.dissonance.itit.global.security.handler; import java.io.IOException; import java.util.HashMap; diff --git a/src/main/java/com/dissonance/itit/common/jwt/handler/RestAuthenticationEntryPoint.java b/src/main/java/com/dissonance/itit/global/security/handler/RestAuthenticationEntryPoint.java similarity index 95% rename from src/main/java/com/dissonance/itit/common/jwt/handler/RestAuthenticationEntryPoint.java rename to src/main/java/com/dissonance/itit/global/security/handler/RestAuthenticationEntryPoint.java index a45b34c..8909408 100644 --- a/src/main/java/com/dissonance/itit/common/jwt/handler/RestAuthenticationEntryPoint.java +++ b/src/main/java/com/dissonance/itit/global/security/handler/RestAuthenticationEntryPoint.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.common.jwt.handler; +package com.dissonance.itit.global.security.handler; import java.io.IOException; import java.util.HashMap; diff --git a/src/main/java/com/dissonance/itit/image/domain/Directory.java b/src/main/java/com/dissonance/itit/image/domain/Directory.java new file mode 100644 index 0000000..32b9bf8 --- /dev/null +++ b/src/main/java/com/dissonance/itit/image/domain/Directory.java @@ -0,0 +1,12 @@ +package com.dissonance.itit.image.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum Directory { + INFORMATION("info-posts"), RECRUITMENT("recruit-posts"); + + private final String name; +} diff --git a/src/main/java/com/dissonance/itit/domain/entity/Image.java b/src/main/java/com/dissonance/itit/image/domain/Image.java similarity index 92% rename from src/main/java/com/dissonance/itit/domain/entity/Image.java rename to src/main/java/com/dissonance/itit/image/domain/Image.java index a19d00b..6eb033c 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/Image.java +++ b/src/main/java/com/dissonance/itit/image/domain/Image.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.image.domain; -import com.dissonance.itit.domain.enums.Directory; +import com.dissonance.itit.post.domain.InfoPost; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/com/dissonance/itit/repository/ImageRepository.java b/src/main/java/com/dissonance/itit/image/repository/ImageRepository.java similarity index 59% rename from src/main/java/com/dissonance/itit/repository/ImageRepository.java rename to src/main/java/com/dissonance/itit/image/repository/ImageRepository.java index 5310e88..c6e7a97 100644 --- a/src/main/java/com/dissonance/itit/repository/ImageRepository.java +++ b/src/main/java/com/dissonance/itit/image/repository/ImageRepository.java @@ -1,6 +1,7 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.image.repository; + +import com.dissonance.itit.image.domain.Image; -import com.dissonance.itit.domain.entity.Image; import org.springframework.data.jpa.repository.JpaRepository; public interface ImageRepository extends JpaRepository { diff --git a/src/main/java/com/dissonance/itit/service/ImageService.java b/src/main/java/com/dissonance/itit/image/service/ImageService.java similarity index 91% rename from src/main/java/com/dissonance/itit/service/ImageService.java rename to src/main/java/com/dissonance/itit/image/service/ImageService.java index 75e55b6..84c26c9 100644 --- a/src/main/java/com/dissonance/itit/service/ImageService.java +++ b/src/main/java/com/dissonance/itit/image/service/ImageService.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.image.service; -import static com.dissonance.itit.common.exception.ErrorCode.*; +import static com.dissonance.itit.global.common.exception.ErrorCode.*; import java.io.IOException; import java.io.InputStream; @@ -15,10 +15,10 @@ import com.amazonaws.services.s3.model.CannedAccessControlList; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.enums.Directory; -import com.dissonance.itit.repository.ImageRepository; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.image.domain.Directory; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.image.repository.ImageRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/java/com/dissonance/itit/client/AppleInformationFeignClient.java b/src/main/java/com/dissonance/itit/oauth/client/AppleInformationFeignClient.java similarity index 71% rename from src/main/java/com/dissonance/itit/client/AppleInformationFeignClient.java rename to src/main/java/com/dissonance/itit/oauth/client/AppleInformationFeignClient.java index a61971a..5e8ee0d 100644 --- a/src/main/java/com/dissonance/itit/client/AppleInformationFeignClient.java +++ b/src/main/java/com/dissonance/itit/oauth/client/AppleInformationFeignClient.java @@ -1,9 +1,10 @@ -package com.dissonance.itit.client; +package com.dissonance.itit.oauth.client; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; @FeignClient(name = "AppleInformationFeignClient", url = "${apple.api_url.information}") +// @EnableFeignClients(basePackages = "com.dissonance.itit.oauth.client") public interface AppleInformationFeignClient { @GetMapping String call(); diff --git a/src/main/java/com/dissonance/itit/oauth/client/KakaoInformationFeignClient.java b/src/main/java/com/dissonance/itit/oauth/client/KakaoInformationFeignClient.java new file mode 100644 index 0000000..f0dbb49 --- /dev/null +++ b/src/main/java/com/dissonance/itit/oauth/client/KakaoInformationFeignClient.java @@ -0,0 +1,16 @@ +package com.dissonance.itit.oauth.client; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; + +@FeignClient(name = "KakaoInformationFeignClient", url = "${kakao.api_url.information}") +// @EnableFeignClients(basePackages = "com.dissonance.itit.oauth.client") +public interface KakaoInformationFeignClient { + @GetMapping + ResponseEntity call( + @RequestHeader("Content-Type") String contentType, + @RequestHeader("Authorization") String accessToken + ); +} diff --git a/src/main/java/com/dissonance/itit/controller/OauthController.java b/src/main/java/com/dissonance/itit/oauth/controller/OauthController.java similarity index 77% rename from src/main/java/com/dissonance/itit/controller/OauthController.java rename to src/main/java/com/dissonance/itit/oauth/controller/OauthController.java index b4ccf27..277bff3 100644 --- a/src/main/java/com/dissonance/itit/controller/OauthController.java +++ b/src/main/java/com/dissonance/itit/oauth/controller/OauthController.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.controller; +package com.dissonance.itit.oauth.controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -6,10 +6,10 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.dissonance.itit.common.util.ApiResponse; -import com.dissonance.itit.dto.request.OauthTokenReq; -import com.dissonance.itit.dto.response.GeneratedToken; -import com.dissonance.itit.service.UserService; +import com.dissonance.itit.global.common.util.ApiResponse; +import com.dissonance.itit.global.security.dto.GeneratedToken; +import com.dissonance.itit.oauth.dto.OauthTokenReq; +import com.dissonance.itit.user.service.UserService; import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; diff --git a/src/main/java/com/dissonance/itit/dto/response/AppleUserInfomation.java b/src/main/java/com/dissonance/itit/oauth/dto/AppleUserInfomation.java similarity index 85% rename from src/main/java/com/dissonance/itit/dto/response/AppleUserInfomation.java rename to src/main/java/com/dissonance/itit/oauth/dto/AppleUserInfomation.java index d265b72..5809bea 100644 --- a/src/main/java/com/dissonance/itit/dto/response/AppleUserInfomation.java +++ b/src/main/java/com/dissonance/itit/oauth/dto/AppleUserInfomation.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.oauth.dto; -import com.dissonance.itit.domain.enums.SocialLoginProvider; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; import lombok.AllArgsConstructor; import lombok.Builder; diff --git a/src/main/java/com/dissonance/itit/dto/response/KakaoUserInformation.java b/src/main/java/com/dissonance/itit/oauth/dto/KakaoUserInformation.java similarity index 95% rename from src/main/java/com/dissonance/itit/dto/response/KakaoUserInformation.java rename to src/main/java/com/dissonance/itit/oauth/dto/KakaoUserInformation.java index ac7ae84..b999903 100644 --- a/src/main/java/com/dissonance/itit/dto/response/KakaoUserInformation.java +++ b/src/main/java/com/dissonance/itit/oauth/dto/KakaoUserInformation.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.oauth.dto; -import com.dissonance.itit.domain.enums.SocialLoginProvider; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/dissonance/itit/dto/response/Keys.java b/src/main/java/com/dissonance/itit/oauth/dto/Keys.java similarity index 89% rename from src/main/java/com/dissonance/itit/dto/response/Keys.java rename to src/main/java/com/dissonance/itit/oauth/dto/Keys.java index 44dcac5..79e1f24 100644 --- a/src/main/java/com/dissonance/itit/dto/response/Keys.java +++ b/src/main/java/com/dissonance/itit/oauth/dto/Keys.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.oauth.dto; import java.util.List; diff --git a/src/main/java/com/dissonance/itit/dto/response/OAuthUserInformation.java b/src/main/java/com/dissonance/itit/oauth/dto/OAuthUserInformation.java similarity index 63% rename from src/main/java/com/dissonance/itit/dto/response/OAuthUserInformation.java rename to src/main/java/com/dissonance/itit/oauth/dto/OAuthUserInformation.java index d6c79ce..14864a9 100644 --- a/src/main/java/com/dissonance/itit/dto/response/OAuthUserInformation.java +++ b/src/main/java/com/dissonance/itit/oauth/dto/OAuthUserInformation.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.oauth.dto; -import com.dissonance.itit.domain.enums.SocialLoginProvider; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; public interface OAuthUserInformation { SocialLoginProvider getProvider(); diff --git a/src/main/java/com/dissonance/itit/oauth/dto/OauthTokenReq.java b/src/main/java/com/dissonance/itit/oauth/dto/OauthTokenReq.java new file mode 100644 index 0000000..fb34783 --- /dev/null +++ b/src/main/java/com/dissonance/itit/oauth/dto/OauthTokenReq.java @@ -0,0 +1,9 @@ +package com.dissonance.itit.oauth.dto; + +import jakarta.validation.constraints.NotBlank; + +public record OauthTokenReq( + @NotBlank(message = "access token은 필수 입력입니다.") + String accessToken +) { +} diff --git a/src/main/java/com/dissonance/itit/dto/request/RefreshTokenReq.java b/src/main/java/com/dissonance/itit/oauth/dto/RefreshTokenReq.java similarity index 58% rename from src/main/java/com/dissonance/itit/dto/request/RefreshTokenReq.java rename to src/main/java/com/dissonance/itit/oauth/dto/RefreshTokenReq.java index 453a061..dd41503 100644 --- a/src/main/java/com/dissonance/itit/dto/request/RefreshTokenReq.java +++ b/src/main/java/com/dissonance/itit/oauth/dto/RefreshTokenReq.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.dto.request; +package com.dissonance.itit.oauth.dto; public record RefreshTokenReq( String refreshToken diff --git a/src/main/java/com/dissonance/itit/domain/enums/SocialLoginProvider.java b/src/main/java/com/dissonance/itit/oauth/enums/SocialLoginProvider.java similarity index 55% rename from src/main/java/com/dissonance/itit/domain/enums/SocialLoginProvider.java rename to src/main/java/com/dissonance/itit/oauth/enums/SocialLoginProvider.java index d9a6c38..6a05cfe 100644 --- a/src/main/java/com/dissonance/itit/domain/enums/SocialLoginProvider.java +++ b/src/main/java/com/dissonance/itit/oauth/enums/SocialLoginProvider.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.domain.enums; +package com.dissonance.itit.oauth.enums; public enum SocialLoginProvider { KAKAO, diff --git a/src/main/java/com/dissonance/itit/service/AppleOAuthServiceImpl.java b/src/main/java/com/dissonance/itit/oauth/service/AppleOAuthServiceImpl.java similarity index 86% rename from src/main/java/com/dissonance/itit/service/AppleOAuthServiceImpl.java rename to src/main/java/com/dissonance/itit/oauth/service/AppleOAuthServiceImpl.java index 6627c59..66828cf 100644 --- a/src/main/java/com/dissonance/itit/service/AppleOAuthServiceImpl.java +++ b/src/main/java/com/dissonance/itit/oauth/service/AppleOAuthServiceImpl.java @@ -1,17 +1,17 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.oauth.service; import java.security.interfaces.RSAPublicKey; import java.text.ParseException; import org.springframework.stereotype.Service; -import com.dissonance.itit.client.AppleInformationFeignClient; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.enums.SocialLoginProvider; -import com.dissonance.itit.dto.response.AppleUserInfomation; -import com.dissonance.itit.dto.response.Keys; -import com.dissonance.itit.dto.response.OAuthUserInformation; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.oauth.client.AppleInformationFeignClient; +import com.dissonance.itit.oauth.dto.AppleUserInfomation; +import com.dissonance.itit.oauth.dto.Keys; +import com.dissonance.itit.oauth.dto.OAuthUserInformation; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.nimbusds.jose.JOSEException; diff --git a/src/main/java/com/dissonance/itit/service/KakaoOAuthServiceImpl.java b/src/main/java/com/dissonance/itit/oauth/service/KakaoOAuthServiceImpl.java similarity index 84% rename from src/main/java/com/dissonance/itit/service/KakaoOAuthServiceImpl.java rename to src/main/java/com/dissonance/itit/oauth/service/KakaoOAuthServiceImpl.java index d01b299..95848a9 100644 --- a/src/main/java/com/dissonance/itit/service/KakaoOAuthServiceImpl.java +++ b/src/main/java/com/dissonance/itit/oauth/service/KakaoOAuthServiceImpl.java @@ -1,12 +1,12 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.oauth.service; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; -import com.dissonance.itit.client.KakaoInformationFeignClient; -import com.dissonance.itit.domain.enums.SocialLoginProvider; -import com.dissonance.itit.dto.response.KakaoUserInformation; -import com.dissonance.itit.dto.response.OAuthUserInformation; +import com.dissonance.itit.oauth.client.KakaoInformationFeignClient; +import com.dissonance.itit.oauth.dto.KakaoUserInformation; +import com.dissonance.itit.oauth.dto.OAuthUserInformation; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; diff --git a/src/main/java/com/dissonance/itit/oauth/service/OAuthService.java b/src/main/java/com/dissonance/itit/oauth/service/OAuthService.java new file mode 100644 index 0000000..05b0866 --- /dev/null +++ b/src/main/java/com/dissonance/itit/oauth/service/OAuthService.java @@ -0,0 +1,10 @@ +package com.dissonance.itit.oauth.service; + +import com.dissonance.itit.oauth.dto.OAuthUserInformation; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; + +public interface OAuthService { + SocialLoginProvider getProvider(); + + OAuthUserInformation requestUserInformation(String token); +} diff --git a/src/main/java/com/dissonance/itit/factory/OAuthServiceFactory.java b/src/main/java/com/dissonance/itit/oauth/service/OAuthServiceFactory.java similarity index 74% rename from src/main/java/com/dissonance/itit/factory/OAuthServiceFactory.java rename to src/main/java/com/dissonance/itit/oauth/service/OAuthServiceFactory.java index 6ac7a1e..dabca38 100644 --- a/src/main/java/com/dissonance/itit/factory/OAuthServiceFactory.java +++ b/src/main/java/com/dissonance/itit/oauth/service/OAuthServiceFactory.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.factory; +package com.dissonance.itit.oauth.service; import java.util.List; import java.util.Map; @@ -8,10 +8,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.enums.SocialLoginProvider; -import com.dissonance.itit.service.OAuthService; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; @Component public class OAuthServiceFactory { diff --git a/src/main/java/com/dissonance/itit/controller/AdminInfoPostController.java b/src/main/java/com/dissonance/itit/post/controller/AdminInfoPostController.java similarity index 84% rename from src/main/java/com/dissonance/itit/controller/AdminInfoPostController.java rename to src/main/java/com/dissonance/itit/post/controller/AdminInfoPostController.java index c48b540..8f230f1 100644 --- a/src/main/java/com/dissonance/itit/controller/AdminInfoPostController.java +++ b/src/main/java/com/dissonance/itit/post/controller/AdminInfoPostController.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.controller; +package com.dissonance.itit.post.controller; import org.springframework.http.MediaType; import org.springframework.web.bind.annotation.DeleteMapping; @@ -11,14 +11,14 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; -import com.dissonance.itit.common.annotation.CurrentUser; -import com.dissonance.itit.common.util.ApiResponse; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.dto.request.InfoPostReq; -import com.dissonance.itit.dto.response.InfoPostCreateRes; -import com.dissonance.itit.dto.response.InfoPostDetailRes; -import com.dissonance.itit.dto.response.InfoPostUpdateRes; -import com.dissonance.itit.service.InfoPostService; +import com.dissonance.itit.global.common.annotation.CurrentUser; +import com.dissonance.itit.global.common.util.ApiResponse; +import com.dissonance.itit.user.domain.User; +import com.dissonance.itit.post.dto.request.InfoPostReq; +import com.dissonance.itit.post.dto.response.InfoPostCreateRes; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes; +import com.dissonance.itit.post.dto.response.InfoPostUpdateRes; +import com.dissonance.itit.post.service.InfoPostService; import io.swagger.v3.oas.annotations.Operation; import jakarta.validation.Valid; diff --git a/src/main/java/com/dissonance/itit/controller/FeaturedPostContorller.java b/src/main/java/com/dissonance/itit/post/controller/FeaturedPostContorller.java similarity index 77% rename from src/main/java/com/dissonance/itit/controller/FeaturedPostContorller.java rename to src/main/java/com/dissonance/itit/post/controller/FeaturedPostContorller.java index 88cd42f..b04e0e0 100644 --- a/src/main/java/com/dissonance/itit/controller/FeaturedPostContorller.java +++ b/src/main/java/com/dissonance/itit/post/controller/FeaturedPostContorller.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.controller; +package com.dissonance.itit.post.controller; import java.util.List; @@ -6,9 +6,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.dissonance.itit.common.util.ApiResponse; -import com.dissonance.itit.dto.response.FeaturedPostRes; -import com.dissonance.itit.service.FeaturedPostService; +import com.dissonance.itit.global.common.util.ApiResponse; +import com.dissonance.itit.post.dto.response.FeaturedPostRes; +import com.dissonance.itit.post.service.FeaturedPostService; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/controller/InfoPostController.java b/src/main/java/com/dissonance/itit/post/controller/InfoPostController.java similarity index 66% rename from src/main/java/com/dissonance/itit/controller/InfoPostController.java rename to src/main/java/com/dissonance/itit/post/controller/InfoPostController.java index e8fc1b2..8abcb68 100644 --- a/src/main/java/com/dissonance/itit/controller/InfoPostController.java +++ b/src/main/java/com/dissonance/itit/post/controller/InfoPostController.java @@ -1,21 +1,17 @@ -package com.dissonance.itit.controller; +package com.dissonance.itit.post.controller; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.dissonance.itit.common.annotation.CurrentUser; -import com.dissonance.itit.common.util.ApiResponse; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.dto.response.InfoPostDetailRes; -import com.dissonance.itit.dto.response.InfoPostRes; -import com.dissonance.itit.service.InfoPostService; -import com.dissonance.itit.service.ReportService; +import com.dissonance.itit.global.common.util.ApiResponse; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes; +import com.dissonance.itit.post.dto.response.InfoPostRes; +import com.dissonance.itit.post.service.InfoPostService; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; @@ -25,7 +21,6 @@ @RequestMapping("/info-posts") public class InfoPostController { private final InfoPostService infoPostService; - private final ReportService reportService; @GetMapping("/{infoPostId}") @Operation(summary = "공고 게시글 조회", description = "공고 게시글을 상세 조회합니다.") @@ -34,13 +29,6 @@ public ApiResponse getInfoPostDetail(@PathVariable Long infoP return ApiResponse.success(infoPostDetailRes); } - @PatchMapping("/{infoPostId}/reports") - @Operation(summary = "공고 게시글 신고", description = "공고 게시글을 신고 처리합니다.") - public ApiResponse reportedInfoPost(@PathVariable Long infoPostId, @CurrentUser User loginUser) { - Long resultId = reportService.reportedInfoPost(infoPostId, loginUser); - return ApiResponse.success(resultId + "번 게시글의 신고가 성공적으로 접수되었습니다."); - } - @GetMapping("/categories/{categoryId}/posts") @Operation(summary = "공고 게시글 목록 조회", description = "카테고리별 공고 게시글 목록을 조회합니다. (정렬: 최신순 - latest, 마감일순 - deadline)") public ApiResponse> getInfoPostsByCategory(@PathVariable Integer categoryId, Pageable pageable) { diff --git a/src/main/java/com/dissonance/itit/post/domain/Category.java b/src/main/java/com/dissonance/itit/post/domain/Category.java new file mode 100644 index 0000000..03b70c2 --- /dev/null +++ b/src/main/java/com/dissonance/itit/post/domain/Category.java @@ -0,0 +1,28 @@ +package com.dissonance.itit.post.domain; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +@Table(name = "category") +public class Category { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "parent_id") + private Category parent; + + @Size(max = 30) + @NotNull + @Column(name = "name") + private String name; +} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/post/domain/FeaturedPost.java b/src/main/java/com/dissonance/itit/post/domain/FeaturedPost.java new file mode 100644 index 0000000..39f2c62 --- /dev/null +++ b/src/main/java/com/dissonance/itit/post/domain/FeaturedPost.java @@ -0,0 +1,28 @@ +package com.dissonance.itit.post.domain; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.*; + +@Getter +@Builder +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Entity +@Table(name = "featured_post") +public class FeaturedPost { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "id") + private Integer id; + + @Size(max = 500) + @NotNull + @Column(name = "banner_image_url") + private String bannerImageUrl; + + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "info_post_id") + private InfoPost infoPost; +} diff --git a/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java b/src/main/java/com/dissonance/itit/post/domain/InfoPost.java similarity index 91% rename from src/main/java/com/dissonance/itit/domain/entity/InfoPost.java rename to src/main/java/com/dissonance/itit/post/domain/InfoPost.java index b3809c1..9cd2786 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/InfoPost.java +++ b/src/main/java/com/dissonance/itit/post/domain/InfoPost.java @@ -1,8 +1,11 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.post.domain; import java.time.LocalDate; -import com.dissonance.itit.dto.request.InfoPostUpdateReq; +import com.dissonance.itit.global.common.entity.BaseTime; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.post.dto.request.InfoPostUpdateReq; +import com.dissonance.itit.user.domain.User; import jakarta.persistence.CascadeType; import jakarta.persistence.Column; @@ -72,9 +75,6 @@ public class InfoPost extends BaseTime { @Column(name = "organization") private String organization; - @Column(name = "reported") - private Boolean reported; - @Column(name = "recruitment_closed") private Boolean recruitmentClosed; diff --git a/src/main/java/com/dissonance/itit/dto/request/InfoPostReq.java b/src/main/java/com/dissonance/itit/post/dto/request/InfoPostReq.java similarity index 86% rename from src/main/java/com/dissonance/itit/dto/request/InfoPostReq.java rename to src/main/java/com/dissonance/itit/post/dto/request/InfoPostReq.java index 8bd337e..e2c1bda 100644 --- a/src/main/java/com/dissonance/itit/dto/request/InfoPostReq.java +++ b/src/main/java/com/dissonance/itit/post/dto/request/InfoPostReq.java @@ -1,13 +1,13 @@ -package com.dissonance.itit.dto.request; +package com.dissonance.itit.post.dto.request; -import static com.dissonance.itit.common.util.DateUtil.*; +import static com.dissonance.itit.global.common.util.DateUtil.*; import java.util.List; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.User; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.post.domain.Category; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.user.domain.User; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotBlank; @@ -55,7 +55,6 @@ public InfoPost toEntity(Image image, User author, Category category) { .activityStartDate(stringToDate(activityStartDate())) .activityEndDate(stringToDate(activityEndDate())) .detailUrl(detailUrl()) - .reported(false) .recruitmentClosed(false) .build(); } diff --git a/src/main/java/com/dissonance/itit/dto/request/InfoPostUpdateReq.java b/src/main/java/com/dissonance/itit/post/dto/request/InfoPostUpdateReq.java similarity index 83% rename from src/main/java/com/dissonance/itit/dto/request/InfoPostUpdateReq.java rename to src/main/java/com/dissonance/itit/post/dto/request/InfoPostUpdateReq.java index 4a98b7a..865d33e 100644 --- a/src/main/java/com/dissonance/itit/dto/request/InfoPostUpdateReq.java +++ b/src/main/java/com/dissonance/itit/post/dto/request/InfoPostUpdateReq.java @@ -1,10 +1,10 @@ -package com.dissonance.itit.dto.request; +package com.dissonance.itit.post.dto.request; -import static com.dissonance.itit.common.util.DateUtil.*; +import static com.dissonance.itit.global.common.util.DateUtil.*; import java.time.LocalDate; -import com.dissonance.itit.domain.entity.Category; +import com.dissonance.itit.post.domain.Category; import lombok.Builder; diff --git a/src/main/java/com/dissonance/itit/post/dto/response/FeaturedPostRes.java b/src/main/java/com/dissonance/itit/post/dto/response/FeaturedPostRes.java new file mode 100644 index 0000000..13ae798 --- /dev/null +++ b/src/main/java/com/dissonance/itit/post/dto/response/FeaturedPostRes.java @@ -0,0 +1,30 @@ +package com.dissonance.itit.post.dto.response; + +import com.dissonance.itit.post.domain.FeaturedPost; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; + +import java.util.List; + +@Getter +@Builder +public class FeaturedPostRes { + @Schema(description = "추천 게시글 id", example = "1") + private final Integer featuredPostId; + @Schema(description = "배너 이미지 url", example = "https://naver.com") + private final String bannerImageUrl; + @Schema(description = "게시글 id", example = "1") + private final Long infoPostId; + + public static List of(List featuredPosts) { + return featuredPosts.stream() + .map(featuredPost -> FeaturedPostRes.builder() + .featuredPostId(featuredPost.getId()) + .bannerImageUrl(featuredPost.getBannerImageUrl()) + .infoPostId(featuredPost.getInfoPost().getId()) + .build()) + .toList(); + } +} diff --git a/src/main/java/com/dissonance/itit/dto/response/InfoPostCreateRes.java b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostCreateRes.java similarity index 79% rename from src/main/java/com/dissonance/itit/dto/response/InfoPostCreateRes.java rename to src/main/java/com/dissonance/itit/post/dto/response/InfoPostCreateRes.java index 7d49bd9..29b1f34 100644 --- a/src/main/java/com/dissonance/itit/dto/response/InfoPostCreateRes.java +++ b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostCreateRes.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.post.dto.response; -import com.dissonance.itit.domain.entity.InfoPost; +import com.dissonance.itit.post.domain.InfoPost; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/src/main/java/com/dissonance/itit/dto/response/InfoPostDetailRes.java b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostDetailRes.java similarity index 92% rename from src/main/java/com/dissonance/itit/dto/response/InfoPostDetailRes.java rename to src/main/java/com/dissonance/itit/post/dto/response/InfoPostDetailRes.java index 924f7fd..3a57731 100644 --- a/src/main/java/com/dissonance/itit/dto/response/InfoPostDetailRes.java +++ b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostDetailRes.java @@ -1,11 +1,11 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.post.dto.response; -import static com.dissonance.itit.common.util.DateUtil.*; +import static com.dissonance.itit.global.common.util.DateUtil.*; import java.time.LocalDate; import java.util.List; -import com.dissonance.itit.domain.entity.InfoPost; +import com.dissonance.itit.post.domain.InfoPost; import lombok.AllArgsConstructor; import lombok.Builder; @@ -38,7 +38,6 @@ public static class InfoPostInfo { private String content; private String detailUrl; private Integer viewCount; - private Boolean reported; private final String imageUrl; } diff --git a/src/main/java/com/dissonance/itit/dto/response/InfoPostRes.java b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostRes.java similarity index 85% rename from src/main/java/com/dissonance/itit/dto/response/InfoPostRes.java rename to src/main/java/com/dissonance/itit/post/dto/response/InfoPostRes.java index 05ebd8a..ba548fa 100644 --- a/src/main/java/com/dissonance/itit/dto/response/InfoPostRes.java +++ b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostRes.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.post.dto.response; import java.time.LocalDate; import java.time.temporal.ChronoUnit; @@ -14,6 +14,7 @@ public class InfoPostRes { private final String imgUrl; private final String title; private final String remainingDays; + private final Integer viewCount; public static List of(List postInfos) { return postInfos.stream() @@ -22,6 +23,7 @@ public static List of(List postInfos) { .imgUrl(postInfo.imgUrl()) .title(postInfo.title()) .remainingDays(calculateRemainingDays(postInfo.deadline())) + .viewCount(postInfo.viewCount()) .build()) .toList(); } @@ -43,6 +45,7 @@ public record InfoPostInfo( Long id, String imgUrl, String title, - LocalDate deadline) { + LocalDate deadline, + Integer viewCount) { } } diff --git a/src/main/java/com/dissonance/itit/dto/response/InfoPostUpdateRes.java b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostUpdateRes.java similarity index 82% rename from src/main/java/com/dissonance/itit/dto/response/InfoPostUpdateRes.java rename to src/main/java/com/dissonance/itit/post/dto/response/InfoPostUpdateRes.java index ae8683f..69016f2 100644 --- a/src/main/java/com/dissonance/itit/dto/response/InfoPostUpdateRes.java +++ b/src/main/java/com/dissonance/itit/post/dto/response/InfoPostUpdateRes.java @@ -1,6 +1,6 @@ -package com.dissonance.itit.dto.response; +package com.dissonance.itit.post.dto.response; -import static com.dissonance.itit.common.util.DateUtil.*; +import static com.dissonance.itit.global.common.util.DateUtil.*; import java.time.LocalDate; import java.util.List; @@ -14,26 +14,26 @@ @Builder public class InfoPostUpdateRes { @Schema(description = "제목", example = "공모전1") - private String title; + private final String title; @Schema(description = "공고 카테고리 id", example = "3") - private Integer categoryId; + private final Integer categoryId; @Schema(description = "모집 기관 or 단체", example = "DDD") - private String organization; + private final String organization; @Schema(description = "모집 시작 일자", example = "2024년 8월 10일") - private String recruitmentStartDate; + private final String recruitmentStartDate; @Schema(description = "모집 종료 일자", example = "2024년 8월 18일") - private String recruitmentEndDate; + private final String recruitmentEndDate; private List positionInfos; @Schema(description = "활동 시작 일자", example = "2024년 10월 1일") - private String activityStartDate; + private final String activityStartDate; @Schema(description = "활동 종료 일자", example = "2024년 12월 31일") - private String activityEndDate; + private final String activityEndDate; @Schema(description = "활동 내용", example = "여러분의 창의력과 디자인 역량을 발휘해볼 특별한 기회를 놓치지 마세요") - private String content; + private final String content; @Schema(description = "공고 url", example = "https://www.google.com/") - private String detailUrl; + private final String detailUrl; @Schema(description = "이메일 url", example = "https://www.s3.bucket/") - private String imageUrl; + private final String imageUrl; @Getter @AllArgsConstructor diff --git a/src/main/java/com/dissonance/itit/repository/CategoryRepository.java b/src/main/java/com/dissonance/itit/post/repository/CategoryRepository.java similarity index 60% rename from src/main/java/com/dissonance/itit/repository/CategoryRepository.java rename to src/main/java/com/dissonance/itit/post/repository/CategoryRepository.java index ed8e5c5..2824250 100644 --- a/src/main/java/com/dissonance/itit/repository/CategoryRepository.java +++ b/src/main/java/com/dissonance/itit/post/repository/CategoryRepository.java @@ -1,7 +1,8 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.post.repository; -import com.dissonance.itit.domain.entity.Category; import org.springframework.data.jpa.repository.JpaRepository; +import com.dissonance.itit.post.domain.Category; + public interface CategoryRepository extends JpaRepository { } diff --git a/src/main/java/com/dissonance/itit/repository/FeaturedPostRepository.java b/src/main/java/com/dissonance/itit/post/repository/FeaturedPostRepository.java similarity index 60% rename from src/main/java/com/dissonance/itit/repository/FeaturedPostRepository.java rename to src/main/java/com/dissonance/itit/post/repository/FeaturedPostRepository.java index 9c58718..777d8ed 100644 --- a/src/main/java/com/dissonance/itit/repository/FeaturedPostRepository.java +++ b/src/main/java/com/dissonance/itit/post/repository/FeaturedPostRepository.java @@ -1,7 +1,8 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.post.repository; -import com.dissonance.itit.domain.entity.FeaturedPost; import org.springframework.data.jpa.repository.JpaRepository; +import com.dissonance.itit.post.domain.FeaturedPost; + public interface FeaturedPostRepository extends JpaRepository { } diff --git a/src/main/java/com/dissonance/itit/repository/InfoPostRepository.java b/src/main/java/com/dissonance/itit/post/repository/InfoPostRepository.java similarity index 59% rename from src/main/java/com/dissonance/itit/repository/InfoPostRepository.java rename to src/main/java/com/dissonance/itit/post/repository/InfoPostRepository.java index 5ec64d8..5364821 100644 --- a/src/main/java/com/dissonance/itit/repository/InfoPostRepository.java +++ b/src/main/java/com/dissonance/itit/post/repository/InfoPostRepository.java @@ -1,7 +1,8 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.post.repository; -import com.dissonance.itit.domain.entity.InfoPost; import org.springframework.data.jpa.repository.JpaRepository; +import com.dissonance.itit.post.domain.InfoPost; + public interface InfoPostRepository extends JpaRepository { } diff --git a/src/main/java/com/dissonance/itit/repository/InfoPostRepositorySupport.java b/src/main/java/com/dissonance/itit/post/repository/InfoPostRepositorySupport.java similarity index 93% rename from src/main/java/com/dissonance/itit/repository/InfoPostRepositorySupport.java rename to src/main/java/com/dissonance/itit/post/repository/InfoPostRepositorySupport.java index 596ca00..ee0794f 100644 --- a/src/main/java/com/dissonance/itit/repository/InfoPostRepositorySupport.java +++ b/src/main/java/com/dissonance/itit/post/repository/InfoPostRepositorySupport.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.post.repository; import java.time.LocalDate; import java.util.ArrayList; @@ -10,10 +10,10 @@ import org.springframework.data.support.PageableExecutionUtils; import org.springframework.stereotype.Repository; -import com.dissonance.itit.domain.entity.QInfoPost; -import com.dissonance.itit.dto.response.InfoPostDetailRes.InfoPostInfo; -import com.dissonance.itit.dto.response.InfoPostRes; -import com.dissonance.itit.dto.response.InfoPostUpdateRes; +import com.dissonance.itit.post.domain.QInfoPost; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes.InfoPostInfo; +import com.dissonance.itit.post.dto.response.InfoPostRes; +import com.dissonance.itit.post.dto.response.InfoPostUpdateRes; import com.querydsl.core.types.Order; import com.querydsl.core.types.OrderSpecifier; import com.querydsl.core.types.Projections; @@ -45,7 +45,6 @@ public InfoPostInfo findInfoPostWithDetails(Long infoPostId) { infoPost.content.as("content"), infoPost.detailUrl.as("detailUrl"), infoPost.viewCount.as("viewCount"), - infoPost.reported.as("reported"), infoPost.image.imageUrl.as("imageUrl") )) .from(infoPost) @@ -66,7 +65,8 @@ public Page findInfoPostsByCategoryId(Integer categoryId, Pageable infoPost.id, infoPost.image.imageUrl, infoPost.title, - infoPost.recruitmentEndDate)) + infoPost.recruitmentEndDate, + infoPost.viewCount)) .from(infoPost) .where(buildCategoryCondition(categoryId)) .offset(pageable.getOffset()) @@ -163,7 +163,8 @@ public Page findInfoPostsByKeyword(String keyword, Pageable pageabl infoPost.id, infoPost.image.imageUrl, infoPost.title, - infoPost.recruitmentEndDate)) + infoPost.recruitmentEndDate, + infoPost.viewCount)) .from(infoPost) .where(buildKeywordMatchCondition(keyword)) .offset(pageable.getOffset()) diff --git a/src/main/java/com/dissonance/itit/post/service/CategoryService.java b/src/main/java/com/dissonance/itit/post/service/CategoryService.java new file mode 100644 index 0000000..caf38ca --- /dev/null +++ b/src/main/java/com/dissonance/itit/post/service/CategoryService.java @@ -0,0 +1,23 @@ +package com.dissonance.itit.post.service; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.post.domain.Category; +import com.dissonance.itit.post.repository.CategoryRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class CategoryService { + private final CategoryRepository categoryRepository; + + @Transactional(readOnly = true) + public Category findById(Integer id) { + return categoryRepository.findById(id) + .orElseThrow(() -> new CustomException(ErrorCode.NON_EXISTENT_CATEGORY_ID)); + } +} diff --git a/src/main/java/com/dissonance/itit/post/service/FeaturedPostService.java b/src/main/java/com/dissonance/itit/post/service/FeaturedPostService.java new file mode 100644 index 0000000..aaaaab3 --- /dev/null +++ b/src/main/java/com/dissonance/itit/post/service/FeaturedPostService.java @@ -0,0 +1,24 @@ +package com.dissonance.itit.post.service; + +import java.util.List; + +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.dissonance.itit.post.domain.FeaturedPost; +import com.dissonance.itit.post.dto.response.FeaturedPostRes; +import com.dissonance.itit.post.repository.FeaturedPostRepository; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class FeaturedPostService { + private final FeaturedPostRepository featuredPostRepository; + + @Transactional(readOnly = true) + public List getFeaturedPost() { + List featuredPosts = featuredPostRepository.findAll(); + return FeaturedPostRes.of(featuredPosts); + } +} diff --git a/src/main/java/com/dissonance/itit/service/InfoPostService.java b/src/main/java/com/dissonance/itit/post/service/InfoPostService.java similarity index 78% rename from src/main/java/com/dissonance/itit/service/InfoPostService.java rename to src/main/java/com/dissonance/itit/post/service/InfoPostService.java index a8980bb..bb40cbf 100644 --- a/src/main/java/com/dissonance/itit/service/InfoPostService.java +++ b/src/main/java/com/dissonance/itit/post/service/InfoPostService.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.post.service; import java.util.List; @@ -8,22 +8,24 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.enums.Directory; -import com.dissonance.itit.dto.request.InfoPostReq; -import com.dissonance.itit.dto.request.InfoPostUpdateReq; -import com.dissonance.itit.dto.response.InfoPostCreateRes; -import com.dissonance.itit.dto.response.InfoPostDetailRes; -import com.dissonance.itit.dto.response.InfoPostDetailRes.InfoPostInfo; -import com.dissonance.itit.dto.response.InfoPostRes; -import com.dissonance.itit.dto.response.InfoPostUpdateRes; -import com.dissonance.itit.repository.InfoPostRepository; -import com.dissonance.itit.repository.InfoPostRepositorySupport; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.image.domain.Directory; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.image.service.ImageService; +import com.dissonance.itit.post.domain.Category; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.post.dto.request.InfoPostReq; +import com.dissonance.itit.post.dto.request.InfoPostUpdateReq; +import com.dissonance.itit.post.dto.response.InfoPostCreateRes; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes.InfoPostInfo; +import com.dissonance.itit.post.dto.response.InfoPostRes; +import com.dissonance.itit.post.dto.response.InfoPostUpdateRes; +import com.dissonance.itit.post.repository.InfoPostRepository; +import com.dissonance.itit.post.repository.InfoPostRepositorySupport; +import com.dissonance.itit.recruitmentPosition.service.RecruitmentPositionService; +import com.dissonance.itit.user.domain.User; import lombok.RequiredArgsConstructor; @@ -57,10 +59,6 @@ public InfoPostDetailRes getInfoPostDetailById(Long infoPostId) { throw new CustomException(ErrorCode.NON_EXISTENT_INFO_POST_ID); } - if (infoPostInfo.getReported()) { - throw new CustomException(ErrorCode.REPORTED_INFO_POST_ID); - } - List positionInfos = recruitmentPositionService.findPositionInfosByInfoPostId(infoPostId); return InfoPostDetailRes.of(infoPostInfo, positionInfos); diff --git a/src/main/java/com/dissonance/itit/domain/entity/RecruitmentPosition.java b/src/main/java/com/dissonance/itit/recruitmentPosition/domain/RecruitmentPosition.java similarity index 90% rename from src/main/java/com/dissonance/itit/domain/entity/RecruitmentPosition.java rename to src/main/java/com/dissonance/itit/recruitmentPosition/domain/RecruitmentPosition.java index 104fded..1f9b2df 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/RecruitmentPosition.java +++ b/src/main/java/com/dissonance/itit/recruitmentPosition/domain/RecruitmentPosition.java @@ -1,4 +1,6 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.recruitmentPosition.domain; + +import com.dissonance.itit.post.domain.InfoPost; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepository.java b/src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepository.java similarity index 60% rename from src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepository.java rename to src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepository.java index 99f66a7..3b0c949 100644 --- a/src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepository.java +++ b/src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepository.java @@ -1,8 +1,8 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.recruitmentPosition.repository; import org.springframework.data.jpa.repository.JpaRepository; -import com.dissonance.itit.domain.entity.RecruitmentPosition; +import com.dissonance.itit.recruitmentPosition.domain.RecruitmentPosition; public interface RecruitmentPositionRepository extends JpaRepository { void deleteByInfoPostId(Long infoPostId); diff --git a/src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepositorySupport.java b/src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepositorySupport.java similarity index 82% rename from src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepositorySupport.java rename to src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepositorySupport.java index 4aa40c1..4d1f92a 100644 --- a/src/main/java/com/dissonance/itit/repository/RecruitmentPositionRepositorySupport.java +++ b/src/main/java/com/dissonance/itit/recruitmentPosition/repository/RecruitmentPositionRepositorySupport.java @@ -1,10 +1,10 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.recruitmentPosition.repository; import java.util.List; import org.springframework.stereotype.Repository; -import com.dissonance.itit.domain.entity.QRecruitmentPosition; +import com.dissonance.itit.recruitmentPosition.domain.QRecruitmentPosition; import com.querydsl.jpa.impl.JPAQueryFactory; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/service/RecruitmentPositionService.java b/src/main/java/com/dissonance/itit/recruitmentPosition/service/RecruitmentPositionService.java similarity index 78% rename from src/main/java/com/dissonance/itit/service/RecruitmentPositionService.java rename to src/main/java/com/dissonance/itit/recruitmentPosition/service/RecruitmentPositionService.java index f25d5af..cb28db4 100644 --- a/src/main/java/com/dissonance/itit/service/RecruitmentPositionService.java +++ b/src/main/java/com/dissonance/itit/recruitmentPosition/service/RecruitmentPositionService.java @@ -1,14 +1,14 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.recruitmentPosition.service; import java.util.List; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.RecruitmentPosition; -import com.dissonance.itit.repository.RecruitmentPositionRepository; -import com.dissonance.itit.repository.RecruitmentPositionRepositorySupport; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.recruitmentPosition.domain.RecruitmentPosition; +import com.dissonance.itit.recruitmentPosition.repository.RecruitmentPositionRepository; +import com.dissonance.itit.recruitmentPosition.repository.RecruitmentPositionRepositorySupport; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/repository/ReportRepository.java b/src/main/java/com/dissonance/itit/repository/ReportRepository.java deleted file mode 100644 index f8f898d..0000000 --- a/src/main/java/com/dissonance/itit/repository/ReportRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dissonance.itit.repository; - -import org.springframework.data.jpa.repository.JpaRepository; - -import com.dissonance.itit.domain.entity.Report; - -public interface ReportRepository extends JpaRepository { - boolean existsByInfoPostIdAndUserId(Long infoPostId, Long UserId); -} diff --git a/src/main/java/com/dissonance/itit/service/CategoryService.java b/src/main/java/com/dissonance/itit/service/CategoryService.java deleted file mode 100644 index dcc77ed..0000000 --- a/src/main/java/com/dissonance/itit/service/CategoryService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.dissonance.itit.service; - -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.repository.CategoryRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@RequiredArgsConstructor -public class CategoryService { - private final CategoryRepository categoryRepository; - - @Transactional(readOnly = true) - public Category findById(Integer id) { - return categoryRepository.findById(id) - .orElseThrow(() -> new CustomException(ErrorCode.NON_EXISTENT_CATEGORY_ID)); - } -} diff --git a/src/main/java/com/dissonance/itit/service/FeaturedPostService.java b/src/main/java/com/dissonance/itit/service/FeaturedPostService.java deleted file mode 100644 index 395abdc..0000000 --- a/src/main/java/com/dissonance/itit/service/FeaturedPostService.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.dissonance.itit.service; - -import com.dissonance.itit.domain.entity.FeaturedPost; -import com.dissonance.itit.dto.response.FeaturedPostRes; -import com.dissonance.itit.repository.FeaturedPostRepository; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.util.List; - -@Service -@RequiredArgsConstructor -public class FeaturedPostService { - private final FeaturedPostRepository featuredPostRepository; - - @Transactional(readOnly = true) - public List getFeaturedPost() { - List featuredPosts = featuredPostRepository.findAll(); - return FeaturedPostRes.of(featuredPosts); - } -} diff --git a/src/main/java/com/dissonance/itit/service/OAuthService.java b/src/main/java/com/dissonance/itit/service/OAuthService.java deleted file mode 100644 index 4ab6bd1..0000000 --- a/src/main/java/com/dissonance/itit/service/OAuthService.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.dissonance.itit.service; - -import com.dissonance.itit.domain.enums.SocialLoginProvider; -import com.dissonance.itit.dto.response.OAuthUserInformation; - -public interface OAuthService { - SocialLoginProvider getProvider(); - - OAuthUserInformation requestUserInformation(String token); -} diff --git a/src/main/java/com/dissonance/itit/service/ReportService.java b/src/main/java/com/dissonance/itit/service/ReportService.java deleted file mode 100644 index 485fcc0..0000000 --- a/src/main/java/com/dissonance/itit/service/ReportService.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.dissonance.itit.service; - -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.Report; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.repository.ReportRepository; - -import lombok.RequiredArgsConstructor; - -@Service -@RequiredArgsConstructor -public class ReportService { - private final ReportRepository reportRepository; - - private final InfoPostService infoPostService; - - @Transactional - public Long reportedInfoPost(Long infoPostId, User user) { - InfoPost infoPost = infoPostService.findById(infoPostId); - - if (reportRepository.existsByInfoPostIdAndUserId(infoPostId, user.getId())) { - throw new CustomException(ErrorCode.ALREADY_REPORTED_POST); - } - - Report report = Report.builder() - .infoPost(infoPost) - .user(user) - .build(); - reportRepository.save(report); - - return infoPost.getId(); - } -} diff --git a/src/main/java/com/dissonance/itit/controller/UserController.java b/src/main/java/com/dissonance/itit/user/controller/UserController.java similarity index 82% rename from src/main/java/com/dissonance/itit/controller/UserController.java rename to src/main/java/com/dissonance/itit/user/controller/UserController.java index 7fc73d1..1c4f3bb 100644 --- a/src/main/java/com/dissonance/itit/controller/UserController.java +++ b/src/main/java/com/dissonance/itit/user/controller/UserController.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.controller; +package com.dissonance.itit.user.controller; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; @@ -8,13 +8,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.dissonance.itit.common.annotation.CurrentUser; -import com.dissonance.itit.common.util.ApiResponse; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.dto.request.RefreshTokenReq; -import com.dissonance.itit.dto.response.GeneratedToken; -import com.dissonance.itit.dto.response.LoginUserInfoRes; -import com.dissonance.itit.service.UserService; +import com.dissonance.itit.global.common.annotation.CurrentUser; +import com.dissonance.itit.global.common.util.ApiResponse; +import com.dissonance.itit.global.security.dto.GeneratedToken; +import com.dissonance.itit.oauth.dto.RefreshTokenReq; +import com.dissonance.itit.user.domain.User; +import com.dissonance.itit.user.dto.LoginUserInfoRes; +import com.dissonance.itit.user.service.UserService; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/user/domain/Role.java b/src/main/java/com/dissonance/itit/user/domain/Role.java new file mode 100644 index 0000000..d6323d8 --- /dev/null +++ b/src/main/java/com/dissonance/itit/user/domain/Role.java @@ -0,0 +1,13 @@ +package com.dissonance.itit.user.domain; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum Role { + USER("ROLE_USER"), + ADMIN("ROLE_ADMIN"); + + private final String key; +} \ No newline at end of file diff --git a/src/main/java/com/dissonance/itit/domain/entity/User.java b/src/main/java/com/dissonance/itit/user/domain/User.java similarity index 89% rename from src/main/java/com/dissonance/itit/domain/entity/User.java rename to src/main/java/com/dissonance/itit/user/domain/User.java index 9dc0665..209e0c3 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/User.java +++ b/src/main/java/com/dissonance/itit/user/domain/User.java @@ -1,7 +1,7 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.user.domain; -import com.dissonance.itit.domain.enums.Role; -import com.dissonance.itit.domain.enums.SocialLoginProvider; +import com.dissonance.itit.global.common.entity.BaseTime; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/com/dissonance/itit/domain/entity/UserDetailsImpl.java b/src/main/java/com/dissonance/itit/user/domain/UserDetailsImpl.java similarity index 95% rename from src/main/java/com/dissonance/itit/domain/entity/UserDetailsImpl.java rename to src/main/java/com/dissonance/itit/user/domain/UserDetailsImpl.java index 6a64da5..efdd4fe 100644 --- a/src/main/java/com/dissonance/itit/domain/entity/UserDetailsImpl.java +++ b/src/main/java/com/dissonance/itit/user/domain/UserDetailsImpl.java @@ -1,4 +1,4 @@ -package com.dissonance.itit.domain.entity; +package com.dissonance.itit.user.domain; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/com/dissonance/itit/user/dto/LoginUserInfoRes.java b/src/main/java/com/dissonance/itit/user/dto/LoginUserInfoRes.java new file mode 100644 index 0000000..e80c992 --- /dev/null +++ b/src/main/java/com/dissonance/itit/user/dto/LoginUserInfoRes.java @@ -0,0 +1,8 @@ +package com.dissonance.itit.user.dto; + +import com.dissonance.itit.oauth.enums.SocialLoginProvider; + +public record LoginUserInfoRes( + boolean isAdmin, + SocialLoginProvider provider) { +} diff --git a/src/main/java/com/dissonance/itit/repository/UserRepository.java b/src/main/java/com/dissonance/itit/user/repository/UserRepository.java similarity index 66% rename from src/main/java/com/dissonance/itit/repository/UserRepository.java rename to src/main/java/com/dissonance/itit/user/repository/UserRepository.java index e4764b8..50329b0 100644 --- a/src/main/java/com/dissonance/itit/repository/UserRepository.java +++ b/src/main/java/com/dissonance/itit/user/repository/UserRepository.java @@ -1,11 +1,11 @@ -package com.dissonance.itit.repository; +package com.dissonance.itit.user.repository; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.enums.SocialLoginProvider; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; +import com.dissonance.itit.user.domain.User; public interface UserRepository extends JpaRepository { boolean existsByProviderAndProviderId(SocialLoginProvider provider, String providerId); diff --git a/src/main/java/com/dissonance/itit/service/UserDetailsServiceImpl.java b/src/main/java/com/dissonance/itit/user/service/UserDetailsServiceImpl.java similarity index 68% rename from src/main/java/com/dissonance/itit/service/UserDetailsServiceImpl.java rename to src/main/java/com/dissonance/itit/user/service/UserDetailsServiceImpl.java index f8c532c..05d4bb9 100644 --- a/src/main/java/com/dissonance/itit/service/UserDetailsServiceImpl.java +++ b/src/main/java/com/dissonance/itit/user/service/UserDetailsServiceImpl.java @@ -1,14 +1,14 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.user.service; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.entity.UserDetailsImpl; -import com.dissonance.itit.repository.UserRepository; +import com.dissonance.itit.user.domain.User; +import com.dissonance.itit.user.domain.UserDetailsImpl; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.user.repository.UserRepository; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/dissonance/itit/service/UserService.java b/src/main/java/com/dissonance/itit/user/service/UserService.java similarity index 80% rename from src/main/java/com/dissonance/itit/service/UserService.java rename to src/main/java/com/dissonance/itit/user/service/UserService.java index a658ad3..435a5cc 100644 --- a/src/main/java/com/dissonance/itit/service/UserService.java +++ b/src/main/java/com/dissonance/itit/user/service/UserService.java @@ -1,19 +1,21 @@ -package com.dissonance.itit.service; +package com.dissonance.itit.user.service; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.common.jwt.util.JwtUtil; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.enums.Role; -import com.dissonance.itit.domain.enums.SocialLoginProvider; -import com.dissonance.itit.dto.response.GeneratedToken; -import com.dissonance.itit.dto.response.LoginUserInfoRes; -import com.dissonance.itit.dto.response.OAuthUserInformation; -import com.dissonance.itit.factory.OAuthServiceFactory; -import com.dissonance.itit.repository.UserRepository; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.global.common.redis.RedisService; +import com.dissonance.itit.global.common.util.JwtUtil; +import com.dissonance.itit.global.security.dto.GeneratedToken; +import com.dissonance.itit.oauth.dto.OAuthUserInformation; +import com.dissonance.itit.oauth.enums.SocialLoginProvider; +import com.dissonance.itit.oauth.service.OAuthService; +import com.dissonance.itit.oauth.service.OAuthServiceFactory; +import com.dissonance.itit.user.domain.Role; +import com.dissonance.itit.user.domain.User; +import com.dissonance.itit.user.dto.LoginUserInfoRes; +import com.dissonance.itit.user.repository.UserRepository; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index d49ab5e..740c997 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ spring: properties: hibernate: format_sql: true - dialect: com.dissonance.itit.config.MariaDBFullTextDialect + dialect: com.dissonance.itit.global.config.MariaDBFullTextDialect defer-datasource-initialization: false servlet: multipart: diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 156c714..cff0b4f 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -14,7 +14,7 @@ spring: properties: hibernate: format_sql: true - dialect: com.dissonance.itit.config.MariaDBFullTextDialect + dialect: com.dissonance.itit.global.config.MariaDBFullTextDialect defer-datasource-initialization: true servlet: multipart: diff --git a/src/test/java/com/dissonance/itit/fixture/TestFixture.java b/src/test/java/com/dissonance/itit/fixture/TestFixture.java index 248ec73..ef39b26 100644 --- a/src/test/java/com/dissonance/itit/fixture/TestFixture.java +++ b/src/test/java/com/dissonance/itit/fixture/TestFixture.java @@ -5,13 +5,13 @@ import org.springframework.http.MediaType; import org.springframework.mock.web.MockMultipartFile; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.enums.Role; -import com.dissonance.itit.dto.request.InfoPostReq; -import com.dissonance.itit.dto.response.InfoPostRes; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.post.domain.Category; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.post.dto.request.InfoPostReq; +import com.dissonance.itit.post.dto.response.InfoPostRes; +import com.dissonance.itit.user.domain.Role; +import com.dissonance.itit.user.domain.User; public class TestFixture { public static MockMultipartFile getMockMultipartFile() { diff --git a/src/test/java/com/dissonance/itit/service/FeaturedPostServiceTest.java b/src/test/java/com/dissonance/itit/service/FeaturedPostServiceTest.java index cb66c6a..246bee8 100644 --- a/src/test/java/com/dissonance/itit/service/FeaturedPostServiceTest.java +++ b/src/test/java/com/dissonance/itit/service/FeaturedPostServiceTest.java @@ -1,9 +1,10 @@ package com.dissonance.itit.service; -import com.dissonance.itit.domain.entity.FeaturedPost; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.dto.response.FeaturedPostRes; -import com.dissonance.itit.repository.FeaturedPostRepository; +import static org.assertj.core.api.Assertions.*; +import static org.mockito.BDDMockito.*; + +import java.util.List; + import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -11,39 +12,40 @@ import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; -import java.util.List; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.BDDMockito.given; +import com.dissonance.itit.post.domain.FeaturedPost; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.post.dto.response.FeaturedPostRes; +import com.dissonance.itit.post.repository.FeaturedPostRepository; +import com.dissonance.itit.post.service.FeaturedPostService; @ExtendWith(MockitoExtension.class) public class FeaturedPostServiceTest { - @InjectMocks - private FeaturedPostService featuredPostService; - @Mock - private FeaturedPostRepository featuredPostRepository; - - @Test - @DisplayName("추천 게시글 목록을 조회한다.") - public void getFeaturedPost_returnFeaturedPostRes() { - InfoPost infoPost = InfoPost.builder().id(10L).build(); - - FeaturedPost featuredPost = FeaturedPost.builder() - .id(1) - .bannerImageUrl("http://example.com/image.jpg") - .infoPost(infoPost) - .build(); - - // given - given(featuredPostRepository.findAll()).willReturn(List.of(featuredPost)); - - // when - List result = featuredPostService.getFeaturedPost(); - - // then - assertThat(result).hasSize(1); - assertThat(result.get(0).getFeaturedPostId()).isEqualTo(featuredPost.getId()); - assertThat(result.get(0).getBannerImageUrl()).isEqualTo(featuredPost.getBannerImageUrl()); - assertThat(result.get(0).getInfoPostId()).isEqualTo(featuredPost.getInfoPost().getId()); - } + @InjectMocks + private FeaturedPostService featuredPostService; + @Mock + private FeaturedPostRepository featuredPostRepository; + + @Test + @DisplayName("추천 게시글 목록을 조회한다.") + public void getFeaturedPost_returnFeaturedPostRes() { + InfoPost infoPost = InfoPost.builder().id(10L).build(); + + FeaturedPost featuredPost = FeaturedPost.builder() + .id(1) + .bannerImageUrl("http://example.com/image.jpg") + .infoPost(infoPost) + .build(); + + // given + given(featuredPostRepository.findAll()).willReturn(List.of(featuredPost)); + + // when + List result = featuredPostService.getFeaturedPost(); + + // then + assertThat(result).hasSize(1); + assertThat(result.get(0).getFeaturedPostId()).isEqualTo(featuredPost.getId()); + assertThat(result.get(0).getBannerImageUrl()).isEqualTo(featuredPost.getBannerImageUrl()); + assertThat(result.get(0).getInfoPostId()).isEqualTo(featuredPost.getInfoPost().getId()); + } } diff --git a/src/test/java/com/dissonance/itit/service/InfoPostServiceTest.java b/src/test/java/com/dissonance/itit/service/InfoPostServiceTest.java index e581845..773b32f 100644 --- a/src/test/java/com/dissonance/itit/service/InfoPostServiceTest.java +++ b/src/test/java/com/dissonance/itit/service/InfoPostServiceTest.java @@ -20,21 +20,25 @@ import org.springframework.data.domain.Pageable; import org.springframework.mock.web.MockMultipartFile; -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.domain.enums.Directory; -import com.dissonance.itit.dto.request.InfoPostReq; -import com.dissonance.itit.dto.response.InfoPostCreateRes; -import com.dissonance.itit.dto.response.InfoPostDetailRes; -import com.dissonance.itit.dto.response.InfoPostRes; -import com.dissonance.itit.dto.response.InfoPostUpdateRes; import com.dissonance.itit.fixture.TestFixture; -import com.dissonance.itit.repository.InfoPostRepository; -import com.dissonance.itit.repository.InfoPostRepositorySupport; +import com.dissonance.itit.global.common.exception.CustomException; +import com.dissonance.itit.global.common.exception.ErrorCode; +import com.dissonance.itit.image.domain.Directory; +import com.dissonance.itit.image.domain.Image; +import com.dissonance.itit.image.service.ImageService; +import com.dissonance.itit.post.domain.Category; +import com.dissonance.itit.post.domain.InfoPost; +import com.dissonance.itit.post.dto.request.InfoPostReq; +import com.dissonance.itit.post.dto.response.InfoPostCreateRes; +import com.dissonance.itit.post.dto.response.InfoPostDetailRes; +import com.dissonance.itit.post.dto.response.InfoPostRes; +import com.dissonance.itit.post.dto.response.InfoPostUpdateRes; +import com.dissonance.itit.post.repository.InfoPostRepository; +import com.dissonance.itit.post.repository.InfoPostRepositorySupport; +import com.dissonance.itit.post.service.CategoryService; +import com.dissonance.itit.post.service.InfoPostService; +import com.dissonance.itit.recruitmentPosition.service.RecruitmentPositionService; +import com.dissonance.itit.user.domain.User; @ExtendWith(MockitoExtension.class) public class InfoPostServiceTest { diff --git a/src/test/java/com/dissonance/itit/service/ReportServiceTest.java b/src/test/java/com/dissonance/itit/service/ReportServiceTest.java deleted file mode 100644 index 92a9fc2..0000000 --- a/src/test/java/com/dissonance/itit/service/ReportServiceTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.dissonance.itit.service; - -import static org.assertj.core.api.Assertions.*; -import static org.mockito.BDDMockito.*; - -import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.junit.jupiter.MockitoExtension; - -import com.dissonance.itit.common.exception.CustomException; -import com.dissonance.itit.common.exception.ErrorCode; -import com.dissonance.itit.domain.entity.Category; -import com.dissonance.itit.domain.entity.Image; -import com.dissonance.itit.domain.entity.InfoPost; -import com.dissonance.itit.domain.entity.User; -import com.dissonance.itit.dto.request.InfoPostReq; -import com.dissonance.itit.fixture.TestFixture; -import com.dissonance.itit.repository.ReportRepository; - -@ExtendWith(MockitoExtension.class) -public class ReportServiceTest { - @InjectMocks - private ReportService reportService; - @Mock - private ReportRepository reportRepository; - @Mock - private InfoPostService infoPostService; - - @Test - @DisplayName("게시글 신고") - void reportedInfoPost_returnInfoPostId() { - // given - Long infoPostId = 1L; - InfoPostReq infoPostReq = TestFixture.createInfoPostReq(); - User author = TestFixture.createUser(); - Image image = TestFixture.createImage(); - Category category = TestFixture.createCategory(); - InfoPost infoPost = TestFixture.createInfoPost(infoPostReq, author, image, category); - - given(infoPostService.findById(infoPostId)).willReturn(infoPost); - given(reportRepository.existsByInfoPostIdAndUserId(infoPostId, author.getId())) - .willReturn(false); - - // when - Long result = reportService.reportedInfoPost(infoPostId, author); - - // then - assertThat(result).isEqualTo(infoPostId); - verify(reportRepository, times(1)).save(any()); - } - - @Test - @DisplayName("게시글 신고시 중복 신고로 인한 exception 발생") - void reportedInfoPost_throwCustomException_givenDuplicateReports() { - // given - Long infoPostId = 999L; - User loginUser = TestFixture.createUser(); - given(reportRepository.existsByInfoPostIdAndUserId(infoPostId, loginUser.getId())) - .willReturn(true); - - // when & then - assertThatThrownBy(() -> reportService.reportedInfoPost(infoPostId, loginUser)) - .isInstanceOf(CustomException.class) - .hasMessage(ErrorCode.ALREADY_REPORTED_POST.getMessage()); - } -}