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

어드민 기능 인덱스 에러 수정 및 선착순 기능 일부 구현 #106

Merged
merged 30 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
9f750f5
[Infra] CI/CD test (#42)
DrRivaski Aug 6, 2024
8f792e8
[Infra] CI CD test 3 (#45)
DrRivaski Aug 6, 2024
4f40a66
config: jwt 속성을 yml에 설정
Jul 29, 2024
e8a25d1
rebase: 원본 develop 브랜치와 병합
Jul 30, 2024
94e1b7d
feat: FcfsException 클래스 구현
Aug 14, 2024
ec58881
feat: Fcfs 퀴즈 화면 응답 dto 구현
Aug 14, 2024
42803ab
feat: 선착순 페이지 접근을 관리하는 인터셉터 구현
Aug 14, 2024
969de49
feat: 선착순 퀴즈 entity 클래스 구현
Aug 14, 2024
f277cf2
feat: 선착순 퀴즈 dto 클래스 구현
Aug 14, 2024
d467add
feat: 선착순 퀴즈 repository 클래스 구현
Aug 14, 2024
a7795fe
feat: 인터셉터 등록
Aug 14, 2024
8b85a48
feat: 선착순 정적 텍스트 등록
Aug 14, 2024
b716101
feat: 선착순 동적 텍스트 바인딩
Aug 14, 2024
b474a1b
feat: swagger에서 파라미터가 보이지 않도록 설정
Aug 14, 2024
be7ee25
refactor: 이벤트 지표 응답 dto 수정
Aug 14, 2024
e64b63e
refactor: 사용하지 않는 메서드 삭제
Aug 14, 2024
0481475
chore: 임시로 주석처리
Aug 14, 2024
4d70797
feat: 선착순 컨트롤러 메서드 구현
Aug 14, 2024
ebdc138
refactor: 패키지 변경
Aug 14, 2024
bf66395
feat: 선착순 당첨 실패 응답 dto에 필드 추가
Aug 14, 2024
d178d58
chore: import문 삭제
Aug 14, 2024
5d65bc3
feat: 선착순 퀴즈 페이지 정보를 제공하는 메서드 구현
Aug 14, 2024
4f8db21
feat: 선착순 설정 매니저에서 메서드 추가
Aug 14, 2024
cdd1976
refactor: 사용하지 않는 메서드 삭제
Aug 14, 2024
efb3c24
feat: 선착순 당첨 응답 dto에 필드 추가
Aug 14, 2024
21972fc
refactor: json format에서 시간값 형식 변경
Aug 14, 2024
1a72867
feat: 메인 페이지 응답 dto에 선착순 힌트 필드 추가
Aug 14, 2024
d21eca6
feat: 메서드에 파라미터 추가
Aug 14, 2024
912959a
feat: 이벤트 페이지에 선착순 힌트를 설정
Aug 14, 2024
dbcaebf
Merge branch 'develop' into feature/91
hyeokson Aug 14, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.softeer.backend.global.annotation.AuthInfo;
import com.softeer.backend.global.common.dto.JwtTokenResponseDto;
import com.softeer.backend.global.common.response.ResponseDto;
import io.swagger.v3.oas.annotations.Parameter;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -28,7 +29,7 @@ ResponseDto<JwtTokenResponseDto> handleLogin(@Valid @RequestBody AdminLoginReque
}

@PostMapping("/logout")
ResponseDto<Void> handleLogout(@AuthInfo Integer adminId) {
ResponseDto<Void> handleLogout(@Parameter(hidden = true) @AuthInfo Integer adminId) {
adminLoginService.handleLogout(adminId);

return ResponseDto.onSuccess();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.softeer.backend.bo_domain.admin.serializer.PercentageSerializer;
import com.softeer.backend.bo_domain.admin.serializer.PhoneNumberSerializer;
import com.softeer.backend.bo_domain.eventparticipation.domain.EventParticipation;
import com.softeer.backend.fo_domain.draw.service.DrawSettingManager;
import lombok.*;

import java.time.LocalDate;
Expand Down Expand Up @@ -48,9 +49,9 @@ public static class VisitorNum {
private int visitorNum;
}

public static EventIndicatorResponseDto of(List<EventParticipation> eventParticipationList) {
LocalDate startDate = eventParticipationList.get(0).getEventDate();
LocalDate endDate = eventParticipationList.get(eventParticipationList.size() - 1).getEventDate();
public static EventIndicatorResponseDto of(List<EventParticipation> eventParticipationList, DrawSettingManager drawSettingManager) {
LocalDate startDate = drawSettingManager.getStartDate();
LocalDate endDate = drawSettingManager.getEndDate();

int totalVisitorCount = eventParticipationList.stream()
.mapToInt(EventParticipation::getVisitorCount)
Expand All @@ -64,8 +65,8 @@ public static EventIndicatorResponseDto of(List<EventParticipation> eventPartici
.mapToInt(EventParticipation::getDrawParticipantCount)
.sum();

double fcfsParticipantRate = (double) totalFcfsParticipantCount / (double) totalVisitorCount;
double drawParticipantRate = (double) totalDrawParticipantCount / (double) totalVisitorCount;
double fcfsParticipantRate = totalVisitorCount == 0 ? 0 : (double) totalFcfsParticipantCount / (double) totalVisitorCount;
double drawParticipantRate = totalVisitorCount == 0 ? 0 : (double) totalDrawParticipantCount / (double) totalVisitorCount;

List<VisitorNum> visitorNumList = eventParticipationList.stream()
.map((eventParticipation) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public EventIndicatorResponseDto getEventIndicator() {
drawSettingManager.getStartDate(), drawSettingManager.getEndDate()
);

return EventIndicatorResponseDto.of(eventParticipationList);
return EventIndicatorResponseDto.of(eventParticipationList, drawSettingManager);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,4 @@ public class EventParticipation {
@Column(name = "event_date", nullable = false)
private LocalDate eventDate;

public void addTotalVisitorsCount(int totalVisitorsCount) {
this.visitorCount += totalVisitorsCount;
}

public void addFcfsParticipantCount(int fcfsParticipantCount) {
this.fcfsParticipantCount += fcfsParticipantCount;
}

public void addDrawParticipantCount(int drawParticipantCount) {
this.drawParticipantCount += drawParticipantCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.softeer.backend.global.annotation.AuthInfo;
import com.softeer.backend.global.common.code.status.ErrorStatus;
import com.softeer.backend.global.common.response.ResponseDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult;
Expand All @@ -20,7 +21,7 @@ public class CommentController {

@GetMapping("/comment")
ResponseDto<CommentsResponseDto> getComment(@RequestParam(name = "cursor", required = false) Integer cursor,
@AuthInfo Integer userId) {
@Parameter(hidden = true) @AuthInfo Integer userId) {
if (cursor == null) {
cursor = Integer.MAX_VALUE;
}
Expand All @@ -35,7 +36,7 @@ ResponseDto<CommentsResponseDto> getComment(@RequestParam(name = "cursor", requi

@PostMapping("/comment")
ResponseDto<Void> saveComment(@RequestParam(name = "commentType") Integer commentType,
@AuthInfo Integer userId) {
@Parameter(hidden = true) @AuthInfo Integer userId) {

if(commentType == null || commentType<1 || commentType > 5){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.softeer.backend.fo_domain.draw.service.DrawService;
import com.softeer.backend.global.annotation.AuthInfo;
import com.softeer.backend.global.common.response.ResponseDto;
import io.swagger.v3.oas.annotations.Parameter;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -16,7 +17,8 @@ public class DrawController {
private final DrawService drawService;

@GetMapping("/event/draw")
public ResponseDto<DrawMainResponseDto> getDrawMainPageInfo(@AuthInfo Integer userId) {
public ResponseDto<DrawResponseDto> getDrawMainPageInfo(@Parameter(hidden = true) @AuthInfo Integer userId) {

return drawService.getDrawMainPageInfo(userId);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,68 @@
package com.softeer.backend.fo_domain.fcfs.controller;

import com.softeer.backend.fo_domain.fcfs.dto.FcfsResponseDto;
import com.softeer.backend.fo_domain.fcfs.dto.FcfsSuccessResponseDto;
import com.softeer.backend.fo_domain.fcfs.dto.FcfsPageResponseDto;
import com.softeer.backend.fo_domain.fcfs.dto.result.FcfsResponseDto;
import com.softeer.backend.fo_domain.fcfs.service.FcfsService;
import com.softeer.backend.global.annotation.AuthInfo;
import com.softeer.backend.global.common.response.ResponseDto;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

@RestController
@Controller
@RequiredArgsConstructor
@RequestMapping("/fcfs")
@Tag(name = "Fcfs Controller", description = "선착순 API")
public class FcfsController {
private final FcfsService fcfsService;

// @PostMapping("/fcfs")
// public ResponseDto<FcfsResponseDto> handleFCFS(@Parameter(hidden = true) @AuthInfo Integer userId) {
// FcfsResponseDto fcfsResponse = fcfsService.handleFcfsEvent(userId);
//
// if (fcfsResponse instanceof FcfsSuccessResponseDto)
// return ResponseDto.onSuccess(fcfsResponse);
@GetMapping
@ResponseBody
public ResponseDto<FcfsPageResponseDto> getFcfsPage(@Parameter(hidden = true) HttpServletRequest request) {

int round = (Integer) request.getAttribute("round");

FcfsPageResponseDto fcfsPageResponseDto = fcfsService.getFcfsPage(round);

return ResponseDto.onSuccess(fcfsPageResponseDto);
}

@GetMapping("/tutorial")
@ResponseBody
public ResponseDto<FcfsPageResponseDto> getFcfsTutorialPage() {

FcfsPageResponseDto fcfsPageResponseDto = fcfsService.getFcfsTutorialPage();

return ResponseDto.onSuccess(fcfsPageResponseDto);
}

@PostMapping
public String handleFcfs(@Parameter(hidden = true) HttpServletRequest request,
@Parameter(hidden = true) @AuthInfo Integer userId,
@RequestParam(value = "answer") String answer,
@Parameter(hidden = true) RedirectAttributes redirectAttributes) {

int round = (Integer) request.getAttribute("round");

// boolean isFcfsWinner = fcfsService.handleFcfsEvent(userId, round, answer);
//
// return ResponseDto.onSuccess(fcfsResponse);
// }
// // 리다이렉트 시 쿼리 파라미터를 추가하여 정보 전달
// redirectAttributes.addAttribute("fcfsWin", isFcfsWinner);

// GET 요청으로 리다이렉트
return "redirect:/fcfs/result";
}

@GetMapping("/result")
@ResponseBody
public ResponseDto<FcfsResponseDto> getFcfsResult(@RequestParam("fcfsWin") Boolean fcfsWin){
FcfsResponseDto fcfsResponseDto = fcfsService.getFcfsResult(fcfsWin);

return ResponseDto.onSuccess(fcfsResponseDto);
}

}
42 changes: 42 additions & 0 deletions src/main/java/com/softeer/backend/fo_domain/fcfs/domain/Quiz.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.softeer.backend.fo_domain.fcfs.domain;

import com.softeer.backend.fo_domain.user.domain.User;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

@Entity
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Builder
@Table(name = "quiz")
public class Quiz {

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

@Column(name = "hint", nullable = false)
private String hint;

@Column(name = "answer_word", nullable = false)
private String answerWord;

@Column(name = "answer_sentence", nullable = false)
private String answerSentence;

@Column(name = "start_index", nullable = false)
private int startIndex;

@Column(name = "end_index", nullable = false)
private int endIndex;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.softeer.backend.fo_domain.fcfs.dto;

import lombok.*;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@Builder
@Getter
@Setter
public class FcfsPageResponseDto {

private String answerWord;

private String answerSentence;

private int startIndex;

private int endIndex;

private String quizDescription;

}

This file was deleted.

This file was deleted.

23 changes: 23 additions & 0 deletions src/main/java/com/softeer/backend/fo_domain/fcfs/dto/QuizDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.softeer.backend.fo_domain.fcfs.dto;

import jakarta.persistence.Column;
import lombok.*;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@Builder
@Getter
@Setter
public class QuizDto {

private String hint;

private String answerWord;

private String answerSentence;

private int startIndex;

private int endIndex;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.softeer.backend.fo_domain.fcfs.dto.result;

import lombok.*;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@Builder
@Getter
public class FcfsFailResponseDto implements FcfsResponseDto {

private String title;

private String subTitle;

private String caution;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.softeer.backend.fo_domain.fcfs.dto.result;

public interface FcfsResponseDto {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.softeer.backend.fo_domain.fcfs.dto.result;

import lombok.*;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor(access = AccessLevel.PUBLIC)
@Builder
@Getter
public class FcfsSuccessResponseDto implements FcfsResponseDto {

private String title;

private String subTitle;

private String qrCode;

private String codeWord;

private String fcfsCode;

private String expirationDate;

private String caution;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.softeer.backend.fo_domain.fcfs.exception;

import com.softeer.backend.global.common.code.BaseErrorCode;
import com.softeer.backend.global.common.exception.GeneralException;

public class FcfsException extends GeneralException {

public FcfsException(BaseErrorCode code) {
super(code);
}
}
Loading
Loading