Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BE] feat: 관리자 학교 응답 누락된 필드 추가, 관리자 아티스트 응답 createdAt, updatedAt 필드 추가 (#849) #850

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.festago.admin.dto.artist;

import com.querydsl.core.annotations.QueryProjection;
import java.time.LocalDateTime;

public record AdminArtistV1Response(
Long id,
String name,
String profileImageUrl,
String backgroundImageUrl
String backgroundImageUrl,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {

@QueryProjection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import com.festago.school.domain.SchoolRegion;
import com.querydsl.core.annotations.QueryProjection;
import java.time.LocalDateTime;

public record AdminSchoolV1Response(
Long id,
String domain,
String name,
SchoolRegion region
SchoolRegion region,
String logoUrl,
String backgroundImageUrl,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {

@QueryProjection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public Page<AdminArtistV1Response> findAll(SearchCondition searchCondition) {
artist.id,
artist.name,
artist.profileImage,
artist.backgroundImageUrl
artist.backgroundImageUrl,
artist.createdAt,
artist.updatedAt
))
.from(artist)
.where(applySearch(searchCondition))
Expand Down Expand Up @@ -77,7 +79,9 @@ public Optional<AdminArtistV1Response> findById(Long artistId) {
artist.id,
artist.name,
artist.profileImage,
artist.backgroundImageUrl
artist.backgroundImageUrl,
artist.createdAt,
artist.updatedAt
))
.from(artist)
.where(artist.id.eq(artistId)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ public Page<AdminSchoolV1Response> findAll(SearchCondition searchCondition) {
school.id,
school.domain,
school.name,
school.region
school.region,
school.logoUrl,
school.backgroundUrl,
school.createdAt,
school.updatedAt
))
.from(school)
.where(containSearchFilter(searchFilter, searchKeyword))
Expand Down Expand Up @@ -86,7 +90,11 @@ public Optional<AdminSchoolV1Response> findById(Long schoolId) {
school.id,
school.domain,
school.name,
school.region
school.region,
school.logoUrl,
school.backgroundUrl,
school.createdAt,
school.updatedAt
))
.from(school)
.where(school.id.eq(schoolId)));
Expand Down
3 changes: 2 additions & 1 deletion backend/src/main/java/com/festago/artist/domain/Artist.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.festago.artist.domain;

import com.festago.common.domain.BaseTimeEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
Expand All @@ -10,7 +11,7 @@

@Entity
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Artist {
public class Artist extends BaseTimeEntity {

private static final String DEFAULT_URL = "https://picsum.photos/536/354";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.festago.support.CustomWebMvcTest;
import com.festago.support.WithMockAuth;
import jakarta.servlet.http.Cookie;
import java.time.LocalDateTime;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
Expand Down Expand Up @@ -191,7 +192,14 @@ class 올바른_주소로 {
@WithMockAuth(role = Role.ADMIN)
void 요청을_보내면_200_응답과_body가_반환된다() throws Exception {
// given
var expected = new AdminArtistV1Response(1L, "윤하", "https://image.com/image.png", "https://image.com/background.png");
var expected = new AdminArtistV1Response(
1L,
"윤하",
"https://image.com/image1.png",
"https://image.com/background1.png",
LocalDateTime.now(),
LocalDateTime.now()
);
given(adminArtistV1QueryService.findById(anyLong()))
.willReturn(expected);

Expand Down Expand Up @@ -235,8 +243,14 @@ class 올바른_주소로 {
void 요청을_보내면_200_응답과_body가_반환된다() throws Exception {
// given
var expected = List.of(
new AdminArtistV1Response(1L, "윤하", "https://image.com/image1.png", "https://image.com/background1.png"),
new AdminArtistV1Response(2L, "고윤하", "https://image.com/image2.png", "https://image.com/background2.png")
new AdminArtistV1Response(
1L,
"윤하",
"https://image.com/image1.png",
"https://image.com/background1.png",
LocalDateTime.now(),
LocalDateTime.now()
)
);
given(adminArtistV1QueryService.findAll(any(SearchCondition.class)))
.willReturn(new PageImpl<>(expected));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.header;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -27,6 +26,7 @@
import com.festago.support.WithMockAuth;
import jakarta.servlet.http.Cookie;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.DisplayNameGeneration;
Expand Down Expand Up @@ -209,8 +209,16 @@ class 올바른_주소로 {
void 요청을_하면_200_응답과_학교_정보_목록이_반환된다() throws Exception {
// given
var expected = List.of(
new AdminSchoolV1Response(1L, "teco.ac.kr", "테코대학교", SchoolRegion.서울),
new AdminSchoolV1Response(2L, "wote.ac.kr", "우테대학교", SchoolRegion.부산)
new AdminSchoolV1Response(
1L,
"teco.ac.kr",
"테코대학교",
SchoolRegion.서울,
"https://image.com/logo.png",
"https://image.com/backgroundImage.png",
LocalDateTime.now(),
LocalDateTime.now()
)
);
given(adminSchoolV1QueryService.findAll(any(SearchCondition.class)))
.willReturn(new PageImpl<>(expected));
Expand All @@ -219,8 +227,7 @@ class 올바른_주소로 {
mockMvc.perform(get(uri)
.contentType(MediaType.APPLICATION_JSON)
.cookie(new Cookie("token", "Bearer token")))
.andExpect(status().isOk())
.andExpect(jsonPath("$.content.size()").value(2));
.andExpect(status().isOk());
}
}
}
Expand All @@ -238,7 +245,16 @@ class 올바른_주소로 {
@WithMockAuth(role = Role.ADMIN)
void 요청을_하면_200_응답과_학교_정보가_반환된다() throws Exception {
// given
var expected = new AdminSchoolV1Response(1L, "teco.ac.kr", "테코대학교", SchoolRegion.서울);
var expected = new AdminSchoolV1Response(
1L,
"teco.ac.kr",
"테코대학교",
SchoolRegion.서울,
"https://image.com/logo.png",
"https://image.com/backgroundImage.png",
LocalDateTime.now(),
LocalDateTime.now()
);
given(adminSchoolV1QueryService.findById(anyLong()))
.willReturn(expected);

Expand Down
Loading