Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
GiHwan2 committed Nov 27, 2024
2 parents 8e4e2f2 + 868f1c0 commit 42da214
Show file tree
Hide file tree
Showing 34 changed files with 707 additions and 74 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ dependencies {
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

//Web Socket
implementation 'org.springframework.boot:spring-boot-starter-websocket'

//jwt
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ services:
OCR_API_SECRET: ${OCR_API_SECRET}
OCR_API_URL: ${OCR_API_URL}
OCR_TEMPLATE_IDS: ${OCR_TEMPLATE_IDS}
MEDICAL_CERTIFICATE_OCR_API_SECRET_KEY: ${MEDICAL_CERTIFICATE_OCR_API_SECRET_KEY}
MEDICAL_CERTIFICATE_OCR_API_URL: ${MEDICAL_CERTIFICATE_OCR_API_URL}
KAKAOPAY_SECRET_KEY: ${KAKAOPAY_SECRET_KEY}
CID: ${CID}

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
OCR_TEMPLATE_IDS: ${OCR_TEMPLATE_IDS}
KAKAOPAY_SECRET_KEY: ${KAKAOPAY_SECRET_KEY}
CID: ${CID}
MEDICAL_CERTIFICATE_OCR_API_SECRET_KEY: ${MEDICAL_CERTIFICATE_OCR_API_SECRET_KEY}
MEDICAL_CERTIFICATE_OCR_API_URL: ${MEDICAL_CERTIFICATE_OCR_API_URL}

SPRING_PROFILES_ACTIVE: prod
depends_on:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
).permitAll()

// 인증 없이 허용할 추가 경로
.requestMatchers("/api/v1/auth/**","/api/v1/apply/payments/**").permitAll() //카카오페이 401에러 때문에,,,일단은,,
.requestMatchers("/api/v1/auth/**","/api/v1/apply/payments/**","/ws/**").permitAll()

// 나머지 요청은 인증 필요
.anyRequest().authenticated()
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/com/ivory/ivory/config/WebSocketConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.ivory.ivory.config;


import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
// 클라이언트가 구독할 엔드포인트
registry.enableSimpleBroker("/topic");
// 클라이언트가 메시지를 보낼 엔드포인트
registry.setApplicationDestinationPrefixes("/app");
}

@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
// WebSocket 연결 엔드포인트
registry.addEndpoint("/ws")
.setAllowedOriginPatterns(
"*"
);
registry.addEndpoint("/ws")
.setAllowedOriginPatterns(
"https://ivorygroup.click",
"https://danpoong-ivory.vercel.app",
"http://localhost:3000"
)
.withSockJS(); // SockJS 지원
}

}
47 changes: 47 additions & 0 deletions src/main/java/com/ivory/ivory/controller/CaregiverController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.ivory.ivory.controller;

import com.ivory.ivory.service.CaregiverService;
import com.ivory.ivory.util.SecurityUtil;
import com.ivory.ivory.util.response.CustomApiResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/caregivers")
@RequiredArgsConstructor
public class CaregiverController {

private final CaregiverService caregiverService;
private final SecurityUtil securityUtil;

@GetMapping("/list")
public ResponseEntity<?> getCareList () {
Long currentMemberId = securityUtil.getCurrentMemberId();
CustomApiResponse<?> response =caregiverService.getCareList(currentMemberId);
return ResponseEntity.ok(response);
}

@GetMapping("/{applyId}")
public ResponseEntity<?> getCareDetail(@PathVariable Long applyId) {
Long currentMemberId = securityUtil.getCurrentMemberId();
CustomApiResponse<?> response = caregiverService.getCareDetail(currentMemberId,applyId);
return ResponseEntity.ok(response);
}

@PostMapping("/{applyId}")
public ResponseEntity<?> AcceptCare (@PathVariable Long applyId) {
Long currentMemberId = securityUtil.getCurrentMemberId();
CustomApiResponse<?> response = caregiverService.AcceptCare(currentMemberId,applyId);
return ResponseEntity.ok(response);
}

@GetMapping()
public ResponseEntity<?> getMatchedCare() {
Long currentMemberId = securityUtil.getCurrentMemberId();
CustomApiResponse<?> response = caregiverService.getMatchedCare(currentMemberId);
return ResponseEntity.ok(response);
}


}
14 changes: 13 additions & 1 deletion src/main/java/com/ivory/ivory/domain/Apply.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
@Builder
@Table(name="apply")
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Apply extends BaseEntity {
Expand Down Expand Up @@ -39,6 +40,9 @@ public class Apply extends BaseEntity {
@Column(name="status", nullable = false)
private Status status;

@Column(name="memo")
private String memo;

@ManyToOne
@JoinColumn(name="member_id")
private Member member;
Expand All @@ -55,16 +59,22 @@ public class Apply extends BaseEntity {
@JoinColumn(name="absence_certificate_id")
private AbsenceCertificate absenceCertificate;

@ManyToOne
@JoinColumn(name="caregiver_id")
private Caregiver caregiver;

public static Apply toEntity(
ApplyDto service,
Long totalAmount,
Long subsidy,
IncomeType incomeType,
Status status,
String memo,
Member member,
Child child,
MedicalCertificate medicalCertificate,
AbsenceCertificate absenceCertificate
AbsenceCertificate absenceCertificate,
Caregiver caregiver
) {
return Apply.builder()
.startDate(service.getStartDate())
Expand All @@ -73,10 +83,12 @@ public static Apply toEntity(
.subsidy(subsidy)
.incomeType(incomeType)
.status(status)
.memo(memo)
.member(member)
.child(child)
.medicalCertificate(medicalCertificate)
.absenceCertificate(absenceCertificate)
.caregiver(caregiver)
.build();
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/ivory/ivory/domain/Authority.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.ivory.ivory.domain;

public enum Authority {
ROLE_USER, ROLE_ADMIN
ROLE_USER, ROLE_CAREGIVER, ROLE_ADMIN
}
40 changes: 40 additions & 0 deletions src/main/java/com/ivory/ivory/domain/Caregiver.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.ivory.ivory.domain;

import jakarta.persistence.*;
import lombok.*;

@Entity
@Table(name="caregiver")
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Caregiver {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "caregiver_seq")
@SequenceGenerator(
name = "caregiver_seq", // 시퀀스 제너레이터 이름
sequenceName = "caregiver_sequence", // 실제 데이터베이스 시퀀스 이름
initialValue = 100, // 시작 값
allocationSize = 1 // 증가 값
)
@Column(name="id")
private Long id;

@Column(name="email")
private String email;

@Column(name="password")
private String password;

@Enumerated(EnumType.STRING)
private Authority authority;

public static Caregiver toEntity(String email, String password) {
return Caregiver.builder()
.email(email)
.password(password)
.authority(Authority.ROLE_CAREGIVER)
.build();
}
}
10 changes: 1 addition & 9 deletions src/main/java/com/ivory/ivory/domain/MedicalCertificate.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,16 @@ public class MedicalCertificate extends BaseEntity {
@Column(name = "disease", nullable = true)
private Disease disease;

@Column(name = "diagnosis_content", nullable = true)
private String diagnosisContent;

@Column(name = "doctor_name", nullable = true)
private String doctorName;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="child_id", nullable = false)
private Child child;

@Builder
public MedicalCertificate(String name, String address, LocalDate diagnosisDate, Disease disease, String diagnosisContent, String doctorName, Child child) {
public MedicalCertificate(String name, String address, LocalDate diagnosisDate, Disease disease, Child child) {
this.name = name;
this.address = address;
this.diagnosisDate = diagnosisDate;
this.disease = disease;
this.diagnosisContent = diagnosisContent;
this.doctorName = doctorName;
this.child = child;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/ivory/ivory/domain/Status.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.ivory.ivory.domain;

public enum Status {
YET, IN_PROGRESS, COMPLETE
YET, MATCHED, IN_PROGRESS, COMPLETE
}
3 changes: 3 additions & 0 deletions src/main/java/com/ivory/ivory/dto/ApplyDetailDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class ApplyDetailDto {
private String incomeType;
private String careDate;
private String careTime;
private String memo;
private String totalAmount;
private String subsidy;
private String copay;
Expand All @@ -34,6 +35,7 @@ public static ApplyDetailDto from(
String incomeType,
String careDate,
String careTime,
String memo,
String totalAmount,
String subsidy,
String copay,
Expand All @@ -49,6 +51,7 @@ public static ApplyDetailDto from(
.incomeType(incomeType)
.careDate(careDate)
.careTime(careTime)
.memo(memo)
.totalAmount(totalAmount)
.subsidy(subsidy)
.copay(copay)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/ivory/ivory/dto/ApplyDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
Expand All @@ -28,4 +29,6 @@ public class ApplyDto {

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime endDate;

private String memo;
}
46 changes: 46 additions & 0 deletions src/main/java/com/ivory/ivory/dto/CareDetailDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.ivory.ivory.dto;

import lombok.*;

import java.time.LocalDate;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CareDetailDto {
private String applyDate;
private String careDate;
private String careTime;
private String memo;
private String childName;
private String birthDate;
private Long age;
private String diagnosisName;
private String image;

public static CareDetailDto from (
String applyDate,
String careDate,
String careTime,
String memo,
String childName,
String birthDate,
Long age,
String diagnosisName,
String image) {
return CareDetailDto.builder()
.applyDate(applyDate)
.careDate(careDate)
.careTime(careTime)
.memo(memo)
.childName(childName)
.birthDate(birthDate)
.age(age)
.diagnosisName(diagnosisName)
.image(image)
.build();
}
}

28 changes: 28 additions & 0 deletions src/main/java/com/ivory/ivory/dto/CareDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.ivory.ivory.dto;

import lombok.*;

@Getter
@Setter
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CareDto {
private Long id;
private String careDate;
private String careTime;
private String childName;
private Long age;
private String image;

public static CareDto of(Long id, String careDate, String careTime, String childName, Long age, String image) {
return CareDto.builder()
.id(id)
.careDate(careDate)
.careTime(careTime)
.childName(childName)
.age(age)
.image(image)
.build();
}
}
Loading

0 comments on commit 42da214

Please sign in to comment.