Skip to content

Commit

Permalink
[FEAT & REFACTOR] ErrorCode and SuccessCode move to constant package …
Browse files Browse the repository at this point in the history
…and add deep link dto and enum
  • Loading branch information
nogamsung committed Feb 13, 2024
1 parent e89d80e commit e42da1d
Show file tree
Hide file tree
Showing 56 changed files with 386 additions and 238 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import javax.validation.constraints.Positive;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;

@Api(tags = "개발")
@Validated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import javax.validation.constraints.Positive;
import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "찜")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import javax.validation.constraints.Positive;
import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.NOTIFICATIONS_FOUND;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.NOTIFICATION_READ;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.NOTIFICATIONS_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.NOTIFICATION_READ;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "알림")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javax.validation.constraints.Positive;
import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "제안")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "프로필")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import java.time.LocalDateTime;
import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "리뷰")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import java.time.LocalDateTime;
import java.util.List;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "팀")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import javax.validation.Valid;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.EMAIL_VERIFIED;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.VERIFICATION_CODE_SENT;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.EMAIL_VERIFIED;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.VERIFICATION_CODE_SENT;

@Api(tags = "연락처")
@RestController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import javax.validation.constraints.Size;
import java.time.LocalDateTime;

import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.HttpHeaders.AUTHORIZATION;

@Api(tags = "회원")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.gabojait.gabojaitspring.api.dto.notification.response;

import com.gabojait.gabojaitspring.common.constant.deepLink.DeepLink;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.ToString;

@Getter
@ToString
@ApiModel(value = "딥링크 응답")
public class DeepLinkResponse {

@ApiModelProperty(position = 1, required = true, value = "URL")
private String url;

@ApiModelProperty(position = 2, required = true, value = "설명")
private String description;

public DeepLinkResponse(DeepLink deepLink) {
this.url = deepLink.getUrl();
this.description = deepLink.getDescription();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class NotificationPageResponse {
@ApiModelProperty(position = 5, required = true, value = "읽음 여부")
private Boolean isRead;

@ApiModelProperty(position = 6, required = true, value = "딥링크")
private DeepLinkResponse deepLink;

@ApiModelProperty(position = 6, required = true, value = "생성일")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createdAt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.List;
import java.util.Random;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.TESTER_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TESTER_NOT_FOUND;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.TEAM_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.code.ErrorCode.USER_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TEAM_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.USER_NOT_FOUND;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import java.util.*;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import java.util.stream.Collectors;
import java.util.stream.IntStream;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.TEAM_MEMBER_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TEAM_MEMBER_NOT_FOUND;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.USER_NOT_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.USER_NOT_FOUND;

@Service
@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import java.time.LocalDateTime;
import java.util.Optional;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Service
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gabojait.gabojaitspring.common.code;
package com.gabojait.gabojaitspring.common.constant.code;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.gabojait.gabojaitspring.common.code;
package com.gabojait.gabojaitspring.common.constant.code;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.gabojait.gabojaitspring.common.constant.deepLink;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum DeepLink {

HOME_PAGE("gabojait://home", "홈페이지"),
TEAM_PAGE("gabojait://team", "팀 페이지"),
REVIEW_PAGE("gabojait://my/team-history/review", "리뷰 작성 페이지"),
USER_OFFER_RECEIVE_PAGE("gabojait://my/offer/user/received", "회원 제안 페이지"),
TEAM_OFFER_RECEIVE_PAGE("gabojait://my/offer/team/received", "팀 제안 페이지")
;

private final String url;
private final String description;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.gabojait.gabojaitspring.common.exception;

import com.gabojait.gabojaitspring.common.code.ErrorCode;
import com.gabojait.gabojaitspring.common.constant.code.ErrorCode;
import lombok.Getter;

@Getter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.validation.ConstraintViolationException;
import java.util.Objects;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;
import static org.springframework.http.HttpStatus.INTERNAL_SERVER_ERROR;
import static org.springframework.http.HttpStatus.PAYLOAD_TOO_LARGE;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gabojait.gabojaitspring.common.response;


import com.gabojait.gabojaitspring.common.code.ErrorCode;
import com.gabojait.gabojaitspring.common.constant.code.ErrorCode;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.EMAIL_SEND_ERROR;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.EMAIL_SEND_ERROR;

@Component
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Objects;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Component
@RequiredArgsConstructor
Expand Down Expand Up @@ -43,20 +44,20 @@ public String upload(String bucketName,

File file = convertMultipartToFile(multipartFile);
String folderFileName = folderName + "/" + fileName;
String url;
URL url;

try {
amazonS3Client.putObject(new PutObjectRequest(bucketName, folderFileName, file)
.withCannedAcl(CannedAccessControlList.PublicRead));

url = amazonS3Client.getUrl(bucketName, folderFileName).toString();
url = amazonS3Client.getUrl(bucketName, folderFileName);
} catch (AmazonServiceException e) {
throw new CustomException(SERVER_ERROR, e.getCause());
}

file.delete();

return url;
return url.toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.SERVER_ERROR;

@Configuration
public class FcmConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import java.io.IOException;
import java.io.OutputStream;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.code.ErrorCode.TOKEN_UNAUTHENTICATED;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TOKEN_UNAUTHENTICATED;

@Component
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.List;
import java.util.stream.Collectors;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.TOKEN_UNAUTHENTICATED;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TOKEN_UNAUTHENTICATED;

@Component
@RequiredArgsConstructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import java.time.LocalDateTime;
import java.util.Objects;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;

@Getter
@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import java.time.LocalDateTime;
import java.util.Objects;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.TEAM_LEADER_UNAVAILABLE;
import static com.gabojait.gabojaitspring.common.code.ErrorCode.UNREGISTER_UNAVAILABLE;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TEAM_LEADER_UNAVAILABLE;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.UNREGISTER_UNAVAILABLE;

@Getter
@Entity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.code.ErrorCode.TESTER_ID_POSITIVE_ONLY;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.SERVER_ERROR;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.TESTER_ID_POSITIVE_ONLY;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.*;
import static org.springframework.http.MediaType.APPLICATION_JSON;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.ResultActions;

import static com.gabojait.gabojaitspring.common.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.NOTIFICATIONS_FOUND;
import static com.gabojait.gabojaitspring.common.code.SuccessCode.NOTIFICATION_READ;
import static com.gabojait.gabojaitspring.common.constant.code.ErrorCode.*;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.NOTIFICATIONS_FOUND;
import static com.gabojait.gabojaitspring.common.constant.code.SuccessCode.NOTIFICATION_READ;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
Expand Down
Loading

0 comments on commit e42da1d

Please sign in to comment.