fix : 결과 전달시 두번 래핑되는 부분 수정
- 컨트롤러와 서비스에서 각각 래핑 후 결과 전달됨으로 이중 래핑되고 있음 -> 서비스에서 래핑하는 부분을 컨트롤러로 옮겨서 컨트롤러에서만 한번 래핑하는 걸로 수정
This commit is contained in:
@@ -52,7 +52,7 @@ public static function index(array $params = [])
|
||||
{
|
||||
$tenantId = self::tenantId();
|
||||
if (!$tenantId) {
|
||||
return ApiResponse::error('활성 테넌트가 없습니다.', 400);
|
||||
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
|
||||
}
|
||||
|
||||
$defs = SettingFieldDef::query()
|
||||
@@ -79,7 +79,7 @@ public static function index(array $params = [])
|
||||
($a['sort_order'] <=> $b['sort_order']) ?: strcmp($a['field_key'], $b['field_key'])
|
||||
);
|
||||
|
||||
return ApiResponse::response('result', array_values($rows));
|
||||
return array_values($rows);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,7 +91,7 @@ public static function bulkUpsert(array $params = [])
|
||||
{
|
||||
$tenantId = self::tenantId();
|
||||
if (!$tenantId) {
|
||||
return ApiResponse::error('활성 테넌트가 없습니다.', 400);
|
||||
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
|
||||
}
|
||||
|
||||
$v = Validator::make($params, [
|
||||
@@ -105,7 +105,7 @@ public static function bulkUpsert(array $params = [])
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return ApiResponse::error($v->errors()->first(), 422);
|
||||
return ['error' => $v->errors()->first(), 'code' => 422];
|
||||
}
|
||||
|
||||
$payload = $v->validated();
|
||||
@@ -136,12 +136,12 @@ public static function bulkUpsert(array $params = [])
|
||||
}
|
||||
});
|
||||
} catch (\RuntimeException $e) {
|
||||
return ApiResponse::error($e->getMessage(), 422);
|
||||
return ['error' => $e->getMessage(), 'code' => 422];
|
||||
} catch (\Throwable $e) {
|
||||
return ApiResponse::error('저장 중 오류가 발생했습니다.', 500);
|
||||
return ['error' => '저장 중 오류가 발생했습니다.', 'code' => 500];
|
||||
}
|
||||
|
||||
return ApiResponse::response('result', ['updated' => true]);
|
||||
return ['updated' => true];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,13 +152,13 @@ public static function updateOne(string $fieldKey, array $params = [])
|
||||
{
|
||||
$tenantId = self::tenantId();
|
||||
if (!$tenantId) {
|
||||
return ApiResponse::error('활성 테넌트가 없습니다.', 400);
|
||||
return ['error' => '활성 테넌트가 없습니다.', 'code' => 400];
|
||||
}
|
||||
|
||||
// 전역 key 존재 확인
|
||||
$def = SettingFieldDef::where('field_key', $fieldKey)->first();
|
||||
if (!$def) {
|
||||
return ApiResponse::error('field_key not found', 404);
|
||||
return ['error' => 'field_key not found', 'code' => 404];
|
||||
}
|
||||
|
||||
$v = Validator::make($params, [
|
||||
@@ -170,7 +170,7 @@ public static function updateOne(string $fieldKey, array $params = [])
|
||||
]);
|
||||
|
||||
if ($v->fails()) {
|
||||
return ApiResponse::error($v->errors()->first(), 422);
|
||||
return ['error' => $v->errors()->first(), 'code' => 422];
|
||||
}
|
||||
$data = $v->validated();
|
||||
|
||||
@@ -180,7 +180,7 @@ public static function updateOne(string $fieldKey, array $params = [])
|
||||
->where('id', $data['option_group_id'])
|
||||
->exists();
|
||||
if (!$ok) {
|
||||
return ApiResponse::error('option_group_id is invalid for this tenant', 422);
|
||||
return ['error' => 'option_group_id is invalid for this tenant', 'code' => 422];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,9 +205,10 @@ public static function updateOne(string $fieldKey, array $params = [])
|
||||
|
||||
$effective = self::buildEffectiveRow($def, $s);
|
||||
|
||||
return ApiResponse::response('result', $effective);
|
||||
return $effective;
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
return ApiResponse::error('수정 중 오류가 발생했습니다.', 500);
|
||||
return ['error' => '수정 중 오류가 발생했습니다.', 'code' => 500];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user