Skip to content

Commit

Permalink
Merge pull request #287 from Denia-park/feat/게시글-조회-기본-값을-1년으로-하기
Browse files Browse the repository at this point in the history
게시글 조회 날짜를 1년 단위로 수정
  • Loading branch information
Denia-park authored Mar 22, 2024
2 parents 41b3c1e + 0650cd0 commit 35643d2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ private void validateSearchDate(final LocalDate startDate, final LocalDate endDa
/**
* 조회 시작일 초기화
* <br><br>
* - 조회 시작일이 없을 경우, 1달 전으로 초기화 <br>
* - 조회 시작일이 없을 경우, 1년 전으로 초기화 <br>
* - 조회 시작일이 있을 경우, 그대로 반환
*
* @param startDate 조회 시작일
* @return 초기화된 조회 시작일
*/
private LocalDate initStartDate(LocalDate startDate) {
if (startDate == null) {
return LocalDate.now().minusMonths(1);
return LocalDate.now().minusYears(1);
}

return startDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void searchDateConstructor() {
}

@Test
@DisplayName("시작일이 null일 때, 시작일은 현재 날짜의 한달 전이다.")
@DisplayName("시작일이 null일 때, 시작일은 현재 날짜의 1년 전이다.")
void searchDateConstructor2() {
//given
final LocalDate startDate = null;
Expand All @@ -44,7 +44,7 @@ void searchDateConstructor2() {
.build();

//then
assertThat(searchDate.startDate()).isEqualTo(LocalDate.now().minusMonths(1));
assertThat(searchDate.startDate()).isEqualTo(LocalDate.now().minusYears(1));
}

@Test
Expand Down Expand Up @@ -253,7 +253,7 @@ void getRequestConstructor() {
final GetRequest.SearchCondition requestSearchCondition = getRequest.getSearchCondition();
final GetRequest.SearchPaging requestSearchPaging = getRequest.getSearchPaging();

assertThat(requestSearchDate.startDate()).isEqualTo(LocalDate.now().minusMonths(1));
assertThat(requestSearchDate.startDate()).isEqualTo(LocalDate.now().minusYears(1));
assertThat(requestSearchDate.endDate()).isEqualTo(LocalDate.now());
assertThat(requestSearchCondition.category()).isEmpty();
assertThat(requestSearchCondition.searchText()).isEmpty();
Expand Down
8 changes: 4 additions & 4 deletions my-garden-fe/src/components/dailyRoutine/api/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export function convertDateFormat(date) {
}

/**
* 현재 시간을 기준으로 한 달 전의 일자를 특정 포맷으로 반환한다.
* 현재 시간을 기준으로 1년 전의 일자를 특정 포맷으로 반환한다.
*
* @returns {string} 한 달 전의 일자 (yyyy-MM-dd)
* @returns {string} 1년 전의 일자 (yyyy-MM-dd)
*/
export function getOneMonthAgoDate() {
export function getOneYearAgoDate() {
const currentDate = new Date();

currentDate.setMonth(currentDate.getMonth() - 1);
currentDate.setFullYear(currentDate.getFullYear() - 1);

const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
Expand Down
4 changes: 2 additions & 2 deletions my-garden-fe/src/pages/boards/learn/LearnBoardList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TableContents from "@/components/boards/common/TableContents.vue";
import {onMounted, ref, watch} from "vue";
import {getLearnBoardCategoryApi, getLearnBoardListApi} from "@/components/boards/learn/api/api.js";
import {getOneMonthAgoDate, getTodayDate} from "@/components/dailyRoutine/api/util.js";
import {getOneYearAgoDate, getTodayDate} from "@/components/dailyRoutine/api/util.js";
import SearchForm from "@/components/boards/common/SearchForm.vue";
import {router} from "@/scripts/router.js";
import {useRoute} from "vue-router";
Expand All @@ -19,7 +19,7 @@ const learnPage = ref({});
const learnTotalCount = ref(0);
const categories = ref([]);
const queryParameter = ref({
startDate: getOneMonthAgoDate(),
startDate: getOneYearAgoDate(),
endDate: getTodayDate(),
category: "",
searchText: "",
Expand Down
4 changes: 2 additions & 2 deletions my-garden-fe/src/pages/boards/notice/NoticeBoardList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getNoticeBoardListApi,
getNoticeImportantBoardListApi
} from "@/components/boards/notice/api/api.js";
import {getOneMonthAgoDate, getTodayDate} from "@/components/dailyRoutine/api/util.js";
import {getOneYearAgoDate, getTodayDate} from "@/components/dailyRoutine/api/util.js";
import SearchForm from "@/components/boards/common/SearchForm.vue";
import {router} from "@/scripts/router.js";
import {useRoute} from "vue-router";
Expand All @@ -24,7 +24,7 @@ const noticeImportantPage = ref([]);
const noticeTotalCount = ref(0);
const categories = ref([]);
const queryParameter = ref({
startDate: getOneMonthAgoDate(),
startDate: getOneYearAgoDate(),
endDate: getTodayDate(),
category: "",
searchText: "",
Expand Down

0 comments on commit 35643d2

Please sign in to comment.