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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ build/
!**/src/main/**/build/
!**/src/test/**/build/
src/main/resources/application-local.yml
src/main/resources/logback-spring.xml
*.env
.env

docker-compose.yml
uploads
### STS ###
.apt_generated
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ dependencies {
//swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.13'

implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'io.micrometer:micrometer-registry-prometheus'
}

node {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cooperation.project.cooperationcenter.domain.member.dto.AgencyRegion;
import com.cooperation.project.cooperationcenter.global.exception.BaseResponse;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
Expand All @@ -17,6 +18,8 @@
@RequestMapping("/api/v1/agency")
@Slf4j
public class AgencyRestController {

@Operation(summary = "유학원 지역 리스트 반환")
@GetMapping("/region")
public BaseResponse<?> getRegionList(){
List<String> regions = Arrays.stream(AgencyRegion.values())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cooperation.project.cooperationcenter.domain.agency.dto.AgencyRequest;
import com.cooperation.project.cooperationcenter.domain.agency.service.homepage.AgencyService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Pageable;
Expand All @@ -24,6 +25,7 @@ public class AgengyController {
private final String agencyPath = "homepage/user/agency";

@RequestMapping("/list")
@Operation(summary = "해당 지역과 키워드 값을 가진 유학원 반환")
public String agencyList(
Model model,
@PageableDefault(size = 12, sort = "createdAt", direction = Sort.Direction.DESC)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.cooperation.project.cooperationcenter.domain.agency.exception;

import com.cooperation.project.cooperationcenter.global.exception.BaseException;
import com.cooperation.project.cooperationcenter.global.exception.codes.BaseCode;

public class AgencyHandler extends BaseException {
public AgencyHandler(BaseCode code){super(code);}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.cooperation.project.cooperationcenter.domain.agency.exception.status;

import com.cooperation.project.cooperationcenter.global.exception.codes.BaseCode;
import com.cooperation.project.cooperationcenter.global.exception.codes.reason.Reason;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum AgencyErrorStatus implements BaseCode {

AGENCY_NOT_FOUND(HttpStatus.BAD_REQUEST,"AGENCY-0001","해당 유학원은 가입 되지 않은 상태입니다. 확인 후에 다시 가입해주세요");

private final HttpStatus httpStatus;
private final String code;
private final String message;

@Override
public Reason.ReasonDto getReasonHttpStatus() {
return Reason.ReasonDto.builder()
.message(message)
.code(code)
.isSuccess(false)
.httpStatus(httpStatus)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public void removeMember(Member member){
this.member.remove(member);
}

public void setShare(){
this.share = !this.share;
}
public void setShare(boolean share){
this.share = share;
}

public static Agency fromDto(
MemberRequest.SignupNewAgencyDto dto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
import java.util.Optional;

public interface AgencyRepository extends JpaRepository<Agency,Long> {
long countByAgencyPicture(FileAttachment file);
Optional<Agency> findAgencyByAgencyNameAndAgencyEmailAndShare(String name, String email,Boolean share);
List<Agency> findAgenciesByShare(boolean share);
Page<Agency> findAgenciesByShare(boolean share, Pageable pageable);

}
long countByAgencyPicture(FileAttachment file);
Optional<Agency> findAgencyByAgencyNameAndAgencyEmailAndShare(String name, String email,Boolean share);
Optional<Agency> findAgencyByAgencyNameAndAgencyEmail(String name, String email);
List<Agency> findAgenciesByShare(boolean share);
Page<Agency> findAgenciesByShare(boolean share, Pageable pageable);

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.cooperation.project.cooperationcenter.domain.file.service.FileService;
import com.cooperation.project.cooperationcenter.domain.oss.OssService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
Expand All @@ -27,41 +28,48 @@ public class FileRestController {
private final FileService fileService;
private final OssService ossService;


//note 다운로드용
@GetMapping("/{type}/{fileId}")
@Operation(summary = "파일 다운로드")
public ResponseEntity<Void> downloadFile(@PathVariable String type,@PathVariable String fileId) throws MalformedURLException {
log.info("enter file controller");
return fileService.loadFile(fileId,type);
}

//note 이미지 뷰용
@GetMapping("/img/{type}/{fileId}")
@Operation(summary = "이미지 뷰")
public ResponseEntity<Void> viewImage(@PathVariable String type,@PathVariable String fileId) throws IOException {
log.info("enter file controller-img");
return fileService.viewFile(fileId,type);
}

//note 이미지 뷰용
@GetMapping("/pdf/{type}/{fileId}")
@Operation(summary = "pdf새 탭으로 열기")
public ResponseEntity<StreamingResponseBody> viewPdf(@PathVariable String type, @PathVariable String fileId) throws IOException {
log.info("enter file controller-img");
return fileService.viewPdf(fileId,type);
}

@Operation(
summary = "학교 이미지 저장",
description = """
학교에 사용되는 이미지를 저장하고 URL을 반환.
"""
)
@PostMapping("/{type}")
public ResponseEntity<Void> saveFile(@PathVariable String type,@RequestParam("file-0") MultipartFile file) throws IOException {
log.info("save file");
return fileService.saveSchoolImgAndReturnUrl(type, file);
}

@GetMapping("/default/agency")
@Operation(summary = "유학원 대체 이미지")
public ResponseEntity<Void> getAgencyDefaultImage(){
log.info("enter agency");
return fileService.viewDefaultImg("agency");
}

@GetMapping("/default/school")
@Operation(summary = "학교 대체 이미지")
public ResponseEntity<Void> getSchoolDefaultImage(){
return fileService.viewDefaultImg("school");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.cooperation.project.cooperationcenter.domain.file.exception;

import com.cooperation.project.cooperationcenter.global.exception.BaseException;
import com.cooperation.project.cooperationcenter.global.exception.codes.BaseCode;

public class FileHandler extends BaseException {
public FileHandler(BaseCode code){super(code);}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.cooperation.project.cooperationcenter.domain.file.exception.status;

import com.cooperation.project.cooperationcenter.global.exception.codes.BaseCode;
import com.cooperation.project.cooperationcenter.global.exception.codes.reason.Reason;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.http.HttpStatus;

@Getter
@AllArgsConstructor
public enum FileErrorStatus implements BaseCode {

// ===== 요청/검증 =====
FILE_EMPTY(HttpStatus.BAD_REQUEST, "FILE-4001", "업로드할 파일이 존재하지 않습니다."),
FILE_TYPE_INVALID(HttpStatus.BAD_REQUEST, "FILE-4002", "지원하지 않는 파일 타입입니다."),
FILE_TARGET_INVALID(HttpStatus.BAD_REQUEST, "FILE-4003", "파일 대상 타입이 올바르지 않습니다."),
FILE_SIZE_ERROR(HttpStatus.BAD_REQUEST, "FILE-4004", "파일 사이즈가 너무 큽니다."),

// ===== 조회 =====
FILE_NOT_FOUND(HttpStatus.NOT_FOUND, "FILE-4041", "파일을 찾을 수 없습니다."),
FILE_META_NOT_FOUND(HttpStatus.NOT_FOUND, "FILE-4042", "파일 메타데이터가 존재하지 않습니다."),

// ===== 저장 =====
FILE_SAVE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "FILE-5001", "파일 저장에 실패했습니다."),
FILE_UPLOAD_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "FILE-5002", "스토리지 업로드에 실패했습니다."),

// ===== 스토리지 =====
FILE_STORAGE_NOT_FOUND(HttpStatus.INTERNAL_SERVER_ERROR, "FILE-5003", "스토리지에 파일이 존재하지 않습니다."),
FILE_DELETE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "FILE-5004", "파일 삭제에 실패했습니다."),

// ===== URL =====
FILE_URL_GENERATE_ERROR(HttpStatus.INTERNAL_SERVER_ERROR, "FILE-5005", "파일 URL 생성에 실패했습니다.");

private final HttpStatus httpStatus;
private final String code;
private final String message;

@Override
public Reason.ReasonDto getReasonHttpStatus() {
return Reason.ReasonDto.builder()
.message(message)
.code(code)
.isSuccess(false)
.httpStatus(httpStatus)
.build();
}
}
Loading