Skip to content

Commit

Permalink
Merge pull request #65 from TaetaetaE01/main
Browse files Browse the repository at this point in the history
admin controller 분리
  • Loading branch information
TaetaetaE01 authored Aug 13, 2024
2 parents 98f6712 + 4108937 commit 221c68f
Show file tree
Hide file tree
Showing 11 changed files with 284 additions and 105 deletions.
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<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);
Expand Down
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<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);
Expand Down
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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<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) {
Expand Down
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));
}
}
Loading

0 comments on commit 221c68f

Please sign in to comment.