feat: 단가 관리 API 구현 및 Flow Tester 호환성 개선
- Price, PriceRevision 모델 추가 (PriceHistory 대체) - PricingService: CRUD, 원가 조회, 확정 기능 - PricingController: statusCode 파라미터로 201 반환 지원 - NotFoundHttpException(404) 적용 (존재하지 않는 리소스) - FormRequest 분리 (Store, Update, Index, Cost, ByItems) - Swagger 문서 업데이트 - ApiResponse::handle()에 statusCode 옵션 추가 - prices/price_revisions 마이그레이션 및 데이터 이관
This commit is contained in:
@@ -47,7 +47,8 @@ public static function debugQueryLog(): array
|
||||
public static function success(
|
||||
$data = null,
|
||||
string $message = '요청 성공',
|
||||
array $debug = []
|
||||
array $debug = [],
|
||||
int $statusCode = 200
|
||||
): JsonResponse {
|
||||
$response = [
|
||||
'success' => true,
|
||||
@@ -58,7 +59,7 @@ public static function success(
|
||||
$response['query'] = $debug;
|
||||
}
|
||||
|
||||
return response()->json($response);
|
||||
return response()->json($response, $statusCode);
|
||||
}
|
||||
|
||||
public static function error(
|
||||
@@ -149,19 +150,21 @@ public static function handle(
|
||||
return self::error($message, $code, ['details' => $details]);
|
||||
}
|
||||
|
||||
// 표준 박스( ['data'=>..., 'query'=>...] ) 하위호환
|
||||
// 표준 박스( ['data'=>..., 'query'=>..., 'statusCode'=>...] ) 하위호환
|
||||
if (is_array($result) && array_key_exists('data', $result)) {
|
||||
$data = $result['data'];
|
||||
$debug = $result['query'] ?? [];
|
||||
$statusCode = $result['statusCode'] ?? 200;
|
||||
} else {
|
||||
// 그냥 도메인 결과만 반환한 경우
|
||||
$data = $result;
|
||||
$debug = (app()->environment('local') && request()->is('api/*'))
|
||||
? self::debugQueryLog()
|
||||
: [];
|
||||
$statusCode = 200;
|
||||
}
|
||||
|
||||
return self::success($data, $responseTitle, $debug);
|
||||
return self::success($data, $responseTitle, $debug, $statusCode);
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user