Skip to content

Commit

Permalink
Merge branch 'main' into booking/230
Browse files Browse the repository at this point in the history
  • Loading branch information
byulcode committed Jan 12, 2024
2 parents 2bba500 + b2a9962 commit e219559
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 119 deletions.
28 changes: 21 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,46 @@
## Bingterpark

[노션 페이지](https://www.notion.so/backend-devcourse/2-BingterPark-4ecfb3943d9c4a8f9bb83f72876b6a80)
[ERD](https://www.erdcloud.com/d/ZadArGCaQXFcxZuu8)

### 모듈 구조

![img.png](img.png)

#### api

- api-member
회원 도메인
회원 도메인
- api-event
공연 도메인
공연 도메인
- api-booking
예매 도메인
예매 도메인

#### batch

스프링 배치 모듈

#### core

- core-domain
JPA 엔티티, 리포지토리
JPA 엔티티, 리포지토리
- core-infra
queryDsl, RDB 설정 파일
queryDsl, RDB 설정 파일
- core-infra-es
elastic search 설정 파일, document, searchRepository
elastic search 설정 파일, document, searchRepository
- core-security
spring security 설정 파일
spring security 설정 파일

## 실행 방법

1. git clone
2. RDB, 레디스 실행 ```docker-compose up -d```
3. api-event 모듈로 이동 ```cd /api/api-event```
4. 엘라스틱 서치 도커 이미지 빌드 ```docker build -t el:0.1 -f ./Dockerfile .```
5. ELK 스택 실행 ```docker-compose up -d```
6. api-booking, api-event, api-member 각 모듈에서 스프링 어플리케이션 실행

## 테스트 방법

- 통합 http 테스트는 /http/bingterpark.http에 있습니다.
- 어드민 플로우, 유저 플로우 http 코드를 위에서부터 하나씩 실행하시면 됩니다.
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,40 @@
import com.pgms.coredomain.response.ApiResponse;
import com.pgms.coresecurity.security.resolver.CurrentAccount;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@Tag(name = "관리자", description = "관리자 관련 API 입니다.")
@RestController
@RequestMapping("/api/v1/admin")
@RequiredArgsConstructor
public class AdminController {

private final AdminService adminService;

@Operation(summary = "회원 목록 조회", description = "회원 목록 조회 API 입니다.")
@GetMapping("/members")
public ResponseEntity<ApiResponse<List<MemberSummaryGetResponse>>> getMembers(
@ModelAttribute @Valid PageCondition pageCondition) {
return ResponseEntity.ok(ApiResponse.ok(adminService.getMembers(pageCondition)));
}

@Operation(summary = "회원 상세 조회", description = "회원 상세 조회 API 입니다.")
@GetMapping("/members/details")
public ResponseEntity<ApiResponse<List<MemberDetailGetResponse>>> getMemberDetails(
@RequestParam List<Long> memberIds) {
return ResponseEntity.ok(ApiResponse.ok(adminService.getMemberDetails(memberIds)));
}

@Operation(summary = "관리자 본인 정보 조회", description = "관리자 본인 정보 조회 API 입니다.")
@GetMapping("/me")
public ResponseEntity<ApiResponse<AdminGetResponse>> getMyInfo(@CurrentAccount Long adminId) {
return ResponseEntity.ok(ApiResponse.ok(adminService.getAdmin(adminId)));
}

@Operation(summary = "관리자 본인 삭제", description = "관리자 본인 삭제 API 입니다.")
@DeleteMapping("/me")
public ResponseEntity<ApiResponse<Void>> deleteMyAccount(@CurrentAccount Long adminId) {
adminService.deleteAdmins(Collections.singletonList(adminId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@
import com.pgms.apimember.service.AdminService;
import com.pgms.coredomain.response.ApiResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;

@Tag(name = "슈퍼관리자", description = "슈퍼관리자 관련 API 입니다.")
@RestController
@RequestMapping("/api/v1/admin/management")
@RequiredArgsConstructor
Expand All @@ -38,6 +41,7 @@ public class AdminManagementController { // 슈퍼관리자 전용 컨트롤러
* 관리자 CRUD
*/

@Operation(summary = "관리자 생성", description = "관리자 생성 API 입니다.")
@PostMapping
public ResponseEntity<ApiResponse<Long>> createAdmin(@RequestBody @Valid AdminCreateRequest requestDto) {
final Long adminId = adminService.createAdmin(requestDto);
Expand All @@ -47,12 +51,14 @@ public ResponseEntity<ApiResponse<Long>> createAdmin(@RequestBody @Valid AdminCr
return ResponseEntity.created(uri).body(ApiResponse.created(adminId));
}

@Operation(summary = "관리자 목록 조회", description = "관리자 목록 조회 API 입니다.")
@GetMapping
public ResponseEntity<ApiResponse<List<AdminGetResponse>>> getAdmins(
@ModelAttribute @Valid PageCondition pageCondition) {
return ResponseEntity.ok(ApiResponse.ok(adminService.getAdmins(pageCondition)));
}

@Operation(summary = "관리자 수정", description = "관리자 수정 API 입니다.")
@PatchMapping("/{adminId}")
public ResponseEntity<ApiResponse<Void>> updateAdmin(
@PathVariable Long adminId,
Expand All @@ -61,6 +67,7 @@ public ResponseEntity<ApiResponse<Void>> updateAdmin(
return ResponseEntity.noContent().build();
}

@Operation(summary = "관리자 삭제", description = "관리자 삭제 API 입니다.")
@DeleteMapping
public ResponseEntity<ApiResponse<Void>> deleteAdmins(@RequestParam List<Long> adminIds) {
adminService.deleteAdmins(adminIds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import com.pgms.coredomain.domain.member.enums.Role;
import com.pgms.coredomain.response.ApiResponse;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@Tag(name = "인증", description = "인증 관련 API 입니다.")
@RestController
@RequestMapping("/api/v1/auth")
@RequiredArgsConstructor
Expand All @@ -26,22 +29,24 @@ public class AuthController {
/**
* 로그인
*/
@Operation(summary = "관리자 로그인", description = "관리자 로그인 API 입니다.")
@PostMapping("/admin/login")
public ResponseEntity<ApiResponse<AuthResponse>> adminLogin(@Valid @RequestBody LoginRequest request) {
AuthResponse response = authService.login(request, Role.ROLE_ADMIN);
return ResponseEntity.ok(ApiResponse.ok(response));
}

@Operation(summary = "회원 로그인", description = "회원 로그인 API 입니다.")
@PostMapping("/members/login")
public ResponseEntity<ApiResponse<AuthResponse>> memberLogin(@Valid @RequestBody LoginRequest request) {
// TODO: 나중에 enum으로..?
AuthResponse response = authService.login(request, Role.ROLE_USER);
return ResponseEntity.ok(ApiResponse.ok(response));
}

/**
* 토큰 재발급
*/
@Operation(summary = "토큰 재발급", description = "토큰 재발급 API 입니다.")
@PostMapping("/refresh")
public ResponseEntity<ApiResponse<AuthResponse>> refresh(@RequestBody RefreshTokenRequest request) {
AuthResponse response = authService.refresh(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@
import com.pgms.coredomain.response.ApiResponse;
import com.pgms.coresecurity.security.resolver.CurrentAccount;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@Tag(name = "회원", description = "회원 관련 API 입니다.")
@RestController
@RequestMapping("/api/v1/members")
@RequiredArgsConstructor
public class MemberController {

private final MemberService memberService;

@Operation(summary = "회원가입", description = "회원가입 API 입니다.")
@PostMapping("/signup")
public ResponseEntity<ApiResponse<Long>> signUp(@RequestBody @Valid MemberSignUpRequest requestDto) {
return ResponseEntity.ok(ApiResponse.ok(memberService.signUp(requestDto)));
}

@Operation(summary = "회원 정보 조회", description = "회원 정보 조회 API 입니다.")
@GetMapping("/me")
public ResponseEntity<ApiResponse<MemberDetailGetResponse>> getMyInfo(@CurrentAccount Long memberId) {
return ResponseEntity.ok(ApiResponse.ok(memberService.getMemberDetail(memberId)));
}

@Operation(summary = "회원 수정", description = "회원 수정 API 입니다.")
@PatchMapping("/me")
public ResponseEntity<Void> updateMyInfo(
@CurrentAccount Long memberId,
Expand All @@ -48,6 +54,7 @@ public ResponseEntity<Void> updateMyInfo(
return ResponseEntity.noContent().build();
}

@Operation(summary = "비밀번호 수정", description = "비밀번호 수정 API 입니다.")
@PatchMapping("/me/password")
public ResponseEntity<Void> updatePassword(
@CurrentAccount Long memberId,
Expand All @@ -56,25 +63,29 @@ public ResponseEntity<Void> updatePassword(
return ResponseEntity.noContent().build();
}

@Operation(summary = "비밀번호 확인", description = "비밀번호 확인 API 입니다.")
@PostMapping("/me/verify-password")
public ResponseEntity<Void> verifyPassword(@CurrentAccount Long memberId,
@RequestBody MemberPasswordVerifyRequest requestDto) {
memberService.verifyPassword(memberId, requestDto.password());
return ResponseEntity.noContent().build();
}

@Operation(summary = "회원 탈퇴", description = "회원 탈퇴 API 입니다.")
@DeleteMapping("/me")
public ResponseEntity<ApiResponse<Void>> deleteMyAccount(@CurrentAccount Long memberId) {
memberService.deleteMember(memberId);
return ResponseEntity.noContent().build();
}

@PostMapping("send-restore-email")
@Operation(summary = "휴면 해제 메일 전송", description = "휴면 해제 메일 전송 API 입니다.")
@PostMapping("/send-restore-email")
public ResponseEntity<ApiResponse<String>> sendRestoreEmail(@RequestBody @Valid MemberRestoreRequest requestDto) {
memberService.sendRestoreEmail(requestDto);
return ResponseEntity.noContent().build();
}

@Operation(summary = "휴면 해제 본인 인증", description = "휴면 해제 본인 인증 API 입니다.")
@PatchMapping("/confirm-restore")
public ResponseEntity<ApiResponse<Void>> confirmRestore(@RequestBody @Valid ConfirmRestoreRequest requestDto) {
memberService.confirmRestoreMember(requestDto);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,49 +1,62 @@
package com.pgms.coredomain.domain.event;

import com.pgms.coredomain.domain.common.BaseEntity;
import jakarta.persistence.*;
import lombok.*;

import java.util.ArrayList;
import java.util.List;

import com.pgms.coredomain.domain.common.BaseEntity;

import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.OneToMany;
import jakarta.persistence.Table;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Entity
@Getter
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Table(name = "event_hall")
public class EventHall extends BaseEntity {

@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "event_name")
private String name;

@Column(name = "address")
private String address;

@OneToMany(mappedBy = "eventHall", cascade = CascadeType.ALL, orphanRemoval = true)
private List<EventHallSeat> eventHallSeats = new ArrayList<>();

@Builder
public EventHall(String name, String address, List<EventHallSeat> eventHallSeats) {
this.name = name;
this.address = address;
this.eventHallSeats = eventHallSeats;
setEventHallSeatsEventHall();
}

public void setEventHallSeatsEventHall(){
if(this.eventHallSeats == null) return;
this.eventHallSeats.forEach(eventHallSeat -> eventHallSeat.setEventHall(this));
}

public void updateEventHall(EventHallEdit eventHallEdit){
this.name = eventHallEdit.getName();
this.address = eventHallEdit.getAddress();
this.eventHallSeats = eventHallEdit.getEventHallSeats();
}
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

@Column(name = "name")
private String name;

@Column(name = "address")
private String address;

@OneToMany(mappedBy = "eventHall", cascade = CascadeType.ALL, orphanRemoval = true)
private List<EventHallSeat> eventHallSeats = new ArrayList<>();

@Builder
public EventHall(String name, String address, List<EventHallSeat> eventHallSeats) {
this.name = name;
this.address = address;
this.eventHallSeats = eventHallSeats;
setEventHallSeatsEventHall();
}

public void setEventHallSeatsEventHall() {
if (this.eventHallSeats == null)
return;
this.eventHallSeats.forEach(eventHallSeat -> eventHallSeat.setEventHall(this));
}

public void updateEventHall(EventHallEdit eventHallEdit) {
this.name = eventHallEdit.getName();
this.address = eventHallEdit.getAddress();
this.eventHallSeats = eventHallEdit.getEventHallSeats();
}
}
6 changes: 5 additions & 1 deletion core/core-infra/src/main/resources/application-infra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spring:
on-profile: prod
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8
url: jdbc:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8c:mysql://localhost:3307/bingterpark?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul&characterEncoding=UTF-8
username: root
password: root1234!
jpa:
Expand All @@ -42,3 +42,7 @@ spring:
sql:
init:
mode: never

logging:
level:
org.hibernate.SQL: INFO
5 changes: 3 additions & 2 deletions core/core-infra/src/main/resources/data.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- EventHall
INSERT INTO event_hall (event_name, address)
INSERT INTO event_hall (name, address)
VALUES ('고척스카이돔', '서울 구로구 경인로 430');

-- Event
Expand Down Expand Up @@ -95,7 +95,8 @@ INSERT INTO payment (booking_id,
approved_at,
created_at,
updated_at)
VALUES ('bookingTestId', 180000, 'CARD', 'HYUNDAI', '11111111****111*', 0, false, 'paymentkey', 'CANCELED', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
VALUES ('bookingTestId', 180000, 'CARD', 'HYUNDAI', '11111111****111*', 0, false, 'paymentkey', 'CANCELED',
CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);

-- Booking Cancel
INSERT INTO booking_cancel (booking_id, amount, reason, created_by, created_at, updated_at)
Expand Down
Loading

0 comments on commit e219559

Please sign in to comment.