Skip to content

Commit

Permalink
Merge pull request #116 from Sinchone/develop
Browse files Browse the repository at this point in the history
Version 1.0.4
  • Loading branch information
Jeongho0805 authored Jul 2, 2023
2 parents 672b1dc + 0f187ec commit 4c49687
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ public ResponseEntity<CommonResponse> getRecruitmentListInMain() {
return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_LIST_FOR_MAIN, recruitmentList));
}

@PreAuthorize("isAuthenticated()")
@GetMapping("/{recruitmentId}/application")
public ResponseEntity<CommonResponse> checkApplyStatusForMember(@PathVariable Long recruitmentId,
@AuthenticationPrincipal UserDetailsImpl userDetails) {
RecruitmentApplyStatusForMember applyStatus = recruitmentService.isAlreadyApplyRecruitment(recruitmentId, userDetails.getId());
return ResponseEntity.ok().body(CommonResponse.success(SuccessCode.RECRUITMENT_APPLY_STATUS_FOR_MEMBER, applyStatus));
}

@PreAuthorize("isAuthenticated()")
@PostMapping
public ResponseEntity<CommonResponse> createRecruitment(@AuthenticationPrincipal UserDetailsImpl userDetails,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public TokenResponse createToken(Oauth2LoginRequestDto loginRequestDto, String r
String token = getToken(loginRequestDto);
KakaoOauth2UserInfo profile = getProfile(token);
Optional<Member> member = memberRepository.findByEmail(profile.getEmail());
if(member.isEmpty()) {
boolean isFirstSignUp = false;
if (member.isEmpty()) {
Member newMember = Member.builder()
.email(profile.getEmail())
.build();
Expand All @@ -49,8 +50,12 @@ public TokenResponse createToken(Oauth2LoginRequestDto loginRequestDto, String r
Member saveMember = memberRepository.save(newMember);
String nickname = "#" + saveMember.getId();
saveMember.initNickname(nickname);
isFirstSignUp = true;
}
TokenResponse tokens = jwtProvider.createToken(profile.getEmail(), requestURI);
if (isFirstSignUp) {
tokens.setFirstSignUp();
}
redisTemplate.opsForValue()
.set("refresh_token:" + profile.getEmail(), tokens.getRefreshToken(), jwtProvider.getRefreshTokenDuration(), TimeUnit.MILLISECONDS);
return tokens;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package com.lastone.apiserver.service.recruitment;

import com.lastone.core.dto.recruitment.RecruitmentRequestDto;
import com.lastone.core.dto.recruitment.RecruitmentDetailDto;
import com.lastone.core.dto.recruitment.RecruitmentListDto;
import com.lastone.core.dto.recruitment.RecruitmentSearchCondition;
import com.lastone.core.dto.recruitment.*;
import org.springframework.data.domain.Slice;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
Expand All @@ -22,4 +19,6 @@ public interface RecruitmentService {
void updateRecruitment(Long recruitmentId, Long memberId, RecruitmentRequestDto recruitment, List<MultipartFile> imgFiles) throws IOException;

void deleteRecruitment(Long recruitmentId, Long id);

RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
import com.lastone.core.domain.recruitment.Recruitment;
import com.lastone.core.domain.recruitment_img.RecruitmentImg;
import com.lastone.core.dto.gym.GymDto;
import com.lastone.core.dto.recruitment.RecruitmentDetailDto;
import com.lastone.core.dto.recruitment.RecruitmentListDto;
import com.lastone.core.dto.recruitment.RecruitmentRequestDto;
import com.lastone.core.dto.recruitment.RecruitmentSearchCondition;
import com.lastone.core.dto.recruitment.*;
import com.lastone.core.util.mapper.GymMapper;
import com.lastone.core.repository.gym.GymRepository;
import com.lastone.core.repository.member.MemberRepository;
Expand Down Expand Up @@ -113,6 +110,14 @@ public void deleteRecruitment(Long recruitmentId, Long memberId) {
recruitment.delete();
}

@Override
public RecruitmentApplyStatusForMember isAlreadyApplyRecruitment(Long recruitmentId, Long memberId) {
Recruitment recruitment = recruitmentRepository.findById(recruitmentId).orElseThrow(RecruitmentNotFoundException::new);
boolean result = recruitment.getApplications().stream()
.anyMatch(application -> application.getApplicant().getId().equals(memberId));
return new RecruitmentApplyStatusForMember(result);
}

private void updateImgFiles(Recruitment recruitment, List<MultipartFile> imgFiles) throws IOException {
if (imgFileIsExist(imgFiles)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum SuccessCode {
RECRUITMENT_CREATE("모집글 작성이 완료되었습니다."),
RECRUITMENT_UPDATE("모집글 수정이 완료되었습니다."),
RECRUITMENT_DELETE("모집글 삭제가 완료되었습니다."),
RECRUITMENT_APPLY_STATUS_FOR_MEMBER("모집글 신청 여부 조회가 완료되었습니다."),

/* 신청 */
APPLICATION_CREATE("신청 처리가 완료되었습니다."),
Expand All @@ -42,7 +43,7 @@ public enum SuccessCode {
NOTIFICATION_LIST("알림 목록 조회가 완료되었습니다."),
NOTIFICATION_READ("알림 읽기 처리가 완료되었습니다."),
NOTIFICATION_DELETE("알림 삭제 처리가 완료되었습니다."),
;
;

private String message;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

public enum PreferGender {

BOTH("무관"),
BOTH("성별무관"),

MALE("남성"),
MALE("남성만"),

FEMALE("여성");
FEMALE("여성만");

private final String text;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.lastone.core.domain.application.Application;
import com.lastone.core.domain.application.ApplicationStatus;
import com.querydsl.core.annotations.QueryProjection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
import java.time.LocalDateTime;

@Getter
@Builder
@ToString
@AllArgsConstructor
public class ApplicationDto {

private final Long applicationId;
Expand All @@ -26,17 +30,18 @@ public class ApplicationDto {
private ApplicationStatus status;

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd 'T' HH:mm")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm")
private LocalDateTime applicationDate;

@QueryProjection
public ApplicationDto(Long applicationId, Long applicantId, String nickname, String profileUrl, String gender, ApplicationStatus status, LocalDateTime applicationDate) {
this.applicationId = applicationId;
this.applicantId = applicantId;
this.nickname = nickname;
this.profileUrl = profileUrl;
this.gender = gender;
this.status = status;
this.applicationDate = applicationDate;
public static ApplicationDto toDto(Application application) {
return ApplicationDto.builder()
.applicantId(application.getId())
.applicantId(application.getApplicant().getId())
.nickname(application.getApplicant().getNickname())
.profileUrl(application.getApplicant().getProfileUrl())
.gender(application.getApplicant().getGender())
.status(application.getStatus())
.applicationDate(application.getCreatedAt())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,40 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.querydsl.core.annotations.QueryProjection;
import com.lastone.core.domain.recruitment.Recruitment;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

@Getter
@Builder
@ToString
@AllArgsConstructor
public class ApplicationReceivedDto {

private final Long id;

private final String title;

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd 'T' HH:mm")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm")
private final LocalDateTime startedAt;

private final String gym;

private List<ApplicationDto> applications;

@QueryProjection
public ApplicationReceivedDto(Long id,String title, LocalDateTime startedAt, String gym) {
this.id = id;
this.title = title;
this.startedAt = startedAt;
this.gym = gym;
}

public void includeApplicants(List<ApplicationDto> applications) {
this.applications = applications;
public static ApplicationReceivedDto toDto(Recruitment recruitment) {
return ApplicationReceivedDto.builder()
.id(recruitment.getId())
.title(recruitment.getTitle())
.startedAt(recruitment.getStartedAt())
.gym(recruitment.getGym().getName())
.applications(recruitment.getApplications().stream().map(ApplicationDto::toDto).collect(Collectors.toList()))
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.lastone.core.domain.application.Application;
import com.lastone.core.domain.application.ApplicationStatus;
import com.querydsl.core.annotations.QueryProjection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;

import java.time.LocalDateTime;

@Getter
@ToString
@Builder
@AllArgsConstructor
public class ApplicationRequestedDto {

private final Long applicationId;
Expand All @@ -23,7 +26,7 @@ public class ApplicationRequestedDto {
private final String gym;

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd 'T' HH:mm")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm")
private final LocalDateTime startedAt;

private final Long memberId;
Expand All @@ -37,24 +40,22 @@ public class ApplicationRequestedDto {
private final ApplicationStatus status;

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd 'T' HH:mm")
private LocalDateTime applicationDate;

@QueryProjection
public ApplicationRequestedDto(Long applicationId, Long recruitmentId, String title, String gym,
LocalDateTime startedAt, Long memberId, String profileUrl,
String nickName, String gender, ApplicationStatus status,
LocalDateTime applicationDate) {
this.applicationId = applicationId;
this.recruitmentId = recruitmentId;
this.title = title;
this.gym = gym;
this.startedAt = startedAt;
this.memberId = memberId;
this.profileUrl = profileUrl;
this.nickname = nickName;
this.gender = gender;
this.status = status;
this.applicationDate = applicationDate;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm")
private final LocalDateTime applicationDate;

public static ApplicationRequestedDto toDto(Application application) {
return ApplicationRequestedDto.builder()
.applicationId(application.getId())
.status(application.getStatus())
.applicationDate(application.getCreatedAt())
.recruitmentId(application.getRecruitment().getId())
.title(application.getRecruitment().getTitle())
.gym(application.getRecruitment().getGym().getName())
.startedAt(application.getRecruitment().getStartedAt())
.memberId(application.getApplicant().getId())
.profileUrl(application.getApplicant().getProfileUrl())
.nickname(application.getApplicant().getNickname())
.gender(application.getApplicant().getGender())
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TodayPartnerDto {
private WorkoutPart workoutPart;

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd 'T' HH:mm")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm")
private LocalDateTime startedAt;

private String gym;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.lastone.core.dto.recruitment;

import lombok.Getter;

@Getter
public class RecruitmentApplyStatusForMember {

Boolean isApply;

public RecruitmentApplyStatusForMember(boolean isApply) {
this.isApply = isApply;
}
}
Loading

0 comments on commit 4c49687

Please sign in to comment.