-
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.
Merge pull request #73 from Stumeet/dev
✨ [STMT-90] 내 정보 수정 API 구현 (#72)
- Loading branch information
Showing
30 changed files
with
597 additions
and
52 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
18 changes: 18 additions & 0 deletions
18
src/main/java/com/stumeet/server/common/annotation/validator/NullOrImageFile.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,18 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Constraint(validatedBy = NullOrImageFileValidator.class) | ||
@Target({ElementType.FIELD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NullOrImageFile { | ||
String message() default "값이 전달되지 않거나 이미지 파일이어야 합니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/stumeet/server/common/annotation/validator/NullOrImageFileValidator.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,17 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import com.stumeet.server.common.util.FileUtil; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
public class NullOrImageFileValidator implements ConstraintValidator<NullOrImageFile, MultipartFile> { | ||
@Override | ||
public boolean isValid(MultipartFile value, ConstraintValidatorContext context) { | ||
if (value == null) { | ||
return true; | ||
} | ||
|
||
return FileUtil.isImageFile(value.getOriginalFilename()); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/stumeet/server/common/annotation/validator/NullOrNotBlank.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,18 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Constraint(validatedBy = NullOrNotBlankValidator.class) | ||
@Target({ElementType.FIELD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NullOrNotBlank { | ||
String message() default "값이 전달되지 않거나 빈 문자열이 아니어야 합니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/stumeet/server/common/annotation/validator/NullOrNotBlankValidator.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,16 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import io.micrometer.common.util.StringUtils; | ||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
public class NullOrNotBlankValidator implements ConstraintValidator<NullOrNotBlank, String> { | ||
@Override | ||
public boolean isValid(String value, ConstraintValidatorContext context) { | ||
if (value == null) { | ||
return true; | ||
} | ||
|
||
return StringUtils.isNotBlank(value); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/stumeet/server/common/annotation/validator/NullOrPositive.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,18 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Constraint(validatedBy = NullOrPositiveValidator.class) | ||
@Target({ElementType.FIELD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NullOrPositive { | ||
String message() default "값이 전달되지 않거나 양수여야 합니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/com/stumeet/server/common/annotation/validator/NullOrPositiveValidator.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,15 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
public class NullOrPositiveValidator implements ConstraintValidator<NullOrPositive, Long> { | ||
@Override | ||
public boolean isValid(Long value, ConstraintValidatorContext context) { | ||
if (value == null) { | ||
return true; | ||
} | ||
|
||
return value > 0; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/stumeet/server/common/annotation/validator/NullOrValidSize.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,22 @@ | ||
package com.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.Constraint; | ||
import jakarta.validation.Payload; | ||
|
||
import java.lang.annotation.*; | ||
|
||
|
||
@Documented | ||
@Constraint(validatedBy = NullOrValidSizeValidator.class) | ||
@Target({ElementType.FIELD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface NullOrValidSize { | ||
String message() default "값이 전달되지 않거나 유효한 크기여야 합니다."; | ||
|
||
Class<?>[] groups() default {}; | ||
|
||
Class<? extends Payload>[] payload() default {}; | ||
|
||
int min() default 0; | ||
int max() default 255; | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/stumeet/server/common/annotation/validator/NullOrValidSizeValidator.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.stumeet.server.common.annotation.validator; | ||
|
||
import jakarta.validation.ConstraintValidator; | ||
import jakarta.validation.ConstraintValidatorContext; | ||
|
||
public class NullOrValidSizeValidator implements ConstraintValidator<NullOrValidSize, String> { | ||
private int min; | ||
private int max; | ||
|
||
@Override | ||
public void initialize(NullOrValidSize constraintAnnotation) { | ||
min = constraintAnnotation.min(); | ||
max = constraintAnnotation.max(); | ||
} | ||
|
||
@Override | ||
public boolean isValid(String value, ConstraintValidatorContext context) { | ||
if (value == null) { | ||
return true; | ||
} | ||
return value.length() >= min && value.length() <= max; | ||
} | ||
} |
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
34 changes: 34 additions & 0 deletions
34
src/main/java/com/stumeet/server/member/adapter/in/web/MemberProfileApi.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,34 @@ | ||
package com.stumeet.server.member.adapter.in.web; | ||
|
||
import com.stumeet.server.common.annotation.WebAdapter; | ||
import com.stumeet.server.common.auth.model.LoginMember; | ||
import com.stumeet.server.common.model.ApiResponse; | ||
import com.stumeet.server.member.application.port.in.MemberProfileUseCase; | ||
import com.stumeet.server.member.application.port.in.command.MemberUpdateCommand; | ||
import jakarta.validation.Valid; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.security.core.annotation.AuthenticationPrincipal; | ||
import org.springframework.web.bind.annotation.PatchMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
@WebAdapter | ||
@RequestMapping("/api/v1/members") | ||
@RequiredArgsConstructor | ||
public class MemberProfileApi { | ||
|
||
private final MemberProfileUseCase memberProfileUseCase; | ||
|
||
@PatchMapping("/me") | ||
public ResponseEntity<ApiResponse<Void>> updateMyProfile( | ||
@AuthenticationPrincipal LoginMember member, | ||
@Valid MemberUpdateCommand request | ||
) { | ||
memberProfileUseCase.updateProfile(member.getMember(), request); | ||
return new ResponseEntity<>( | ||
ApiResponse.success(HttpStatus.OK.value(), "내 프로필 수정에 성공했습니다."), | ||
HttpStatus.OK | ||
); | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/stumeet/server/member/application/port/in/MemberProfileUseCase.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,11 @@ | ||
package com.stumeet.server.member.application.port.in; | ||
|
||
import com.stumeet.server.member.application.port.in.command.MemberSignupCommand; | ||
import com.stumeet.server.member.application.port.in.command.MemberUpdateCommand; | ||
import com.stumeet.server.member.domain.Member; | ||
|
||
public interface MemberProfileUseCase { | ||
void signup(Member member, MemberSignupCommand request); | ||
|
||
void updateProfile(Member member, MemberUpdateCommand request); | ||
} |
6 changes: 3 additions & 3 deletions
6
...pplication/port/in/MemberAuthUseCase.java → ...plication/port/in/MemberTokenUseCase.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,11 +1,11 @@ | ||
package com.stumeet.server.member.application.port.in; | ||
|
||
import com.stumeet.server.member.adapter.in.web.response.TokenResponse; | ||
import com.stumeet.server.member.domain.Member; | ||
import com.stumeet.server.member.application.port.in.command.TokenRenewCommand; | ||
|
||
public interface MemberTokenUseCase { | ||
|
||
public interface MemberAuthUseCase { | ||
|
||
void signup(Member member, MemberSignupCommand request); | ||
|
||
TokenResponse renewAccessToken(TokenRenewCommand request); | ||
} |
14 changes: 14 additions & 0 deletions
14
...main/java/com/stumeet/server/member/application/port/in/command/MemberProfileCommand.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,14 @@ | ||
package com.stumeet.server.member.application.port.in.command; | ||
|
||
import com.stumeet.server.profession.domain.Profession; | ||
import lombok.Builder; | ||
|
||
|
||
@Builder | ||
public record MemberProfileCommand( | ||
Profession profession, | ||
String url, | ||
String nickname, | ||
String region | ||
) { | ||
} |
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
Oops, something went wrong.