Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:FITPET-A/FITPET_BE into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboysj committed Sep 19, 2024
2 parents f92df12 + 9920cc2 commit efadafe
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 59 deletions.
1 change: 1 addition & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
echo "Starting new Docker container fitpet-container..."
sudo docker run -d -p 8080:8080 --name fitpet-container \
-e DB_URL=${{ secrets.DB_URL }} \
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
-e ACCESS_TOKEN_EXP=${{ secrets.ACCESS_TOKEN_EXP }} \
Expand Down
62 changes: 54 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# FITPET_BE
๋Œ€ํ•™์ƒ IT๊ฒฝ์˜ํ•™ํšŒ ํ์‹œ์ฆ˜ 30๊ธฐ ๊ธฐ์—… ํ”„๋กœ์ ํŠธ : FITPET A์กฐ Backend Repository
๋Œ€ํ•™์ƒ IT๊ฒฝ์˜ํ•™ํšŒ ํ์‹œ์ฆ˜ 30๊ธฐ ๊ธฐ์—… ํ”„๋กœ์ ํŠธ : FITPET A์กฐ Backend Repository <br>
2024.08.19 ~ 2024.09.08

![1](https://github.com/user-attachments/assets/0f660c6e-7207-4f7f-b101-f687bd0e12bc)
<br><br><br>



<br><br>

## Member
| ๊น€๋‹ค์€ | ๊น€์ˆ˜์ง„ |
Expand All @@ -10,8 +15,45 @@
| [@daeun084](https://github.com/daeun084) | [@cowboysj](https://github.com/cowboysj) |
| ์ˆญ์‹ค๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐํ•™๋ถ€ | ๊ฒฝํฌ๋Œ€ํ•™๊ต ์ปดํ“จํ„ฐ๊ณตํ•™๊ณผ |

<br><br><br>


## Stack
**Language & Framework**
<img src="https://img.shields.io/badge/Java-007396?style=flat&logo=Java&logoColor=white" />
<img src="https://img.shields.io/badge/Spring Boot-6DB33F?style=flat&logo=SpringBoot&logoColor=white" />
<img src="https://img.shields.io/badge/Spring Security-6DB33F?style=flat&logo=SpringSecurity&logoColor=white" />


**Documentation**
<img src="https://img.shields.io/badge/Rest Docs-6DB33F?style=flat&logo=Spring&logoColor=white" />
<img src="https://img.shields.io/badge/Swagger-85EA2D?style=flat&logo=Swagger&logoColor=black" />

**Database & ORM**
<img src="https://img.shields.io/badge/Spring Data JPA-6DB33F?style=flat&logo=Spring&logoColor=white" />
<img src="https://img.shields.io/badge/MySQL-4479A1?style=flat&logo=MySQL&logoColor=white" />

**Build Tool**
<img src="https://img.shields.io/badge/Gradle-02303A?style=flat&logo=Gradle&logoColor=white" />

**Cloud & Hosting**
<img src="https://img.shields.io/badge/AmazonEC2-FF9900?style=flat&logo=AmazonEC2&logoColor=white" />
<img src="https://img.shields.io/badge/AmazonRDS-527FFF?style=flat&logo=AmazonRDS&logoColor=white" />

**Containerization & CI/CD**
<img src="https://img.shields.io/badge/Docker-2496ED?style=flat&logo=Docker&logoColor=white" />
<img src="https://img.shields.io/badge/GithubActions-2088FF?style=flat&logo=GithubActions&logoColor=white" />

<br><br><br>


## Architecture
![image](https://github.com/user-attachments/assets/55b51461-42d4-4105-99bf-8f930a1266db) <br><br><br>


## ERD
![20](https://github.com/user-attachments/assets/b9384cc6-e3cf-4405-9c5f-057c09523ab5) <br><br><br>

<br><br>

## Convention

Expand All @@ -31,8 +73,8 @@
| `test` | ํ…Œ์ŠคํŠธ ์ฝ”๋“œ ์ถ”๊ฐ€ ๋ฐ ์ˆ˜์ •, ์‚ญ์ œ |
| `refactor` | ์ฝ”๋“œ ๋ฆฌํŒฉํ† ๋ง |

<br><br><br>

<br><br>


## Branch
Expand All @@ -41,10 +83,10 @@
- pull request๋ฅผ ํ†ตํ•ด develop branch์— merge ํ›„, branch delete
- ๋ถ€๋“์ดํ•˜๊ฒŒ develop branch์— ์ง์ ‘ commit ํ•ด์•ผ ํ•  ๊ฒฝ์šฐ, `!hotfix:` ์‚ฌ์šฉ

<br><br><br>

<br><br>

## Dir
## Directory

```PlainText
src/
Expand All @@ -66,10 +108,14 @@ src/
โ””โ”€โ”€ dto/
โ”œโ”€โ”€ request/
โ””โ”€โ”€ response/
```

<br><br><br>




## ๋ถ€ํ•˜ ํ…Œ์ŠคํŠธ
๊ฐ€์žฅ ์š”์ฒญ์ด ๋งŽ์„ ๊ฒƒ์œผ๋กœ ์˜ˆ์ƒ๋˜๋Š” `๊ฒฌ์ ์„œ ์š”์ฒญ API`์— ๋Œ€ํ•ด K6์„ ์ด์šฉํ•ด ๋ถ€ํ•˜ํ…Œ์ŠคํŠธ๋ฅผ ์ง„ํ–‰ํ–ˆ์Šต๋‹ˆ๋‹ค.

Expand Down
1 change: 1 addition & 0 deletions src/main/java/FITPET/dev/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public AdminResponse.SignDto signUp(AdminRequest.SignUpDto signUpDto) {
* @param signInDto
* @return
*/
@Transactional
public AdminResponse.SignDto signIn(AdminRequest.SignInDto signInDto) {
Admin admin = findAdminById(signInDto.getId());

Expand Down
25 changes: 1 addition & 24 deletions src/main/java/FITPET/dev/service/ComparisonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ComparisonService {
* @param request
* @return
*/
@Transactional
public ComparisonResponse.ComparisonDto createComparisonAndGetInsurance(ComparisonRequest request) {
validatePhoneNumber(request.getPhoneNumber());
validateAge(request.getPetAge());
Expand All @@ -81,24 +82,6 @@ public ComparisonResponse.ComparisonDto createComparisonAndGetInsurance(Comparis
}


/*
* default ๊ฐ’์œผ๋กœ ๋ณดํ—˜๋ฃŒ ์กฐํšŒ
* @param petInfo
* @return
*/
public InsuranceResponse.InsuranceListDto getInsurancePremiumsByPetInfo(PetInfo petInfo) {

String detailType = petInfo.getPet().getPetSpecies();
int age = petInfo.getAge();
String renewalCycle = "3๋…„";
String deductible = "1๋งŒ์›";
String coverageRatio = "70";
String compensation = "15๋งŒ";

return insuranceService.getInsurancePremium(detailType, age, renewalCycle, coverageRatio, deductible, compensation);
}


public InsuranceResponse.InsuranceListDto getInsurancePremiumsByPetInfoAndCoverageRatio(PetInfo petInfo, String coverageRatio) {

String detailType = petInfo.getPet().getPetSpecies();
Expand Down Expand Up @@ -188,11 +171,6 @@ public ComparisonResponse.ComparisonDto patchComparisonStatus(Long comparisonId,
// ๊ฒฌ์ ์„œ ๋‹จ์ผ ์กฐํšŒ
Comparison comparison = findComparisonById(comparisonId);

// validate status
ComparisonStatus currentComparisonStatus = comparison.getStatus();
if (currentComparisonStatus.getIndex() > comparisonStatus.getIndex())
throw new GeneralException(ErrorStatus.INVALID_PATCH_PERIOR_STATUS);

// patch status
comparison.updateStatus(comparisonStatus);
return ComparisonConverter.toComparisonDto(comparison);
Expand All @@ -217,7 +195,6 @@ public ComparisonResponse.ComparisonPageDto searchComparisons(String content, in
* ComparisonId๋“ค ๋ฐ›์•„์„œ ์‚ญ์ œ
* @param ComparisonId
*/

@Transactional
public void deleteComparison(Long comparisonId) {
Comparison comparison = findComparisonById(comparisonId);
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/FITPET/dev/service/InquiryService.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,6 @@ public InquiryResponse.InquiryDto patchInquiryStatus(Long inquiryId, InquiryStat
// 1:1 ๋ฌธ์˜ ๋‹จ์ผ ์กฐํšŒ
Inquiry inquiry = findInquiryById(inquiryId);

// validate status
InquiryStatus currentInquiryStatus = inquiry.getStatus();
if (currentInquiryStatus.getIndex() > inquiryStatus.getIndex())
throw new GeneralException(ErrorStatus.INVALID_PATCH_PERIOR_STATUS);

// patch status
inquiry.updateStatus(inquiryStatus);
return InquiryConverter.toInquiryDto(inquiry);
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/FITPET/dev/service/InsuranceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ public InsuranceResponse.InsuranceListDto getInsurancePremium(
}


/*
* ์ƒ์„ธ ํ’ˆ์ข…๋ช…์œผ๋กœ Pet ๊ฐ์ฒด๋ฅผ ์ฐพ์•„ ๋ฐ˜ํ™˜
* @param detailType
* @return
*/
private Pet findPetByPetSpecies(String petSpecies){
return petRepository.findByPetSpecies(petSpecies)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_PET));
}


/*
* ํ•„๋“œ ์ •๋ณด๋“ค์„ ๋งŒ์กฑํ•˜๋Š” insurance ๊ฐ์ฒด๋“ค์„ ์ฐพ์•„ ๋ฆฌ์ŠคํŠธ๋กœ ๋ฐ˜ํ™˜
* @param pet
Expand Down Expand Up @@ -181,6 +170,7 @@ public List<InsuranceHistoryResponse> getPremiumHistory(Long insuranceId) {
/*
* ๋ณดํ—˜ ์ •๋ณด ์ถ”๊ฐ€
*/
@Transactional
public InsuranceResponse.InsuranceDetailDto addInsurance(InsuranceRequest request) {
Insurance insurance = InsuranceConverter.RequestToInsurance(request);
insuranceRepository.save(insurance);
Expand Down Expand Up @@ -246,6 +236,17 @@ private void saveInsuranceHistory(Insurance insurance, int oldPremium, int newPr
}


/*
* ์ƒ์„ธ ํ’ˆ์ข…๋ช…์œผ๋กœ Pet ๊ฐ์ฒด๋ฅผ ์ฐพ์•„ ๋ฐ˜ํ™˜
* @param detailType
* @return
*/
private Pet findPetByPetSpecies(String petSpecies){
return petRepository.findByPetSpecies(petSpecies)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_PET));
}


private Insurance findInsuranceById(Long insuranceId){
return insuranceRepository.findByInsuranceId(insuranceId)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_INSURANCE));
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/FITPET/dev/service/ProposalService.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,6 @@ public ProposalResponse.ProposalPageDto getProposals(String startDate, String en
public ProposalResponse.ProposalDto patchProposalStatus(Long proposalId, ProposalStatus proposalStatus) {
Proposal proposal = findProposalById(proposalId);

// validate status
ProposalStatus currentProposalStatus = proposal.getStatus();
if (currentProposalStatus.getIndex() > proposalStatus.getIndex())
throw new GeneralException(ErrorStatus.INVALID_PATCH_PERIOR_STATUS);

// patch status
proposal.updateStatus(proposalStatus);
return ProposalConverter.toProposalDto(proposal);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/FITPET/dev/service/ReferSiteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ public class ReferSiteService {

private final ReferSiteRepository referSiteRepository;

private ReferSite findReferSiteById(Long referSiteId) {
return referSiteRepository.findByIdAndNotDeleted(referSiteId)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_REFERSITE));
}

/*
* ์‹ ๊ทœ ์œ ์ž…์ฑ„๋„ ์ถ”๊ฐ€
*/
Expand Down Expand Up @@ -85,4 +80,9 @@ public ReferSiteResponse.ReferSitePageDto searchReferSite(String content, int pa

return ReferSiteConverter.toReferSitePageDto(referSitePage);
}

private ReferSite findReferSiteById(Long referSiteId) {
return referSiteRepository.findByIdAndNotDeleted(referSiteId)
.orElseThrow(() -> new GeneralException(ErrorStatus.NOT_EXIST_REFERSITE));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ spring:
name: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://fitpet-a-db.cj8cios80977.ap-northeast-2.rds.amazonaws.com:3306/fitpet_a_db
url: ${DB_URL}
username: ${DB_USERNAME}
password: ${DB_PASSWORD}
sql:
Expand Down

0 comments on commit efadafe

Please sign in to comment.