-
Notifications
You must be signed in to change notification settings - Fork 5
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 #105 from kakao-tech-campus-2nd-step3/weekly/10
동기화
- Loading branch information
Showing
17 changed files
with
447 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package jeje.work.aeatbe.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.RedisStandaloneConfiguration; | ||
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.StringRedisSerializer; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
|
||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
@Value("${spring.data.redis.password}") | ||
private String password; | ||
|
||
@Value("${spring.data.redis.username}") | ||
private String username; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(host, port); | ||
config.setUsername(username); | ||
config.setPassword(password); | ||
return new LettuceConnectionFactory(config); | ||
|
||
} | ||
|
||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate() { | ||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory()); | ||
|
||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new StringRedisSerializer()); | ||
|
||
redisTemplate.setHashKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setHashValueSerializer(new StringRedisSerializer()); | ||
|
||
redisTemplate.setDefaultSerializer(new StringRedisSerializer()); | ||
|
||
return redisTemplate; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jeje.work.aeatbe.entity; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@RedisHash(value = "blackList" , timeToLive = 3600) | ||
public class BlackList { | ||
|
||
@Id | ||
private String token; | ||
|
||
private String userId; | ||
} |
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
51 changes: 51 additions & 0 deletions
51
src/main/java/jeje/work/aeatbe/mapper/article/ArticleMapper.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,51 @@ | ||
package jeje.work.aeatbe.mapper.article; | ||
|
||
import java.util.Arrays; | ||
import jeje.work.aeatbe.dto.article.ArticleDTO; | ||
import jeje.work.aeatbe.dto.article.ArticleResponseDTO; | ||
import jeje.work.aeatbe.entity.Article; | ||
import jeje.work.aeatbe.utility.ArticleUtil; | ||
import org.springframework.stereotype.Component; | ||
|
||
/* | ||
칼럼 매퍼 | ||
*/ | ||
@Component | ||
public class ArticleMapper { | ||
|
||
/** | ||
* Entity -> DTO | ||
* @param article | ||
* @return | ||
*/ | ||
public ArticleDTO toDTO(Article article) { | ||
return ArticleDTO.builder() | ||
.title(article.getTitle()) | ||
.date(article.getDate()) | ||
.author(article.getAuthor()) | ||
.tags(article.getTags()) | ||
.content(article.getContent()) | ||
.thumbnailUrl(article.getThumbnailUrl()) | ||
.likes(article.getLikes()) | ||
.build(); | ||
} | ||
|
||
/** | ||
* Entity -> ResponseDTO | ||
* @param article | ||
* @return | ||
*/ | ||
public ArticleResponseDTO toResponseDTO(Article article) { | ||
return ArticleResponseDTO.builder() | ||
.id(article.getId()) | ||
.title(article.getTitle()) | ||
.imgurl(article.getThumbnailUrl()) | ||
.createdAt(article.getDate()) | ||
.auth(article.getAuthor()) | ||
.keyword(Arrays.asList(article.getTags().split(","))) | ||
.content(ArticleUtil.extractContentList(article.getContent())) | ||
.subtitle(ArticleUtil.extractSubtitle(article.getContent())) | ||
.build(); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/jeje/work/aeatbe/repository/BlackListRepository.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,9 @@ | ||
package jeje.work.aeatbe.repository; | ||
|
||
import java.util.Optional; | ||
import jeje.work.aeatbe.entity.BlackList; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface BlackListRepository extends CrudRepository<BlackList, String> { | ||
|
||
} |
Oops, something went wrong.