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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.mAInd.springboot.config.auth.dto;

import com.mAInd.springboot.domain.user.Role;
import com.mAInd.springboot.domain.user.UserStatus;
import com.mAInd.springboot.domain.user.Users;
import lombok.Builder;
import lombok.Getter;
Expand Down Expand Up @@ -52,6 +53,7 @@ public Users toEntity() {
.email(email)
.picture(picture)
.role(Role.CLIENT)
.userStatus(UserStatus.BEFORE_SURVEY)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.mAInd.springboot.domain.mypage;

public class MyPageController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.mAInd.springboot.domain.mypage;

import com.mAInd.springboot.domain.user.Users;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface MyPageRepository extends JpaRepository<Users, Long> {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.mAInd.springboot.domain.mypage;

import com.mAInd.springboot.domain.user.Users;
import lombok.Getter;

import java.time.LocalDateTime;
import java.util.Date;

@Getter
public class MyPageResponseDto {

private String name;
private String email;
private LocalDateTime createdDate;

public MyPageResponseDto(Users entity){
this.name = entity.getName();
this.email = entity.getEmail();
this.createdDate = entity.getCreatedDate();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.mAInd.springboot.domain.mypage;

import com.mAInd.springboot.domain.user.UserRepository;
import com.mAInd.springboot.domain.user.Users;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@RequiredArgsConstructor
@Service
public class MyPageService {

private final UserRepository userRepository;


}

17 changes: 17 additions & 0 deletions src/main/java/com/mAInd/springboot/domain/surveys/ApplyStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.mAInd.springboot.domain.surveys;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum ApplyStatus {
BEFORE("BEFORE", "상담사 확인 전"),
ACCEPT("ACCEPT", "상담 승인"),
HOLD("HOLD", "상담 보류"),
REJECT("REJECT", "상담 반려");

private final String key;
private final String title;
}
41 changes: 26 additions & 15 deletions src/main/java/com/mAInd/springboot/domain/surveys/Surveys.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@

import com.mAInd.springboot.domain.BaseTimeEntity;
import com.mAInd.springboot.domain.surveys.Gender;
import com.mAInd.springboot.domain.user.Users;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import net.minidev.json.annotate.JsonIgnore;
import org.apache.tomcat.jni.Local;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import static javax.persistence.FetchType.LAZY;

@Getter
@NoArgsConstructor
@Entity
Expand Down Expand Up @@ -51,22 +57,32 @@ public class Surveys extends BaseTimeEntity {
private String q_6;
private String q_7;
private String q_8;
private String q_9;
private String q_10;
private String q_11;

@Column(nullable = true)
private Long client_id;
// @Column(nullable = true)
// private Long client_id;

@ManyToOne(fetch = LAZY)
@JoinColumn(name = "client_id", nullable = true)
@JsonIgnore
private Users client_id;

@Column(nullable = true)
private Long counselor_id;

@Enumerated(EnumType.STRING)
@Column
private ApplyStatus applyStatus;

@Column
private LocalDateTime statusDate;


@Builder
public Surveys(String name, Gender gender, String email, Date birth,
String phone, String education, List<String> symptoms,
String q_1, String q_2, String q_3, String q_4, String q_5, String q_6,
String q_7, String q_8, String q_9, String q_10, String q_11, Long client_id, Long counselor_id) {
String q_1, String q_2, String q_3, String q_4, String q_5, String q_6,
String q_7, String q_8, Users client_id, Long counselor_id,
ApplyStatus applyStatus, LocalDateTime statusDate) {
this.name = name;
this.gender = gender;
this.email = email;
Expand All @@ -82,17 +98,15 @@ public Surveys(String name, Gender gender, String email, Date birth,
this.q_6 = q_6;
this.q_7 = q_7;
this.q_8 = q_8;
this.q_9 = q_9;
this.q_10 = q_10;
this.q_11 = q_11;
this.client_id = client_id;
this.counselor_id = counselor_id;
this.applyStatus = applyStatus;
this.statusDate = statusDate;
}

public void update(String name, Gender gender, String email, Date birth,
String phone, String education, List<String> symptoms, String q_1, String q_2,
String q_3, String q_4, String q_5, String q_6, String q_7,
String q_8, String q_9, String q_10, String q_11){
String q_3, String q_4, String q_5, String q_6, String q_7, String q_8){
this.name = name;
this.gender = gender;
this.email = email;
Expand All @@ -108,9 +122,6 @@ public void update(String name, Gender gender, String email, Date birth,
this.q_6 = q_6;
this.q_7 = q_7;
this.q_8 = q_8;
this.q_9 = q_9;
this.q_10 = q_10;
this.q_11 = q_11;
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.mAInd.springboot.domain.surveys;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.List;

public interface SurveysRepository extends JpaRepository<Surveys, Long> {
@Query("SELECT s FROM Surveys s ORDER BY s.id DESC")
List<Surveys> findAllDesc();


}
15 changes: 15 additions & 0 deletions src/main/java/com/mAInd/springboot/domain/user/UserStatus.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mAInd.springboot.domain.user;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum UserStatus {
BEFORE_SURVEY("BEFORE_SURVEY", "설문지 작성 전"),
ON_MATCHING("ON_MATCHING", "매칭 중"),
AFTER_MATCHING("AFTER_MATCHING", "매칭 완료");

private final String key;
private final String title;
}
7 changes: 6 additions & 1 deletion src/main/java/com/mAInd/springboot/domain/user/Users.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ public class Users extends BaseTimeEntity {
@Column(nullable = false)
private Role role;

@Enumerated(EnumType.STRING)
@Column
private UserStatus userStatus;

// private String refreshToken;

// @OneToOne(fetch = FetchType.LAZY)
// @JoinColumn(name="profile_id", referencedColumnName = "profile_id")
// private Profiles profile_id;

@Builder
public Users(String name, String email, String picture, Role role){
public Users(String name, String email, String picture, Role role, UserStatus userStatus){
this.name = name;
this.email = email;
this.picture = picture;
this.role = role;
this.userStatus = userStatus;
}

public Users update(String name, String picture){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public Long update(Long survey_id, SurveysUpdateRequestDto requestDto){
requestDto.getBirth(), requestDto.getPhone(), requestDto.getEducation(), requestDto.getSymptoms(),
requestDto.getQ_1(), requestDto.getQ_2(), requestDto.getQ_3(),
requestDto.getQ_4(), requestDto.getQ_5(), requestDto.getQ_6(),
requestDto.getQ_7(), requestDto.getQ_8(), requestDto.getQ_9(),
requestDto.getQ_10(), requestDto.getQ_11());
requestDto.getQ_7(), requestDto.getQ_8());

return survey_id;
}
Expand All @@ -51,6 +50,15 @@ public SurveysResponseDto findById(Long survey_id){
return new SurveysResponseDto(entity);
}


@Transactional
public SurveysStatusResponseDto findById2(Long survey_id){
Surveys entity = surveysRepository.findById(survey_id)
.orElseThrow(()-> new
IllegalArgumentException("해당 설문지가 없습니다. survey_id=" + survey_id));
return new SurveysStatusResponseDto(entity);
}

@Transactional(readOnly = true)
public List<SurveysListResponseDto> findAllDesc(){
return surveysRepository.findAllDesc().stream()
Expand Down
10 changes: 6 additions & 4 deletions src/main/java/com/mAInd/springboot/web/SurveysApiController.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.mAInd.springboot.web;

import com.mAInd.springboot.service.surveys.SurveysService;
import com.mAInd.springboot.web.dto.SurveysListResponseDto;
import com.mAInd.springboot.web.dto.SurveysResponseDto;
import com.mAInd.springboot.web.dto.SurveysSaveRequestDto;
import com.mAInd.springboot.web.dto.SurveysUpdateRequestDto;
import com.mAInd.springboot.web.dto.*;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

Expand Down Expand Up @@ -41,4 +38,9 @@ public SurveysResponseDto findById(@PathVariable Long survey_id){
public List<SurveysListResponseDto> findAll(){
return surveysService.findAllDesc();
}

@GetMapping("/mypage/surveys/{survey_id}/status")
public SurveysStatusResponseDto findById2(@PathVariable Long survey_id){
return surveysService.findById2(survey_id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mAInd.springboot.domain.surveys.Gender;
import com.mAInd.springboot.domain.surveys.Surveys;
import com.mAInd.springboot.domain.user.Users;

import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -24,11 +25,8 @@ public class SurveysListResponseDto {
private String q_6;
private String q_7;
private String q_8;
private String q_9;
private String q_10;
private String q_11;
private Long client_id;
private Long counselor_id;
// private Users client_id;
// private Long counselor_id;

private List<String> symptoms;
private LocalDateTime modifiedDate;
Expand All @@ -50,11 +48,8 @@ public SurveysListResponseDto(Surveys entity){
this.q_6 = entity.getQ_6();
this.q_7 = entity.getQ_7();
this.q_8 = entity.getQ_8();
this.q_9 = entity.getQ_9();
this.q_10 = entity.getQ_10();
this.q_11 = entity.getQ_11();
this.client_id = entity.getClient_id();
this.counselor_id = entity.getCounselor_id();
// this.client_id = entity.getClient_id();
// this.counselor_id = entity.getCounselor_id();
this.modifiedDate = entity.getModifiedDate();
}
}
19 changes: 9 additions & 10 deletions src/main/java/com/mAInd/springboot/web/dto/SurveysResponseDto.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.mAInd.springboot.web.dto;

import com.mAInd.springboot.domain.surveys.ApplyStatus;
import com.mAInd.springboot.domain.surveys.Gender;
import com.mAInd.springboot.domain.surveys.Surveys;
import com.mAInd.springboot.domain.user.Users;
import lombok.Getter;

import java.util.Date;
Expand All @@ -25,11 +27,10 @@ public class SurveysResponseDto {
private String q_6;
private String q_7;
private String q_8;
private String q_9;
private String q_10;
private String q_11;
private Long client_id;
private Long counselor_id;
// private Users client_id;
// private Long counselor_id;

private ApplyStatus applyStatus;


public SurveysResponseDto(Surveys entity){
Expand All @@ -49,10 +50,8 @@ public SurveysResponseDto(Surveys entity){
this.q_6 = entity.getQ_6();
this.q_7 = entity.getQ_7();
this.q_8 = entity.getQ_8();
this.q_9 = entity.getQ_9();
this.q_10 = entity.getQ_10();
this.q_11 = entity.getQ_11();
this.client_id = entity.getClient_id();
this.counselor_id = entity.getCounselor_id();
// this.client_id = entity.getClient_id();
// this.counselor_id = entity.getCounselor_id();
this.applyStatus = entity.getApplyStatus();
}
}
Loading