-
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.
Tht server 253 [Admin] CORS 설정 및 유저 리스트에 프로필 사진 추가 (#254)
* feat : webmvc & spring security CORS 설정 * feat : user list 응답값에 프로필 사진 url 추가 * add : static 디렉토리 추가
- Loading branch information
Showing
13 changed files
with
123 additions
and
26 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
tht-admin/src/main/java/com/tht/thtadmin/security/CorsConfig.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,19 @@ | ||
package com.tht.thtadmin.security; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
@Component | ||
public class CorsConfig implements WebMvcConfigurer { | ||
|
||
@Override | ||
public void addCorsMappings(CorsRegistry registry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("http://localhost:5173") | ||
.allowedHeaders("*") | ||
.allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "PATCH") | ||
.exposedHeaders("Authorization") | ||
.allowCredentials(true); | ||
} | ||
} |
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
9 changes: 3 additions & 6 deletions
9
tht-admin/src/main/java/com/tht/thtadmin/ui/user/response/UserSimpleListResponse.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 |
---|---|---|
@@ -1,20 +1,17 @@ | ||
package com.tht.thtadmin.ui.user.response; | ||
|
||
import com.tht.enums.EntityState; | ||
import com.tht.thtcommonutils.utils.CustomDateFormatUtils; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record UserSimpleListResponse( | ||
String username, | ||
String profilePhotoUrl, | ||
String userUuid, | ||
String createdAt, | ||
EntityState userSate | ||
) { | ||
|
||
public static UserSimpleListResponse of(final String username, final String uuid, final LocalDateTime createdAt, final EntityState userSate) { | ||
public static UserSimpleListResponse of(final String username, final String profile, final String uuid, final String createdAt, final EntityState userSate) { | ||
|
||
final String convertCreateAt = createdAt.format(CustomDateFormatUtils.getDateTimeInstance()); | ||
return new UserSimpleListResponse(username, uuid, convertCreateAt, userSate); | ||
return new UserSimpleListResponse(username, profile, uuid, createdAt, userSate); | ||
} | ||
} |
Empty file.
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
19 changes: 19 additions & 0 deletions
19
tht-core/domain/src/main/java/com/tht/domain/entity/user/mapper/UserListMapper.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,19 @@ | ||
package com.tht.domain.entity.user.mapper; | ||
|
||
import com.querydsl.core.annotations.QueryProjection; | ||
import com.tht.enums.EntityState; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
public record UserListMapper( | ||
String username, | ||
String profilePhotoUrl, | ||
String userUuid, | ||
LocalDateTime createdAt, | ||
EntityState userSate | ||
) { | ||
|
||
@QueryProjection | ||
public UserListMapper { | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
tht-core/domain/src/main/java/com/tht/domain/entity/user/service/dto/UserListDto.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,23 @@ | ||
package com.tht.domain.entity.user.service.dto; | ||
|
||
import com.tht.domain.entity.user.mapper.UserListMapper; | ||
import com.tht.enums.EntityState; | ||
import com.tht.thtcommonutils.utils.CustomDateFormatUtils; | ||
|
||
public record UserListDto( | ||
String username, | ||
String profilePhotoUrl, | ||
String userUuid, | ||
String createdAt, | ||
EntityState userSate | ||
) { | ||
public static UserListDto ofMapper(final UserListMapper mapper) { | ||
return new UserListDto( | ||
mapper.username(), | ||
mapper.profilePhotoUrl(), | ||
mapper.userUuid(), | ||
mapper.createdAt().format(CustomDateFormatUtils.getDateTimeInstance()), | ||
mapper.userSate() | ||
); | ||
} | ||
} |