-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from reading-log/develop
04.03 Main merge
- Loading branch information
Showing
52 changed files
with
1,358 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/com/api/readinglog/common/aws/DomainType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.api.readinglog.common.aws; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum DomainType { | ||
|
||
MEMBERS("members"), BOOK("books"); | ||
|
||
private final String type; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/com/api/readinglog/common/exception/custom/EmailException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.api.readinglog.common.exception.custom; | ||
|
||
import com.api.readinglog.common.exception.CustomException; | ||
import com.api.readinglog.common.exception.ErrorCode; | ||
|
||
public class EmailException extends CustomException { | ||
|
||
public EmailException(ErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/api/readinglog/common/exception/custom/RecordException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.api.readinglog.common.exception.custom; | ||
|
||
import com.api.readinglog.common.exception.CustomException; | ||
import com.api.readinglog.common.exception.ErrorCode; | ||
|
||
public class RecordException extends CustomException { | ||
public RecordException(ErrorCode errorCode) { | ||
super(errorCode); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/api/readinglog/common/image/ImageUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.api.readinglog.common.image; | ||
|
||
import java.util.Optional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public class ImageUtil { | ||
|
||
// 파일의 확장자를 반환해주는 메서드 | ||
public static String getExt(String fileName) { | ||
return Optional.ofNullable(fileName) | ||
.filter(f -> f.contains(".")) | ||
.map(f -> f.substring(fileName.lastIndexOf(".") + 1)) | ||
.orElse(""); | ||
} | ||
|
||
// 이미지 존재 여부 확인 | ||
public static boolean isNotEmptyImageFile(MultipartFile file) { | ||
return !(file == null || file.isEmpty()); | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/api/readinglog/common/redis/config/RedisConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.api.readinglog.common.redis.config; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.redis.connection.RedisConnectionFactory; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
|
||
@Value("${spring.redis.host}") | ||
private String redisHost; | ||
|
||
@Value("${spring.redis.port}") | ||
private int redisPort; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
return new LettuceConnectionFactory(redisHost, redisPort); | ||
} | ||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate() { | ||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory()); | ||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); | ||
return redisTemplate; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/api/readinglog/common/redis/service/RedisService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.api.readinglog.common.redis.service; | ||
|
||
import java.util.concurrent.TimeUnit; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
|
||
public class RedisService { | ||
|
||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
|
||
public void setData(String key, Object value, Long time, TimeUnit timeUnit) { | ||
redisTemplate.opsForValue().set(key, value.toString(), time, timeUnit); | ||
} | ||
|
||
public Object getData(String key) { | ||
return redisTemplate.opsForValue().get(key); | ||
} | ||
|
||
|
||
public void deleteData(String key) { | ||
redisTemplate.delete(key); | ||
} | ||
|
||
|
||
public void increaseData(String key) { | ||
redisTemplate.opsForValue().increment(key); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/api/readinglog/common/swagger/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.api.readinglog.common.swagger; | ||
|
||
|
||
import io.swagger.v3.oas.annotations.OpenAPIDefinition; | ||
import io.swagger.v3.oas.annotations.info.Contact; | ||
import io.swagger.v3.oas.annotations.info.Info; | ||
import io.swagger.v3.oas.annotations.servers.Server; | ||
import io.swagger.v3.oas.annotations.tags.Tag; | ||
import io.swagger.v3.oas.models.Components; | ||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.security.SecurityRequirement; | ||
import io.swagger.v3.oas.models.security.SecurityScheme; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import org.springdoc.core.models.GroupedOpenApi; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@OpenAPIDefinition( | ||
servers = {@Server(url = "/")}, | ||
info = @Info( | ||
title = "리딩로그 API 명세서", | ||
description = "독서 기록 서비스 리딩로그의 API 명세서", | ||
version = "v1.0") | ||
) | ||
@Configuration | ||
public class SwaggerConfig { | ||
|
||
@Bean | ||
public OpenAPI openAPI(){ | ||
String securityRequirementName = "Bearer를 제외한 accessToken값을 넣어주세요."; | ||
SecurityRequirement securityRequirement = new SecurityRequirement().addList(securityRequirementName); | ||
|
||
Components components = new Components() | ||
.addSecuritySchemes(securityRequirementName, new SecurityScheme() | ||
.name(securityRequirementName) | ||
.type(SecurityScheme.Type.HTTP) | ||
.scheme("bearer") | ||
.bearerFormat("JWT")); | ||
|
||
return new OpenAPI() | ||
.components(components) | ||
.addSecurityItem(securityRequirement); | ||
} | ||
} |
Oops, something went wrong.