File tree Expand file tree Collapse file tree 12 files changed +34
-33
lines changed
src/main/kotlin/com/psr/psr Expand file tree Collapse file tree 12 files changed +34
-33
lines changed Original file line number Diff line number Diff line change 1
1
package com.psr.psr.cs.controller
2
2
3
- import com.psr.psr.cs.dto.FaqListRes
4
- import com.psr.psr.cs.dto.FaqRes
5
- import com.psr.psr.cs.dto.NoticeListRes
6
- import com.psr.psr.cs.dto.NoticeRes
3
+ import com.psr.psr.cs.dto.response. FaqListRes
4
+ import com.psr.psr.cs.dto.response. FaqRes
5
+ import com.psr.psr.cs.dto.response. NoticeListRes
6
+ import com.psr.psr.cs.dto.response. NoticeRes
7
7
import com.psr.psr.cs.service.CsService
8
8
import com.psr.psr.global.dto.BaseResponse
9
9
import org.springframework.web.bind.annotation.*
Original file line number Diff line number Diff line change 1
1
package com.psr.psr.cs.dto.assembler
2
2
3
- import com.psr.psr.cs.dto.FaqListRes
4
- import com.psr.psr.cs.dto.FaqRes
5
- import com.psr.psr.cs.dto.NoticeListRes
6
- import com.psr.psr.cs.dto.NoticeRes
3
+ import com.psr.psr.cs.dto.response. FaqListRes
4
+ import com.psr.psr.cs.dto.response. FaqRes
5
+ import com.psr.psr.cs.dto.response. NoticeListRes
6
+ import com.psr.psr.cs.dto.response. NoticeRes
7
7
import com.psr.psr.cs.entity.Faq
8
8
import com.psr.psr.cs.entity.Notice
9
9
import org.springframework.stereotype.Component
Original file line number Diff line number Diff line change 1
- package com.psr.psr.cs.dto
1
+ package com.psr.psr.cs.dto.response
2
2
3
3
data class FaqListRes (
4
4
val faqLists : List <FaqRes >?
Original file line number Diff line number Diff line change 1
- package com.psr.psr.cs.dto
1
+ package com.psr.psr.cs.dto.response
2
2
3
3
import com.fasterxml.jackson.annotation.JsonInclude
4
4
Original file line number Diff line number Diff line change 1
- package com.psr.psr.cs.dto
1
+ package com.psr.psr.cs.dto.response
2
2
3
3
data class NoticeListRes (
4
4
val noticeLists : List <NoticeRes >?
Original file line number Diff line number Diff line change 1
- package com.psr.psr.cs.dto
1
+ package com.psr.psr.cs.dto.response
2
2
3
3
import com.fasterxml.jackson.annotation.JsonFormat
4
4
import com.fasterxml.jackson.annotation.JsonInclude
Original file line number Diff line number Diff line change 1
1
package com.psr.psr.cs.service
2
2
3
- import com.psr.psr.cs.dto.FaqListRes
4
- import com.psr.psr.cs.dto.FaqRes
5
- import com.psr.psr.cs.dto.NoticeListRes
6
- import com.psr.psr.cs.dto.NoticeRes
3
+ import com.psr.psr.cs.dto.response. FaqListRes
4
+ import com.psr.psr.cs.dto.response. FaqRes
5
+ import com.psr.psr.cs.dto.response. NoticeListRes
6
+ import com.psr.psr.cs.dto.response. NoticeRes
7
7
import com.psr.psr.cs.dto.assembler.CsAssembler
8
8
import com.psr.psr.cs.entity.FaqType
9
9
import com.psr.psr.cs.repository.FaqRepository
@@ -21,12 +21,12 @@ class CsService(
21
21
22
22
) {
23
23
// 공지사항 메인
24
- fun getNotices () : NoticeListRes {
24
+ fun getNotices () : NoticeListRes {
25
25
return csAssembler.toNoticeListRes(noticeRepository.findByStatusOrderByCreatedAtDesc(ACTIVE_STATUS ))
26
26
}
27
27
28
28
// 공지사항 상세
29
- fun getNotice (noticeId : Long ) : NoticeRes {
29
+ fun getNotice (noticeId : Long ) : NoticeRes {
30
30
val notice = noticeRepository.findByIdAndStatus(noticeId, ACTIVE_STATUS ) ? : throw BaseException (BaseResponseCode .NOT_FOUND_NOTICE )
31
31
return csAssembler.toNoticeRes(notice)
32
32
}
Original file line number Diff line number Diff line change 1
1
package com.psr.psr.user.dto
2
2
3
+ import com.psr.psr.global.resolver.EnumValid
3
4
import com.psr.psr.user.entity.Category
4
5
5
6
data class UserInterestDto (
7
+ @EnumValid(enumClass = Category ::class , message = " 올바르지 않은 상품 카테고리입니다." )
6
8
val category : String
7
- ){
8
- fun checkInterestCategory () : Category {
9
- return Category .getCategoryByName(category)
10
- }
11
- }
9
+ )
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class UserAssembler {
30
30
fun toEntity (signUpReq : SignUpReq ): User {
31
31
return User (email = signUpReq.email,
32
32
password = signUpReq.password,
33
- type = Type .getTypeByName (signUpReq.type),
33
+ type = Type .getTypeByValue (signUpReq.type),
34
34
phone = signUpReq.phone,
35
35
imgUrl = signUpReq.imgUrl,
36
36
provider = Provider .LOCAL ,
@@ -43,7 +43,7 @@ class UserAssembler {
43
43
fun toInterestListEntity (user : User , signUpReq : SignUpReq ): List <UserInterest > {
44
44
return signUpReq.interestList.stream()
45
45
.map { i ->
46
- UserInterest (category = Category .getCategoryByName (i.category),
46
+ UserInterest (category = Category .getCategoryByValue (i.category),
47
47
user = user)
48
48
}.collect(Collectors .toList())
49
49
}
Original file line number Diff line number Diff line change 1
1
package com.psr.psr.user.dto.request
2
2
3
+ import com.psr.psr.global.resolver.EnumValid
3
4
import com.psr.psr.user.dto.UserInterestDto
5
+ import com.psr.psr.user.entity.Category
6
+ import com.psr.psr.user.entity.Type
4
7
import jakarta.annotation.Nullable
5
8
import jakarta.validation.constraints.Email
6
9
import jakarta.validation.constraints.NotBlank
@@ -20,6 +23,7 @@ data class SignUpReq (
20
23
)
21
24
var password : String ,
22
25
@field:NotBlank
26
+ @EnumValid(enumClass = Type ::class , message = " 올바르지 않은 사용자 역할니다." )
23
27
val type : String ,
24
28
@field:Pattern(
25
29
regexp = "^01([0|1|6|7|8|9])-? ([0-9]{3,4})-? ([0-9]{4})\$",
Original file line number Diff line number Diff line change 1
1
package com.psr.psr.user.entity
2
2
3
- import com.psr.psr.global.exception.BaseException
4
- import com.psr.psr.global.exception.BaseResponseCode
3
+ import com.psr.psr.global.resolver.EnumType
5
4
6
5
7
- enum class Type (val value : String ) {
6
+ enum class Type (override val value : String ) : EnumType {
8
7
GENERAL (" 일반" ),
9
8
ENTREPRENEUR (" 사업자" ),
10
9
SHOW_HOST (" 쇼호스트" ),
11
10
MANAGER (" 관리자" );
12
11
13
12
companion object {
14
- fun getTypeByName (name : String ): Type {
15
- return enumValues<Type >().find { it.value == name }
16
- ? : throw BaseException (BaseResponseCode .INVALID_USER_TYPE_NAME )
13
+ fun getTypeByValue (value : String ): Type {
14
+ return enumValues<Type >().find { it.value == value }!!
17
15
}
18
16
}
19
17
}
Original file line number Diff line number Diff line change @@ -80,7 +80,8 @@ class UserService(
80
80
// 회원가입
81
81
@Transactional
82
82
fun signUp (signUpReq : SignUpReq ): TokenDto {
83
- val categoryCheck = signUpReq.interestList.stream().map { i -> i.checkInterestCategory() }.collect(Collectors .toList()).groupingBy { it }.eachCount().any { it.value > 1 }
83
+ // 중복 값 확인
84
+ val categoryCheck = signUpReq.interestList.groupingBy { it }.eachCount().any { it.value > 1 }
84
85
if (categoryCheck) throw BaseException (INVALID_USER_INTEREST_COUNT )
85
86
// category 의 사이즈 확인
86
87
val listSize = signUpReq.interestList.size
@@ -242,7 +243,7 @@ class UserService(
242
243
// 관심 목록 변경
243
244
@Transactional
244
245
fun patchWatchLists (user : User , userInterestListReq : UserInterestListDto ) {
245
- val reqLists = userInterestListReq.interestList!! .map { i -> Category .getCategoryByName (i.category) }
246
+ val reqLists = userInterestListReq.interestList!! .map { i -> Category .getCategoryByValue (i.category) }
246
247
if (reqLists.isEmpty() || reqLists.size > 3 ) throw BaseException (INVALID_USER_INTEREST_COUNT )
247
248
val userWatchLists = userInterestRepository.findByUserAndStatus(user, ACTIVE_STATUS )
248
249
val categoryLists = userWatchLists.map { c -> c.category }
You can’t perform that action at this time.
0 commit comments