From 997abf63c3f6b84c55cfbb7119266cb91baefa52 Mon Sep 17 00:00:00 2001 From: TaetaetaE01 Date: Wed, 14 Aug 2024 01:00:31 +0900 Subject: [PATCH 1/2] =?UTF-8?q?[feat]=20:=20admin=20controller=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EventAdminController.java | 72 ++++++++++++++++++ .../event/controller/EventController.java | 23 +----- .../controller/MeetingsAdminController.java | 72 ++++++++++++++++++ .../controller/MeetingsController.java | 24 +----- .../rule/controller/RuleAdminController.java | 73 +++++++++++++++++++ .../rule/controller/RuleController.java | 22 +----- .../TransactionsAdminController.java | 45 ++++++++++++ .../controller/TransactionsController.java | 16 +--- .../global/database/InitialDataLoader.java | 2 +- .../global/ssh/SshTunnelingInitializer.java | 4 +- src/main/resources/application.yml | 28 ++++--- 11 files changed, 283 insertions(+), 98 deletions(-) create mode 100644 src/main/java/com/example/bigbrotherbe/domain/event/controller/EventAdminController.java create mode 100644 src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsAdminController.java create mode 100644 src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleAdminController.java create mode 100644 src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsAdminController.java diff --git a/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventAdminController.java b/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventAdminController.java new file mode 100644 index 0000000..ff3bced --- /dev/null +++ b/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventAdminController.java @@ -0,0 +1,72 @@ +package com.example.bigbrotherbe.domain.event.controller; + +import com.example.bigbrotherbe.domain.event.dto.request.EventRegisterRequest; +import com.example.bigbrotherbe.domain.event.dto.request.EventUpdateRequest; +import com.example.bigbrotherbe.domain.event.dto.response.EventResponse; +import com.example.bigbrotherbe.domain.event.entity.Event; +import com.example.bigbrotherbe.domain.event.service.EventService; +import com.example.bigbrotherbe.global.exception.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.PAGE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.SIZE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.exception.enums.SuccessCode.SUCCESS; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/admin/event") +public class EventAdminController { + + private final EventService eventService; + + @PostMapping + public ResponseEntity> registerEvent(@RequestPart(value = "eventRegisterRequest") EventRegisterRequest eventRegisterRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + eventService.registerEvent(eventRegisterRequest, multipartFiles); + return ResponseEntity.ok().build(); + } + + @PutMapping("/{eventId}") + public ResponseEntity> updateEvent(@PathVariable("eventId") Long eventId, + @RequestPart(value = "eventUpdateRequest") EventUpdateRequest eventUpdateRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + eventService.updateEvent(eventId, eventUpdateRequest, multipartFiles); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @DeleteMapping("/{eventId}") + public ResponseEntity> deleteEvent(@PathVariable("eventId") Long eventId) { + eventService.deleteEvent(eventId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @GetMapping("/{eventId}") + public ResponseEntity> getEventById(@PathVariable("eventId") Long eventId) { + EventResponse eventResponse = eventService.getEventById(eventId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS, eventResponse)); + } + + @GetMapping() + public ResponseEntity>> getMeetingsList(@RequestParam(name = "affiliationId") Long affiliationId, + @RequestParam(name = "page", defaultValue = PAGE_DEFAULT_VALUE) int page, + @RequestParam(name = "size", defaultValue = SIZE_DEFAULT_VALUE) int size, + @RequestParam(name = "search", required = false) String search) { + Page envetPage; + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id")); + if (search != null && !search.isEmpty()) { + envetPage = eventService.searchEvent(affiliationId, search, pageable); + } else { + envetPage = eventService.getEvents(affiliationId, pageable); + } + return ResponseEntity.ok(ApiResponse.success(SUCCESS, envetPage)); + } +} diff --git a/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventController.java b/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventController.java index c6bb479..c43b8e1 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/event/controller/EventController.java @@ -23,32 +23,11 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/big-brother/event") +@RequestMapping("/api/v1/event") public class EventController { private final EventService eventService; - @PostMapping - public ResponseEntity> registerEvent(@RequestPart(value = "eventRegisterRequest") EventRegisterRequest eventRegisterRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - eventService.registerEvent(eventRegisterRequest, multipartFiles); - return ResponseEntity.ok().build(); - } - - @PutMapping("/{eventId}") - public ResponseEntity> updateEvent(@PathVariable("eventId") Long eventId, - @RequestPart(value = "eventUpdateRequest") EventUpdateRequest eventUpdateRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - eventService.updateEvent(eventId, eventUpdateRequest, multipartFiles); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @DeleteMapping("/{eventId}") - public ResponseEntity> deleteEvent(@PathVariable("eventId") Long eventId) { - eventService.deleteEvent(eventId); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - @GetMapping("/{eventId}") public ResponseEntity> getEventById(@PathVariable("eventId") Long eventId) { EventResponse eventResponse = eventService.getEventById(eventId); diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsAdminController.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsAdminController.java new file mode 100644 index 0000000..4b8ac29 --- /dev/null +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsAdminController.java @@ -0,0 +1,72 @@ +package com.example.bigbrotherbe.domain.meetings.controller; + +import com.example.bigbrotherbe.domain.meetings.dto.request.MeetingsRegisterRequest; +import com.example.bigbrotherbe.domain.meetings.dto.request.MeetingsUpdateRequest; +import com.example.bigbrotherbe.domain.meetings.dto.response.MeetingsResponse; +import com.example.bigbrotherbe.domain.meetings.entity.Meetings; +import com.example.bigbrotherbe.domain.meetings.service.MeetingsService; +import com.example.bigbrotherbe.global.exception.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.PAGE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.SIZE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.exception.enums.SuccessCode.SUCCESS; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/admin/meetings") +public class MeetingsAdminController { + + private final MeetingsService meetingsService; + + @PostMapping + public ResponseEntity> registerMeetings(@RequestPart(value = "meetingsRegisterRequest") MeetingsRegisterRequest meetingsRegisterRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + meetingsService.registerMeetings(meetingsRegisterRequest, multipartFiles); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @PutMapping("/{meetingsId}") + public ResponseEntity> updateMeetings(@PathVariable("meetingsId") Long meetingsId, + @RequestPart(value = "meetingsUpdateRequest") MeetingsUpdateRequest meetingsUpdateRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + meetingsService.updateMeetings(meetingsId, meetingsUpdateRequest, multipartFiles); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @DeleteMapping("/{meetingsId}") + public ResponseEntity> deleteMeetings(@PathVariable("meetingsId") Long meetingsId) { + meetingsService.deleteMeetings(meetingsId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @GetMapping("/{meetingsId}") + public ResponseEntity> getMeetingsById(@PathVariable("meetingsId") Long MeetingsId) { + MeetingsResponse meetingsResponse = meetingsService.getMeetingsById(MeetingsId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS, meetingsResponse)); + } + + @GetMapping() + public ResponseEntity>> getMeetingsList(@RequestParam(name = "affiliationId") Long affiliationId, + @RequestParam(name = "page", defaultValue = PAGE_DEFAULT_VALUE) int page, + @RequestParam(name = "size", defaultValue = SIZE_DEFAULT_VALUE) int size, + @RequestParam(name = "search", required = false) String search) { + Page meetingsPage; + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id")); + if (search != null && !search.isEmpty()) { + meetingsPage = meetingsService.searchMeetings(affiliationId, search, pageable); + } else { + meetingsPage = meetingsService.getMeetings(affiliationId, pageable); + } + return ResponseEntity.ok(ApiResponse.success(SUCCESS, meetingsPage)); + } +} diff --git a/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java index 81257b6..83fc22f 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsController.java @@ -27,33 +27,11 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/big-brother/meetings") +@RequestMapping("/api/v1/meetings") public class MeetingsController { private final MeetingsService meetingsService; - - @PostMapping - public ResponseEntity> registerMeetings(@RequestPart(value = "meetingsRegisterRequest") MeetingsRegisterRequest meetingsRegisterRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - meetingsService.registerMeetings(meetingsRegisterRequest, multipartFiles); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @PutMapping("/{meetingsId}") - public ResponseEntity> updateMeetings(@PathVariable("meetingsId") Long meetingsId, - @RequestPart(value = "meetingsUpdateRequest") MeetingsUpdateRequest meetingsUpdateRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - meetingsService.updateMeetings(meetingsId, meetingsUpdateRequest, multipartFiles); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @DeleteMapping("/{meetingsId}") - public ResponseEntity> deleteMeetings(@PathVariable("meetingsId") Long meetingsId) { - meetingsService.deleteMeetings(meetingsId); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - @GetMapping("/{meetingsId}") public ResponseEntity> getMeetingsById(@PathVariable("meetingsId") Long MeetingsId) { MeetingsResponse meetingsResponse = meetingsService.getMeetingsById(MeetingsId); diff --git a/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleAdminController.java b/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleAdminController.java new file mode 100644 index 0000000..705dfc9 --- /dev/null +++ b/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleAdminController.java @@ -0,0 +1,73 @@ +package com.example.bigbrotherbe.domain.rule.controller; + + +import com.example.bigbrotherbe.domain.rule.dto.request.RuleRegisterRequest; +import com.example.bigbrotherbe.domain.rule.dto.request.RuleUpdateRequest; +import com.example.bigbrotherbe.domain.rule.dto.response.RuleResponse; +import com.example.bigbrotherbe.domain.rule.entity.Rule; +import com.example.bigbrotherbe.domain.rule.service.RuleService; +import com.example.bigbrotherbe.global.exception.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.PAGE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.constant.Constant.GetContent.SIZE_DEFAULT_VALUE; +import static com.example.bigbrotherbe.global.exception.enums.SuccessCode.SUCCESS; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/admin/rule") +public class RuleAdminController { + + private final RuleService ruleService; + + @PostMapping + public ResponseEntity> registerRule(@RequestPart(value = "ruleRegisterRequest") RuleRegisterRequest ruleRegisterRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + ruleService.registerRule(ruleRegisterRequest, multipartFiles); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @PutMapping("/{ruleId}") + public ResponseEntity> updateRule(@PathVariable("ruleId") Long ruleId, + @RequestPart(value = "ruleUpdateRequest") RuleUpdateRequest ruleUpdateRequest, + @RequestPart(value = "file", required = false) List multipartFiles) { + ruleService.updateRule(ruleId, ruleUpdateRequest, multipartFiles); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @DeleteMapping("/{ruleId}") + public ResponseEntity> deleteRule(@PathVariable("ruleId") Long ruleId) { + ruleService.deleteRule(ruleId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @GetMapping("/{ruleId}") + public ResponseEntity> getRuleById(@PathVariable("ruleId") Long ruleId) { + RuleResponse ruleResponse = ruleService.getRuleById(ruleId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS, ruleResponse)); + } + + @GetMapping() + public ResponseEntity>> getRuleList(@RequestParam(name = "affiliationId") Long affiliationId, + @RequestParam(name = "page", defaultValue = PAGE_DEFAULT_VALUE) int page, + @RequestParam(name = "size", defaultValue = SIZE_DEFAULT_VALUE) int size, + @RequestParam(name = "search", required = false) String search) { + Page rulePage; + Pageable pageable = PageRequest.of(page, size, Sort.by(Sort.Direction.DESC, "id")); + if (search != null && !search.isEmpty()) { + rulePage = ruleService.searchRules(affiliationId, search, pageable); + } else { + rulePage = ruleService.getRules(affiliationId, pageable); + } + return ResponseEntity.ok(ApiResponse.success(SUCCESS, rulePage)); + } +} diff --git a/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleController.java b/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleController.java index e65ad8c..17ebc3d 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleController.java @@ -23,31 +23,11 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/big-brother/rule") +@RequestMapping("/api/v1/rule") public class RuleController { private final RuleService ruleService; - @PostMapping - public ResponseEntity> registerRule(@RequestPart(value = "ruleRegisterRequest") RuleRegisterRequest ruleRegisterRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - ruleService.registerRule(ruleRegisterRequest, multipartFiles); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @PutMapping("/{ruleId}") - public ResponseEntity> updateRule(@PathVariable("ruleId") Long ruleId, - @RequestPart(value = "ruleUpdateRequest") RuleUpdateRequest ruleUpdateRequest, - @RequestPart(value = "file", required = false) List multipartFiles) { - ruleService.updateRule(ruleId, ruleUpdateRequest, multipartFiles); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @DeleteMapping("/{ruleId}") - public ResponseEntity> deleteRule(@PathVariable("ruleId") Long ruleId) { - ruleService.deleteRule(ruleId); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } @GetMapping("/{ruleId}") public ResponseEntity> getRuleById(@PathVariable("ruleId") Long ruleId) { diff --git a/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsAdminController.java b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsAdminController.java new file mode 100644 index 0000000..3abddf3 --- /dev/null +++ b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsAdminController.java @@ -0,0 +1,45 @@ +package com.example.bigbrotherbe.domain.transactions.controller; + + +import com.example.bigbrotherbe.domain.transactions.dto.request.TransactionsUpdateRequest; +import com.example.bigbrotherbe.domain.transactions.dto.response.TransactionsResponse; +import com.example.bigbrotherbe.domain.transactions.service.TransactionsService; +import com.example.bigbrotherbe.global.exception.response.ApiResponse; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +import static com.example.bigbrotherbe.global.exception.enums.SuccessCode.SUCCESS; + +@RestController +@RequiredArgsConstructor +@RequestMapping("/api/v1/admin/transactions") +public class TransactionsAdminController { + + private final TransactionsService transactionsService; + + @PostMapping + public ResponseEntity> registerTransaction(@RequestParam("affiliationId") Long affiliationId, + @RequestPart(value = "file") MultipartFile multipartFile) { + transactionsService.register(multipartFile, affiliationId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @PutMapping("/{transactionsId}") + public ResponseEntity> updateTransactions(@PathVariable("transactionsId") Long transactionsId, + @RequestBody TransactionsUpdateRequest transactionsUpdateRequest) { + transactionsService.update(transactionsId, transactionsUpdateRequest); + return ResponseEntity.ok(ApiResponse.success(SUCCESS)); + } + + @GetMapping + public ResponseEntity>> getTransactions(@RequestParam("affiliationId") Long affiliationId, + @RequestParam("year") int year, + @RequestParam("month") int month) { + List transactionsList = transactionsService.getTransactionsWithMonth(year, month, affiliationId); + return ResponseEntity.ok(ApiResponse.success(SUCCESS, transactionsList)); + } +} diff --git a/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java index b973c52..a00eceb 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java @@ -21,25 +21,11 @@ @RestController @RequiredArgsConstructor -@RequestMapping("/api/big-brother/transactions") +@RequestMapping("/api/v1/transactions") public class TransactionsController { private final TransactionsService transactionsService; - @PostMapping - public ResponseEntity> registerTransaction(@RequestParam("affiliationId") Long affiliationId, - @RequestPart(value = "file") MultipartFile multipartFile) { - transactionsService.register(multipartFile, affiliationId); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - - @PutMapping("/{transactionsId}") - public ResponseEntity> updateTransactions(@PathVariable("transactionsId") Long transactionsId, - @RequestBody TransactionsUpdateRequest transactionsUpdateRequest) { - transactionsService.update(transactionsId, transactionsUpdateRequest); - return ResponseEntity.ok(ApiResponse.success(SUCCESS)); - } - @GetMapping public ResponseEntity>> getTransactions(@RequestParam("affiliationId") Long affiliationId, @RequestParam("year") int year, diff --git a/src/main/java/com/example/bigbrotherbe/global/database/InitialDataLoader.java b/src/main/java/com/example/bigbrotherbe/global/database/InitialDataLoader.java index c32b1a8..cf1f688 100644 --- a/src/main/java/com/example/bigbrotherbe/global/database/InitialDataLoader.java +++ b/src/main/java/com/example/bigbrotherbe/global/database/InitialDataLoader.java @@ -36,7 +36,7 @@ public CommandLineRunner loadData(MemberRepository memberRepository, Affiliation admin.setEmail("developthreefeet@gmail.com"); admin.setUsername("admin"); memberRepository.save(admin); - Affiliation affiliation = affiliationRepository.findByAffiliationName("융소") + Affiliation affiliation = affiliationRepository.findByAffiliationName("응용소프트웨어전공") .orElseThrow(() -> new IllegalArgumentException("잘못된 소속 이름입니다.")); // AffiliationMember 엔티티 생성 diff --git a/src/main/java/com/example/bigbrotherbe/global/ssh/SshTunnelingInitializer.java b/src/main/java/com/example/bigbrotherbe/global/ssh/SshTunnelingInitializer.java index 749ef3a..e197ca1 100644 --- a/src/main/java/com/example/bigbrotherbe/global/ssh/SshTunnelingInitializer.java +++ b/src/main/java/com/example/bigbrotherbe/global/ssh/SshTunnelingInitializer.java @@ -13,7 +13,8 @@ // //@Slf4j //@Component -//@Validated @Setter +//@Validated +//@Setter //public class SshTunnelingInitializer { // // @Value("${ssh.remote-host}") @@ -30,6 +31,7 @@ // private int databasePort = 3306; // // private Session session; +// // @PreDestroy // public void destroy() { // if (session.isConnected()) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 482b27a..702bf5a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,21 +11,21 @@ spring: write-dates-as-timestamps: false time-zone: Asia/Seoul + # 환경 변수를 사용하는 데이터베이스 설정 (주석 해제 필요시) +# datasource: +# url: ${DB_URL} +# username: ${DB_USER_NAME} +# password: ${DB_PASSWORD} +# hikari: +# max-lifetime: 177000 # 177초, hikari는 RDS wait_timeout(180초) 보다 2 ~ 3초 정도 짧게 줄 것을 권장 +# driver-class-name: com.mysql.cj.jdbc.Driver + # 태태 로컬 데이터베이스 설정 datasource: - url: ${DB_URL} - username: ${DB_USER_NAME} - password: ${DB_PASSWORD} - hikari: - max-lifetime: 177000 # 177초, hikari는 RDS wait_timeout(180초) 보다 2 ~ 3초 정도 짧게 줄 것을 권장 + url: jdbc:mysql://localhost:3306/bigbrother driver-class-name: com.mysql.cj.jdbc.Driver - # 환경 변수를 사용하는 데이터베이스 설정 (주석 해제 필요시) # datasource: - # 태태 로컬 데이터베이스 설정 - # datasource: - # url: jdbc:mysql://localhost:3306/bigbrother - # driver-class-name: com.mysql.cj.jdbc.Driver - # username: root - # password: 1234 + username: root + password: 1234 # 상윤 로컬 데이터베이스 설정 # datasource: @@ -54,7 +54,7 @@ spring: jpa: hibernate: - ddl-auto: create-drop + ddl-auto: update properties: hibernate: format_sql: true @@ -71,7 +71,6 @@ spring: max-request-size: 300MB max-file-size: 300MB - jwt: secret: ${JWT_SECRET} @@ -92,4 +91,3 @@ ssh: ssh-port: 22 user-name: ${SSH_USER_NAME} private-key-path: ${SSH_PRIVATE_KEY_PATH} - From 761b8c73041450d962d7ffd39255ac864bb6a398 Mon Sep 17 00:00:00 2001 From: TaetaetaE01 Date: Wed, 14 Aug 2024 01:02:08 +0900 Subject: [PATCH 2/2] =?UTF-8?q?[refactor]=20:=20transactions=20=EC=B9=BC?= =?UTF-8?q?=EB=9F=BC=20=EC=84=A4=EC=A0=95=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../transactions/controller/TransactionsController.java | 7 ------- .../domain/transactions/entity/Transactions.java | 3 ++- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java index a00eceb..21f7f06 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java +++ b/src/main/java/com/example/bigbrotherbe/domain/transactions/controller/TransactionsController.java @@ -1,18 +1,11 @@ package com.example.bigbrotherbe.domain.transactions.controller; -import com.amazonaws.Response; -import com.example.bigbrotherbe.domain.meetings.dto.request.MeetingsUpdateRequest; -import com.example.bigbrotherbe.domain.transactions.dto.request.TransactionsUpdateRequest; import com.example.bigbrotherbe.domain.transactions.dto.response.TransactionsResponse; import com.example.bigbrotherbe.domain.transactions.service.TransactionsService; -import com.example.bigbrotherbe.domain.transactions.service.TransactionsServiceImpl; import com.example.bigbrotherbe.global.exception.response.ApiResponse; -import com.example.bigbrotherbe.global.ocr.dto.OcrDTO; -import jakarta.servlet.http.HttpServletRequest; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; import java.util.List; diff --git a/src/main/java/com/example/bigbrotherbe/domain/transactions/entity/Transactions.java b/src/main/java/com/example/bigbrotherbe/domain/transactions/entity/Transactions.java index f478a2f..3e556a9 100644 --- a/src/main/java/com/example/bigbrotherbe/domain/transactions/entity/Transactions.java +++ b/src/main/java/com/example/bigbrotherbe/domain/transactions/entity/Transactions.java @@ -47,8 +47,9 @@ public class Transactions extends BaseTimeEntity { @Column(name = "affiliation_id") private Long affiliationId; - @OneToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "file_id") + @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) private File file; // 거래일자, 구분, 거래금액, 거래 후 잔액, 거래내용 , 계좌번호 // date, type, amount, balance, Description , accountNumber