Skip to content

Commit

Permalink
Merge pull request #33 from KCY-Fit-a-Pet/feat/30
Browse files Browse the repository at this point in the history
✨ DtoMapper v1.0
  • Loading branch information
psychology50 authored Nov 12, 2023
2 parents cda225f + 5f869bf commit 51897d2
Show file tree
Hide file tree
Showing 41 changed files with 388 additions and 92 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/todo_bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Run TODO to Issue"
on:
push:
workflow_dispatch:
inputs:
MANUAL_COMMIT_REF:
description: "The SHA of the commit to get the diff for"
required: true
MANUAL_BASE_REF:
description: "By default, the commit entered above is compared to the one directly before it; to go back further, enter an earlier SHA here"
required: false
jobs:
build:
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@master"
env:
MANUAL_COMMIT_REF: ${{ inputs.MANUAL_COMMIT_REF }}
MANUAL_BASE_REF: ${{ inputs.MANUAL_BASE_REF }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ out/

### VS Code ###
.vscode/

### test ###
src/main/java/com/kcy/fitapet/test/
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

## Tech Stack
### Framework & Library
- JDK 11
- JDK 17
- SpringBoot 3.1.0
- SpringBoot Security
- Spring Data JPA
Expand Down Expand Up @@ -65,16 +65,16 @@
- Goorm IDE (for DB Server)

## Project Check List
- [ ] 실제 서비스를 공개적으로 배포하고 운영하는 경험을 해보았다.
- [ ] 유저의 피드백에 따라 성능/사용성을 개선하고 신규 기능을 추가해보았다.
- [ ] 발견되는 버그와 개선사항들을 정리하고 쌓인 이슈들을 체계적으로 관리해보았다.
- [ ] 코드를 지속적으로 리팩토링하고 디자인 패턴을 적용해보았다.
- [ ] 위의 시도에서 더 좋은 설계와 더 빠른 개발 사이의 트레이드 오프를 고민해본 적이 있다.
- [ ] 반복되는 수정과 배포에 수반되는 작업들을 자동화 해보았다.
- [ ] 언어나 프레임워크만으로 구현할 수 없는 것들을 직접 구현해보았다.
- [ ] 내가 사용한 라이브러리나 프레임 워크의 한계를 느끼고 개선해보았다.
- [ ] 코드나 제품의 퀄리티를 유지하기 위한 분석툴이나 테스트 툴을 도입해보았다.
- [ ] 타인과의 협업을 효율적으로 하기 위한 고민을 해보았다.
- [ ] 실제 서비스를 공개적으로 배포하고 운영하는 경험을 해보았다.
- [ ] 유저의 피드백에 따라 성능/사용성을 개선하고 신규 기능을 추가해보았다.
- [ ] 발견되는 버그와 개선사항들을 정리하고 쌓인 이슈들을 체계적으로 관리해보았다.
- [ ] 코드를 지속적으로 리팩토링하고 디자인 패턴을 적용해보았다.
- [ ] 위의 시도에서 더 좋은 설계와 더 빠른 개발 사이의 트레이드 오프를 고민해본 적이 있다.
- [ ] 반복되는 수정과 배포에 수반되는 작업들을 자동화 해보았다.
- [ ] 언어나 프레임워크만으로 구현할 수 없는 것들을 직접 구현해보았다.
- [ ] 내가 사용한 라이브러리나 프레임 워크의 한계를 느끼고 개선해보았다.
- [ ] 코드나 제품의 퀄리티를 유지하기 위한 분석툴이나 테스트 툴을 도입해보았다.
- [X] 타인과의 협업을 효율적으로 하기 위한 고민을 해보았다.

## System Architecture
<div align="center"><img src="https://github.com/KCY-Fit-a-Pet/fit-a-pet-client/assets/96044622/08a48299-460b-46c9-ac83-ac7aec15d73c"></img></div>
Expand Down
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ dependencies {
implementation 'org.apache.httpcomponents.client5:httpclient5:5.2.1'
implementation 'org.apache.httpcomponents:httpcore:4.4.14'

// jackson
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.5'
implementation 'com.fasterxml.jackson.core:jackson-core:2.13.5'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.5'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.13.5'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'

Expand Down
22 changes: 12 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
version: '3.7'
services:
proxy:
image: jaeseo/nginx:latest
restart: always
ports:
- "80:80"
- "443:443"
networks:
- was-net
depends_on:
- api
# proxy:
# image: jaeseo/nginx:latest
# restart: always
# ports:
# - "80:80"
# - "443:443"
# networks:
# - was-net
# depends_on:
# - api

fitapet-api:
image: jaeseo/fitapet:latest
Expand All @@ -18,6 +18,8 @@ services:
- "8080:8080"
env_file:
- .env
environment:
- TZ=Asia/Seoul
networks:
- was-net

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/kcy/fitapet/FitapetApplication.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.kcy.fitapet;

import jakarta.annotation.PostConstruct;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import java.util.TimeZone;

@SpringBootApplication
public class FitapetApplication {
public static void main(String[] args) {
SpringApplication.run(FitapetApplication.class, args);
}

@PostConstruct
public void init() {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Seoul"));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kcy.fitapet.domain.member.api;

import com.kcy.fitapet.domain.member.dao.MemberRepository;
import com.kcy.fitapet.domain.member.dto.auth.SignInReq;
import com.kcy.fitapet.domain.member.dto.auth.SignUpReq;
import com.kcy.fitapet.domain.member.dto.sms.SmsReq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import com.kcy.fitapet.domain.pet.domain.Pet;
import jakarta.persistence.*;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.ColumnDefault;
import org.springframework.data.annotation.CreatedDate;

import java.time.LocalDateTime;

@Entity
@Getter
@Table(name = "MANAGER")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class Manager extends Auditable {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.kcy.fitapet.domain.member.domain;

import com.kcy.fitapet.domain.member.type.RoleType;
import com.kcy.fitapet.domain.member.type.RoleTypeConverter;
import com.kcy.fitapet.domain.model.Auditable;
import com.kcy.fitapet.domain.notification.domain.Notification;
import com.kcy.fitapet.domain.notification.domain.NotificationSetting;
Expand All @@ -26,13 +28,14 @@ public class Member extends Auditable {

@Getter
private String uid;
@Getter
private String name;
private String password;
@Getter
private String phone;
@Getter
private String email;
@Column(name = "profile_img")
@Column(name = "profile_img") @Getter
private String profileImg;
@Column(name = "account_locked") @ColumnDefault("false")
private Boolean accountLocked;
Expand All @@ -50,9 +53,9 @@ public class Member extends Auditable {
private List<Notification> notifications = new ArrayList<>();
@OneToOne(mappedBy = "member", cascade = CascadeType.ALL)
private NotificationSetting notificationSetting;
@OneToMany(mappedBy = "master")
@OneToMany(mappedBy = "master") @Getter
private List<Pet> pets = new ArrayList<>();
@OneToMany(mappedBy = "manager", cascade = CascadeType.ALL)
@OneToMany(mappedBy = "manager", cascade = CascadeType.ALL) @Getter
private List<Manager> underCares = new ArrayList<>();

@Builder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.kcy.fitapet.domain.member.dto.auth;

import com.kcy.fitapet.domain.member.domain.Member;
import com.kcy.fitapet.domain.member.domain.RoleType;
import com.kcy.fitapet.domain.member.type.RoleType;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import com.kcy.fitapet.domain.member.dto.sms.SensReq;
import com.kcy.fitapet.domain.member.dto.sms.SensRes;
import com.kcy.fitapet.domain.member.dto.sms.SmsReq;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
Expand All @@ -26,6 +28,8 @@
@Service
@Slf4j
public class SmsService {
private final ObjectMapper objectMapper;

private final String accessKey;
private final String secretKey;
private final String serviceId;
Expand All @@ -35,12 +39,14 @@ public SmsService(
@Value("${ncp.api-key}") String accessKey,
@Value("${ncp.secret-key}") String secretKey,
@Value("${ncp.sms.service-key}") String serviceId,
@Value("${ncp.sms.sender-phone}") String phone
@Value("${ncp.sms.sender-phone}") String phone,
@Autowired ObjectMapper objectMapper
) {
this.accessKey = accessKey;
this.secretKey = secretKey;
this.serviceId = serviceId;
this.phone = phone;
this.objectMapper = objectMapper;
}

public SensRes sendCertificationNumber(SmsReq smsReq, String certificationNumber)
Expand All @@ -57,7 +63,6 @@ public SensRes sendCertificationNumber(SmsReq smsReq, String certificationNumber

SensReq request = SensReq.of("SMS", "COMM", "82", phone, createAuthCodeMessage(certificationNumber), messages);

ObjectMapper objectMapper = new ObjectMapper();
String body = objectMapper.writeValueAsString(request);
HttpEntity<String> httpEntity = new HttpEntity<>(body, headers);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kcy.fitapet.domain.member.domain;
package com.kcy.fitapet.domain.member.type;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
Expand All @@ -20,7 +20,6 @@ public enum RoleType implements LegacyCommonType {
private static final Map<String, RoleType> stringToEnum =
Stream.of(values()).collect(toMap(Object::toString, e -> e));


@JsonValue
public String getRole() { return role; }
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.kcy.fitapet.domain.member.domain;
package com.kcy.fitapet.domain.member.type;

import com.kcy.fitapet.global.common.util.converter.AbstractLegacyEnumAttributeConverter;
import jakarta.persistence.Converter;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/kcy/fitapet/domain/pet/api/PetApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kcy.fitapet.domain.pet.api;

import org.springframework.web.bind.annotation.RestController;

@RestController
public class PetApi {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.kcy.fitapet.domain.pet.dao;

import com.kcy.fitapet.domain.pet.domain.Pet;
import org.springframework.data.jpa.repository.JpaRepository;

public interface PetRepository extends JpaRepository<Pet, Long> {
}
9 changes: 6 additions & 3 deletions src/main/java/com/kcy/fitapet/domain/pet/domain/Pet.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.kcy.fitapet.domain.member.domain.Member;
import com.kcy.fitapet.domain.memo.domain.Memo;
import com.kcy.fitapet.domain.model.Auditable;
import com.kcy.fitapet.domain.pet.type.GenderType;
import com.kcy.fitapet.domain.pet.type.GenderTypeConverter;
import com.kcy.fitapet.domain.schedule.domain.Schedule;
import jakarta.persistence.*;
import lombok.*;
Expand All @@ -24,7 +26,8 @@ public class Pet extends Auditable {
private Long id;
@Column(name = "pet_name")
private String petName;
private boolean gender;
@Convert(converter = GenderTypeConverter.class)
private GenderType gender;
@Column(name = "pet_profile_img")
private String petProfileImg;
@ColumnDefault("false")
Expand Down Expand Up @@ -52,7 +55,7 @@ public class Pet extends Auditable {
private List<Memo> memos = new ArrayList<>();

@Builder
private Pet(String petName, boolean gender, String petProfileImg, boolean neutered, LocalDateTime birth,
private Pet(String petName, GenderType gender, String petProfileImg, boolean neutered, LocalDateTime birth,
Integer age, String species, String feed) {
this.petName = petName;
this.gender = gender;
Expand All @@ -64,7 +67,7 @@ private Pet(String petName, boolean gender, String petProfileImg, boolean neuter
this.feed = feed;
}

public static Pet of(String petName, boolean gender, String petProfileImg, boolean neutered, LocalDateTime birth,
public static Pet of(String petName, GenderType gender, String petProfileImg, boolean neutered, LocalDateTime birth,
Integer age, String species, String feed) {
return Pet.builder()
.petName(petName)
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/kcy/fitapet/domain/pet/dto/PetRegisterReq.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.kcy.fitapet.domain.pet.dto;

import com.kcy.fitapet.domain.pet.type.GenderType;

import java.time.LocalDate;

public class PetRegisterReq {
private String petName;
private String species;
private GenderType gender;
private boolean neutralization;
private LocalDate birthDate;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.kcy.fitapet.domain.pet.service;

import com.kcy.fitapet.domain.pet.dao.PetRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class PetManageService {
private final PetRepository petRepository;


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.kcy.fitapet.domain.pet.service;

public class PetSearchService {
}
18 changes: 18 additions & 0 deletions src/main/java/com/kcy/fitapet/domain/pet/type/GenderType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.kcy.fitapet.domain.pet.type;

import com.kcy.fitapet.global.common.util.converter.LegacyCommonType;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public enum GenderType implements LegacyCommonType {
MALE("1", "수컷"),
FEMALE("2", "암컷");

private final String code;
private final String gender;

@Override
public String getCode() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.kcy.fitapet.domain.pet.type;

import com.kcy.fitapet.global.common.util.converter.AbstractLegacyEnumAttributeConverter;
import jakarta.persistence.Converter;

@Converter
public class GenderTypeConverter extends AbstractLegacyEnumAttributeConverter<GenderType> {
private static final String ENUM_NAME = "성별";

public GenderTypeConverter() {
super(GenderType.class, false, ENUM_NAME);
}
}
Loading

0 comments on commit 51897d2

Please sign in to comment.