Skip to content

Commit

Permalink
kahluaband#9 Chore: merge conflict in error status
Browse files Browse the repository at this point in the history
  • Loading branch information
kjiyun committed Aug 1, 2024
2 parents 8e95e79 + d5d21a8 commit ce7621a
Show file tree
Hide file tree
Showing 20 changed files with 199 additions and 136 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ public enum ErrorStatus implements BaseCode {

// 티켓 에러
TICKET_NOT_FOUND(HttpStatus.NOT_FOUND, "TICKET NOT FOUND", "티켓을 찾을 수 없습니다."),
ALREADY_EXIST_STUDENTID(HttpStatus.BAD_REQUEST, "ALREADY EXIST STUDENT_ID", "이미 존재하는 학번입니다.");
TICKET_COLUMN_INVALID(HttpStatus.BAD_REQUEST, "TICKET COLUMN INVALID", "올바르지 않은 티켓 속성입니다."),
ALREADY_EXIST_STUDENT_ID(HttpStatus.BAD_REQUEST, "ALREADY EXIST STUDENT_ID", "이미 존재하는 학번입니다."),

//지원하기 에러
ALREADY_EXIST_APPLICANT(HttpStatus.BAD_REQUEST, "ALREADY EXIST APPLICANT", "이미 존재하는 지원자입니다."),
APPLICANT_NOT_FOUND(HttpStatus.NOT_FOUND, "APPLICANT NOT FOUND", "존지해지 않는 지원자입니다.");

private final HttpStatus httpStatus;
private final String code;
Expand Down
88 changes: 0 additions & 88 deletions src/main/java/kahlua/KahluaProject/controller/AdminController.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package kahlua.KahluaProject.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import kahlua.KahluaProject.apipayload.ApiResponse;
import kahlua.KahluaProject.dto.apply.request.ApplyCreateRequest;
import kahlua.KahluaProject.dto.apply.response.ApplyCreateResponse;
Expand All @@ -8,6 +10,7 @@
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Tag(name = "지원하기", description = "지원하기 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/apply")
Expand All @@ -16,14 +19,14 @@ public class ApplyController {
private final ApplyService applyService;

@PostMapping
public ApiResponse<ApplyCreateResponse> createApplyFrom(@RequestBody ApplyCreateRequest applyCreateRequest) {
ApplyCreateResponse applyCreateResponse = applyService.createApply(applyCreateRequest);
return ApiResponse.onSuccess(applyCreateResponse);
@Operation(summary = "지원자 생성", description = "지원서 양식에 맞추어 지원자를 생성합니다")
public ApiResponse<ApplyCreateResponse> createApplicant(@RequestBody ApplyCreateRequest applyCreateRequest) {
return ApiResponse.onSuccess(applyService.createApply(applyCreateRequest));
}

@GetMapping("/{applyId}")
public ApiResponse<ApplyGetResponse> viewApplyForm(@PathVariable Long applyId) {
ApplyGetResponse applyGetResponse = applyService.getApply(applyId);
return ApiResponse.onSuccess(applyGetResponse);
@Operation(summary = "지원자 조회", description = "지원 폼 아이디를 통해 지원자를 조회합니다")
public ApiResponse<ApplyGetResponse> getApplicant(@PathVariable Long applyId) {
return ApiResponse.onSuccess(applyService.getApply(applyId));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package kahlua.KahluaProject.controller.adminController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import kahlua.KahluaProject.apipayload.ApiResponse;
import kahlua.KahluaProject.apipayload.code.status.ErrorStatus;
import kahlua.KahluaProject.domain.apply.Preference;
import kahlua.KahluaProject.domain.user.UserType;
import kahlua.KahluaProject.dto.apply.response.ApplyGetResponse;
import kahlua.KahluaProject.dto.apply.response.ApplyListResponse;
import kahlua.KahluaProject.exception.GeneralException;
import kahlua.KahluaProject.security.AuthDetails;
import kahlua.KahluaProject.service.ApplyService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Tag(name = "관리자(지원하기)", description = "관리자(지원하기) 페이지 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/apply")
public class AdminApplyController {

private final ApplyService applyService;

@GetMapping("/all")
@Operation(summary = "지원자 리스트 조회", description = "id 기준으로 정렬된 지원자 리스트를 조회합니다")
public ApiResponse<ApplyListResponse> getApplyList(@AuthenticationPrincipal AuthDetails authDetails) {
ApplyListResponse applyListResponse = applyService.getApplyList(authDetails.user());
return ApiResponse.onSuccess(applyListResponse);
}

@GetMapping("/{applyId}")
@Operation(summary = "지원자 상세정보 조회", description = "지원자 상세정보를 조회합니다")
public ApiResponse<ApplyGetResponse> getApplyDetail(@PathVariable Long applyId, @AuthenticationPrincipal AuthDetails authDetails) {
if(authDetails.getUser().getUserType() != UserType.ADMIN){
throw new GeneralException(ErrorStatus.UNAUTHORIZED);
}
ApplyGetResponse applyGetResponse = applyService.getApply(applyId);
return ApiResponse.onSuccess(applyGetResponse);
}

@GetMapping
@Operation(summary = "지원자 리스트 세션별 조회", description = "1지망 -> 2지망 악기 순서로 정렬된 지원자 리스트를 조회합니다")
public ApiResponse<ApplyListResponse> getApplyListByPreference(@AuthenticationPrincipal AuthDetails authDetails, @RequestParam(name = "preference") Preference preference) {
ApplyListResponse applyListResponse = applyService.getApplyListByPreference(authDetails.user(), preference);
return ApiResponse.onSuccess(applyListResponse);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package kahlua.KahluaProject.controller.adminController;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import kahlua.KahluaProject.apipayload.ApiResponse;
import kahlua.KahluaProject.dto.ticket.response.TicketListResponse;
import kahlua.KahluaProject.dto.ticket.response.TicketUpdateResponse;
import kahlua.KahluaProject.security.AuthDetails;
import kahlua.KahluaProject.service.TicketService;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

@Tag(name = "관리자(예매하기)", description = "관리자(예매하기) 페이지 관련 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/tickets")
public class AdminTicketController {

private final TicketService ticketService;

@GetMapping
@Operation(summary = "전체 티켓 리스트 조회", description = "sort-by에 정의된 티켓 속성 기준으로 정렬된 전체 티켓 리스트를 조회합니다 </br> sort-by를 쿼리에 포함시키지 않은 경우 최신순으로 정렬합니다")
public ApiResponse<TicketListResponse> getTicketList(@AuthenticationPrincipal AuthDetails authDetails,
@RequestParam(name = "sort-by", required = false) String sortBy) {
TicketListResponse ticketListResponse = ticketService.getTicketList(authDetails.user(), sortBy);
return ApiResponse.onSuccess(ticketListResponse);
}

@GetMapping("/general")
@Operation(summary = "일반 티켓 리스트 조회", description = "sort-by에 정의된 티켓 속성 기준으로 정렬된 일반 티켓 리스트를 조회합니다 </br> sort-by를 쿼리에 포함시키지 않은 경우 최신순으로 정렬합니다")
public ApiResponse<TicketListResponse> getGeneralTicketList(@AuthenticationPrincipal AuthDetails authDetails,
@RequestParam(name = "sort-by", required = false) String sortBy) {
TicketListResponse ticketListResponse = ticketService.getGeneralTicketList(authDetails.user(), sortBy);
return ApiResponse.onSuccess(ticketListResponse);
}

@GetMapping("/freshman")
@Operation(summary = "신입생 티켓 리스트 조회", description = "sort-by에 정의된 티켓 속성 기준으로 정렬된 신입생 티켓 리스트를 조회합니다 </br> sort-by를 쿼리에 포함시키지 않은 경우 최신순으로 정렬합니다")
public ApiResponse<TicketListResponse> getFreshmanTicketList(@AuthenticationPrincipal AuthDetails authDetails,
@RequestParam(name = "sort-by", required = false) String sortBy) {
TicketListResponse ticketListResponse = ticketService.getFreshmanTicketList(authDetails.user(), sortBy);
return ApiResponse.onSuccess(ticketListResponse);
}

@PatchMapping("/{ticketId}/ticket-complete")
@Operation(summary = "티켓 결제 완료", description = "티켓 결제를 완료한 뒤 어드민 페이지에서 결제 완료를 클릭하는 경우 결제 완료로 상태가 변합니다.")
public ApiResponse<TicketUpdateResponse> completePaymentForm(@PathVariable(name = "ticketId") Long ticketId, @AuthenticationPrincipal AuthDetails authDetails) {
TicketUpdateResponse ticketUpdateResponse = ticketService.completePayment(authDetails.user(), ticketId);
return ApiResponse.onSuccess(ticketUpdateResponse);
}

@PatchMapping("/{ticketId}/cancel-complete")
@Operation(summary = "티켓 취소 완료", description = "티켓 환불을 완료한 뒤 어드민 페이지에서 취소 완료를 클릭하는 경우 취소가 완료로 상태가 변합니다.")
public ApiResponse<TicketUpdateResponse> completeCancelForm(@PathVariable(name = "ticketId") Long ticketId, @AuthenticationPrincipal AuthDetails authDetails) {
TicketUpdateResponse ticketUpdateResponse = ticketService.completeCancelTicket(authDetails.user(), ticketId);
return ApiResponse.onSuccess(ticketUpdateResponse);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ApplyConverter {
public static Apply toApply(ApplyCreateRequest applyCreateRequest) {
return Apply.builder()
.name(applyCreateRequest.getName())
.phone_num(applyCreateRequest.getPhone_num())
.phoneNum(applyCreateRequest.getPhone_num())
.birth_date(applyCreateRequest.getBirth_date())
.gender(applyCreateRequest.getGender())
.address(applyCreateRequest.getAddress())
Expand All @@ -30,7 +30,7 @@ public static ApplyCreateResponse toApplyCreateResponse(Apply apply) {
return ApplyCreateResponse.builder()
.id(apply.getId())
.name(apply.getName())
.phone_num(apply.getPhone_num())
.phone_num(apply.getPhoneNum())
.birth_date(apply.getBirth_date())
.gender(apply.getGender())
.address(apply.getAddress())
Expand All @@ -50,7 +50,7 @@ public static ApplyGetResponse toApplyGetResponse(Apply apply) {
return ApplyGetResponse.builder()
.id(apply.getId())
.name(apply.getName())
.phone_num(apply.getPhone_num())
.phone_num(apply.getPhoneNum())
.birth_date(apply.getBirth_date())
.gender(apply.getGender())
.address(apply.getAddress())
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/kahlua/KahluaProject/domain/BaseEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@ public class BaseEntity {

@Column(name = "deleted_at", columnDefinition = "TIMESTAMP")
private LocalDateTime deletedAt;

public void deletedTime() {
this.deletedAt = LocalDateTime.now();
}
}
8 changes: 5 additions & 3 deletions src/main/java/kahlua/KahluaProject/domain/apply/Apply.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class Apply extends BaseEntity{

private String name;

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

private String birth_date;

Expand All @@ -30,13 +31,14 @@ public class Apply extends BaseEntity{

private String address;

@Enumerated(EnumType.STRING)
private Major major;
private String major;

@Enumerated(EnumType.STRING)
@Column(name = "first_preference")
private Preference firstPreference;

@Enumerated(EnumType.STRING)
@Column(name = "second_preference")
private Preference secondPreference;

private String experience_and_reason;
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/kahlua/KahluaProject/domain/apply/Major.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import jakarta.persistence.*;
import kahlua.KahluaProject.domain.BaseEntity;
import lombok.*;
import org.hibernate.annotations.SQLDelete;

import static kahlua.KahluaProject.domain.ticket.Type.FRESHMAN;
import static kahlua.KahluaProject.domain.ticket.Type.GENERAL;
Expand Down Expand Up @@ -61,6 +62,5 @@ public void requestCancelTicket() {

public void completeCancel() {
this.status = Status.CANCEL_COMPLETE;
deletedTime();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Getter
@Entity
@SQLDelete(sql = "UPDATE credentials SET deleted_at = NOW() where id = ?")
@SQLDelete(sql = "UPDATE credential SET deleted_at = NOW() where id = ?")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Schema(hidden = true)
public class Credential extends BaseEntity {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kahlua/KahluaProject/domain/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@Entity
@Getter
@SQLDelete(sql = "UPDATE credentials SET deleted_at = NOW() where id = ?")
@SQLDelete(sql = "UPDATE user SET deleted_at = NOW() where id = ?")
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class User extends BaseEntity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import kahlua.KahluaProject.domain.apply.Gender;
import kahlua.KahluaProject.domain.apply.Major;
import kahlua.KahluaProject.domain.apply.Preference;
import lombok.AllArgsConstructor;
import lombok.Getter;
Expand All @@ -21,7 +20,7 @@ public class ApplyCreateRequest {

private String address;

private Major major;
private String major;

private Preference first_preference;
private Preference second_preference;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package kahlua.KahluaProject.dto.apply.response;

import kahlua.KahluaProject.domain.apply.Gender;
import kahlua.KahluaProject.domain.apply.Major;
import kahlua.KahluaProject.domain.apply.Preference;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -21,7 +20,7 @@ public class ApplyCreateResponse {

private String address;

private Major major;
private String major;

private Preference first_preference;
private Preference second_preference;
Expand Down
Loading

0 comments on commit ce7621a

Please sign in to comment.