Skip to content

Commit

Permalink
Merge pull request #324 from IceButler/refactor/#323-exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sojungpp authored Jul 6, 2024
2 parents 710c9c2 + a401a5f commit cb33243
Show file tree
Hide file tree
Showing 16 changed files with 137 additions and 427 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package com.example.icebutler_server.admin.controller;

import com.example.icebutler_server.admin.dto.condition.SearchCond;
import com.example.icebutler_server.admin.dto.request.*;
import com.example.icebutler_server.admin.dto.response.*;
import com.example.icebutler_server.admin.dto.response.AdminResponse;
import com.example.icebutler_server.admin.dto.response.LoginResponse;
import com.example.icebutler_server.admin.dto.response.LogoutResponse;
import com.example.icebutler_server.admin.dto.response.SearchFoodsResponse;
import com.example.icebutler_server.admin.dto.response.PostAdminRes;
Expand All @@ -16,7 +14,6 @@
import com.example.icebutler_server.global.resolver.*;
import com.example.icebutler_server.global.sqs.AmazonSQSSender;
import com.example.icebutler_server.global.sqs.FoodData;
import com.example.icebutler_server.user.dto.response.MyProfileRes;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
Expand All @@ -41,21 +38,21 @@ public class AdminController {
@PostMapping("/join")
public ResponseCustom<AdminResponse> join(@RequestBody JoinRequest request)
{
return ResponseCustom.OK(adminService.join(request));
return ResponseCustom.success(adminService.join(request));
}

@PostMapping("/login")
public ResponseCustom<PostAdminRes> login(@RequestBody LoginRequest request)
{
return ResponseCustom.OK(adminService.login(request));
return ResponseCustom.success(adminService.login(request));
}

@Admin
@PostMapping("/logout")
public ResponseCustom<LogoutResponse> logout(@IsAdminLogin AdminLoginStatus loginStatus)
{
adminService.logout(loginStatus.getAdminIdx());
return ResponseCustom.OK();
return ResponseCustom.success();
}

@Admin
Expand All @@ -67,7 +64,7 @@ public ResponseCustom<Page<UserResponse>> search(
@RequestParam(defaultValue = "true") boolean active
)
{
return ResponseCustom.OK(adminService.search(pageable, nickname, active,loginStatus.getAdminIdx()));
return ResponseCustom.success(adminService.search(pageable, nickname, active,loginStatus.getAdminIdx()));
}

@Admin
Expand All @@ -79,7 +76,7 @@ public ResponseCustom<Void> withdraw(
)
{
adminService.withdraw(userIdx, loginStatus.getAdminIdx(), request.getHeader("Authorization"));
return ResponseCustom.OK();
return ResponseCustom.success();
}

// ์‹ํ’ˆ์กฐํšŒ
Expand All @@ -89,7 +86,7 @@ public ResponseCustom<Page<SearchFoodsResponse>> searchFoods(@RequestParam Strin
,@IsAdminLogin AdminLoginStatus loginStatus
)
{
return ResponseCustom.OK(adminService.searchFoods(cond, pageable,loginStatus.getAdminIdx()));
return ResponseCustom.success(adminService.searchFoods(cond, pageable,loginStatus.getAdminIdx()));
}

// ์‹ํ’ˆ์ˆ˜์ •
Expand All @@ -101,7 +98,7 @@ public ResponseCustom<Void> modifyFood(@PathVariable(name = "foodIdx") Long food
)
{
adminService.modifyFood(foodIdx, request,loginStatus.getAdminIdx());
return ResponseCustom.OK();
return ResponseCustom.success();
}

// ์‹ํ’ˆ์‚ญ์ œ
Expand All @@ -111,7 +108,7 @@ public ResponseCustom<Void> removeFoods(@PathVariable(name = "foodIdx") Long foo
,@IsAdminLogin AdminLoginStatus loginStatus
) {
adminService.removeFoods(foodIdx,loginStatus.getAdminIdx());
return ResponseCustom.OK();
return ResponseCustom.success();
}

@GetMapping("/sqs-test")
Expand All @@ -126,6 +123,6 @@ public ResponseCustom<Void> getUserReportCheck() {
foodRepository.save(testFood);
amazonSQSSender.sendMessage(FoodData.toDto(testFood));

return ResponseCustom.OK();
return ResponseCustom.success();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.example.icebutler_server.cart.dto.request.RemoveFoodFromCartRequest;
import com.example.icebutler_server.cart.dto.response.CartResponse;
import com.example.icebutler_server.cart.service.CartServiceImpl;
import com.example.icebutler_server.food.dto.response.FoodRes;
import com.example.icebutler_server.global.dto.response.ResponseCustom;
import com.example.icebutler_server.global.dto.response.SwaggerApiSuccess;
import com.example.icebutler_server.global.resolver.Auth;
Expand Down Expand Up @@ -46,7 +45,7 @@ public class CartController {
@GetMapping("/{fridgeIdx}/foods")
public ResponseCustom<List<CartResponse>> getCartFoods(@Parameter(name = "๋ƒ‰์žฅ๊ณ  ID") @PathVariable Long fridgeIdx,
@Parameter(hidden = true) @IsLogin LoginStatus loginStatus) {
return ResponseCustom.OK(cartService.getCartFoods(fridgeIdx, loginStatus.getUserIdx()));
return ResponseCustom.success(cartService.getCartFoods(fridgeIdx, loginStatus.getUserIdx()));
}

@Operation(summary = "์žฅ๋ฐ”๊ตฌ๋‹ˆ ์‹ํ’ˆ ์ถ”๊ฐ€", description = "์žฅ๋ฐ”๊ตฌ๋‹ˆ์— ์‹ํ’ˆ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.")
Expand All @@ -66,7 +65,7 @@ public ResponseCustom<?> addCartFoods(@Parameter(name = "๋ƒ‰์žฅ๊ณ  ID") @PathVar
@RequestBody AddFoodToCartRequest request,
@Parameter(hidden = true) @IsLogin LoginStatus loginStatus) {
cartService.addCartFoods(fridgeIdx, request, loginStatus.getUserIdx());
return ResponseCustom.OK();
return ResponseCustom.success();
}

@Operation(summary = "์žฅ๋ฐ”๊ตฌ๋‹ˆ ์‹ํ’ˆ ์‚ญ์ œ", description = "์žฅ๋ฐ”๊ตฌ๋‹ˆ์˜ ์‹ํ’ˆ์„ ์‚ญ์ œํ•œ๋‹ค.")
Expand All @@ -86,6 +85,6 @@ public ResponseCustom<?> deleteCartFoods(@Parameter(name = "๋ƒ‰์žฅ๊ณ  ID") @Path
@RequestBody RemoveFoodFromCartRequest request,
@Parameter(hidden = true) @IsLogin LoginStatus loginStatus) {
cartService.deleteCartFoods(fridgeIdx, request, loginStatus.getUserIdx());
return ResponseCustom.OK();
return ResponseCustom.success();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -27,7 +26,6 @@

import java.io.IOException;
import java.util.List;
import java.util.UUID;

@Slf4j
@RequiredArgsConstructor
Expand All @@ -49,10 +47,10 @@ public class FoodController {
@GetMapping("")
public ResponseCustom<List<FoodRes>> searchFood(@Parameter(name = "category", description = "์‹ํ’ˆ ์นดํ…Œ๊ณ ๋ฆฌ") @RequestParam(required = false) String category,
@Parameter(name = "word", description = "๊ฒ€์ƒ‰์–ด")@RequestParam(required = false) String word) {
if(category != null && word != null) return ResponseCustom.OK(foodService.getAllFoodByCategoryAndWord(category, word));
else if(category != null) return ResponseCustom.OK(foodService.getAllFoodByCategory(category));
else if(word != null) return ResponseCustom.OK(foodService.getAllFoodByWord(word));
else return ResponseCustom.OK(foodService.getAllFood());
if(category != null && word != null) return ResponseCustom.success(foodService.getAllFoodByCategoryAndWord(category, word));
else if(category != null) return ResponseCustom.success(foodService.getAllFoodByCategory(category));
else if(word != null) return ResponseCustom.success(foodService.getAllFoodByWord(word));
else return ResponseCustom.success(foodService.getAllFood());
}

@Operation(summary = "์‹ํ’ˆ ๋ฐ”์ฝ”๋“œ ์กฐํšŒ", description = "๋ฐ”์ฝ”๋“œ ๋ฒˆํ˜ธ๋กœ ์‹ํ’ˆ์„ ์กฐํšŒํ•œ๋‹ค.")
Expand All @@ -61,7 +59,7 @@ public ResponseCustom<List<FoodRes>> searchFood(@Parameter(name = "category", de
content = @Content(schema = @Schema(implementation = ResponseCustom.class)))
@GetMapping("/barcode")
public ResponseCustom<BarcodeFoodRes> searchByBarcode(@RequestParam String code_num) throws IOException, org.json.simple.parser.ParseException {
return ResponseCustom.OK(foodService.searchByBarcode(code_num));
return ResponseCustom.success(foodService.searchByBarcode(code_num));
}

@GetMapping("/hihitest")
Expand Down

This file was deleted.

Loading

0 comments on commit cb33243

Please sign in to comment.