Skip to content

Commit

Permalink
Merge pull request #154 from softeerbootcamp4th/dev
Browse files Browse the repository at this point in the history
0816 Pull
  • Loading branch information
wjddn2165 authored Aug 16, 2024
2 parents d269b1a + a0be216 commit daef2de
Show file tree
Hide file tree
Showing 96 changed files with 3,545 additions and 726 deletions.
1 change: 0 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ env:
jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 2 additions & 0 deletions Server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
implementation 'io.awspring.cloud:spring-cloud-aws-starter-parameter-store'
implementation 'mysql:mysql-connector-java:8.0.33' // MySQL JDBC 드라이버 추가
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'

implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

Expand All @@ -46,6 +47,7 @@ dependencies {
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.5'
runtimeOnly("io.jsonwebtoken:jjwt-jackson:0.11.5")
annotationProcessor('org.projectlombok:lombok')
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3'

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,205 @@
package JGS.CasperEvent.domain.event.controller.adminController;

import JGS.CasperEvent.domain.event.dto.RequestDto.AdminRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.lotteryEventDto.LotteryEventRequestDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.rushEventDto.RushEventRequestDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.ImageUrlResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.*;
import JGS.CasperEvent.domain.event.dto.ResponseDto.rushEventResponseDto.AdminRushEventOptionResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.rushEventResponseDto.AdminRushEventResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.rushEventResponseDto.LotteryEventWinnerListResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.rushEventResponseDto.RushEventParticipantsListResponseDto;
import JGS.CasperEvent.domain.event.service.adminService.AdminService;
import JGS.CasperEvent.global.response.ResponseDto;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/admin")
@RequiredArgsConstructor
public class AdminController {
private final AdminService adminService;

@Autowired
public AdminController(AdminService adminService) {
this.adminService = adminService;
}

// 어드민 생성
@PostMapping("/join")
public ResponseEntity<ResponseDto> postAdmin(@RequestBody @Valid AdminRequestDto adminRequestDto){
public ResponseEntity<ResponseDto> postAdmin(@RequestBody @Valid AdminRequestDto adminRequestDto) {
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.postAdmin(adminRequestDto));
}

// 이미지 업로드
@PostMapping("/image")
public ResponseEntity<ImageUrlResponseDto> postImage(@RequestPart(value = "image") MultipartFile image) {
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.postImage(image));
}

// 추첨 이벤트 조회
@GetMapping("/event/lottery")
public ResponseEntity<LotteryEventDetailResponseDto> getLotteryEvent() {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getLotteryEvent());
}

// 추첨 이벤트 생성
@PostMapping("/event/lottery")
public ResponseEntity<LotteryEventResponseDto> createLotteryEvent(
@Valid @RequestBody LotteryEventRequestDto lotteryEventRequestDto) {
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.createLotteryEvent(lotteryEventRequestDto));
}

// 추첨 이벤트 참여자 조회
@GetMapping("/event/lottery/participants")
public ResponseEntity<LotteryEventParticipantsListResponseDto> getLotteryEventParticipants(
@RequestParam(name = "size", required = false, defaultValue = "10") int size,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "number", required = false, defaultValue = "") String phoneNumber) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getLotteryEventParticipants(size, page, phoneNumber));
}

// 선착순 이벤트 생성
@PostMapping("/event/rush")
public ResponseEntity<AdminRushEventResponseDto> createRushEvent(
@RequestPart(value = "dto") RushEventRequestDto rushEventRequestDto,
@RequestPart(value = "prizeImg") MultipartFile prizeImg,
@RequestPart(value = "leftOptionImg") MultipartFile leftOptionImg,
@RequestPart(value = "rightOptionImg") MultipartFile rightOptionImg) {
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.createRushEvent(rushEventRequestDto, prizeImg, leftOptionImg, rightOptionImg));
}

// 선착순 이벤트 전체 조회
@GetMapping("/event/rush")
public ResponseEntity<List<AdminRushEventResponseDto>> getRushEvents() {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getRushEvents());
}

// 선착순 이벤트 참여자 조회
@GetMapping("/event/rush/{rushEventId}/participants")
public ResponseEntity<RushEventParticipantsListResponseDto> getRushEventParticipants(
@PathVariable("rushEventId") Long rushEventId,
@RequestParam(name = "size", required = false, defaultValue = "10") int size,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "option", required = false, defaultValue = "0") int option,
@RequestParam(name = "number", required = false, defaultValue = "") String phoneNumber) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getRushEventParticipants(rushEventId, size, page, option, phoneNumber));
}

// 선착순 이벤트 당첨자 조회
@GetMapping("/event/rush/{rushEventId}/winner")
public ResponseEntity<RushEventParticipantsListResponseDto> getRushEventWinners(
@PathVariable("rushEventId") Long rushEventId,
@RequestParam(name = "size", required = false, defaultValue = "10") int size,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "number", required = false, defaultValue = "") String phoneNumber) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getRushEventWinners(rushEventId, size, page, phoneNumber));
}

// 선착순 이벤트 수정
@PutMapping("/event/rush")
public ResponseEntity<List<AdminRushEventResponseDto>> updateRushEvent(
@RequestBody List<RushEventRequestDto> rushEventListRequestDto) {

return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.updateRushEvents(rushEventListRequestDto));
}

// 선착순 이벤트 삭제
@DeleteMapping("/event/rush/{rushEventId}")
public ResponseEntity<ResponseDto> deleteRushEvent(@PathVariable Long rushEventId) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.deleteRushEvent(rushEventId));
}

// 선착순 이벤트 선택지 조회
@GetMapping("/event/rush/{rushEventId}/options")
public ResponseEntity<AdminRushEventOptionResponseDto> getRushEventOptions(@PathVariable Long rushEventId) {
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getRushEventOptions(rushEventId));
}

// 추첨 이벤트 삭제
@DeleteMapping("/event/lottery")
public ResponseEntity<Void> deleteLotteryEvent() {
adminService.deleteLotteryEvent();
return ResponseEntity.noContent().build(); // 204 No Content

}

// 추첨 이벤트 수정
@PutMapping("/event/lottery")
public ResponseEntity<LotteryEventDetailResponseDto> updateLotteryEvent(@RequestBody @Valid LotteryEventRequestDto lotteryEventRequestDto) {
LotteryEventDetailResponseDto updatedLotteryEventDetailResponseDto = adminService.updateLotteryEvent(lotteryEventRequestDto);

return ResponseEntity.ok(updatedLotteryEventDetailResponseDto);
}

// 추첨 이벤트 특정 사용자의 기대평 조회
@GetMapping("/event/lottery/participants/{participantId}/expectations")
public ResponseEntity<LotteryEventExpectationsResponseDto> getLotteryEventExpectations(@PathVariable("participantId") Long participantId,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "size", required = false, defaultValue = "10") int size) {
LotteryEventExpectationsResponseDto lotteryEventExpectationResponseDtoList = adminService.getLotteryEventExpectations(page, size, participantId);

return ResponseEntity.ok(lotteryEventExpectationResponseDtoList);
}

// 추첨 이벤트 특정 기대평을 삭제
@PatchMapping("/event/lottery/expectations/{casperId}")
public ResponseEntity<Void> deleteLotteryEventExpectation(@PathVariable("casperId") Long casperId) {
adminService.deleteLotteryEventExpectation(casperId);

return ResponseEntity.noContent().build();
}

// 추첨 이벤트 당첨자 추첨
@PostMapping("/event/lottery/winner")
public ResponseEntity<ResponseDto> pickLotteryEventWinners() {
return ResponseEntity
.status(HttpStatus.CREATED)
.body(adminService.pickLotteryEventWinners());
}

// 추첨 이벤트 당첨자 삭제
@DeleteMapping("/event/lottery/winner")
public ResponseEntity<ResponseDto> deleteLotteryEventWinners(){
return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.deleteLotteryEventWinners());
}

// 추첨 이벤트 당첨자 조회
@GetMapping("/event/lottery/winner")
public ResponseEntity<LotteryEventWinnerListResponseDto> getWinners(
@RequestParam(name = "size", required = false, defaultValue = "10") int size,
@RequestParam(name = "page", required = false, defaultValue = "0") int page,
@RequestParam(name = "number", required = false, defaultValue = "") String phoneNumber) {

return ResponseEntity
.status(HttpStatus.OK)
.body(adminService.getLotteryEventWinners(size, page, phoneNumber));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package JGS.CasperEvent.domain.event.controller.eventController;


import JGS.CasperEvent.domain.event.dto.ResponseDto.TotalEventDateResponseDto;
import JGS.CasperEvent.domain.event.service.eventService.EventService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/event")

public class EventController {
private final EventService eventService;

@GetMapping("/total")
public ResponseEntity<TotalEventDateResponseDto> getTotalEventDate() {
TotalEventDateResponseDto totalEventDateResponseDto = eventService.getTotalEventDate();
return ResponseEntity.ok(totalEventDateResponseDto);
}
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
package JGS.CasperEvent.domain.event.controller.eventController;

import JGS.CasperEvent.domain.event.dto.RequestDto.CasperBotRequestDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.CasperBotResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.LotteryEventResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.LotteryParticipantResponseDto;
import JGS.CasperEvent.domain.event.dto.RequestDto.lotteryEventDto.CasperBotRequestDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.CasperBotResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryEventResponseDto;
import JGS.CasperEvent.domain.event.dto.ResponseDto.lotteryEventResponseDto.LotteryParticipantResponseDto;
import JGS.CasperEvent.domain.event.service.redisService.RedisService;
import JGS.CasperEvent.domain.event.service.eventService.LotteryEventService;
import JGS.CasperEvent.global.entity.BaseUser;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.apache.coyote.BadRequestException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.crypto.BadPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import java.nio.file.attribute.UserPrincipalNotFoundException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.List;

@RestController
Expand All @@ -30,18 +34,20 @@ public LotteryEventController(LotteryEventService lotteryEventService, RedisServ
this.lotteryEventService = lotteryEventService;
this.redisService = redisService;
}
// 추첨 이벤트 조회 API -> 가짜 API

// 추첨 이벤트 조회 API
@GetMapping
public ResponseEntity<LotteryEventResponseDto> getLotteryEvent(){
return ResponseEntity
.status(HttpStatus.OK)
.body(lotteryEventService.getLotteryEvent());
}

// 캐스퍼 봇 생성 API
@PostMapping("/casperBot")
public ResponseEntity<CasperBotResponseDto> postCasperBot(
HttpServletRequest request,
@RequestBody @Valid CasperBotRequestDto postCasperBot) throws BadRequestException {
@RequestBody @Valid CasperBotRequestDto postCasperBot) throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException, BadPaddingException, InvalidKeyException {
BaseUser user = (BaseUser) request.getAttribute("user");
return ResponseEntity
.status(HttpStatus.CREATED)
Expand All @@ -63,12 +69,4 @@ public ResponseEntity<List<CasperBotResponseDto>> getCasperBots() {
return ResponseEntity.status(HttpStatus.OK)
.body(redisService.getRecentData());
}

// 캐스퍼 봇 조회 API
@GetMapping("/{casperId}")
public ResponseEntity<CasperBotResponseDto> getCasperBot(@PathVariable String casperId) {
return ResponseEntity
.status(HttpStatus.OK)
.body(lotteryEventService.getCasperBot(Long.parseLong(casperId)));
}
}
Loading

0 comments on commit daef2de

Please sign in to comment.