feat(mng): 사업자등록증 OCR 기능 구현
## 주요 변경사항
- BizCertController: 내부 API (OCR, CRUD)
- BizCertOcrService: Claude Vision API 연동, Tesseract.js 지원
- BizCert 모델 및 FormRequest 추가
- config/services.php에 Claude API 설정 추가
## 프론트엔드
- business-ocr.blade.php: layouts.app 레이아웃 적용
- JS/AI 토글 모드 (Tesseract.js / Claude Vision)
- 이미지 전처리 추가 (그레이스케일, 대비 강화, 이진화)
- SweetAlert2 연동 (토스트, 삭제 확인)
## API 엔드포인트
- POST /api/biz-cert/ocr - OCR 처리
- GET /api/biz-cert - 목록 조회
- POST /api/biz-cert - 저장
- DELETE /api/biz-cert/{id} - 삭제
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
89
app/Http/Controllers/Api/BizCertController.php
Normal file
89
app/Http/Controllers/Api/BizCertController.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\BizCertStoreRequest;
|
||||
use App\Services\BizCertOcrService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/**
|
||||
* 사업자등록증 OCR API 컨트롤러
|
||||
*/
|
||||
class BizCertController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private BizCertOcrService $service
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Claude Vision OCR 처리
|
||||
*
|
||||
* POST /api/biz-cert/ocr
|
||||
*/
|
||||
public function ocr(Request $request): JsonResponse
|
||||
{
|
||||
$request->validate([
|
||||
'image' => 'required|string',
|
||||
'raw_text' => 'nullable|string',
|
||||
]);
|
||||
|
||||
$result = $this->service->processWithClaude(
|
||||
$request->input('image'),
|
||||
$request->input('raw_text')
|
||||
);
|
||||
|
||||
if (! $result['ok']) {
|
||||
return response()->json($result, 400);
|
||||
}
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 저장된 목록 조회
|
||||
*
|
||||
* GET /api/biz-cert
|
||||
*/
|
||||
public function index(): JsonResponse
|
||||
{
|
||||
$list = $this->service->list();
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'data' => $list,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 사업자등록증 데이터 저장
|
||||
*
|
||||
* POST /api/biz-cert
|
||||
*/
|
||||
public function store(BizCertStoreRequest $request): JsonResponse
|
||||
{
|
||||
$bizCert = $this->service->store($request->validated());
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'message' => '저장되었습니다.',
|
||||
'data' => $bizCert,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제
|
||||
*
|
||||
* DELETE /api/biz-cert/{id}
|
||||
*/
|
||||
public function destroy(int $id): JsonResponse
|
||||
{
|
||||
$this->service->delete($id);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'message' => '삭제되었습니다.',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user