Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#323 exception 구조 변경 #324

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading