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

Feat/#54 사업자 정보 검증 및 사장 회원가입 api 구현 #56

Open
wants to merge 39 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9174063
#50 (dto) 카카오, 네이버 응답 및 oauth2 유저 정보 dto 추가
taeyeongKims Dec 28, 2024
ca80c04
#50 (handler) 카카오, 네이버 핸들러 및 인증 성공, 실패 핸들러 추가
taeyeongKims Dec 28, 2024
9218337
#50 (CookieUtils) 쿠키 Utils 추가
taeyeongKims Dec 28, 2024
809741a
#50 (CookieRepository) 쿠키 저장소 추가
taeyeongKims Dec 28, 2024
d055c42
#50 (Oauth2UserService) oauth2 유저 정보를 처리하는 service
taeyeongKims Dec 28, 2024
9362d8c
#50 (application.properties) 카카오, 네이버, 허용 uri 속성 추가
taeyeongKims Dec 28, 2024
77c0c90
#50 (build.gradle) oauth2 의존성 추가
taeyeongKims Dec 28, 2024
068fea4
#50 (SecurityConfig) oauth2 로그인 설정 추가
taeyeongKims Dec 28, 2024
7cd44f9
#50 (UserRole) 문자열을 객체로 매핑시켜주는 @JsonCreator 메서드 추가
taeyeongKims Dec 28, 2024
92cc766
#50 (UserDetail) oauth2 로그인과 일반 로그인의 authentication 양식을 통일
taeyeongKims Dec 28, 2024
aa89fa1
#50 (AuthController) println 삭제
taeyeongKims Dec 28, 2024
97e03af
#50 (AccountRepository) findByEmail 메소드 추가
taeyeongKims Dec 28, 2024
6d32d77
#50 (Accoutn) Account 생성자 추가(오버로딩)
taeyeongKims Dec 28, 2024
d37f600
#50 (ApiApplication) 필요 없는 줄바꿈 제거
taeyeongKims Dec 28, 2024
24de46f
#50 (SecurityConfig) 인증 에러 핸들링 추가
taeyeongKims Dec 28, 2024
4b79b00
#50 (Oauth2Properties) oauth2 속성 클래스 추가
taeyeongKims Dec 28, 2024
efdd606
#50 (ErrorCode) oauth2 관련 에러코드 추가
taeyeongKims Dec 28, 2024
c45fa80
Merge branch 'develop' into feat/#50
taeyeongKims Dec 28, 2024
777090c
#50 컨벤션 맞춰서 수정
taeyeongKims Dec 28, 2024
ff0ed38
Merge branch 'feat/#50' of https://github.com/danpatime/backend into …
taeyeongKims Dec 28, 2024
bf8b964
#50 @Validated 추가
taeyeongKims Dec 28, 2024
9b9461c
#50 Oauth2UserService 객체 테스트 검증 코드
taeyeongKims Dec 30, 2024
3b8ce6e
#50 Mockito, wireMock 의존성 추가
taeyeongKims Dec 30, 2024
9b50729
#50 충돌나는 공통 클래스 병합
taeyeongKims Dec 30, 2024
94b96c1
#54 (AccountController) 사업자 정보 검증, 사장 회원가입 api 구현
taeyeongKims Jan 3, 2025
66a9414
#54 (dto) 사업자 정보 검증 및 회원가입 dto 구현
taeyeongKims Jan 3, 2025
32d02b8
#54 (AccountController) 사업자 정보 검증, 사장 회원가입 api 구현
taeyeongKims Jan 3, 2025
026125a
#54 (Location) 사업장 위치(Location) 엔티티 생성
taeyeongKims Jan 3, 2025
b721238
#54 (Repository) AuthRepository를 AccountRepository로 병합 및 LocationRepo…
taeyeongKims Jan 3, 2025
05ce390
#54 (Service) 사업자 정보 검증 및 회원가입 서비스 구현
taeyeongKims Jan 3, 2025
ef99199
#54 (application.properties) 사업자 정보 검증 openApi 설정
taeyeongKims Jan 3, 2025
f33e523
#54 (RestTemplateConfig) RestTemplate 빈 등록
taeyeongKims Jan 3, 2025
4946c18
#54 (VendorProperties) 사업자 정보 검증 api 속성 클래스 생성
taeyeongKims Jan 3, 2025
f1cb561
#54 (ErrorCode) 유효하지 않은 사업자 정보 검증 결과 에러 코드 생성
taeyeongKims Jan 3, 2025
a235cdd
#54 Business 도메인 location을 String -> Location 타입 엔티티 변경으로 인한 수정
taeyeongKims Jan 3, 2025
646bebb
#54 컨벤션 수정
taeyeongKims Jan 3, 2025
076de6e
#54 (AccountServiceTest) 사업자 등록 정보 검증 및 중복 id 검증 테스트 코드 작성
taeyeongKims Jan 4, 2025
ab86724
merge develop
taeyeongKims Jan 6, 2025
8918881
.
taeyeongKims Jan 6, 2025
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
14 changes: 12 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'


// WEB SOCKET
implementation 'org.springframework.boot:spring-boot-starter-websocket'

Expand All @@ -42,6 +41,7 @@ dependencies {

// ENV
implementation 'me.paulschwarz:spring-dotenv:4.0.0'

// VALIDATION
implementation 'org.springframework.boot:spring-boot-starter-validation'

Expand All @@ -56,11 +56,21 @@ dependencies {
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'

// Query DSL
implementation 'com.querydsl:querydsl-jpa:5.0.0:jakarta'
annotationProcessor "com.querydsl:querydsl-apt:${dependencyManagement.importedProperties['querydsl.version']}:jakarta"
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

// OAUTH2
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// MOCKITO
testImplementation "org.mockito:mockito-core:3.+"

//WIREMOCK (외부 의존성 테스트용)
implementation 'org.wiremock.integrations:wiremock-spring-boot:3.3.0'

// 인메모리 몽고디비 flapdoodle
testImplementation 'de.flapdoodle.embed:de.flapdoodle.embed.mongo:4.6.0'
Expand Down Expand Up @@ -91,4 +101,4 @@ sourceSets {
srcDirs = ['src/test/java']
}
}
}
}
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ eval "set -- $(
tr '\n' ' '
)" '"$@"'

exec "$JAVACMD" "$@"
exec "$JAVACMD" "$@"
43 changes: 43 additions & 0 deletions src/main/generated/com/example/api/account/entity/QLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.example.api.account.entity;

import static com.querydsl.core.types.PathMetadataFactory.*;

import com.querydsl.core.types.dsl.*;

import com.querydsl.core.types.PathMetadata;
import javax.annotation.processing.Generated;
import com.querydsl.core.types.Path;


/**
* QLocation is a Querydsl query type for Location
*/
@Generated("com.querydsl.codegen.DefaultEntitySerializer")
public class QLocation extends EntityPathBase<Location> {

private static final long serialVersionUID = -590127238L;

public static final QLocation location = new QLocation("location");

public final StringPath address = createString("address");

public final StringPath detailAddress = createString("detailAddress");

public final NumberPath<Long> id = createNumber("id", Long.class);

public final StringPath zipcode = createString("zipcode");

public QLocation(String variable) {
super(Location.class, forVariable(variable));
}

public QLocation(Path<? extends Location> path) {
super(path.getType(), path.getMetadata());
}

public QLocation(PathMetadata metadata) {
super(Location.class, metadata);
}

}

3 changes: 2 additions & 1 deletion src/main/generated/com/example/api/domain/QBusiness.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class QBusiness extends EntityPathBase<Business> {

public final QAccount employer;

public final StringPath location = createString("location");
public final com.example.api.account.entity.QLocation location;

public final DatePath<java.time.LocalDate> openDate = createDate("openDate", java.time.LocalDate.class);

Expand Down Expand Up @@ -65,6 +65,7 @@ public QBusiness(PathMetadata metadata, PathInits inits) {
public QBusiness(Class<? extends Business> type, PathMetadata metadata, PathInits inits) {
super(type, metadata, inits);
this.employer = inits.isInitialized("employer") ? new QAccount(forProperty("employer")) : null;
this.location = inits.isInitialized("location") ? new com.example.api.account.entity.QLocation(forProperty("location")) : null;
}

}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/com/example/api/ApiApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
@SpringBootApplication
@EnableJpaAuditing
public class ApiApplication {

public static void main(String[] args) {

SpringApplication.run(ApiApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.example.api.account.controller;

import com.example.api.account.dto.EmailCodeRequest;
import com.example.api.account.dto.EmailRequest;
import com.example.api.account.dto.*;
import com.example.api.account.entity.Code;
import com.example.api.account.service.AccountService;
import com.example.api.account.dto.SignUpRequest;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;

@RestController
@RequestMapping("/api/v1/account")
@RequiredArgsConstructor
Expand All @@ -30,9 +31,21 @@ public ResponseEntity<String> verifyEmail(@Valid @RequestBody final EmailCodeReq
return ResponseEntity.ok(successMessage);
}

@PostMapping("/sign-up")
public ResponseEntity<String> signUp(@Valid @RequestBody final SignUpRequest request) {
String successMessage = signUpService.signUp(request);
@PostMapping("/sign-up/employee")
public ResponseEntity<String> signUpEmployee(@Valid @RequestBody final SignUpEmployeeRequest request) {
String successMessage = signUpService.signUpEmployee(request);
return ResponseEntity.status(HttpStatus.CREATED).body(successMessage);
}

@PostMapping("/validation/business-number")
public ResponseEntity<String> verifyBusinessNumber(@Valid @RequestBody final BusinessNumberRequest request) {
String successMessage = signUpService.verifyBusinessNumber(request);
return ResponseEntity.ok(successMessage);
}

@PostMapping("/sign-up/employer")
public ResponseEntity<String> signUpEmployer(@Valid @RequestBody final SignUpEmployerRequest request) {
String successMessage = signUpService.signUpEmployer(request);
return ResponseEntity.status(HttpStatus.CREATED).body(successMessage);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.example.api.account.dto;

import jakarta.validation.constraints.NotBlank;

public record BusinessNumberRequest(
@NotBlank
String businessRegistrationNumber,
@NotBlank
String businessName,
@NotBlank
String representationName,
@NotBlank
String businessOpenDate) {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.example.api.account.dto;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.List;


public record BusinessNumberResponse(
@JsonProperty("request_cnt") int requestCount,
@JsonProperty("valid_cnt") int validCount,
@JsonProperty("status_code") String statusCode,
List<Data> data
) {
private record Data(
@JsonProperty("b_no") String businessNumber,
String valid,
@JsonProperty("request_param") RequestParam requestParam,
Status status
) {
}
private record RequestParam(
@JsonProperty("b_no") String businessNumber,
@JsonProperty("start_dt") String startDate,
@JsonProperty("p_nm") String name,
@JsonProperty("b_nm") String businessName
) {
}
private record Status(
@JsonProperty("b_no") String businessNumber,
@JsonProperty("b_stt") String businessStatus,
@JsonProperty("b_stt_cd") String businessStatusCode,
@JsonProperty("tax_type") String taxType,
@JsonProperty("tax_type_cd") String taxTypeCode,
@JsonProperty("end_dt") String endDate,
@JsonProperty("utcc_yn") String utccYn,
@JsonProperty("tax_type_change_dt") String taxTypeChangeDate,
@JsonProperty("invoice_apply_dt") String invoiceApplyDate,
@JsonProperty("rbf_tax_type") String rbfTaxType,
@JsonProperty("rbf_tax_type_cd") String rbfTaxTypeCode
) {
}

public String getValid(){
return data.get(0).valid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import com.example.api.account.entity.Nationality;
import com.example.api.account.entity.UserRole;
import com.example.api.global.config.resolver.ValidEmail;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

public record SignUpRequest(
public record SignUpEmployeeRequest(
@NotBlank
String loginId,
@NotBlank
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.api.account.dto;

import com.example.api.account.entity.Location;
import com.example.api.account.entity.Nationality;
import com.example.api.account.entity.UserRole;
import com.example.api.global.config.resolver.ValidEmail;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;

public record SignUpEmployerRequest(
@NotBlank
String loginId, // 로그인 id
@NotBlank
String password, // 비밀번호
@ValidEmail
String email, // 이메일
@NotBlank
String businessRegistrationNumber, // 사업자 번호
@NotBlank
String businessName, // 회사명
@NotBlank
String representationName, // 대표명
@NotBlank
String businessOpenDate, // 개업연월일
@NotNull
Location location,
@NotNull
Nationality nationality, // 국적
@NotNull
UserRole role, // 권한
@NotBlank
String phoneNumber // 휴대폰 번호
) {
}
28 changes: 28 additions & 0 deletions src/main/java/com/example/api/account/entity/Location.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.example.api.account.entity;

import jakarta.persistence.*;
import lombok.Getter;

@Entity
@Getter
public class Location {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "LOCATION_UNIQUE_ID")
private Long id;
@Column(name = "LOCATION_ZIPCODE")
private String zipcode;
@Column(name = "LOCATION_ADDRESS")
private String address;
@Column(name = "LOCATION_DETAIL_ADDRESS")
private String detailAddress;

public Location() {
}

public Location(String zipcode, String address, String detailAddress) {
this.zipcode = zipcode;
this.address = address;
this.detailAddress = detailAddress;
}
}
17 changes: 16 additions & 1 deletion src/main/java/com/example/api/account/entity/UserRole.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package com.example.api.account.entity;

public enum UserRole {
import com.example.api.exception.BusinessException;
import com.example.api.exception.ErrorCode;
import com.fasterxml.jackson.annotation.JsonCreator;
import org.springframework.security.core.GrantedAuthority;

public enum UserRole implements GrantedAuthority {
EMPLOYEE(0, "알바생"),
EMPLOYER(1, "사장");

Expand All @@ -21,6 +26,16 @@ public static UserRole of(final Integer code) {
return null;
}

@JsonCreator
public static UserRole from(String value) {
for (UserRole role : values()) {
if (role.name().equalsIgnoreCase(value)) {
return role;
}
}
throw new BusinessException(ErrorCode.INCORRECT_DATA);
}

public Integer getCode() {
return code;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.example.api.account.repository;

import com.example.api.domain.Account;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.Optional;

public interface AccountRepository extends JpaRepository<Account, Long> {
boolean existsByLoginId(String loginId);

boolean existsByEmail(String email);

@EntityGraph(attributePaths = "roles")
Optional<Account> findByEmail(String email);

Optional<Account> findUserByLoginId(String loginId);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.example.api.account.repository;

import com.example.api.account.entity.Location;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

@Repository
public interface LocationRepository extends JpaRepository<Location, Long> {
}
Loading