-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from TaetaetaE01/main
admin controller 분리
- Loading branch information
Showing
11 changed files
with
284 additions
and
105 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/main/java/com/example/bigbrotherbe/domain/event/controller/EventAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiResponse<Void>> registerEvent(@RequestPart(value = "eventRegisterRequest") EventRegisterRequest eventRegisterRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
eventService.registerEvent(eventRegisterRequest, multipartFiles); | ||
return ResponseEntity.ok().build(); | ||
} | ||
|
||
@PutMapping("/{eventId}") | ||
public ResponseEntity<ApiResponse<Void>> updateEvent(@PathVariable("eventId") Long eventId, | ||
@RequestPart(value = "eventUpdateRequest") EventUpdateRequest eventUpdateRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
eventService.updateEvent(eventId, eventUpdateRequest, multipartFiles); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{eventId}") | ||
public ResponseEntity<ApiResponse<Void>> deleteEvent(@PathVariable("eventId") Long eventId) { | ||
eventService.deleteEvent(eventId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@GetMapping("/{eventId}") | ||
public ResponseEntity<ApiResponse<EventResponse>> getEventById(@PathVariable("eventId") Long eventId) { | ||
EventResponse eventResponse = eventService.getEventById(eventId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS, eventResponse)); | ||
} | ||
|
||
@GetMapping() | ||
public ResponseEntity<ApiResponse<Page<Event>>> 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<Event> 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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...ain/java/com/example/bigbrotherbe/domain/meetings/controller/MeetingsAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiResponse<Void>> registerMeetings(@RequestPart(value = "meetingsRegisterRequest") MeetingsRegisterRequest meetingsRegisterRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
meetingsService.registerMeetings(meetingsRegisterRequest, multipartFiles); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@PutMapping("/{meetingsId}") | ||
public ResponseEntity<ApiResponse<Void>> updateMeetings(@PathVariable("meetingsId") Long meetingsId, | ||
@RequestPart(value = "meetingsUpdateRequest") MeetingsUpdateRequest meetingsUpdateRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
meetingsService.updateMeetings(meetingsId, meetingsUpdateRequest, multipartFiles); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{meetingsId}") | ||
public ResponseEntity<ApiResponse<Void>> deleteMeetings(@PathVariable("meetingsId") Long meetingsId) { | ||
meetingsService.deleteMeetings(meetingsId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@GetMapping("/{meetingsId}") | ||
public ResponseEntity<ApiResponse<MeetingsResponse>> getMeetingsById(@PathVariable("meetingsId") Long MeetingsId) { | ||
MeetingsResponse meetingsResponse = meetingsService.getMeetingsById(MeetingsId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS, meetingsResponse)); | ||
} | ||
|
||
@GetMapping() | ||
public ResponseEntity<ApiResponse<Page<Meetings>>> 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<Meetings> 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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/com/example/bigbrotherbe/domain/rule/controller/RuleAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiResponse<Void>> registerRule(@RequestPart(value = "ruleRegisterRequest") RuleRegisterRequest ruleRegisterRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
ruleService.registerRule(ruleRegisterRequest, multipartFiles); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@PutMapping("/{ruleId}") | ||
public ResponseEntity<ApiResponse<Void>> updateRule(@PathVariable("ruleId") Long ruleId, | ||
@RequestPart(value = "ruleUpdateRequest") RuleUpdateRequest ruleUpdateRequest, | ||
@RequestPart(value = "file", required = false) List<MultipartFile> multipartFiles) { | ||
ruleService.updateRule(ruleId, ruleUpdateRequest, multipartFiles); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@DeleteMapping("/{ruleId}") | ||
public ResponseEntity<ApiResponse<Void>> deleteRule(@PathVariable("ruleId") Long ruleId) { | ||
ruleService.deleteRule(ruleId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@GetMapping("/{ruleId}") | ||
public ResponseEntity<ApiResponse<RuleResponse>> getRuleById(@PathVariable("ruleId") Long ruleId) { | ||
RuleResponse ruleResponse = ruleService.getRuleById(ruleId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS, ruleResponse)); | ||
} | ||
|
||
@GetMapping() | ||
public ResponseEntity<ApiResponse<Page<Rule>>> 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<Rule> 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)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
.../com/example/bigbrotherbe/domain/transactions/controller/TransactionsAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<ApiResponse<Void>> registerTransaction(@RequestParam("affiliationId") Long affiliationId, | ||
@RequestPart(value = "file") MultipartFile multipartFile) { | ||
transactionsService.register(multipartFile, affiliationId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@PutMapping("/{transactionsId}") | ||
public ResponseEntity<ApiResponse<Void>> updateTransactions(@PathVariable("transactionsId") Long transactionsId, | ||
@RequestBody TransactionsUpdateRequest transactionsUpdateRequest) { | ||
transactionsService.update(transactionsId, transactionsUpdateRequest); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS)); | ||
} | ||
|
||
@GetMapping | ||
public ResponseEntity<ApiResponse<List<TransactionsResponse>>> getTransactions(@RequestParam("affiliationId") Long affiliationId, | ||
@RequestParam("year") int year, | ||
@RequestParam("month") int month) { | ||
List<TransactionsResponse> transactionsList = transactionsService.getTransactionsWithMonth(year, month, affiliationId); | ||
return ResponseEntity.ok(ApiResponse.success(SUCCESS, transactionsList)); | ||
} | ||
} |
Oops, something went wrong.