-
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 branch 'dev' of https://github.com/Kernel360/KDEV3_DevLens_BE i…
…nto feature/member-security-#20
- Loading branch information
Showing
11 changed files
with
122 additions
and
59 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
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
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
47 changes: 47 additions & 0 deletions
47
src/main/java/com/seveneleven/devlens/global/util/file/Service/CompanyFileService.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,47 @@ | ||
package com.seveneleven.devlens.global.util.file.Service; | ||
|
||
import com.seveneleven.devlens.domain.admin.db.CompanyRepository; | ||
import com.seveneleven.devlens.domain.member.entity.Company; | ||
import com.seveneleven.devlens.global.exception.BusinessException; | ||
import com.seveneleven.devlens.global.response.APIResponse; | ||
import com.seveneleven.devlens.global.response.ErrorCode; | ||
import com.seveneleven.devlens.global.util.file.dto.FileMetadataDto; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class CompanyFileService { | ||
private final FileService fileService; | ||
private final CompanyRepository companyRepository; | ||
|
||
/** | ||
* 1. 회사 로고 이미지 등록 | ||
* @auth admin, super(해당 회사 대표회원) | ||
* @param file 업로드할 로고 이미지 파일 | ||
* @param companyId 해당 회사 id | ||
* @param uploaderId 업로드 수행자 id | ||
* @return APIResponse S3에 저장된 파일의 메타데이터 response | ||
*/ | ||
|
||
@Transactional | ||
public APIResponse uploadLogoImage(MultipartFile file, Long companyId, Long uploaderId) throws Exception{ | ||
//1. 회사 id로 존재여부 판별 | ||
Company companyEntity = companyRepository.findById(companyId) | ||
.orElseThrow(() -> new BusinessException(ErrorCode.COMPANY_IS_NOT_FOUND)); | ||
|
||
//TODO) 2. 수행자 권한 판별 validation - admin판별, super의 회사 판별 | ||
|
||
//3. S3파일 업로드, 메타데이터 테이블 저장 | ||
APIResponse uploadResponse = fileService.uploadFile(file, "COMPANY_LOGO_IMAGE", companyId); | ||
|
||
//4. 회사 대표 이미지 유무 칸을 Y로 변경한다. | ||
companyEntity.addRepresentativeImage(); | ||
companyRepository.save(companyEntity); | ||
|
||
//5. 반환 | ||
return uploadResponse; | ||
} | ||
} |
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
Oops, something went wrong.