Skip to content

Commit

Permalink
Merge pull request #143 from kakao-tech-campus-2nd-step3/ApplyAndUser-10
Browse files Browse the repository at this point in the history
[์œ ์ €์ •๋ณด] feat : ํšŒ์‚ฌ ๊ธฐ๋ณธ์ด๋ฏธ์ง€ ์ €์žฅ
  • Loading branch information
minsu-cnu authored Nov 11, 2024
2 parents 82cdcd2 + 09dfa07 commit 893d5d8
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import team18.team18_be.auth.entity.User;
Expand Down Expand Up @@ -33,7 +34,8 @@ public class UserInformationService {
private final AuthRepository authRepository;
private final GcsUploader gcsUploader;
private final FileUtil fileUtil;

@Value("${company.default-logo-url}")
private String defaultLogoUrl;

public UserInformationService(ForeignerInformationRepository foreignerInformationRepository,
CompanyRepository companyRepository, SignRepository signRepository,
Expand All @@ -48,11 +50,18 @@ public UserInformationService(ForeignerInformationRepository foreignerInformatio
}

public Long createCompany(CompanyRequest companyRequest, MultipartFile logoImage, User user) {
byte[] imageFile = fileUtil.safelyGetBytes(logoImage)
.orElseThrow(() -> new IllegalArgumentException("multipart ํŒŒ์ผ์„ ์ฝ์ง€ ๋ชปํ•˜์˜€์Šต๋‹ˆ๋‹ค."));
String storedFileName = gcsUploader.upload(imageFile, "companyLogo",
user.getId().toString() + logoImage.getOriginalFilename())
.orElseThrow(() -> new NoSuchElementException("ํŒŒ์ผ ์—…๋กœ๋“œ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."));
byte[] imageFile = null;
String storedFileName = null;

if (logoImage.isEmpty()) {
storedFileName = defaultLogoUrl;
} else {
imageFile = fileUtil.safelyGetBytes(logoImage)
.orElseThrow(() -> new IllegalArgumentException("multipart ํŒŒ์ผ์„ ์ฝ์ง€ ๋ชปํ•˜์˜€์Šต๋‹ˆ๋‹ค."));
storedFileName = gcsUploader.upload(imageFile, "companyLogo",
user.getId().toString() + "Real" + logoImage.getOriginalFilename())
.orElseThrow(() -> new NoSuchElementException("ํŒŒ์ผ ์—…๋กœ๋“œ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค."));
}
Company company = new Company(companyRequest.name(), companyRequest.industryOccupation(),
companyRequest.brand(), companyRequest.revenuePerYear(), storedFileName, user);
Company savedCompany = companyRepository.save(company);
Expand All @@ -72,7 +81,6 @@ private CompanyResponse createCompanyResponse(Company company) {
return companyResponse;
}


public Long fillInVisa(VisaRequest visaRequest, User user) {
LocalDate visaGenerateDate = LocalDate.parse(visaRequest.visaGenerateDate());
LocalDate visaExpiryDate = visaGenerateDate.plusYears(10);
Expand Down

0 comments on commit 893d5d8

Please sign in to comment.