-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into refactor/excel-duplicate
- Loading branch information
Showing
11 changed files
with
216 additions
and
63 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
21 changes: 21 additions & 0 deletions
21
src/main/java/in/koreatech/koin/domain/bus/dto/BusNoticeResponse.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 in.koreatech.koin.domain.bus.dto; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import static com.fasterxml.jackson.databind.PropertyNamingStrategies.SnakeCaseStrategy; | ||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.NOT_REQUIRED; | ||
|
||
@JsonNaming(value = SnakeCaseStrategy.class) | ||
public record BusNoticeResponse( | ||
@Schema(description = "공지글 번호", example = "17153", requiredMode = NOT_REQUIRED) | ||
Integer id, | ||
|
||
@Schema(description = "공지글 제목", example = "[긴급][총무팀]2024.11.27.(수, 오늘) 천안, 청주 야간 셔틀 20시 지연운행", requiredMode = NOT_REQUIRED) | ||
String title | ||
) { | ||
|
||
public static BusNoticeResponse of(Integer id, String title) { | ||
return new BusNoticeResponse(id, title); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/in/koreatech/koin/domain/bus/repository/BusNoticeRepository.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,25 @@ | ||
package in.koreatech.koin.domain.bus.repository; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Map; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class BusNoticeRepository { | ||
|
||
public static final String BUS_NOTICE_KEY = "busNoticeArticle"; | ||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
public Map<Object, Object> getBusNotice() { | ||
Map<Object, Object> article = redisTemplate.opsForHash().entries(BUS_NOTICE_KEY); | ||
|
||
if (article.isEmpty()) { | ||
return null; | ||
} | ||
|
||
return article; | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
src/main/java/in/koreatech/koin/domain/community/article/model/redis/BusNoticeArticle.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,30 @@ | ||
package in.koreatech.koin.domain.community.article.model.redis; | ||
|
||
import in.koreatech.koin.domain.community.article.model.Article; | ||
import org.springframework.data.annotation.Id; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@RedisHash(value = "busNoticeArticle") | ||
public class BusNoticeArticle { | ||
|
||
@Id | ||
private Integer id; | ||
|
||
private String title; | ||
|
||
@Builder | ||
private BusNoticeArticle(Integer id, String title) { | ||
this.id = id; | ||
this.title = title; | ||
} | ||
|
||
public static BusNoticeArticle from(Article article) { | ||
return BusNoticeArticle.builder() | ||
.id(article.getId()) | ||
.title(article.getTitle()) | ||
.build(); | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
...ava/in/koreatech/koin/domain/community/article/repository/redis/BusArticleRepository.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,31 @@ | ||
package in.koreatech.koin.domain.community.article.repository.redis; | ||
|
||
import in.koreatech.koin.domain.community.article.model.redis.BusNoticeArticle; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.Map; | ||
|
||
@Repository | ||
@RequiredArgsConstructor | ||
public class BusArticleRepository { | ||
|
||
public static final String BUS_NOTICE_KEY = "busNoticeArticle"; | ||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
public void save(BusNoticeArticle article) { | ||
Map<Object, Object> existingArticle = redisTemplate.opsForHash().entries(BUS_NOTICE_KEY); | ||
|
||
if (!existingArticle.isEmpty()) { | ||
Object existingId = existingArticle.get("id"); | ||
if (existingId.equals(article.getId())) { | ||
return; | ||
} | ||
} | ||
|
||
redisTemplate.delete(BUS_NOTICE_KEY); | ||
redisTemplate.opsForHash().put(BUS_NOTICE_KEY, "id", article.getId()); | ||
redisTemplate.opsForHash().put(BUS_NOTICE_KEY, "title", article.getTitle()); | ||
} | ||
} |
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