Skip to content

Commit

Permalink
Merge pull request #49 from softeerbootcamp4th/fix/refactor
Browse files Browse the repository at this point in the history
[Refactor] 패키지 리팩토링
  • Loading branch information
eckrin authored Aug 14, 2024
2 parents d50e114 + 1ed257e commit 73df55a
Show file tree
Hide file tree
Showing 67 changed files with 198 additions and 191 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.softeer.podo.admin.controller;

import com.softeer.podo.admin.model.dto.*;
import com.softeer.podo.admin.model.dto.user.ArrivalUserListDto;
import com.softeer.podo.admin.model.dto.user.LotsUserListDto;
import com.softeer.podo.admin.model.entity.validation.LotsValidationSequence;
import com.softeer.podo.admin.model.dto.request.ConfigEventRequestDto;
import com.softeer.podo.admin.model.dto.request.ConfigEventRewardRequestDto;
import com.softeer.podo.admin.model.dto.response.EventListResponseDto;
import com.softeer.podo.admin.model.dto.response.ConfigEventRewardResponseDto;
import com.softeer.podo.admin.model.dto.ArrivalUserListDto;
import com.softeer.podo.admin.model.dto.LotsUserListDto;
import com.softeer.podo.admin.validation.LotsValidationSequence;
import com.softeer.podo.admin.service.AdminService;
import com.softeer.podo.common.response.CommonResponse;
import io.swagger.v3.oas.annotations.Operation;
Expand All @@ -21,50 +25,49 @@
public class AdminController {
private final AdminService adminService;


@GetMapping("/eventlist")
@Operation(summary = "이벤트 목록 반환 Api")
public CommonResponse<EventListResponseDto> eventList(){
public CommonResponse<EventListResponseDto> getEventList(){
return new CommonResponse<>(adminService.getEventList());
}

@PutMapping("/arrival/config")
@Operation(summary = "선착순 이벤트 수정 Api")
public CommonResponse<EventDto> arrivalEventConfig(@RequestBody @Valid EventConfigRequestDto dto){
public CommonResponse<EventDto> configArrivalEvent(@RequestBody @Valid ConfigEventRequestDto dto){
return new CommonResponse<>(adminService.configArrivalEvent(dto));
}

@PutMapping("/lots/config")
@Operation(summary = "랜덤추첨 이벤트 수정 Api")
public CommonResponse<EventDto> lotsEventConfig(@RequestBody @Valid EventConfigRequestDto dto){
public CommonResponse<EventDto> configLotsEvent(@RequestBody @Valid ConfigEventRequestDto dto){
return new CommonResponse<>(adminService.configLotsEvent(dto));
}

@PutMapping("/arrival/rewardconfig")
@Operation(summary = "선착순 이벤트 상품 수정 Api")
public CommonResponse<EventRewardConfigResponseDto> arrivalEventRewardConfig(@RequestBody @Valid EventRewardConfigRequestDto dto){
public CommonResponse<ConfigEventRewardResponseDto> configArrivalEventReward(@RequestBody @Valid ConfigEventRewardRequestDto dto){
return new CommonResponse<>(adminService.configArrivalEventReward(dto));
}

@PutMapping("/lots/rewardconfig")
@Operation(summary = "랜덤추첨 이벤트 상품 수정 Api")
public CommonResponse<EventRewardConfigResponseDto> lotsEventRewardConfig(@RequestBody @Validated(LotsValidationSequence.class) EventRewardConfigRequestDto dto){
public CommonResponse<ConfigEventRewardResponseDto> configLotsEventReward(@RequestBody @Validated(LotsValidationSequence.class) ConfigEventRewardRequestDto dto){
return new CommonResponse<>(adminService.configLotsEventReward(dto));
}

@GetMapping("/arrival/applicationList")
@Operation(summary = "선착순 응모 인원 반환 Api")
public CommonResponse<ArrivalUserListDto> arrivalApplicationList(@RequestParam(required = false, defaultValue = "0", value = "page") int pageNo){
public CommonResponse<ArrivalUserListDto> getArrivalEventUserList(@RequestParam(required = false, defaultValue = "0", value = "page") int pageNo){
return new CommonResponse<>(adminService.getArrivalApplicationList(pageNo));
}

@GetMapping("/lots/applicationList")
@Operation(summary = "랜덤추첨 응모 인원 반환 Api")
public CommonResponse<LotsUserListDto> lotsApplicationList(@RequestParam(required = false, defaultValue = "0", value = "page") int pageNo){
public CommonResponse<LotsUserListDto> getLotsEventUserList(@RequestParam(required = false, defaultValue = "0", value = "page") int pageNo){
return new CommonResponse<>(adminService.getLotsApplicationList(pageNo));
}

@GetMapping("/lots/pickrandom")
@GetMapping("/lots/random")
@Operation(summary = "랜덤추첨 Api")
public CommonResponse<LotsUserListDto> pickRandomLotsUser(){
return new CommonResponse<>(adminService.getLotsResult());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.exception;
package com.softeer.podo.admin.exception;

import com.softeer.podo.common.response.CommonResponse;
import com.softeer.podo.common.response.ErrorCode;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.exception;
package com.softeer.podo.admin.exception;

public class EventNotFoundException extends RuntimeException {
private String message;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.dto.user;
package com.softeer.podo.admin.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.dto.user;
package com.softeer.podo.admin.model.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.dto.user;
package com.softeer.podo.admin.model.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.dto.user;
package com.softeer.podo.admin.model.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package com.softeer.podo.admin.model.dto;

public interface UserListDto {
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.dto;
package com.softeer.podo.admin.model.dto.request;


import com.fasterxml.jackson.annotation.JsonFormat;
Expand All @@ -12,7 +12,7 @@
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class EventConfigRequestDto {
public class ConfigEventRequestDto {

@NotBlank(message = "title이 존재하지 않습니다.")
private String title;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.softeer.podo.admin.model.dto;
package com.softeer.podo.admin.model.dto.request;

import com.softeer.podo.admin.model.entity.validation.ValidationGroups;
import com.softeer.podo.admin.model.dto.EventRewardDto;
import com.softeer.podo.admin.model.dto.EventWeightDto;
import com.softeer.podo.admin.validation.ValidationGroups;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
Expand All @@ -11,13 +13,13 @@
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class EventRewardConfigRequestDto {
public class ConfigEventRewardRequestDto {

@NotEmpty(message = "상품 리스트가 비어있습니다.")
@Valid
List<@Valid EventRewardDto> eventRewardList;

@Valid
@NotNull(message = "가중치가 비어있습니다.", groups = ValidationGroups.LotsRewardValidation.class)
EventWeightDto eventWeight;
EventWeightDto eventWeight;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.softeer.podo.admin.model.dto;
package com.softeer.podo.admin.model.dto.response;

import com.softeer.podo.admin.model.dto.user.UserListDto;
import com.softeer.podo.admin.model.dto.EventRewardDto;
import com.softeer.podo.admin.model.dto.EventWeightDto;
import com.softeer.podo.admin.model.dto.UserListDto;
import jakarta.annotation.Nullable;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -9,7 +11,7 @@

@Data
@AllArgsConstructor
public class EventRewardConfigResponseDto {
public class ConfigEventRewardResponseDto {
private List<EventRewardDto> eventRewards;
@Nullable
private EventWeightDto eventWeight;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.softeer.podo.admin.model.dto;
package com.softeer.podo.admin.model.dto.response;

import com.softeer.podo.admin.model.dto.EventDto;
import lombok.AllArgsConstructor;
import lombok.Data;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.softeer.podo.admin.model.dto.mapper;
package com.softeer.podo.admin.model.mapper;

import com.softeer.podo.admin.model.dto.EventDto;
import com.softeer.podo.admin.model.dto.EventListResponseDto;
import com.softeer.podo.admin.model.dto.response.EventListResponseDto;
import com.softeer.podo.admin.model.dto.EventRewardDto;
import com.softeer.podo.admin.model.dto.EventWeightDto;
import com.softeer.podo.admin.model.entity.Event;
import com.softeer.podo.admin.model.entity.EventReward;
import com.softeer.podo.admin.model.entity.EventWeight;
import org.springframework.stereotype.Component;
import com.softeer.podo.event.model.entity.Event;
import com.softeer.podo.event.model.entity.EventReward;
import com.softeer.podo.event.model.entity.EventWeight;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.softeer.podo.admin.model.dto.mapper;
package com.softeer.podo.admin.model.mapper;


import com.softeer.podo.admin.model.dto.user.ArrivalUserDto;
import com.softeer.podo.admin.model.dto.user.ArrivalUserListDto;
import com.softeer.podo.admin.model.dto.user.LotsUserDto;
import com.softeer.podo.admin.model.dto.user.LotsUserListDto;
import com.softeer.podo.admin.model.entity.ArrivalUser;
import com.softeer.podo.admin.model.entity.LotsUser;
import com.softeer.podo.admin.model.dto.ArrivalUserDto;
import com.softeer.podo.admin.model.dto.ArrivalUserListDto;
import com.softeer.podo.admin.model.dto.LotsUserDto;
import com.softeer.podo.admin.model.dto.LotsUserListDto;
import com.softeer.podo.event.model.entity.ArrivalUser;
import com.softeer.podo.event.model.entity.LotsUser;
import org.springframework.data.domain.Page;

import java.util.ArrayList;
Expand Down
46 changes: 25 additions & 21 deletions src/main/java/com/softeer/podo/admin/service/AdminService.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@


import com.softeer.podo.admin.model.dto.*;
import com.softeer.podo.admin.model.dto.user.ArrivalUserDto;
import com.softeer.podo.admin.model.dto.user.ArrivalUserListDto;
import com.softeer.podo.admin.model.dto.mapper.EventMapper;
import com.softeer.podo.admin.model.dto.mapper.UserMapper;
import com.softeer.podo.admin.model.dto.user.LotsUserListDto;
import com.softeer.podo.admin.model.entity.ArrivalUser;
import com.softeer.podo.admin.model.entity.Event;
import com.softeer.podo.admin.model.entity.EventReward;
import com.softeer.podo.admin.model.exception.EventNotFoundException;
import com.softeer.podo.admin.repository.EventRepository;
import com.softeer.podo.admin.model.entity.LotsUser;
import com.softeer.podo.admin.repository.ArrivalUserRepository;
import com.softeer.podo.admin.repository.EventRewardRepository;
import com.softeer.podo.admin.repository.LotsUserRepository;
import com.softeer.podo.admin.model.dto.request.ConfigEventRequestDto;
import com.softeer.podo.admin.model.dto.request.ConfigEventRewardRequestDto;
import com.softeer.podo.admin.model.dto.response.EventListResponseDto;
import com.softeer.podo.admin.model.dto.response.ConfigEventRewardResponseDto;
import com.softeer.podo.admin.model.dto.ArrivalUserDto;
import com.softeer.podo.admin.model.dto.ArrivalUserListDto;
import com.softeer.podo.admin.model.mapper.EventMapper;
import com.softeer.podo.admin.model.mapper.UserMapper;
import com.softeer.podo.admin.model.dto.LotsUserListDto;
import com.softeer.podo.event.model.entity.ArrivalUser;
import com.softeer.podo.event.model.entity.Event;
import com.softeer.podo.event.model.entity.EventReward;
import com.softeer.podo.admin.exception.EventNotFoundException;
import com.softeer.podo.event.repository.EventRepository;
import com.softeer.podo.event.model.entity.LotsUser;
import com.softeer.podo.event.repository.ArrivalUserRepository;
import com.softeer.podo.event.repository.EventRewardRepository;
import com.softeer.podo.event.repository.LotsUserRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
Expand Down Expand Up @@ -44,19 +48,19 @@ public EventListResponseDto getEventList() {
}

@Transactional
public EventDto configArrivalEvent(EventConfigRequestDto dto) {
public EventDto configArrivalEvent(ConfigEventRequestDto dto) {
Event arrivalEvent = updateEventByConfigDto(arrivalEventId, dto);
return EventMapper.EventToEventDto(arrivalEvent);
}

@Transactional
public EventDto configLotsEvent(EventConfigRequestDto dto) {
public EventDto configLotsEvent(ConfigEventRequestDto dto) {
Event lotsEvent = updateEventByConfigDto(lotsEventId, dto);
return EventMapper.EventToEventDto(lotsEvent);
}

@Transactional
public EventRewardConfigResponseDto configArrivalEventReward(EventRewardConfigRequestDto dto) {
public ConfigEventRewardResponseDto configArrivalEventReward(ConfigEventRewardRequestDto dto) {
Event arrivalEvent = eventRepository.findById(arrivalEventId).orElseThrow(EventNotFoundException::new);
List<EventReward> arrivalRewards = eventRewardRepository.findByEvent(arrivalEvent);
eventRewardRepository.deleteAllInBatch(arrivalRewards);
Expand All @@ -78,11 +82,11 @@ public EventRewardConfigResponseDto configArrivalEventReward(EventRewardConfigRe
.map(EventMapper::eventRewardToEventRewardDto)
.toList();

return new EventRewardConfigResponseDto(eventRewardDtoList, null, getArrivalApplicationList(0));
return new ConfigEventRewardResponseDto(eventRewardDtoList, null, getArrivalApplicationList(0));
}

@Transactional
public EventRewardConfigResponseDto configLotsEventReward(EventRewardConfigRequestDto dto) {
public ConfigEventRewardResponseDto configLotsEventReward(ConfigEventRewardRequestDto dto) {
Event lotsEvent = eventRepository.findById(lotsEventId).orElseThrow(EventNotFoundException::new);
List<EventReward> lotsRewards = eventRewardRepository.findByEvent(lotsEvent);
eventRewardRepository.deleteAllInBatch(lotsRewards);
Expand All @@ -109,7 +113,7 @@ public EventRewardConfigResponseDto configLotsEventReward(EventRewardConfigReque
.toList();
EventWeightDto eventWeightDto = EventMapper.eventWeightToEventWeightDto(lotsEvent.getEventWeight());

return new EventRewardConfigResponseDto(eventRewardDtoList, eventWeightDto, getLotsApplicationList(0));
return new ConfigEventRewardResponseDto(eventRewardDtoList, eventWeightDto, getLotsApplicationList(0));
}

@Transactional
Expand Down Expand Up @@ -202,7 +206,7 @@ public LotsUserListDto getLotsResult() {
return getLotsApplicationList(0);
}

private Event updateEventByConfigDto(Long eventId, EventConfigRequestDto dto) {
private Event updateEventByConfigDto(Long eventId, ConfigEventRequestDto dto) {
Event event = eventRepository.findById(eventId).orElseThrow(EventNotFoundException::new);
event.updateEvent(
dto.getTitle(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.entity.validation;
package com.softeer.podo.admin.validation;

import jakarta.validation.GroupSequence;
import jakarta.validation.groups.Default;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.admin.model.entity.validation;
package com.softeer.podo.admin.validation;


public class ValidationGroups {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.softeer.podo.event.controller;

import com.softeer.podo.common.response.CommonResponse;
import com.softeer.podo.event.model.dto.LotsTypeRequestDto;
import com.softeer.podo.event.model.dto.LotsTypeResponseDto;
import com.softeer.podo.event.model.dto.request.LotsTypeRequestDto;
import com.softeer.podo.event.model.dto.response.LotsTypeResponseDto;
import com.softeer.podo.event.model.dto.WordCloudResponseDto;
import com.softeer.podo.event.service.EventLotsService;
import io.swagger.v3.oas.annotations.Operation;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.softeer.podo.event.controller;

import com.softeer.podo.common.response.CommonResponse;
import com.softeer.podo.event.model.dto.LotsApplicationRequestDto;
import com.softeer.podo.event.model.dto.LotsApplicationResponseDto;
import com.softeer.podo.event.model.dto.LotsCommentRequestDto;
import com.softeer.podo.event.model.dto.LotsCommentResponseDto;
import com.softeer.podo.event.model.dto.request.LotsApplicationRequestDto;
import com.softeer.podo.event.model.dto.response.LotsApplicationResponseDto;
import com.softeer.podo.event.model.dto.request.LotsCommentRequestDto;
import com.softeer.podo.event.model.dto.response.LotsCommentResponseDto;
import com.softeer.podo.event.service.EventLotsService;
import com.softeer.podo.security.Auth;
import com.softeer.podo.security.AuthInfo;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.event.model.dto;
package com.softeer.podo.event.model.dto.request;


import jakarta.validation.constraints.Max;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.event.model.dto;
package com.softeer.podo.event.model.dto.request;


import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.event.model.dto;
package com.softeer.podo.event.model.dto.request;


import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.event.model.dto;
package com.softeer.podo.event.model.dto.response;


import jakarta.validation.constraints.NotBlank;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.softeer.podo.event.model.dto;
package com.softeer.podo.event.model.dto.response;


import com.softeer.podo.event.model.entity.LotsComment;
Expand Down
Loading

0 comments on commit 73df55a

Please sign in to comment.