Skip to content

Commit

Permalink
Update server code
Browse files Browse the repository at this point in the history
  • Loading branch information
raae7742 committed Jun 4, 2023
1 parent 4d5a7ca commit 2f15d29
Show file tree
Hide file tree
Showing 112 changed files with 2,370 additions and 3,084 deletions.
2 changes: 1 addition & 1 deletion CPR2U-Server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ out/
/.nb-gradle/

### VS Code ###
.vscode/
.vscode/
2 changes: 1 addition & 1 deletion CPR2U-Server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM adoptopenjdk:11-jre-hotspot
ARG JAR_FILE=./build/libs/app.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
ENTRYPOINT ["java","-jar","-Duser.timezone=Asia/Seoul", "/app.jar"]
100 changes: 99 additions & 1 deletion CPR2U-Server/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,99 @@
# cpr2u-server
# 2023 Solution Challenge: CPR2U
<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/thumbnail.png" border="0" width="1000px" />

`CPR2U` is an education solution to solve Korean's low CPR performance and survival rates for out-of-hostpital cradiac arrest patients. Users can receive CPR education through online and receive their CPR postures feedback through machine learning. In case of cardiac arrest, users can call for nearby certified users who have completed our training course to request emergency CPR.

<br>

<br>

## 📱 How to run our app service
- Click [here](https://drive.google.com/drive/folders/1_wUgyb4SwmRlgZxCLX3tP-cZ9-uzlA8I?usp=share_link) to download an apk file.
- Install the apk file on your android smartphone.
- Enter `1111` in the verification code field to log in our service. (We temporarily removed the verification code sending API due to cost issue..)

<br>

<br>

## 🖌 Introduction
In Korea where the aging is fast, the number of patients with sudden cardiac arrest is expected to increase. In those cases, the survival rate could increase 2.4 times higher if CPR is performed by a bystander. However, the actual rate of CPR performed in Korea is only 24.7%. According to a study done by the Korea Centers for Disease Control and Prevention, 94% of people were aware of CPR, but only about 25% of them had actually learned it. Furthermore, among those people, over 53.6% of them have not received any training in the past two years.

Firstly, we will make it easier for general public to receive CPR education. Since the rate of CPR graduated is declined nearly 80% after the pandemic, we believe the opportunity to learn cpr through online should be expanded to people, rather than through offline. Next, We want to make people take turns as much as they can during CPR in the emergency. CPR is a physically demanding processing that requires 120 compressions per minute. According to the guidelines, it is safe to replace the person compressing every two minutes. Therefore, we want to find people who can do CPR nearby and send them to emergencies.

<br>

<br>

## ✔ UN SDGs Goals & Target
- 3. Good Health and Well-being (Target 3.4.)
- 4. Quality Education (Target 4.7.)

<br>

<br>

## 🔧 Google Technology Used
- Android / Kotlin
- Firebase
- Tensorflow Lite
- Google Cloud Platform(Google Container Registry, Google Cloud SQL, Google Kubernetes Engine)
- Google Maps Platform

<br>

<br>

## 🛠 Project Architecture
<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/architecture.png" border="0" width="1000px" />

<br>

<br>

## 🗂 ERD
<img src="https://github.com/CPR2U/CPR2U-Server/blob/develop/images/cpr2u_erd.png" border="0" width="1000px" />

## 📸 Screenshots

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot1.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot2.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot3.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot4.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot5.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot6.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot7.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot8.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot9.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot10.png" border="0" width="1000px" />

<br>

<img src="https://github.com/dsc-sookmyung/2023-mention-all-SolutionChallenge/blob/main/images/screenshot11.png" border="0" width="1000px" />
71 changes: 69 additions & 2 deletions CPR2U-Server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '2.7.9'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
id 'jacoco'
}

group = 'com.mentionall'
Expand Down Expand Up @@ -43,15 +44,16 @@ dependencies {
implementation 'com.google.firebase:firebase-admin:6.8.1'
implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '4.2.2'

compileOnly 'org.projectlombok:lombok'
implementation 'com.twilio.sdk:twilio:8.8.0'

runtimeOnly 'com.h2database:h2'
compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'

annotationProcessor 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'

testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2:1.4.200'
}

sourceSets {
Expand All @@ -60,6 +62,18 @@ sourceSets {
srcDirs = ["$projectDir/src/main/java", "$projectDir/build/generated"]
}
}
test{
java {
srcDirs = ["$projectDir/src/test", "$projectDir/build/generated"]
}
resources {
includes = ["$projectDir/src/test/resources/config/application.yml"]
}
}
}

test {
classpath += sourceSets.test.output
}

bootJar {
Expand All @@ -68,4 +82,57 @@ bootJar {

tasks.named('test') {
useJUnitPlatform()
finalizedBy 'jacocoTestReport'
finalizedBy 'jacocoTestCoverageVerification'
}

jacoco {
toolVersion = '0.8.7'
}

jacocoTestReport {
reports {
xml.enabled true
csv.enabled true
html.enabled true

xml.destination file("${buildDir}/jacoco/index.xml")
csv.destination file("${buildDir}/jacoco/index.csv")
html.destination file("${buildDir}/jacoco/index.html")
}

afterEvaluate {
classDirectories.setFrom(
files(classDirectories.files.collect {
fileTree(dir: it, excludes: [
'**/*Application*',
'**/*Exception*',
'**/dto/**',
'**/controller/**'
])
})
)
}
}

jacocoTestCoverageVerification {
var Qdomains = new ArrayList<String>()

for (char qPattern = 'A'; qPattern <= 'Z'; qPattern++) {
Qdomains.add("*.Q${qPattern}*")
}

violationRules {
rule {
element = 'CLASS'

limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.00
}

excludes = Qdomains
}
}
}
Binary file added CPR2U-Server/images/cpr2u_erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.util.TimeZone;

@EnableJpaAuditing
@SpringBootApplication
@EnableScheduling
public class Cpr2uApplication {

public static void main(String[] args) {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
SpringApplication.run(Cpr2uApplication.class, args);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.mentionall.cpr2u.call.controller;

import com.mentionall.cpr2u.call.dto.CprCallGuideResponseDto;
import com.mentionall.cpr2u.call.dto.CprCallIdDto;
import com.mentionall.cpr2u.call.dto.CprCallNearUserDto;
import com.mentionall.cpr2u.call.dto.CprCallOccurDto;
import com.mentionall.cpr2u.call.dto.cpr_call.CprCallGuideResponseDto;
import com.mentionall.cpr2u.call.dto.cpr_call.CprCallIdResponseDto;
import com.mentionall.cpr2u.call.dto.cpr_call.CprCallNearUserResponseDto;
import com.mentionall.cpr2u.call.dto.cpr_call.CprCallRequestDto;
import com.mentionall.cpr2u.call.service.CprCallService;
import com.mentionall.cpr2u.user.domain.PrincipalDetails;
import com.mentionall.cpr2u.util.GetUserDetails;
Expand Down Expand Up @@ -33,7 +33,7 @@ public class CprCallController {

@Operation(summary = "홈 화면", description = "현재 근처에서 진행중인 CPR 요청이 있는지 확인한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallNearUserDto.class)))),
@ApiResponse(responseCode = "200", description = "성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallNearUserResponseDto.class)))),
@ApiResponse(responseCode = "400", description = "엔젤 자격증이 있으나, 주소를 설정하지 않음", content = @Content(array = @ArraySchema(schema = @Schema(implementation = ResponseTemplate.class))))
})
@GetMapping
Expand All @@ -43,13 +43,13 @@ public ResponseEntity<ResponseDataTemplate> getNowCallStatusNearUser(@GetUserDet

@Operation(summary = "호출하기", description = "사건 발생 지역의 CPR Angel들을 호출한다.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallIdDto.class)))),
@ApiResponse(responseCode = "404", description = "해당 주소지에 맞는 주소 지역구를 찾을 수 없습니다", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallIdDto.class))))
@ApiResponse(responseCode = "200", description = "성공", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallIdResponseDto.class)))),
@ApiResponse(responseCode = "404", description = "해당 주소지에 맞는 주소 지역구를 찾을 수 없습니다", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CprCallIdResponseDto.class))))
})
@PostMapping
public ResponseEntity<ResponseDataTemplate> makeCall(@RequestBody CprCallOccurDto cprCallOccurDto,
public ResponseEntity<ResponseDataTemplate> makeCall(@RequestBody CprCallRequestDto cprCallRequestDto,
@GetUserDetails PrincipalDetails userDetails) {
return ResponseDataTemplate.toResponseEntity(OK_SUCCESS, cprCallService.makeCall(cprCallOccurDto, userDetails.getUser()));
return ResponseDataTemplate.toResponseEntity(OK_SUCCESS, cprCallService.makeCall(cprCallRequestDto, userDetails.getUser()));
}

@Operation(summary = "실시간 호출 상황 안내", description = "현재 출동 중인 CPR 엔젤이 몇명인지 확인한다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mentionall.cpr2u.call.controller;

import com.mentionall.cpr2u.call.dto.DispatchRequestDto;
import com.mentionall.cpr2u.call.dto.DispatchResponseDto;
import com.mentionall.cpr2u.call.dto.dispatch.DispatchRequestDto;
import com.mentionall.cpr2u.call.dto.dispatch.DispatchResponseDto;
import com.mentionall.cpr2u.call.dto.ReportRequestDto;
import com.mentionall.cpr2u.call.service.DispatchService;
import com.mentionall.cpr2u.user.domain.PrincipalDetails;
Expand Down Expand Up @@ -34,6 +34,8 @@ public class DispatchController {
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "성공",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = DispatchResponseDto.class)))),
@ApiResponse(responseCode = "400", description = "이미 종료되었거나, 본인이 생성한 호출에 대한 출동입니다.",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ResponseTemplate.class)))),
@ApiResponse(responseCode = "404", description = "해당 ID의 CPR 요청 정보를 찾을 수 없습니다.",
content = @Content(array = @ArraySchema(schema = @Schema(implementation = ResponseTemplate.class)))),
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mentionall.cpr2u.call.domain;

import com.mentionall.cpr2u.call.dto.CprCallOccurDto;
import com.mentionall.cpr2u.call.dto.cpr_call.CprCallRequestDto;
import com.mentionall.cpr2u.user.domain.Address;
import com.mentionall.cpr2u.user.domain.User;
import lombok.AllArgsConstructor;
Expand Down Expand Up @@ -54,13 +54,13 @@ public class CprCall {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "cprCall")
List<Report> reportList = new ArrayList<>();

public CprCall(User user, Address address, LocalDateTime calledAt, CprCallOccurDto cprCallOccurDto) {
public CprCall(User user, Address address, LocalDateTime calledAt, CprCallRequestDto cprCallRequestDto) {
this.caller = user;
this.address = address;
this.fullAddress = cprCallOccurDto.getFullAddress();
this.fullAddress = cprCallRequestDto.getFullAddress();
this.calledAt = calledAt;
this.latitude = cprCallOccurDto.getLatitude();
this.longitude = cprCallOccurDto.getLongitude();
this.latitude = cprCallRequestDto.getLatitude();
this.longitude = cprCallRequestDto.getLongitude();
this.status = CprCallStatus.IN_PROGRESS;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class Dispatch {
private LocalDateTime arrivedAt;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "cpr_call")
@JoinColumn(name = "cpr_call_id")
private CprCall cprCall;


Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.mentionall.cpr2u.call.dto;
package com.mentionall.cpr2u.call.dto.cpr_call;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@AllArgsConstructor
public class CprCallGuideResponseDto {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.mentionall.cpr2u.call.dto;
package com.mentionall.cpr2u.call.dto.cpr_call;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
Expand All @@ -7,7 +7,7 @@

@Data
@AllArgsConstructor
public class CprCallIdDto {
public class CprCallIdResponseDto {
@Schema(description = "호출 id")
@JsonProperty("call_id")
private Long callId;
Expand Down
Loading

0 comments on commit 2f15d29

Please sign in to comment.