diff --git a/backend/build.gradle b/backend/build.gradle index 54a71cbfe..e966c075c 100644 --- a/backend/build.gradle +++ b/backend/build.gradle @@ -50,6 +50,12 @@ dependencies { // Firebase implementation 'com.google.firebase:firebase-admin:8.1.0' + + // Lombok + compileOnly 'org.projectlombok:lombok' + annotationProcessor 'org.projectlombok:lombok' + testCompileOnly 'org.projectlombok:lombok' + testAnnotationProcessor 'org.projectlombok:lombok' } tasks.named('test') { diff --git a/backend/src/main/java/com/festago/admin/application/AdminService.java b/backend/src/main/java/com/festago/admin/application/AdminService.java index 764487998..6caf46f1a 100644 --- a/backend/src/main/java/com/festago/admin/application/AdminService.java +++ b/backend/src/main/java/com/festago/admin/application/AdminService.java @@ -19,11 +19,13 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Transactional @Service +@RequiredArgsConstructor public class AdminService { private final FestivalRepository festivalRepository; @@ -31,15 +33,6 @@ public class AdminService { private final TicketRepository ticketRepository; private final SchoolRepository schoolRepository; - public AdminService(FestivalRepository festivalRepository, StageRepository stageRepository, - TicketRepository ticketRepository, - SchoolRepository schoolRepository) { - this.festivalRepository = festivalRepository; - this.stageRepository = stageRepository; - this.ticketRepository = ticketRepository; - this.schoolRepository = schoolRepository; - } - @Transactional(readOnly = true) public AdminResponse getAdminResponse() { List allSchool = schoolRepository.findAll(); diff --git a/backend/src/main/java/com/festago/admin/domain/Admin.java b/backend/src/main/java/com/festago/admin/domain/Admin.java index b3956233a..a7937444e 100644 --- a/backend/src/main/java/com/festago/admin/domain/Admin.java +++ b/backend/src/main/java/com/festago/admin/domain/Admin.java @@ -7,6 +7,8 @@ import jakarta.persistence.Id; import jakarta.persistence.Table; import jakarta.persistence.UniqueConstraint; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity @Table( @@ -17,6 +19,7 @@ ) } ) +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Admin extends BaseTimeEntity { @Id @@ -27,9 +30,6 @@ public class Admin extends BaseTimeEntity { private String password; - protected Admin() { - } - public Admin(String username, String password) { this(null, username, password); } diff --git a/backend/src/main/java/com/festago/auth/application/AdminAuthService.java b/backend/src/main/java/com/festago/auth/application/AdminAuthService.java index 9d80d2ccd..ff21eea0e 100644 --- a/backend/src/main/java/com/festago/auth/application/AdminAuthService.java +++ b/backend/src/main/java/com/festago/auth/application/AdminAuthService.java @@ -12,11 +12,13 @@ import com.festago.common.exception.ForbiddenException; import com.festago.common.exception.UnauthorizedException; import java.util.Objects; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class AdminAuthService { private static final String ROOT_ADMIN = "admin"; @@ -24,11 +26,6 @@ public class AdminAuthService { private final AuthProvider authProvider; private final AdminRepository adminRepository; - public AdminAuthService(AuthProvider authProvider, AdminRepository adminRepository) { - this.authProvider = authProvider; - this.adminRepository = adminRepository; - } - @Transactional(readOnly = true) public String login(AdminLoginRequest request) { Admin admin = findAdmin(request); diff --git a/backend/src/main/java/com/festago/auth/application/AuthFacadeService.java b/backend/src/main/java/com/festago/auth/application/AuthFacadeService.java index 3e8a22347..6642e956b 100644 --- a/backend/src/main/java/com/festago/auth/application/AuthFacadeService.java +++ b/backend/src/main/java/com/festago/auth/application/AuthFacadeService.java @@ -6,22 +6,17 @@ import com.festago.auth.domain.UserInfo; import com.festago.auth.dto.LoginMemberDto; import com.festago.auth.dto.LoginResponse; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @Service +@RequiredArgsConstructor public class AuthFacadeService { private final AuthService authService; private final OAuth2Clients oAuth2Clients; private final AuthProvider authProvider; - public AuthFacadeService(AuthService authService, OAuth2Clients oAuth2Clients, - AuthProvider authProvider) { - this.authService = authService; - this.oAuth2Clients = oAuth2Clients; - this.authProvider = authProvider; - } - public LoginResponse login(SocialType socialType, String oAuthToken) { UserInfo userInfo = getUserInfo(socialType, oAuthToken); LoginMemberDto loginMember = authService.login(userInfo); diff --git a/backend/src/main/java/com/festago/auth/application/AuthService.java b/backend/src/main/java/com/festago/auth/application/AuthService.java index 63101e914..512c3022c 100644 --- a/backend/src/main/java/com/festago/auth/application/AuthService.java +++ b/backend/src/main/java/com/festago/auth/application/AuthService.java @@ -7,23 +7,19 @@ import com.festago.member.domain.Member; import com.festago.member.repository.MemberRepository; import java.util.Optional; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor +@Slf4j public class AuthService { - private static final Logger log = LoggerFactory.getLogger(AuthService.class); - private final MemberRepository memberRepository; - public AuthService(MemberRepository memberRepository) { - this.memberRepository = memberRepository; - } - public LoginMemberDto login(UserInfo userInfo) { LoginMemberDto loginMemberDto = handleLoginRequest(userInfo); return loginMemberDto; diff --git a/backend/src/main/java/com/festago/auth/config/LoginConfig.java b/backend/src/main/java/com/festago/auth/config/LoginConfig.java index 34715834f..e340587a6 100644 --- a/backend/src/main/java/com/festago/auth/config/LoginConfig.java +++ b/backend/src/main/java/com/festago/auth/config/LoginConfig.java @@ -8,6 +8,7 @@ import com.festago.presentation.auth.AuthenticateContext; import com.festago.presentation.auth.RoleArgumentResolver; import java.util.List; +import lombok.RequiredArgsConstructor; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.method.support.HandlerMethodArgumentResolver; @@ -15,16 +16,12 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @Configuration +@RequiredArgsConstructor public class LoginConfig implements WebMvcConfigurer { private final AuthExtractor authExtractor; private final AuthenticateContext authenticateContext; - public LoginConfig(AuthExtractor authExtractor, AuthenticateContext context) { - this.authExtractor = authExtractor; - this.authenticateContext = context; - } - @Override public void addArgumentResolvers(List resolvers) { resolvers.add(new RoleArgumentResolver(Role.MEMBER, authenticateContext)); diff --git a/backend/src/main/java/com/festago/entry/application/EntryCodeManager.java b/backend/src/main/java/com/festago/entry/application/EntryCodeManager.java index ac6e0d509..b8dbcbbd3 100644 --- a/backend/src/main/java/com/festago/entry/application/EntryCodeManager.java +++ b/backend/src/main/java/com/festago/entry/application/EntryCodeManager.java @@ -3,9 +3,11 @@ import com.festago.entry.domain.EntryCode; import com.festago.entry.domain.EntryCodePayload; import java.util.Date; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @Component +@RequiredArgsConstructor public class EntryCodeManager { private static final int MILLISECOND_FACTOR = 1_000; @@ -15,11 +17,6 @@ public class EntryCodeManager { private final EntryCodeProvider entryCodeProvider; private final EntryCodeExtractor entryCodeExtractor; - public EntryCodeManager(EntryCodeProvider entryCodeProvider, EntryCodeExtractor entryCodeExtractor) { - this.entryCodeProvider = entryCodeProvider; - this.entryCodeExtractor = entryCodeExtractor; - } - public EntryCode provide(EntryCodePayload entryCodePayload, long currentTimeMillis) { Date expiredAt = new Date(currentTimeMillis + (DEFAULT_PERIOD + DEFAULT_OFFSET) * MILLISECOND_FACTOR); String code = entryCodeProvider.provide(entryCodePayload, expiredAt); diff --git a/backend/src/main/java/com/festago/entry/application/EntryService.java b/backend/src/main/java/com/festago/entry/application/EntryService.java index 68602f67e..061e369d8 100644 --- a/backend/src/main/java/com/festago/entry/application/EntryService.java +++ b/backend/src/main/java/com/festago/entry/application/EntryService.java @@ -13,12 +13,14 @@ import com.festago.ticketing.repository.MemberTicketRepository; import java.time.Clock; import java.time.LocalDateTime; +import lombok.RequiredArgsConstructor; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class EntryService { private final EntryCodeManager entryCodeManager; @@ -26,14 +28,6 @@ public class EntryService { private final ApplicationEventPublisher publisher; private final Clock clock; - public EntryService(EntryCodeManager entryCodeManager, MemberTicketRepository memberTicketRepository, - ApplicationEventPublisher publisher, Clock clock) { - this.entryCodeManager = entryCodeManager; - this.memberTicketRepository = memberTicketRepository; - this.publisher = publisher; - this.clock = clock; - } - public EntryCodeResponse createEntryCode(Long memberId, Long memberTicketId) { MemberTicket memberTicket = findMemberTicket(memberTicketId); if (!memberTicket.isOwner(memberId)) { diff --git a/backend/src/main/java/com/festago/festival/application/FestivalService.java b/backend/src/main/java/com/festago/festival/application/FestivalService.java index 6bdf4d2bf..bcd5fe00d 100644 --- a/backend/src/main/java/com/festago/festival/application/FestivalService.java +++ b/backend/src/main/java/com/festago/festival/application/FestivalService.java @@ -17,24 +17,19 @@ import com.festago.stage.repository.StageRepository; import java.time.LocalDate; import java.util.List; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class FestivalService { private final FestivalRepository festivalRepository; private final StageRepository stageRepository; private final SchoolRepository schoolRepository; - public FestivalService(FestivalRepository festivalRepository, StageRepository stageRepository, - SchoolRepository schoolRepository) { - this.festivalRepository = festivalRepository; - this.stageRepository = stageRepository; - this.schoolRepository = schoolRepository; - } - public FestivalResponse create(FestivalCreateRequest request) { School school = schoolRepository.findById(request.schoolId()) .orElseThrow(() -> new NotFoundException(ErrorCode.SCHOOL_NOT_FOUND)); diff --git a/backend/src/main/java/com/festago/festival/domain/Festival.java b/backend/src/main/java/com/festago/festival/domain/Festival.java index 64602cc87..5cc47311f 100644 --- a/backend/src/main/java/com/festago/festival/domain/Festival.java +++ b/backend/src/main/java/com/festago/festival/domain/Festival.java @@ -14,8 +14,11 @@ import jakarta.validation.constraints.Size; import java.time.LocalDate; import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Festival extends BaseTimeEntity { private static final String DEFAULT_THUMBNAIL = "https://picsum.photos/536/354"; @@ -24,7 +27,6 @@ public class Festival extends BaseTimeEntity { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @NotNull @Size(max = 50) private String name; @@ -42,9 +44,6 @@ public class Festival extends BaseTimeEntity { @ManyToOne(fetch = FetchType.LAZY) private School school; - protected Festival() { - } - public Festival(String name, LocalDate startDate, LocalDate endDate, School school) { this(null, name, startDate, endDate, DEFAULT_THUMBNAIL, school); } diff --git a/backend/src/main/java/com/festago/member/application/MemberService.java b/backend/src/main/java/com/festago/member/application/MemberService.java index e9528e803..bd8cdf397 100644 --- a/backend/src/main/java/com/festago/member/application/MemberService.java +++ b/backend/src/main/java/com/festago/member/application/MemberService.java @@ -5,19 +5,17 @@ import com.festago.member.domain.Member; import com.festago.member.dto.MemberProfileResponse; import com.festago.member.repository.MemberRepository; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Transactional @Service +@RequiredArgsConstructor public class MemberService { private final MemberRepository memberRepository; - public MemberService(MemberRepository memberRepository) { - this.memberRepository = memberRepository; - } - @Transactional(readOnly = true) public MemberProfileResponse findMemberProfile(Long memberId) { Member member = memberRepository.findById(memberId) diff --git a/backend/src/main/java/com/festago/member/domain/Member.java b/backend/src/main/java/com/festago/member/domain/Member.java index d58d2140e..2ee68e879 100644 --- a/backend/src/main/java/com/festago/member/domain/Member.java +++ b/backend/src/main/java/com/festago/member/domain/Member.java @@ -13,6 +13,8 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.hibernate.annotations.SQLDelete; import org.hibernate.annotations.Where; @@ -30,6 +32,7 @@ ) } ) +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Member extends BaseTimeEntity { private static final String DEFAULT_IMAGE_URL = "https://festa-go.site/images/default-profile.png"; @@ -55,9 +58,6 @@ public class Member extends BaseTimeEntity { private LocalDateTime deletedAt = null; - protected Member() { - } - public Member(Long id) { this.id = id; } diff --git a/backend/src/main/java/com/festago/presentation/AdminController.java b/backend/src/main/java/com/festago/presentation/AdminController.java index 59e4ad92b..c60987500 100644 --- a/backend/src/main/java/com/festago/presentation/AdminController.java +++ b/backend/src/main/java/com/festago/presentation/AdminController.java @@ -30,6 +30,7 @@ import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Optional; +import lombok.RequiredArgsConstructor; import org.springframework.boot.info.BuildProperties; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseCookie; @@ -48,6 +49,7 @@ @RestController @RequestMapping("/admin") @Hidden +@RequiredArgsConstructor public class AdminController { private final FestivalService festivalService; @@ -58,18 +60,6 @@ public class AdminController { private final SchoolService schoolService; private final Optional properties; - public AdminController(FestivalService festivalService, StageService stageService, TicketService ticketService, - AdminService adminService, AdminAuthService adminAuthService, - SchoolService schoolService, Optional buildProperties) { - this.festivalService = festivalService; - this.stageService = stageService; - this.ticketService = ticketService; - this.adminService = adminService; - this.adminAuthService = adminAuthService; - this.schoolService = schoolService; - this.properties = buildProperties; - } - @PostMapping("/schools") public ResponseEntity createSchool(@RequestBody @Valid SchoolCreateRequest request) { SchoolResponse response = schoolService.create(request); diff --git a/backend/src/main/java/com/festago/presentation/AuthController.java b/backend/src/main/java/com/festago/presentation/AuthController.java index 36038cdbf..012cecfe6 100644 --- a/backend/src/main/java/com/festago/presentation/AuthController.java +++ b/backend/src/main/java/com/festago/presentation/AuthController.java @@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -18,16 +19,12 @@ @RestController @RequestMapping("/auth") @Tag(name = "로그인 관련 요청") +@RequiredArgsConstructor public class AuthController { private final AuthFacadeService authFacadeService; private final MemberFCMService memberFCMService; - public AuthController(AuthFacadeService authFacadeService, MemberFCMService memberFCMService) { - this.authFacadeService = authFacadeService; - this.memberFCMService = memberFCMService; - } - @PostMapping("/oauth2") @Operation(description = "소셜 엑세스 토큰을 기반으로 로그인 요청을 보낸다.", summary = "OAuth2 로그인") public ResponseEntity login(@RequestBody LoginRequest request) { diff --git a/backend/src/main/java/com/festago/presentation/FestivalController.java b/backend/src/main/java/com/festago/presentation/FestivalController.java index 462b0f0b3..67b9c94fd 100644 --- a/backend/src/main/java/com/festago/presentation/FestivalController.java +++ b/backend/src/main/java/com/festago/presentation/FestivalController.java @@ -5,6 +5,7 @@ import com.festago.festival.dto.FestivalsResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -14,14 +15,11 @@ @RestController @RequestMapping("/festivals") @Tag(name = "축제 정보 요청") +@RequiredArgsConstructor public class FestivalController { private final FestivalService festivalService; - public FestivalController(FestivalService festivalService) { - this.festivalService = festivalService; - } - @GetMapping @Operation(description = "모든 축제들을 조회한다.", summary = "축제 목록 조회") public ResponseEntity findAll() { diff --git a/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java b/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java index 1bc3b023b..d38dc11be 100644 --- a/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java +++ b/backend/src/main/java/com/festago/presentation/GlobalExceptionHandler.java @@ -10,6 +10,7 @@ import com.festago.common.exception.dto.ErrorResponse; import com.festago.presentation.auth.AuthenticateContext; import jakarta.servlet.http.HttpServletRequest; +import lombok.RequiredArgsConstructor; import org.slf4j.Logger; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; @@ -23,6 +24,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; @RestControllerAdvice +@RequiredArgsConstructor public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { private static final String LOG_FORMAT_INFO = "\n[🔵INFO] - ({} {})\n(id: {}, role: {})\n{}\n {}: {}"; @@ -55,11 +57,6 @@ public class GlobalExceptionHandler extends ResponseEntityExceptionHandler { private final AuthenticateContext authenticateContext; private final Logger errorLogger; - public GlobalExceptionHandler(AuthenticateContext authenticateContext, Logger errorLogger) { - this.authenticateContext = authenticateContext; - this.errorLogger = errorLogger; - } - @ExceptionHandler(InvalidMediaTypeException.class) public ResponseEntity handle(InvalidMediaTypeException e) { return ResponseEntity.badRequest().build(); @@ -104,7 +101,8 @@ public ResponseEntity handle(Exception e, HttpServletRequest requ } @Override - protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException e, HttpHeaders headers, + protected ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException e, + HttpHeaders headers, HttpStatusCode status, WebRequest request) { return ResponseEntity.status(HttpStatus.BAD_REQUEST) .body(ErrorResponse.from(ErrorCode.INVALID_REQUEST_ARGUMENT)); diff --git a/backend/src/main/java/com/festago/presentation/MemberController.java b/backend/src/main/java/com/festago/presentation/MemberController.java index b27cb3550..66ec99595 100644 --- a/backend/src/main/java/com/festago/presentation/MemberController.java +++ b/backend/src/main/java/com/festago/presentation/MemberController.java @@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -14,14 +15,11 @@ @RestController @RequestMapping("/members") @Tag(name = "유저 정보 요청") +@RequiredArgsConstructor public class MemberController { private final MemberService memberService; - public MemberController(MemberService memberService) { - this.memberService = memberService; - } - @GetMapping("/profile") @SecurityRequirement(name = "bearerAuth") @Operation(description = "현재 로그인한 유저의 프로필 정보를 조회한다.", summary = "사용자 정보 조회") diff --git a/backend/src/main/java/com/festago/presentation/MemberTicketController.java b/backend/src/main/java/com/festago/presentation/MemberTicketController.java index 2997fb3a6..ba7cda57a 100644 --- a/backend/src/main/java/com/festago/presentation/MemberTicketController.java +++ b/backend/src/main/java/com/festago/presentation/MemberTicketController.java @@ -13,6 +13,7 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; @@ -29,19 +30,13 @@ @SecurityRequirement(name = "bearerAuth") @RequestMapping("/member-tickets") @Tag(name = "유저 티켓 요청") +@RequiredArgsConstructor public class MemberTicketController { private final EntryService entryService; private final MemberTicketService memberTicketService; private final TicketingService ticketingService; - public MemberTicketController(EntryService entryService, MemberTicketService memberTicketService, - TicketingService ticketingService) { - this.entryService = entryService; - this.memberTicketService = memberTicketService; - this.ticketingService = ticketingService; - } - @PostMapping("/{memberTicketId}/qr") @Operation(description = "티켓 제시용 QR 코드를 생성한다.", summary = "티켓 제시용 QR 생성") public ResponseEntity createQR(@Member Long memberId, diff --git a/backend/src/main/java/com/festago/presentation/SchoolController.java b/backend/src/main/java/com/festago/presentation/SchoolController.java index 672d0c0e6..884b50ff7 100644 --- a/backend/src/main/java/com/festago/presentation/SchoolController.java +++ b/backend/src/main/java/com/festago/presentation/SchoolController.java @@ -2,6 +2,7 @@ import com.festago.school.application.SchoolService; import com.festago.school.dto.SchoolsResponse; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -9,14 +10,11 @@ @RestController @RequestMapping("/schools") +@RequiredArgsConstructor public class SchoolController { private final SchoolService schoolService; - public SchoolController(SchoolService schoolService) { - this.schoolService = schoolService; - } - @GetMapping public ResponseEntity findAll() { return ResponseEntity.ok(schoolService.findAll()); diff --git a/backend/src/main/java/com/festago/presentation/StaffMemberTicketController.java b/backend/src/main/java/com/festago/presentation/StaffMemberTicketController.java index be44bda14..4c05c3e42 100644 --- a/backend/src/main/java/com/festago/presentation/StaffMemberTicketController.java +++ b/backend/src/main/java/com/festago/presentation/StaffMemberTicketController.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -16,14 +17,11 @@ @RestController @RequestMapping("/staff/member-tickets") @Tag(name = "스태프 요청") +@RequiredArgsConstructor public class StaffMemberTicketController { private final EntryService entryService; - public StaffMemberTicketController(EntryService entryService) { - this.entryService = entryService; - } - @PostMapping("/validation") @Operation(description = "스태프가 티켓을 검사한다.", summary = "티켓 검사") public ResponseEntity validate(@RequestBody @Valid TicketValidationRequest request) { diff --git a/backend/src/main/java/com/festago/presentation/StageController.java b/backend/src/main/java/com/festago/presentation/StageController.java index 73b707239..53c85716a 100644 --- a/backend/src/main/java/com/festago/presentation/StageController.java +++ b/backend/src/main/java/com/festago/presentation/StageController.java @@ -4,6 +4,7 @@ import com.festago.ticket.dto.StageTicketsResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; @@ -13,14 +14,11 @@ @RestController @RequestMapping("/stages") @Tag(name = "공연 정보 요청") +@RequiredArgsConstructor public class StageController { private final TicketService ticketService; - public StageController(TicketService ticketService) { - this.ticketService = ticketService; - } - @GetMapping("/{stageId}/tickets") @Operation(description = "특정 무대의 티켓 정보를 보여준다.", summary = "무대 티켓 목록 조회") public ResponseEntity findStageTickets(@PathVariable Long stageId) { diff --git a/backend/src/main/java/com/festago/presentation/StudentController.java b/backend/src/main/java/com/festago/presentation/StudentController.java index d0f397f92..0672ece6a 100644 --- a/backend/src/main/java/com/festago/presentation/StudentController.java +++ b/backend/src/main/java/com/festago/presentation/StudentController.java @@ -7,6 +7,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -16,14 +17,11 @@ @RestController @RequestMapping("/students") @Tag(name = "학생 요청") +@RequiredArgsConstructor public class StudentController { private final StudentService studentService; - public StudentController(StudentService studentService) { - this.studentService = studentService; - } - @PostMapping("/send-verification") @Operation(description = "학교 인증 이메일을 전송한다.", summary = "학생 인증 이메일 전송") public ResponseEntity sendEmail(@Member Long memberId, diff --git a/backend/src/main/java/com/festago/school/application/SchoolService.java b/backend/src/main/java/com/festago/school/application/SchoolService.java index 3464cc4f8..0477121a7 100644 --- a/backend/src/main/java/com/festago/school/application/SchoolService.java +++ b/backend/src/main/java/com/festago/school/application/SchoolService.java @@ -7,19 +7,17 @@ import com.festago.school.dto.SchoolResponse; import com.festago.school.dto.SchoolsResponse; import com.festago.school.repository.SchoolRepository; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class SchoolService { private final SchoolRepository schoolRepository; - public SchoolService(SchoolRepository schoolRepository) { - this.schoolRepository = schoolRepository; - } - public SchoolResponse create(SchoolCreateRequest request) { validateSchool(request); School school = schoolRepository.save(new School(request.domain(), request.name())); diff --git a/backend/src/main/java/com/festago/school/domain/School.java b/backend/src/main/java/com/festago/school/domain/School.java index 36ccd746b..84534ddc5 100644 --- a/backend/src/main/java/com/festago/school/domain/School.java +++ b/backend/src/main/java/com/festago/school/domain/School.java @@ -10,8 +10,11 @@ import jakarta.persistence.Id; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class School extends BaseTimeEntity { @Id @@ -28,9 +31,6 @@ public class School extends BaseTimeEntity { @Column(unique = true) private String name; - protected School() { - } - public School(String domain, String name) { this(null, domain, name); } diff --git a/backend/src/main/java/com/festago/stage/application/StageService.java b/backend/src/main/java/com/festago/stage/application/StageService.java index 5198becab..391bc2d78 100644 --- a/backend/src/main/java/com/festago/stage/application/StageService.java +++ b/backend/src/main/java/com/festago/stage/application/StageService.java @@ -8,21 +8,18 @@ import com.festago.stage.dto.StageCreateRequest; import com.festago.stage.dto.StageResponse; import com.festago.stage.repository.StageRepository; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class StageService { private final StageRepository stageRepository; private final FestivalRepository festivalRepository; - public StageService(StageRepository stageRepository, FestivalRepository festivalRepository) { - this.stageRepository = stageRepository; - this.festivalRepository = festivalRepository; - } - public StageResponse create(StageCreateRequest request) { Festival festival = findFestivalById(request.festivalId()); Stage newStage = stageRepository.save(new Stage( diff --git a/backend/src/main/java/com/festago/stage/domain/Stage.java b/backend/src/main/java/com/festago/stage/domain/Stage.java index 9faaf2b5e..d15327e12 100644 --- a/backend/src/main/java/com/festago/stage/domain/Stage.java +++ b/backend/src/main/java/com/festago/stage/domain/Stage.java @@ -17,8 +17,11 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Stage extends BaseTimeEntity { @Id @@ -41,9 +44,6 @@ public class Stage extends BaseTimeEntity { @OneToMany(mappedBy = "stage", fetch = FetchType.LAZY) private List tickets = new ArrayList<>(); - protected Stage() { - } - public Stage(LocalDateTime startTime, String lineUp, LocalDateTime ticketOpenTime, Festival festival) { this(null, startTime, lineUp, ticketOpenTime, festival); } diff --git a/backend/src/main/java/com/festago/student/application/StudentService.java b/backend/src/main/java/com/festago/student/application/StudentService.java index 0ae184eb3..872937a66 100644 --- a/backend/src/main/java/com/festago/student/application/StudentService.java +++ b/backend/src/main/java/com/festago/student/application/StudentService.java @@ -15,11 +15,13 @@ import com.festago.student.dto.StudentVerificateRequest; import com.festago.student.repository.StudentCodeRepository; import com.festago.student.repository.StudentRepository; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class StudentService { private final MailClient mailClient; @@ -29,17 +31,6 @@ public class StudentService { private final MemberRepository memberRepository; private final StudentRepository studentRepository; - public StudentService(MailClient mailClient, VerificationCodeProvider codeProvider, - StudentCodeRepository studentCodeRepository, SchoolRepository schoolRepository, - MemberRepository memberRepository, StudentRepository studentRepository) { - this.mailClient = mailClient; - this.codeProvider = codeProvider; - this.studentCodeRepository = studentCodeRepository; - this.schoolRepository = schoolRepository; - this.memberRepository = memberRepository; - this.studentRepository = studentRepository; - } - public void sendVerificationMail(Long memberId, StudentSendMailRequest request) { validateStudent(memberId); validateDuplicateEmail(request); @@ -76,7 +67,8 @@ private School findSchool(Long schoolId) { public void verificate(Long memberId, StudentVerificateRequest request) { validateStudent(memberId); Member member = findMember(memberId); - StudentCode studentCode = studentCodeRepository.findByCodeAndMember(new VerificationCode(request.code()), member) + StudentCode studentCode = studentCodeRepository.findByCodeAndMember(new VerificationCode(request.code()), + member) .orElseThrow(() -> new BadRequestException(ErrorCode.INVALID_STUDENT_VERIFICATION_CODE)); studentRepository.save(new Student(member, studentCode.getSchool(), studentCode.getUsername())); studentCodeRepository.deleteByMember(member); diff --git a/backend/src/main/java/com/festago/student/domain/Student.java b/backend/src/main/java/com/festago/student/domain/Student.java index 2b7b46214..b1559d660 100644 --- a/backend/src/main/java/com/festago/student/domain/Student.java +++ b/backend/src/main/java/com/festago/student/domain/Student.java @@ -14,8 +14,11 @@ import jakarta.persistence.OneToOne; import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Size; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Student extends BaseTimeEntity { @Id @@ -34,9 +37,6 @@ public class Student extends BaseTimeEntity { @NotNull private String username; - protected Student() { - } - public Student(Member member, School school, String username) { this(null, member, school, username); } diff --git a/backend/src/main/java/com/festago/student/domain/StudentCode.java b/backend/src/main/java/com/festago/student/domain/StudentCode.java index 947e58a61..9ef3239f3 100644 --- a/backend/src/main/java/com/festago/student/domain/StudentCode.java +++ b/backend/src/main/java/com/festago/student/domain/StudentCode.java @@ -13,9 +13,12 @@ import jakarta.persistence.Id; import jakarta.persistence.ManyToOne; import jakarta.persistence.OneToOne; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.springframework.util.StringUtils; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class StudentCode extends BaseTimeEntity { @Id @@ -33,9 +36,6 @@ public class StudentCode extends BaseTimeEntity { private String username; - protected StudentCode() { - } - public StudentCode(VerificationCode code, School school, Member member, String username) { this(null, code, school, member, username); } diff --git a/backend/src/main/java/com/festago/student/domain/VerificationCode.java b/backend/src/main/java/com/festago/student/domain/VerificationCode.java index 2236a9b24..4c5f751be 100644 --- a/backend/src/main/java/com/festago/student/domain/VerificationCode.java +++ b/backend/src/main/java/com/festago/student/domain/VerificationCode.java @@ -5,8 +5,11 @@ import jakarta.persistence.Column; import jakarta.persistence.Embeddable; import java.util.regex.Pattern; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Embeddable +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class VerificationCode { public static final int LENGTH = 6; @@ -14,9 +17,6 @@ public class VerificationCode { @Column(name = "code") private String value; - protected VerificationCode() { - } - public VerificationCode(String value) { validate(value); this.value = value; diff --git a/backend/src/main/java/com/festago/ticket/application/TicketService.java b/backend/src/main/java/com/festago/ticket/application/TicketService.java index 88b022e11..74e72d5f4 100644 --- a/backend/src/main/java/com/festago/ticket/application/TicketService.java +++ b/backend/src/main/java/com/festago/ticket/application/TicketService.java @@ -13,23 +13,19 @@ import com.festago.ticket.repository.TicketRepository; import java.time.Clock; import java.time.LocalDateTime; +import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @Service @Transactional +@RequiredArgsConstructor public class TicketService { private final TicketRepository ticketRepository; private final StageRepository stageRepository; private final Clock clock; - public TicketService(TicketRepository ticketRepository, StageRepository stageRepository, Clock clock) { - this.ticketRepository = ticketRepository; - this.stageRepository = stageRepository; - this.clock = clock; - } - public TicketCreateResponse create(TicketCreateRequest request) { Stage stage = findStageById(request.stageId()); TicketType ticketType = request.ticketType(); diff --git a/backend/src/main/java/com/festago/ticket/domain/Ticket.java b/backend/src/main/java/com/festago/ticket/domain/Ticket.java index fe873d0ff..1e22d76e9 100644 --- a/backend/src/main/java/com/festago/ticket/domain/Ticket.java +++ b/backend/src/main/java/com/festago/ticket/domain/Ticket.java @@ -24,9 +24,12 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; import org.hibernate.annotations.SortNatural; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class Ticket extends BaseTimeEntity { private static final int EARLY_ENTRY_LIMIT = 12; @@ -53,9 +56,6 @@ public class Ticket extends BaseTimeEntity { @SortNatural private SortedSet ticketEntryTimes = new TreeSet<>(); - protected Ticket() { - } - public Ticket(Stage stage, TicketType ticketType, School school) { this(null, stage, ticketType, school); } diff --git a/backend/src/main/java/com/festago/ticket/domain/TicketAmount.java b/backend/src/main/java/com/festago/ticket/domain/TicketAmount.java index b3faa00b6..738ccfc6c 100644 --- a/backend/src/main/java/com/festago/ticket/domain/TicketAmount.java +++ b/backend/src/main/java/com/festago/ticket/domain/TicketAmount.java @@ -10,8 +10,10 @@ import jakarta.persistence.MapsId; import jakarta.persistence.OneToOne; import jakarta.validation.constraints.Min; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor public class TicketAmount extends BaseTimeEntity { @Id @@ -28,9 +30,6 @@ public class TicketAmount extends BaseTimeEntity { @JoinColumn(name = "ticket_id") private Ticket ticket; - public TicketAmount() { - } - public TicketAmount(Ticket ticket) { validate(ticket); this.ticket = ticket; diff --git a/backend/src/main/java/com/festago/ticket/domain/TicketEntryTime.java b/backend/src/main/java/com/festago/ticket/domain/TicketEntryTime.java index 3a0500f6d..f26cf7d4b 100644 --- a/backend/src/main/java/com/festago/ticket/domain/TicketEntryTime.java +++ b/backend/src/main/java/com/festago/ticket/domain/TicketEntryTime.java @@ -10,8 +10,11 @@ import jakarta.validation.constraints.Min; import jakarta.validation.constraints.NotNull; import java.time.LocalDateTime; +import lombok.AccessLevel; +import lombok.NoArgsConstructor; @Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) public class TicketEntryTime extends BaseTimeEntity implements Comparable { private static final int MIN_TOTAL_AMOUNT = 1; @@ -26,9 +29,6 @@ public class TicketEntryTime extends BaseTimeEntity implements Comparable