Skip to content

Commit

Permalink
Merge pull request #41 from SSUDevelog/fix/#40
Browse files Browse the repository at this point in the history
[#40] 요청/응답 형식 수정
  • Loading branch information
k0000k authored Jan 7, 2024
2 parents c9b55ef + 16ca4a8 commit 383c927
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 5 deletions.
37 changes: 37 additions & 0 deletions src/main/java/com/easyvel/server/global/dto/BaseResponse.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.easyvel.server.global.dto;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

@Getter
@AllArgsConstructor
@ToString
public class BaseResponse<T> {

private final boolean success;
private final int code;
private final String message;
private final T result;


public static <T> BaseResponse<T> success() {
return new BaseResponse<>(true, 200, null, null);
}

public static <T> BaseResponse<T> success(String message) {
return new BaseResponse<>(true, 200, message, null);
}

public static <T> BaseResponse<T> success(String message, T result) {
return new BaseResponse<>(true, 200, message, result);
}

public static <T> BaseResponse<T> fail(int httpStatus, String message) {
return new BaseResponse<>(false, httpStatus, message, null);
}

public static <T> BaseResponse<T> fail(int httpStatus, String message, T result) {
return new BaseResponse<>(false, httpStatus, message, result);
}
}
9 changes: 5 additions & 4 deletions src/main/java/com/easyvel/server/sign/SignController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.easyvel.server.annotation.EasyvelTokenApiImplicitParams;
import com.easyvel.server.config.security.SecurityConfiguration;
import com.easyvel.server.exception.SignException;
import com.easyvel.server.global.dto.BaseResponse;
import com.easyvel.server.jwt.JwtTokenProvider;
import com.easyvel.server.sign.apple.AppleAuthService;
import com.easyvel.server.sign.apple.dto.GetTokensDto;
Expand Down Expand Up @@ -42,7 +43,7 @@ public String refreshToken(@RequestHeader(SecurityConfiguration.TOKEN_HEADER) St
* @throws Exception
*/
@PostMapping("/apple-login")
public String appleLogin(@Validated @RequestBody GetTokensDto getTokensDto) throws Exception {
public BaseResponse<String> appleLogin(@Validated @RequestBody GetTokensDto getTokensDto) throws Exception {
LOGGER.info("[apple-login] 애플 로그인을 수행합니다.");
appleAuthService.checkIdentityToken(getTokensDto.getIdentity_token());
LOGGER.info("[apple-login] identityToken 검정 완료");
Expand All @@ -65,7 +66,7 @@ public String appleLogin(@Validated @RequestBody GetTokensDto getTokensDto) thro
}

@GetMapping(value = "/google-login")
public String googleLogin(@RequestParam("code") String code) throws Exception {
public BaseResponse<String> googleLogin(@RequestParam("code") String code) throws Exception {
GetGoogleTokenResponse getGoogleTokenResponse = googleAuthService.getTokensResponse(code);
String uid = signService.getGoogleID(getGoogleTokenResponse.getTokenResponse().getId_token());
String password = "password";
Expand Down Expand Up @@ -99,7 +100,7 @@ public void signUp(
* @throws SignException
*/
@PostMapping("/sign-in")
public String signIn(
public BaseResponse<String> signIn(
@Validated @RequestBody SignInDto signInDto) throws SignException {
LOGGER.info("[signIn] 로그인을 시도하고 있습니다. id : {}, pw : ****", signInDto.getId());
String token = signService.signIn(signInDto);
Expand All @@ -108,7 +109,7 @@ public String signIn(
JoinGroupDto joinGroupDto = new JoinGroupDto(signInDto.getId(), "AllGroup");
notificationService.joinGroup(joinGroupDto);//로그아웃할때는 제거하는 기능 추가하기
*/
return token;
return BaseResponse.success("ok", token);
}

@EasyvelTokenApiImplicitParams
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/easyvel/server/tag/TagController.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TagList getUserTagList(@RequestHeader(SecurityConfiguration.TOKEN_HEADER)
@ApiOperation("유저 태그 추가")
@EasyvelTokenApiImplicitParams
@PostMapping("add")
public void addUserTag(@RequestBody String tag,
public void addUserTag(@RequestParam String tag,
@RequestHeader(SecurityConfiguration.TOKEN_HEADER) String token) {
String uid = jwtTokenProvider.getUid(token);
tagService.addTag(uid, tag);
Expand Down

0 comments on commit 383c927

Please sign in to comment.