Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
1b4a5b0
[#47] feat: 모집 마감이 가까운 순으로 전체 프로그램 정렬
choiseoji Jan 18, 2025
a26f695
[#46] fix: 배너에서 isPost 필드 제거
sseuldev Jan 18, 2025
63a0dc1
[#47] feat: 수강 내역 내림차순 정렬
choiseoji Jan 18, 2025
7cff5e0
Merge pull request #48 from angel-bridge/refactor/list
sseuldev Jan 18, 2025
0657b93
[#46] fix: 카카오 redirect-uri 변경
sseuldev Jan 18, 2025
a3b0c35
Merge pull request #50 from angel-bridge/refactor/hackathonQA
sseuldev Jan 18, 2025
1a31bc4
feat: cors 추가
sseuldev Jan 18, 2025
397b874
[#46] chore: cookie https 허용
sseuldev Jan 18, 2025
8a4ba6f
Merge pull request #51 from angel-bridge/refactor/hackathonQA
sseuldev Jan 18, 2025
a6b4d9c
feat: 프론트 cors 추가
sseuldev Jan 18, 2025
c86a411
[#53] feat: 임시 결제 정보 저장할 dto 추가
choiseoji Jan 18, 2025
f42e906
[#53] feat: 결제 정보 검증 서비스 추가
choiseoji Jan 18, 2025
dee0e81
[#53] feat: 결제 정보 저장, 검증 컨트롤러 추가
choiseoji Jan 18, 2025
64e40e0
[#53] feat: 유효하지 않은 결제 Exception 추가
choiseoji Jan 18, 2025
952df03
Merge branch 'dev' into feat/payment-all
choiseoji Jan 18, 2025
e0ef6f9
[#53] fix : 리다이렉트 주소 수정
choiseoji Jan 18, 2025
783dce9
Merge pull request #54 from angel-bridge/feat/payment-all
choiseoji Jan 18, 2025
5544bc2
[#55] feat: max_post_size 설정 추가
choiseoji Jan 22, 2025
f8bb9c8
Merge pull request #56 from angel-bridge/bug/413-error
choiseoji Jan 22, 2025
6b43505
[#52] feat: recruitment 상태를 업데이트 하는 메서드 추가
choiseoji Jan 22, 2025
d6ffe4c
[#52] feat: 자정마다 recruitment 상태 체크해서 업데이트
choiseoji Jan 22, 2025
d98fd45
[#52] delete : 쓸데없는 코드 삭제
choiseoji Jan 22, 2025
68d013d
Merge pull request #57 from angel-bridge/fix/scheduled
choiseoji Jan 22, 2025
e99c77a
fix : 확장자 없어도 이미지 업로드 가능하게 수정
choiseoji Jan 22, 2025
64bba73
[#46] feat: checkToken API 추가
sseuldev Jan 22, 2025
e3d467f
Merge branch 'dev' into refactor/hackathonQA
sseuldev Jan 22, 2025
bf93d04
Merge pull request #58 from angel-bridge/refactor/hackathonQA
sseuldev Jan 22, 2025
6404946
[#46] refactor: 토큰 재발급 로직 수정
sseuldev Jan 22, 2025
84fab3d
Merge pull request #59 from angel-bridge/refactor/hackathonQA
sseuldev Jan 22, 2025
e71e75a
fix: 결제 정보 저장, 검증 로직 수정
choiseoji Jan 23, 2025
ce17ca1
fix: Enrollment에 soft delete 추가
choiseoji Jan 25, 2025
0f7c52e
feat: Access-Control-Expose-Headers 추가
choiseoji Jan 25, 2025
646d80b
chore: qa용 도메인 cors 추가1
sseuldev Jan 27, 2025
1f3c2ae
test: qa용 카카오 완료 주소 임시 변경
sseuldev Jan 27, 2025
48f4418
chore: 스웨거 https 설정 추가
sseuldev Jan 27, 2025
47104b7
chore: 스웨거 오류 해결
sseuldev Jan 27, 2025
c956c6a
chore: redirect 주소 원래대로
sseuldev Jan 28, 2025
336358d
[#46] fix: 수강완료 미션수행률 추가
sseuldev Jan 28, 2025
856e9b6
Merge pull request #60 from angel-bridge/refactor/hackathonQA
sseuldev Jan 28, 2025
dfa19d4
[#61] fix: 전체 프로그램 조회에서 교육 마감을 제일 뒤로 뺌
choiseoji Jan 28, 2025
ed46cf1
Merge pull request #62 from angel-bridge/fix/recruitmentEnd
choiseoji Jan 28, 2025
2c652fc
[#46] test: 임시로 이미지 저장 로직 변경
sseuldev Jan 28, 2025
f578ca6
Merge pull request #64 from angel-bridge/refactor/hackathonQA
sseuldev Jan 28, 2025
c5e86d9
fix: 가격 BigDecimal로 수정
choiseoji Jan 29, 2025
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 @@ -48,10 +48,11 @@ public static AssignmentResponseDto fromOngoing(Assignment assignment, int perfo
.build();
}

public static AssignmentResponseDto fromClosed(Education education) {
public static AssignmentResponseDto fromClosed(Education education, int performanceRate) {
return AssignmentResponseDto.builder()
.educationId(education.getId())
.educationTitle(education.getEducationTitle())
.performanceRate(performanceRate)
.noticeLink(education.getNoticeLink())
.methodLink(education.getMethodLink())
.isFinished(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ public AssignmentResponseDto getAssignmentBox(Long educationId, Long memberId) {
Assignment currentAssignment = assignmentRepository.findCurrentAssignmentByEducationId(educationId, LocalDateTime.now())
.orElse(null);

int performanceRate = calculatePerformanceRate(educationId, memberId);

if (currentAssignment == null) {
return AssignmentResponseDto.fromClosed(education);
return AssignmentResponseDto.fromClosed(education, performanceRate);
}

int performanceRate = calculatePerformanceRate(educationId, memberId);

return AssignmentResponseDto.fromOngoing(currentAssignment, performanceRate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ public CommonResponse<AdminBannerResponseDto> updateBanner(@Valid @RequestPart(v
return new CommonResponse<>(bannerService.updateBanner(request, file, bannerId), "해당 배너 이미지 수정에 성공하였습니다.");
}

@Operation(summary = "배너 게시 여부 변경", description = "해당 배너 게시 여부를 변경하는 API")
@PatchMapping("/{bannerId}")
public CommonResponse<AdminBannerResponseDto> changeIsPost(@PathVariable Long bannerId) {

return new CommonResponse<>(bannerService.changeIsPost(bannerId), "해당 배너의 게시 여부를 변경하였습니다.");
}

@Operation(summary = "배너 삭제", description = "하나의 배너를 삭제하는 API")
@DeleteMapping("/{bannerId}")
public CommonResponse<Void> deleteBanner(@PathVariable Long bannerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ public record AdminBannerRequestDto(
String name,

@Schema(description = "배너 게시 순서", example = "1")
Integer priority,

@NotNull
@Schema(description = "배너 게시 유무", example = "true")
Boolean isPost
Integer priority
) {
public Banner toEntity(String file) {

return Banner.builder()
.bannerImage(file)
.name(this.name)
.priority(this.priority)
.isPost(this.isPost)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ public record AdminBannerResponseDto(

String name,

Integer priority,

Boolean isPost
Integer priority
) {
public static AdminBannerResponseDto from(Banner banner) {

Expand All @@ -23,7 +21,6 @@ public static AdminBannerResponseDto from(Banner banner) {
.imageFile(banner.getBannerImage())
.name(banner.getName())
.priority(banner.getPriority())
.isPost(banner.getIsPost())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,16 @@ public class Banner extends BaseEntity {
@Column(name = "priority")
private Integer priority;

@Column(name = "is_post", nullable = false)
private Boolean isPost;

public void changeIsPost() {
this.isPost = !this.isPost;
}

public void update(AdminBannerRequestDto request, String file) {
this.bannerImage = file;
this.name = request.name();
this.priority = request.priority();
this.isPost = request.isPost();
}

@Builder
public Banner(String bannerImage, String name, Integer priority, Boolean isPost) {
public Banner(String bannerImage, String name, Integer priority) {
this.bannerImage = bannerImage;
this.name = name;
this.priority = priority;
this.isPost = isPost;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,6 @@ public AdminBannerResponseDto updateBanner(AdminBannerRequestDto request, Multip
return AdminBannerResponseDto.from(updateBanner);
}

// [PATCH] 어드민 배너 게시 여부 변경
@Transactional
public AdminBannerResponseDto changeIsPost(Long bannerId) {

Banner banner = findBannerById(bannerId);

banner.changeIsPost();
Banner updateBanner = bannerRepository.save(banner);

return AdminBannerResponseDto.from(updateBanner);
}

// [DELETE] 어드민 배너 삭제
@Transactional
public void deleteBanner(Long bannerId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;

import java.math.BigDecimal;
import java.time.LocalDate;

@Builder
Expand All @@ -26,8 +27,8 @@ public record EducationDetailResponseDto(
@Schema(description = "모집 마감일", example = "2025-01-05")
LocalDate recruitmentEndDate,

@Schema(description = "가격", example = "119,000원")
String price,
@Schema(description = "가격", example = "119,000")
BigDecimal price,

@Schema(description = "프리뷰 이미지", example = "프리뷰 이미지 url")
String preFile,
Expand All @@ -39,14 +40,17 @@ public record EducationDetailResponseDto(

public static EducationDetailResponseDto from(Education education, String preImage, String detailImage) {

String priceString = education.getPrice();
BigDecimal price = new BigDecimal(priceString.replaceAll("[^0-9]", ""));

return EducationDetailResponseDto.builder()
.title(education.getEducationTitle())
.description(education.getEducationDescription())
.educationStartDate(education.getEducationStartDate())
.educationEndDate(education.getEducationEndDate())
.recruitmentStartDate(education.getRecruitmentStartDate())
.recruitmentEndDate(education.getRecruitmentEndDate())
.price(education.getPrice())
.price(price)
.preFile(preImage)
.detailFile(detailImage)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public class Education extends BaseEntity {
@Column(name = "recruitment_status")
private RecruitmentStatus recruitmentStatus;

public void setRecruitmentStatus(RecruitmentStatus status) {
this.recruitmentStatus = status;
}

public void update(AdminEducationRequestDto request, String preFile, String detailFile) {
this.educationPreImage = preFile;
this.educationDetailImage = detailFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
import angel_bridge.angel_bridge_server.global.s3.service.ImageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.*;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

Expand All @@ -35,6 +35,26 @@ public class EducationService {
private final ImageService imageService;
private final EducationRepository educationRepository;

// 자정에 recruitment Status 업데이트
@Transactional
@Scheduled(cron = "0 0 0 * * ?")
public void updateRecruitmentStatus() {

LocalDate today = LocalDate.now();

// 모집 예정 상태 업데이트
educationRepository.findAllByRecruitmentStartDateAfter(today)
.forEach(education -> education.setRecruitmentStatus(RecruitmentStatus.UPCOMING));

// 모집 중 상태 업데이트
educationRepository.findAllByRecruitmentStartDateBeforeAndRecruitmentEndDateAfter(today, today)
.forEach(education -> education.setRecruitmentStatus(RecruitmentStatus.ONGOING));

// 모집 종료 상태 업데이트
educationRepository.findAllByRecruitmentEndDateBefore(today)
.forEach(education -> education.setRecruitmentStatus(RecruitmentStatus.CLOSED));
}

// [GET] 일반 사용자 추천 교육 프로그램 조회
public List<EducationResponseDto> getRecommendationProgram() {

Expand Down Expand Up @@ -106,14 +126,14 @@ public AdminEducationResponseDto updateEducation(AdminEducationRequestDto reques
// 기존 이미지 삭제 후 새로운 이미지 저장
if (preImage != null && !preImage.isEmpty()) {
if (preFile != null && !preFile.isEmpty()) {
imageService.deleteImage(preFile);
// imageService.deleteImage(preFile);
}

preFile = imageService.uploadImage(preImage);
}
if (detailImage != null && !detailImage.isEmpty()) {
if (detailFile != null && !detailFile.isEmpty()) {
imageService.deleteImage(detailFile);
// imageService.deleteImage(detailFile);
}

detailFile = imageService.uploadImage(detailImage);
Expand Down Expand Up @@ -154,20 +174,35 @@ public PagedResponseDto<EducationResponseDto> getAllProgram(int page) {

if (page == 0)
throw new ApplicationException(BAD_REQUEST_ERROR);
Pageable pageable = PageRequest.of(page - 1, 12);

// 페이지 조회
Page<Education> educationPage = educationRepository.findAllActive(pageable);
// 모집 마감이 아닌 데이터와 모집 마감 데이터 모두 조회
List<Education> activeEducations = educationRepository.findAllActiveAndNotClosed();
List<Education> closedEducations = educationRepository.findAllClosed();

// Education 객체를 EducationResponseDto로 매핑
List<EducationResponseDto> content = educationPage.getContent().stream()
// 모집 중 데이터와 마감 데이터 병합
List<Education> allEducations = new ArrayList<>();
allEducations.addAll(activeEducations);
allEducations.addAll(closedEducations);

// 전체 데이터를 EducationResponseDto로 매핑
List<EducationResponseDto> allContent = allEducations.stream()
.map(education -> EducationResponseDto.from(
education, imageService.getImageUrl(education.getEducationPreImage())))
.toList();

// 페이지네이션 처리
int pageSize = 12;
int start = (page - 1) * pageSize;
int end = Math.min(start + pageSize, allContent.size());

if (start >= allContent.size())
throw new ApplicationException(BAD_REQUEST_ERROR);

List<EducationResponseDto> pagedContent = allContent.subList(start, end);

// PagedResponseDto로 변환하여 반환
return PagedResponseDto.from(
new PageImpl<>(content, pageable, educationPage.getTotalElements())
new PageImpl<>(pagedContent, PageRequest.of(page - 1, pageSize), allContent.size())
);
}

Expand All @@ -178,7 +213,7 @@ public PagedResponseDto<EducationResponseDto> getAllOngoingProgram(int page) {
throw new ApplicationException(BAD_REQUEST_ERROR);
}

Pageable pageable = PageRequest.of(page - 1, 12);
Pageable pageable = PageRequest.of(page - 1, 12, Sort.by(Sort.Direction.ASC, "recruitmentEndDate"));

// 페이지 조회
Page<Education> educationPage = educationRepository.findByRecruitmentStatusAndDeletedAtIsNull(RecruitmentStatus.ONGOING, pageable);
Expand All @@ -202,7 +237,7 @@ public PagedResponseDto<EducationResponseDto> getAllUpcomingProgram(int page) {
throw new ApplicationException(BAD_REQUEST_ERROR);
}

Pageable pageable = PageRequest.of(page - 1, 12);
Pageable pageable = PageRequest.of(page - 1, 12, Sort.by(Sort.Direction.ASC, "recruitmentEndDate"));

// 페이지 조회
Page<Education> educationPage = educationRepository.findByRecruitmentStatusAndDeletedAtIsNull(RecruitmentStatus.UPCOMING, pageable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.SQLDelete;

@Entity
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@SQLDelete(sql = "UPDATE Enrollment SET deleted_at = NOW() where enrollment_id = ?")
public class Enrollment extends BaseEntity {

@Id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import angel_bridge.angel_bridge_server.global.repository.MemberRepository;
import angel_bridge.angel_bridge_server.global.s3.service.ImageService;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.*;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
Expand Down Expand Up @@ -51,7 +48,7 @@ public PagedResponseDto<EnrollmentResponseDto> getInProgressProgram(int page, Lo
throw new ApplicationException(BAD_REQUEST_ERROR);
}

Pageable pageable = PageRequest.of(page - 1, 4);
Pageable pageable = PageRequest.of(page - 1, 4, Sort.by(Sort.Direction.DESC, "createdAt"));

Page<Enrollment> enrollmentPage = enrollmentRepository.findByMemberAndEnrollmentStatusAndDeletedAtIsNull(member, EnrollmentStatus.IN_PROGRESS, pageable);

Expand All @@ -75,7 +72,7 @@ public PagedResponseDto<EnrollmentResponseDto> getScheduledProgram(int page, Lon
throw new ApplicationException(BAD_REQUEST_ERROR);
}

Pageable pageable = PageRequest.of(page - 1, 4);
Pageable pageable = PageRequest.of(page - 1, 4, Sort.by(Sort.Direction.DESC, "createdAt"));

Page<Enrollment> enrollmentPage = enrollmentRepository.findByMemberAndEnrollmentStatusAndDeletedAtIsNull(member, EnrollmentStatus.SCHEDULED, pageable);

Expand All @@ -99,7 +96,7 @@ public PagedResponseDto<EnrollmentResponseDto> getCompletedProgram(int page, Lon
throw new ApplicationException(BAD_REQUEST_ERROR);
}

Pageable pageable = PageRequest.of(page - 1, 4);
Pageable pageable = PageRequest.of(page - 1, 4, Sort.by(Sort.Direction.DESC, "createdAt"));

Page<Enrollment> enrollmentPage = enrollmentRepository.findByMemberAndEnrollmentStatusAndDeletedAtIsNull(member, EnrollmentStatus.COMPLETED, pageable);

Expand Down
Loading