feat: Product API에 FormRequest 및 i18n 적용
- ProductStoreRequest, ProductUpdateRequest 생성 - ProductController에 FormRequest 적용 - 하드코딩된 메시지를 i18n 키로 변경 - lang/ko/message.php에 product 관련 메시지 키 추가 - SAM API Development Rules 준수 Phase 3-1: ProductApi.php Swagger 점검 완료
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
|
||||
use App\Helpers\ApiResponse;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\Product\ProductStoreRequest;
|
||||
use App\Http\Requests\Product\ProductUpdateRequest;
|
||||
use App\Services\ProductService;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
@@ -15,7 +17,7 @@ public function getCategory(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->getCategory($request);
|
||||
}, '제품 카테고리 조회');
|
||||
}, __('message.product.category_fetched'));
|
||||
}
|
||||
|
||||
// GET /products
|
||||
@@ -23,15 +25,15 @@ public function index(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->index($request->all());
|
||||
}, '제품 목록');
|
||||
}, __('message.product.fetched'));
|
||||
}
|
||||
|
||||
// POST /products
|
||||
public function store(Request $request)
|
||||
public function store(ProductStoreRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->store($request->all());
|
||||
}, '제품 생성');
|
||||
return $this->service->store($request->validated());
|
||||
}, __('message.product.created'));
|
||||
}
|
||||
|
||||
// GET /products/{id}
|
||||
@@ -39,15 +41,15 @@ public function show(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->show($id);
|
||||
}, '제품 단건');
|
||||
}, __('message.product.fetched'));
|
||||
}
|
||||
|
||||
// PATCH /products/{id}
|
||||
public function update(int $id, Request $request)
|
||||
public function update(int $id, ProductUpdateRequest $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id, $request) {
|
||||
return $this->service->update($id, $request->all());
|
||||
}, '제품 수정');
|
||||
return $this->service->update($id, $request->validated());
|
||||
}, __('message.product.updated'));
|
||||
}
|
||||
|
||||
// DELETE /products/{id}
|
||||
@@ -57,7 +59,7 @@ public function destroy(int $id)
|
||||
$this->service->destroy($id);
|
||||
|
||||
return 'success';
|
||||
}, '제품 삭제');
|
||||
}, __('message.product.deleted'));
|
||||
}
|
||||
|
||||
// GET /products/search
|
||||
@@ -65,7 +67,7 @@ public function search(Request $request)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($request) {
|
||||
return $this->service->search($request->all());
|
||||
}, '제품 검색');
|
||||
}, __('message.product.searched'));
|
||||
}
|
||||
|
||||
// POST /products/{id}/toggle
|
||||
@@ -73,6 +75,6 @@ public function toggle(int $id)
|
||||
{
|
||||
return ApiResponse::handle(function () use ($id) {
|
||||
return $this->service->toggle($id);
|
||||
}, '제품 활성 토글');
|
||||
}, __('message.product.toggled'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user