Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #6

Merged
merged 26 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

applicaion.properties
*.properties

### IntelliJ IDEA ###
.idea
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
runtimeOnly 'com.mysql:mysql-connector-j'
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.4.0'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.vacation.platform.stayfinder.certify.controller;

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

@RestController
@RequestMapping("/api/v1/phone_certify")
public class PhoneCertifyController {

// 휴대폰 인증 요청 하고 응답 받으면
// 유저 회원 컨트롤러로 넘긴다.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.vacation.platform.stayfinder.certify.controller;

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

@RestController
@RequestMapping("/api/v1/terms_user")
public class TermsUserAgreementController {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.vacation.platform.stayfinder.certify.entity;

import com.vacation.platform.stayfinder.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.sql.Timestamp;

@ToString
@Entity
@NoArgsConstructor
@Data
@Table(name = "certify_req")
@EqualsAndHashCode(callSuper = true)
public class CertifyReq extends BaseEntity {

// 인증 테이블을 공통으로 사용할수 있게 처리
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;

private String userId;

// create_at 을 사용하는게 좋음
private Timestamp reqTime;

private Timestamp resTime;

private String reqCertifyNumber;

private int tryNumber;

// 삭제 대상
// 인증 대상 enum으로 처리
private String certifyPhoneNumber;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.vacation.platform.stayfinder.certify.entity;

import com.vacation.platform.stayfinder.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.sql.Timestamp;

@ToString
@Entity
@NoArgsConstructor
@Data
@Table
@EqualsAndHashCode(callSuper = true)
public class TermsUserAgreement extends BaseEntity {

// 필요 없음
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private int id;

// 아래 3개로 복합키

// 유저 id로 걸어야함
@Column(name = "phone_number")
private String phoneNumber;

// termsSub의 mainId
@Column(name = "terms_id")
private int termsId;

// version도 들어와야됨.


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.vacation.platform.stayfinder.certify.repository;

import com.vacation.platform.stayfinder.certify.entity.CertifyReq;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface CertifyRepository extends JpaRepository<CertifyReq, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.vacation.platform.stayfinder.certify.repository;

import com.vacation.platform.stayfinder.certify.entity.TermsUserAgreement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface TermsUserAgreementRepository extends JpaRepository<TermsUserAgreement, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.vacation.platform.stayfinder.certify.service;

import org.springframework.stereotype.Service;

@Service
public interface PhoneCertifyService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.vacation.platform.stayfinder.certify.service;

import org.springframework.stereotype.Service;

@Service
public interface TermsUserAgreementService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.vacation.platform.stayfinder.certify.service.serviceImpl;

import com.vacation.platform.stayfinder.certify.service.PhoneCertifyService;
import org.springframework.stereotype.Service;

@Service
public class PhoneCertifyServiceImpl implements PhoneCertifyService {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.vacation.platform.stayfinder.certify.service.serviceImpl;

import com.vacation.platform.stayfinder.certify.service.TermsUserAgreementService;
import org.springframework.stereotype.Service;

@Service
public class TermsUserAgreementServiceImpl implements TermsUserAgreementService {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.vacation.platform.stayfinder.common;

import jakarta.persistence.*;
import lombok.Getter;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
public class BaseEntity {

@CreatedDate
@Column(name = "create_at")
private Long createAt;

@LastModifiedDate
@Column(name = "modify_at")
private Long modifyAt;

@PrePersist
public void prePersist() {
long currentTimeMillis = System.currentTimeMillis();
this.createAt = currentTimeMillis;
this.modifyAt = currentTimeMillis;
}

@PreUpdate
public void preUpdate() {
this.modifyAt = System.currentTimeMillis();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.vacation.platform.stayfinder.terms.controller;


import com.vacation.platform.stayfinder.terms.dto.TermsDto;
import com.vacation.platform.stayfinder.terms.entity.Terms;
import com.vacation.platform.stayfinder.terms.service.TermsService;
import com.vacation.platform.stayfinder.terms.service.serviceImpl.TermsServiceImpl;
import com.vacation.platform.stayfinder.util.Result;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/terms_main")
public class TermsController {

private final TermsService termsService;

public TermsController(TermsServiceImpl termsService) {
this.termsService = termsService;
}

//처음에 약관 동의 하는 api 전송
//특정 고객이 약관 상세 보고 싶다면 해당 약관 sub 전송
//메인 동의 api 에서 응답으로 필수 동의를 전체 동의 한 경우에 휴대폰 인증으로 넘어감
@PostMapping("/getMain")
public Result<Terms> getMain() {
return termsService.getTermsMain();
}

@PostMapping("/terms_register")
public Result<?> termsRegistration(@Valid @RequestBody TermsDto termsDto) {
try {
return termsService.registerTerms(termsDto);
} catch(Exception e) {
e.printStackTrace();
}
return null;
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.vacation.platform.stayfinder.terms.dto;

import lombok.Data;

@Data
public class TermsDto {
private String mainTitle;
private String subTitle;
private String detailContent;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.vacation.platform.stayfinder.terms.entity;

import com.vacation.platform.stayfinder.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@ToString
@Entity(name = "Terms")
@NoArgsConstructor
@Data
@Table(name = "TERMS", uniqueConstraints = {@UniqueConstraint(
name = "termsId_mainTitle",
columnNames = {"terms_id", "terms_main_title"}
)})
@EqualsAndHashCode(callSuper = true)
public class Terms extends BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "terms_id", nullable = false)
private int termsId;

// 유니크 해야됨.
@Column(name = "terms_main_title", nullable = false, length = 100)
private String termsMainTile;

@Column(name = "is_terms_required", nullable = false, length = 20)
private String isTermsRequired;

@Column(name = "is_active", nullable = false, length = 1)
private boolean isActive;

@OneToMany(mappedBy = "termsMainId")
private List<TermsSub> subList = new ArrayList<>();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.vacation.platform.stayfinder.terms.entity;


import com.vacation.platform.stayfinder.common.BaseEntity;
import com.vacation.platform.stayfinder.user.entity.TermsSubId;
import jakarta.persistence.*;
import lombok.*;

@ToString
@Entity
@NoArgsConstructor
@Data
@Table
@EqualsAndHashCode(callSuper = true)
@IdClass(TermsSubId.class) // 복합 키 클래스 설정
public class TermsSub extends BaseEntity {

@Id
@ManyToOne
@JoinColumn(name = "terms_id")
private Terms termsMainId;

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "version", nullable = false)
private int version;

@Column(name = "terms_details_title", nullable = false, length = 100)
private String termsDetailsTitle;

@Column(name = "terms_details_content", nullable = false, length = 10000)
private String termsDetailsContent;

@Column(name = "is_active", nullable = false, length = 1)
private boolean isActive;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.vacation.platform.stayfinder.terms.repository;

import com.vacation.platform.stayfinder.terms.entity.Terms;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface TermsRepository extends JpaRepository<Terms, Long> {

List<Terms> findByTermsMainTile(String mainTitle);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.vacation.platform.stayfinder.terms.repository;

import com.vacation.platform.stayfinder.terms.entity.TermsSub;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface TermsSubRepository extends JpaRepository<TermsSub, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.vacation.platform.stayfinder.terms.service;

import com.vacation.platform.stayfinder.terms.dto.TermsDto;
import com.vacation.platform.stayfinder.terms.entity.Terms;
import com.vacation.platform.stayfinder.util.Result;
import org.springframework.stereotype.Service;

@Service
public interface TermsService {

public Result<Terms> getTermsMain();

public Result<?> registerTerms (TermsDto termsDto);

}
Loading
Loading