Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@Getter
public class UploadFileLocation {

private static final String HTTPS_PROTOCOL = "https://";

private final String fileUrl;
private final String fileName;

Expand All @@ -14,13 +16,13 @@ private UploadFileLocation(String fileUrl, String fileName) {
}

public static UploadFileLocation of(String domainName, UploadFile uploadFile) {
return new UploadFileLocation(domainName + UploadFileFullPath.SLASH + uploadFile.getFullPath(),
return new UploadFileLocation(HTTPS_PROTOCOL + domainName + UploadFileFullPath.SLASH + uploadFile.getFullPath(),
uploadFile.getFileName());
}

public static UploadFileLocation of(String domainName, UploadFileFullPath uploadFileFullPath) {
return new UploadFileLocation(domainName + UploadFileFullPath.SLASH + uploadFileFullPath.unixValue(),
return new UploadFileLocation(
HTTPS_PROTOCOL + domainName + UploadFileFullPath.SLASH + uploadFileFullPath.unixValue(),
uploadFileFullPath.getFileFullName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public class UploadFileResponse {
@ApiModelProperty(notes = "업로드된 파일 url",
example = "static.koreatech.in/example.png",
example = "https://static.koreatech.in/example.png",
required = true
)
private final String fileUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public static class Attachment {
private Integer id;

@ApiModelProperty(notes = "업로드된 파일 url"
, example = "static.koreatech.in/example.png"
, example = "https://static.koreatech.in/example.png"
, required = true
)
private final String fileUrl;
Expand Down
40 changes: 25 additions & 15 deletions src/main/java/koreatech/in/service/OwnerServiceImpl.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
package koreatech.in.service;

import static koreatech.in.domain.Mail.MailForm.OWNER_FIND_PASSWORD_MAIL_FORM;
import static koreatech.in.domain.Mail.MailForm.OWNER_REGISTRATION_MAIL_FORM;
import static koreatech.in.domain.RedisOwnerKeyPrefix.ownerAuthPrefix;
import static koreatech.in.domain.RedisOwnerKeyPrefix.ownerChangePasswordAuthPrefix;

import java.sql.SQLException;

import org.apache.velocity.app.VelocityEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import koreatech.in.domain.User.EmailAddress;
import koreatech.in.domain.User.User;
import koreatech.in.domain.User.owner.CertificationCode;
Expand All @@ -26,15 +39,6 @@
import koreatech.in.util.SesMailSender;
import koreatech.in.util.SlackNotiSender;
import koreatech.in.util.StringRedisUtilObj;
import org.apache.velocity.app.VelocityEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import static koreatech.in.domain.Mail.MailForm.*;

import static koreatech.in.domain.RedisOwnerKeyPrefix.*;

@Service
public class OwnerServiceImpl implements OwnerService {
Expand Down Expand Up @@ -90,19 +94,22 @@ public void inputPasswordToChangePassword(OwnerChangePasswordRequest ownerChange

public void certificateToChangePassword(VerifyCodeRequest verifyCodeRequest) {
OwnerInCertification ownerInCertification = OwnerConverter.INSTANCE.toOwnerInCertification(verifyCodeRequest);
redisOwnerMapper.changeAuthStatus(ownerInCertification, ownerInCertification.getEmail(), ownerChangePasswordAuthPrefix);
redisOwnerMapper.changeAuthStatus(ownerInCertification, ownerInCertification.getEmail(),
ownerChangePasswordAuthPrefix);
}

public void requestVerificationToChangePassword(VerifyEmailRequest verifyEmailRequest) {
EmailAddress emailAddress = OwnerConverter.INSTANCE.toEmailAddress(verifyEmailRequest);
validateEmailFromOwner(emailAddress);

CertificationCode certificationCode = mailService.sendMailWithTimes(emailAddress, OWNER_FIND_PASSWORD_MAIL_FORM);
CertificationCode certificationCode = mailService.sendMailWithTimes(emailAddress,
OWNER_FIND_PASSWORD_MAIL_FORM);

OwnerInVerification ownerInVerification = OwnerInVerification.of(certificationCode, emailAddress);

emailAddress.validateSendable();
redisOwnerMapper.putRedisFor(ownerChangePasswordAuthPrefix.getKey(emailAddress.getEmailAddress()), ownerInVerification);
redisOwnerMapper.putRedisFor(ownerChangePasswordAuthPrefix.getKey(emailAddress.getEmailAddress()),
ownerInVerification);

slackNotiSender.noticeEmailVerification(ownerInVerification);
}
Expand All @@ -112,7 +119,7 @@ private Owner validateEmailFromOwner(EmailAddress emailAddress) {
if (user == null || user.isStudent()) {
throw new BaseException(ExceptionInformation.NOT_EXIST_EMAIL);
}
return (Owner) user;
return (Owner)user;
}

@Override
Expand Down Expand Up @@ -224,7 +231,7 @@ private static OwnerAttachments ownerAttachmentsFillWithOwnerId(Owner owner) {
}

private OwnerAttachments updateAttachment(OwnerAttachments ownerAttachments,
OwnerAttachments ownerAttachmentsInDB) {
OwnerAttachments ownerAttachmentsInDB) {
OwnerAttachments result = ownerAttachmentsInDB.intersectionWith(ownerAttachments);

OwnerAttachments toAdd = ownerAttachments.removeDuplicatesFrom(ownerAttachmentsInDB);
Expand Down Expand Up @@ -281,7 +288,8 @@ private void validateOwnerIdUniqueness(int id) {

private void putRedisForRequestShop(OwnerShop ownerShop) {
try {
stringRedisUtilObj.setDataAsString(StringRedisUtilObj.makeOwnerShopKeyFor(ownerShop.getOwner_id()), ownerShop);
stringRedisUtilObj.setDataAsString(StringRedisUtilObj.makeOwnerShopKeyFor(ownerShop.getOwner_id()),
ownerShop);
} catch (Exception exception) {
throw new RuntimeException(exception);
}
Expand All @@ -302,6 +310,8 @@ private void createInDBFor(Owner owner) {
if (owner.hasRegistrationInformation()) {
ownerMapper.insertOwnerAttachments(ownerAttachmentsFillWithOwnerId(owner));
}
} catch (DuplicateKeyException e) {
throw new BaseException(ExceptionInformation.EMAIL_DUPLICATED);
} catch (SQLException e) {
throw new RuntimeException(e);
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/koreatech/in/service/S3UploadServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
@Service
public class S3UploadServiceImpl implements UploadService {

private static final String HTTPS_PROTOCOL = "https://";

private final S3Util s3Util;
private final String bucketName;
private final String domainUrlPrefix;
Expand Down Expand Up @@ -95,7 +93,7 @@ public PreSignedUrlResponse generatePreSignedUrl(DomainEnum domain, PreSignedUrl
PreSignedUrlResult preSignedUrlResult = s3Util.generatePreSignedUrlForPut(bucketName, uploadFileMetaData,
uploadFileFullPath.unixValue(), new Date());

UploadFileLocation uploadFileLocation = UploadFileLocation.of(HTTPS_PROTOCOL + domainUrlPrefix,
UploadFileLocation uploadFileLocation = UploadFileLocation.of(domainUrlPrefix,
uploadFileFullPath);
return UploadFileConverter.INSTANCE.toPreSignedUrlResponse(preSignedUrlResult, uploadFileLocation);
}
Expand Down