diff --git a/back/.idea/.name b/back/.idea/.name
new file mode 100644
index 0000000..445d235
--- /dev/null
+++ b/back/.idea/.name
@@ -0,0 +1 @@
+PetChatBot
\ No newline at end of file
diff --git a/back/.idea/compiler.xml b/back/.idea/compiler.xml
index 4a72e34..7a4905d 100644
--- a/back/.idea/compiler.xml
+++ b/back/.idea/compiler.xml
@@ -8,6 +8,7 @@
+
diff --git a/back/.idea/vcs.xml b/back/.idea/vcs.xml
index 94a25f7..288b36b 100644
--- a/back/.idea/vcs.xml
+++ b/back/.idea/vcs.xml
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/back/build.gradle b/back/build.gradle
index 13a1863..2974fbf 100644
--- a/back/build.gradle
+++ b/back/build.gradle
@@ -13,6 +13,7 @@ repositories {
}
dependencies {
+ implementation 'org.projectlombok:lombok:1.18.22'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
// implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
@@ -40,6 +41,10 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
+ //테스트에서 lombok 사용
+ testCompileOnly 'org.projectlombok:lombok'
+ testAnnotationProcessor 'org.projectlombok:lombok'
+
}
test {
diff --git a/back/out/production/classes/com/petchatbot/ApiController.class b/back/out/production/classes/com/petchatbot/ApiController.class
new file mode 100644
index 0000000..28449e9
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/ApiController.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/CorsConfig.class b/back/out/production/classes/com/petchatbot/config/CorsConfig.class
new file mode 100644
index 0000000..595a378
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/CorsConfig.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/ResponseMessage.class b/back/out/production/classes/com/petchatbot/config/ResponseMessage.class
new file mode 100644
index 0000000..de5e2a6
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/ResponseMessage.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/SecurityConfig.class b/back/out/production/classes/com/petchatbot/config/SecurityConfig.class
new file mode 100644
index 0000000..4a906a0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/SecurityConfig.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/StatusCode.class b/back/out/production/classes/com/petchatbot/config/StatusCode.class
new file mode 100644
index 0000000..893b550
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/StatusCode.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/auth/CustomAuthenticationEntryPoint.class b/back/out/production/classes/com/petchatbot/config/auth/CustomAuthenticationEntryPoint.class
new file mode 100644
index 0000000..f70f43a
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/auth/CustomAuthenticationEntryPoint.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetails.class b/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetails.class
new file mode 100644
index 0000000..576e1e0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetails.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetailsService.class b/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetailsService.class
new file mode 100644
index 0000000..7f5bc1c
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/auth/PrincipalDetailsService.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthenticationFilter.class b/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthenticationFilter.class
new file mode 100644
index 0000000..d7edffe
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthenticationFilter.class differ
diff --git a/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthorizationFilter.class b/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthorizationFilter.class
new file mode 100644
index 0000000..0b0d74c
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/config/auth/jwt/JwtAuthorizationFilter.class differ
diff --git a/back/out/production/classes/com/petchatbot/controller/ControllerExceptionHandler.class b/back/out/production/classes/com/petchatbot/controller/ControllerExceptionHandler.class
new file mode 100644
index 0000000..aabd1f0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/controller/ControllerExceptionHandler.class differ
diff --git a/back/out/production/classes/com/petchatbot/controller/MemberController.class b/back/out/production/classes/com/petchatbot/controller/MemberController.class
new file mode 100644
index 0000000..2438bf2
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/controller/MemberController.class differ
diff --git a/back/out/production/classes/com/petchatbot/controller/PetController.class b/back/out/production/classes/com/petchatbot/controller/PetController.class
new file mode 100644
index 0000000..7fff2b2
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/controller/PetController.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/dto/CodeDto.class b/back/out/production/classes/com/petchatbot/domain/dto/CodeDto.class
new file mode 100644
index 0000000..b440e22
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/dto/CodeDto.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/dto/EmailCodeDto.class b/back/out/production/classes/com/petchatbot/domain/dto/EmailCodeDto.class
new file mode 100644
index 0000000..2cc32c9
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/dto/EmailCodeDto.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/dto/EmailDto.class b/back/out/production/classes/com/petchatbot/domain/dto/EmailDto.class
new file mode 100644
index 0000000..f5b64b6
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/dto/EmailDto.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/dto/MemberDto.class b/back/out/production/classes/com/petchatbot/domain/dto/MemberDto.class
new file mode 100644
index 0000000..c0323e0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/dto/MemberDto.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/model/Breed.class b/back/out/production/classes/com/petchatbot/domain/model/Breed.class
new file mode 100644
index 0000000..96f79d7
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/model/Breed.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/model/Member.class b/back/out/production/classes/com/petchatbot/domain/model/Member.class
new file mode 100644
index 0000000..6da1f87
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/model/Member.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/model/Neutralization.class b/back/out/production/classes/com/petchatbot/domain/model/Neutralization.class
new file mode 100644
index 0000000..c9d22b0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/model/Neutralization.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/model/Pet.class b/back/out/production/classes/com/petchatbot/domain/model/Pet.class
new file mode 100644
index 0000000..18507ff
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/model/Pet.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/model/PetSex.class b/back/out/production/classes/com/petchatbot/domain/model/PetSex.class
new file mode 100644
index 0000000..68b5568
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/model/PetSex.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/requestAndResponse/ChangePwReq.class b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/ChangePwReq.class
new file mode 100644
index 0000000..ca68546
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/ChangePwReq.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes$DefaultResBuilder.class b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes$DefaultResBuilder.class
new file mode 100644
index 0000000..cdc5801
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes$DefaultResBuilder.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes.class b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes.class
new file mode 100644
index 0000000..3b71921
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/DefaultRes.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/requestAndResponse/JoinReq.class b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/JoinReq.class
new file mode 100644
index 0000000..3ea5386
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/JoinReq.class differ
diff --git a/back/out/production/classes/com/petchatbot/domain/requestAndResponse/PetRegReq.class b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/PetRegReq.class
new file mode 100644
index 0000000..0dc701b
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/domain/requestAndResponse/PetRegReq.class differ
diff --git a/back/out/production/classes/com/petchatbot/repository/MemberRepository.class b/back/out/production/classes/com/petchatbot/repository/MemberRepository.class
new file mode 100644
index 0000000..bd4a4c1
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/repository/MemberRepository.class differ
diff --git a/back/out/production/classes/com/petchatbot/repository/PetRepository.class b/back/out/production/classes/com/petchatbot/repository/PetRepository.class
new file mode 100644
index 0000000..6f0b222
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/repository/PetRepository.class differ
diff --git a/back/out/production/classes/com/petchatbot/service/EmailService.class b/back/out/production/classes/com/petchatbot/service/EmailService.class
new file mode 100644
index 0000000..55312a5
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/service/EmailService.class differ
diff --git a/back/out/production/classes/com/petchatbot/service/MemberService.class b/back/out/production/classes/com/petchatbot/service/MemberService.class
new file mode 100644
index 0000000..0aa18c0
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/service/MemberService.class differ
diff --git a/back/out/production/classes/com/petchatbot/service/MemberServiceImpl.class b/back/out/production/classes/com/petchatbot/service/MemberServiceImpl.class
new file mode 100644
index 0000000..e8b1492
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/service/MemberServiceImpl.class differ
diff --git a/back/out/production/classes/com/petchatbot/service/PetService.class b/back/out/production/classes/com/petchatbot/service/PetService.class
new file mode 100644
index 0000000..70e6d69
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/service/PetService.class differ
diff --git a/back/out/production/classes/com/petchatbot/service/PetServiceImpl.class b/back/out/production/classes/com/petchatbot/service/PetServiceImpl.class
new file mode 100644
index 0000000..2a49ca5
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/service/PetServiceImpl.class differ
diff --git a/back/out/production/classes/com/petchatbot/startApp.class b/back/out/production/classes/com/petchatbot/startApp.class
new file mode 100644
index 0000000..a05d727
Binary files /dev/null and b/back/out/production/classes/com/petchatbot/startApp.class differ
diff --git a/back/out/production/resources/application.yml b/back/out/production/resources/application.yml
new file mode 100644
index 0000000..8759a4c
--- /dev/null
+++ b/back/out/production/resources/application.yml
@@ -0,0 +1,38 @@
+server:
+ port: 8080
+ servlet:
+ context-path: /
+ encoding:
+ charset: UTF-8
+ enabled: true
+ force: true
+
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://localhost:3306/test?serverTimezone=Asia/Seoul
+ username: user1
+ password: 1234
+
+ mvc:
+ view:
+ prefix: /templates/
+ suffix: .mustache
+
+ jpa:
+ hibernate:
+ ddl-auto: create #create update none
+ naming:
+ physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
+ show-sql: true
+ format_sql : true #이쁘게 해줌
+
+ mail:
+ host: smtp.naver.com
+ port: 465
+ username: lightson23@naver.com
+ password: anjdianjdi2239!!
+ properties:
+ mail.smtp.auth: true
+ mail.smtp.ssl.enable: true
+ mail.smtp.ssl.trust: smtp.naver.com
\ No newline at end of file
diff --git a/back/out/test/classes/com/petchatbot/controller/MemberControllerTest.class b/back/out/test/classes/com/petchatbot/controller/MemberControllerTest.class
new file mode 100644
index 0000000..0188f57
Binary files /dev/null and b/back/out/test/classes/com/petchatbot/controller/MemberControllerTest.class differ
diff --git a/back/out/test/classes/com/petchatbot/repository/MemberRepositoryTest.class b/back/out/test/classes/com/petchatbot/repository/MemberRepositoryTest.class
new file mode 100644
index 0000000..c3dfd9a
Binary files /dev/null and b/back/out/test/classes/com/petchatbot/repository/MemberRepositoryTest.class differ
diff --git a/back/out/test/classes/com/petchatbot/service/AnimalServiceImplTest.class b/back/out/test/classes/com/petchatbot/service/AnimalServiceImplTest.class
new file mode 100644
index 0000000..c55e414
Binary files /dev/null and b/back/out/test/classes/com/petchatbot/service/AnimalServiceImplTest.class differ
diff --git a/back/src/main/java/com/petchatbot/config/SecurityConfig.java b/back/src/main/java/com/petchatbot/config/SecurityConfig.java
index 583f077..85c5d2a 100644
--- a/back/src/main/java/com/petchatbot/config/SecurityConfig.java
+++ b/back/src/main/java/com/petchatbot/config/SecurityConfig.java
@@ -39,7 +39,7 @@ protected void configure(HttpSecurity http) throws Exception
.authenticationEntryPoint(new CustomAuthenticationEntryPoint())
.and()
.authorizeRequests()
- .antMatchers("/", "/login", "/join", "/sendEmail", "/enterEmailCode/join","/validateDuplicateEmail").permitAll()
+ .antMatchers("/", "/login", "/join", "/sendEmail", "/enterEmailCode/join","/validateDuplicateEmail","/addPet").permitAll()
.anyRequest().authenticated();
diff --git a/back/src/main/java/com/petchatbot/controller/MemberController.java b/back/src/main/java/com/petchatbot/controller/MemberController.java
index 44090f0..ffd60c6 100644
--- a/back/src/main/java/com/petchatbot/controller/MemberController.java
+++ b/back/src/main/java/com/petchatbot/controller/MemberController.java
@@ -95,7 +95,7 @@ public ResponseEntity enterEmailCode(@RequestBody EmailCodeDto ecCode){
}
}
- // 인증코드 입력 (비밀번호 변경)2
+ // 인증코드 입력 (비밀번호 변경)
@PostMapping("/enterEmailCode/changePw")
public ResponseEntity enterEmailCode_password(@RequestBody CodeDto codeDto){
int sendCode = codeDto.getSendCode();
diff --git a/back/src/main/java/com/petchatbot/controller/PetController.java b/back/src/main/java/com/petchatbot/controller/PetController.java
new file mode 100644
index 0000000..6f9cf3d
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/controller/PetController.java
@@ -0,0 +1,36 @@
+package com.petchatbot.controller;
+
+import com.petchatbot.config.ResponseMessage;
+import com.petchatbot.config.StatusCode;
+import com.petchatbot.domain.dto.MemberDto;
+import com.petchatbot.domain.requestAndResponse.DefaultRes;
+import com.petchatbot.domain.requestAndResponse.JoinReq;
+import com.petchatbot.domain.requestAndResponse.PetRegReq;
+import com.petchatbot.repository.MemberRepository;
+import com.petchatbot.service.MemberService;
+import com.petchatbot.service.PetService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@Slf4j
+@RestController
+@RequiredArgsConstructor
+public class PetController {
+
+ private final MemberRepository memberRepository;
+ private final MemberService memberService;
+ private final PetService petService;
+
+ @PostMapping("/addPet")
+ public ResponseEntity addPet(@RequestBody PetRegReq petRegReq) {
+
+ petService.registerPet(petRegReq);
+ log.info("petRegReg={}",petRegReq.getPetName());
+ return new ResponseEntity(DefaultRes.res(StatusCode.OK, ResponseMessage.ENTER_JOIN_INFORMATION), HttpStatus.OK);
+ }
+}
diff --git a/back/src/main/java/com/petchatbot/domain/model/Breed.java b/back/src/main/java/com/petchatbot/domain/model/Breed.java
new file mode 100644
index 0000000..538b38a
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/domain/model/Breed.java
@@ -0,0 +1,5 @@
+package com.petchatbot.domain.model;
+
+public enum Breed {
+ DOG, CAT
+}
diff --git a/back/src/main/java/com/petchatbot/domain/model/Member.java b/back/src/main/java/com/petchatbot/domain/model/Member.java
index a9d4c66..e8a5298 100644
--- a/back/src/main/java/com/petchatbot/domain/model/Member.java
+++ b/back/src/main/java/com/petchatbot/domain/model/Member.java
@@ -1,6 +1,7 @@
package com.petchatbot.domain.model;
import lombok.Getter;
+import lombok.extern.slf4j.Slf4j;
import javax.persistence.*;
import javax.validation.constraints.Email;
@@ -12,6 +13,7 @@
@Getter
@Entity
+@Slf4j
public class Member {
@Id
@@ -21,6 +23,9 @@ public class Member {
private String memberPassword;
private String roles; // USER, ADMIN
+ @OneToMany(mappedBy = "member")
+ private List petList = new ArrayList<>();
+
public Member() {
}
@@ -29,6 +34,12 @@ public Member(String memberEmail, String memberPassword) {
this.memberPassword = memberPassword;
}
+ public void addPet(Pet pet){
+ petList.add(pet);
+ pet.addMember(this);
+ log.info("pet.addMember={}", pet.getMember());
+ }
+
public void changePassword(String password){
this.memberPassword = password;
diff --git a/back/src/main/java/com/petchatbot/domain/model/Neutralization.java b/back/src/main/java/com/petchatbot/domain/model/Neutralization.java
new file mode 100644
index 0000000..5ba6c92
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/domain/model/Neutralization.java
@@ -0,0 +1,5 @@
+package com.petchatbot.domain.model;
+
+public enum Neutralization {
+ NEUTER, NOTNEUTER
+}
diff --git a/back/src/main/java/com/petchatbot/domain/model/Pet.java b/back/src/main/java/com/petchatbot/domain/model/Pet.java
new file mode 100644
index 0000000..787b674
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/domain/model/Pet.java
@@ -0,0 +1,51 @@
+package com.petchatbot.domain.model;
+
+import lombok.Getter;
+
+import javax.persistence.*;
+
+@Getter
+@Entity
+public class Pet {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Long pet_serial;
+
+ @ManyToOne
+ @JoinColumn(name="member_serial")
+ private Member member;
+ @Enumerated(EnumType.STRING)
+ private Breed petBreed;
+ private String petName;
+ private String petAge;
+ @Enumerated(EnumType.STRING)
+ private PetSex petSex;
+ @Enumerated(EnumType.STRING)
+ private Neutralization petNeutralization;
+
+ public Pet() {
+ }
+
+ public Pet(Breed petBreed, String petName, String petAge, PetSex petSex, Neutralization petNeutralization) {
+ this.petBreed = petBreed;
+ this.petName = petName;
+ this.petAge = petAge;
+ this.petSex = petSex;
+ this.petNeutralization = petNeutralization;
+ }
+
+ public void changePetInfo(String petName, String petAge, PetSex petSex, Neutralization petNeutralization){
+ this.petName = petName;
+ this.petAge = petAge;
+ this.petSex = petSex;
+ this.petNeutralization = petNeutralization;
+ }
+
+ public void addMember(Member member) {
+ this.member = member;
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/back/src/main/java/com/petchatbot/domain/model/PetSex.java b/back/src/main/java/com/petchatbot/domain/model/PetSex.java
new file mode 100644
index 0000000..44a2ec0
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/domain/model/PetSex.java
@@ -0,0 +1,5 @@
+package com.petchatbot.domain.model;
+
+public enum PetSex {
+ MALE, FEMALE
+}
diff --git a/back/src/main/java/com/petchatbot/domain/requestAndResponse/PetRegReq.java b/back/src/main/java/com/petchatbot/domain/requestAndResponse/PetRegReq.java
new file mode 100644
index 0000000..99cd073
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/domain/requestAndResponse/PetRegReq.java
@@ -0,0 +1,25 @@
+package com.petchatbot.domain.requestAndResponse;
+
+import com.petchatbot.domain.model.Breed;
+import com.petchatbot.domain.model.Neutralization;
+import com.petchatbot.domain.model.PetSex;
+import lombok.Data;
+
+@Data
+public class PetRegReq {
+ private String memberEmail;
+ private Breed petBreed;
+ private String petName;
+ private String petAge;
+ private PetSex petSex;
+ private Neutralization petNeutralization;
+
+ public PetRegReq(String memberEmail, Breed petBreed, String petName, String petAge, PetSex petSex, Neutralization petNeutralization) {
+ this.memberEmail = memberEmail;
+ this.petBreed = petBreed;
+ this.petName = petName;
+ this.petAge = petAge;
+ this.petSex = petSex;
+ this.petNeutralization = petNeutralization;
+ }
+}
diff --git a/back/src/main/java/com/petchatbot/repository/PetRepository.java b/back/src/main/java/com/petchatbot/repository/PetRepository.java
new file mode 100644
index 0000000..446d084
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/repository/PetRepository.java
@@ -0,0 +1,10 @@
+package com.petchatbot.repository;
+
+
+import com.petchatbot.domain.model.Member;
+import com.petchatbot.domain.model.Pet;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface PetRepository extends JpaRepository {
+
+}
\ No newline at end of file
diff --git a/back/src/main/java/com/petchatbot/service/PetService.java b/back/src/main/java/com/petchatbot/service/PetService.java
new file mode 100644
index 0000000..8f31bc6
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/service/PetService.java
@@ -0,0 +1,16 @@
+package com.petchatbot.service;
+
+import com.petchatbot.domain.dto.MemberDto;
+import com.petchatbot.domain.model.Member;
+import com.petchatbot.domain.model.Pet;
+import com.petchatbot.domain.requestAndResponse.PetRegReq;
+
+public interface PetService {
+
+ // 반려동물 추가
+ void registerPet(PetRegReq petRegReq);
+
+ // 반려동물 변경
+ void changePetInfo(Pet pet);
+
+}
diff --git a/back/src/main/java/com/petchatbot/service/PetServiceImpl.java b/back/src/main/java/com/petchatbot/service/PetServiceImpl.java
new file mode 100644
index 0000000..06be6ae
--- /dev/null
+++ b/back/src/main/java/com/petchatbot/service/PetServiceImpl.java
@@ -0,0 +1,53 @@
+package com.petchatbot.service;
+
+import com.petchatbot.domain.model.*;
+import com.petchatbot.domain.requestAndResponse.PetRegReq;
+import com.petchatbot.repository.MemberRepository;
+import com.petchatbot.repository.PetRepository;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class PetServiceImpl implements PetService{
+
+ private final MemberRepository memberRepository;
+ private final PetRepository petRepository;
+
+
+
+ @Transactional
+ @Override
+ public void registerPet(PetRegReq petRegReq) {
+ Member findMember = getFindMember(petRegReq);
+ Pet pet = createPetEntity(petRegReq);
+ petRepository.save(pet);
+ findMember.addPet(pet);
+ }
+
+ private Member getFindMember(PetRegReq petRegReq) {
+ String memberEmail = petRegReq.getMemberEmail();
+ Member findMember = memberRepository.findByMemberEmail(memberEmail);
+ return findMember;
+ }
+
+ private Pet createPetEntity(PetRegReq petRegReq) {
+ Breed petBreed = petRegReq.getPetBreed();
+ log.info("petBreed={}", petBreed);
+ String petName = petRegReq.getPetName();
+ String petAge = petRegReq.getPetAge();
+ PetSex petSex = petRegReq.getPetSex();
+ Neutralization petNeutralization = petRegReq.getPetNeutralization();
+
+ Pet pet = new Pet(petBreed, petName, petAge, petSex, petNeutralization);
+ return pet;
+ }
+
+ @Override
+ public void changePetInfo(Pet pet) {
+
+ }
+}
diff --git a/back/src/test/java/com/petchatbot/service/AnimalServiceImplTest.java b/back/src/test/java/com/petchatbot/service/AnimalServiceImplTest.java
index a009199..dbc8f21 100644
--- a/back/src/test/java/com/petchatbot/service/AnimalServiceImplTest.java
+++ b/back/src/test/java/com/petchatbot/service/AnimalServiceImplTest.java
@@ -1,7 +1,40 @@
package com.petchatbot.service;
+import com.petchatbot.domain.dto.MemberDto;
+import com.petchatbot.domain.model.*;
+import com.petchatbot.domain.requestAndResponse.PetRegReq;
+import com.petchatbot.repository.MemberRepository;
+import com.petchatbot.repository.PetRepository;
+import lombok.extern.slf4j.Slf4j;
+import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import static org.assertj.core.api.Assertions.*;
+
+@SpringBootTest
+@Slf4j
class AnimalServiceImplTest {
+ @Autowired
+ PetService petServiceImpl;
+
+ @Autowired
+ MemberService memberService;
+
+
+ @Test
+ void 반려동물추가(){
+ MemberDto memberDto = new MemberDto("abc@naver.com", "password");
+ memberService.join(memberDto);
+ PetRegReq petRegReq = new PetRegReq("abc@naver.com", Breed.DOG, "hera", "33", PetSex.FEMALE, Neutralization.NOTNEUTER);
+
+ petServiceImpl.registerPet(petRegReq);
+
+ }
+
+
}
\ No newline at end of file