feat: [bending] 기초자료 복사 API 추가 — 같은 분류의 다음 번호 자동 채번
This commit is contained in:
@@ -96,6 +96,16 @@ public function update(BendingItemUpdateRequest $request, int $id): JsonResponse
|
||||
);
|
||||
}
|
||||
|
||||
public function duplicate(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$this->ensureContext($request);
|
||||
|
||||
return ApiResponse::handle(
|
||||
fn () => new BendingItemResource($this->service->duplicate($id)),
|
||||
__('message.created')
|
||||
);
|
||||
}
|
||||
|
||||
public function destroy(Request $request, int $id): JsonResponse
|
||||
{
|
||||
$this->ensureContext($request);
|
||||
|
||||
@@ -135,6 +135,43 @@ public function update(int $id, array $data): BendingItem
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* 기초자료 복사 — 같은 분류코드의 다음 번호 자동 채번
|
||||
*/
|
||||
public function duplicate(int $id): BendingItem
|
||||
{
|
||||
$source = BendingItem::findOrFail($id);
|
||||
|
||||
// 분류코드 추출 (BD-CL.001 → CL)
|
||||
preg_match('/^BD-([A-Z]{2})/', $source->code, $m);
|
||||
$prefix = $m[1] ?? 'XX';
|
||||
$newCode = $this->generateCode($prefix);
|
||||
|
||||
return BendingItem::create([
|
||||
'tenant_id' => $source->tenant_id,
|
||||
'code' => $newCode,
|
||||
'item_name' => $source->item_name,
|
||||
'item_sep' => $source->item_sep,
|
||||
'item_bending' => $source->item_bending,
|
||||
'material' => $source->material,
|
||||
'item_spec' => $source->item_spec,
|
||||
'model_name' => $source->model_name,
|
||||
'model_UA' => $source->model_UA,
|
||||
'rail_width' => $source->rail_width,
|
||||
'exit_direction' => $source->exit_direction,
|
||||
'box_width' => $source->box_width,
|
||||
'box_height' => $source->box_height,
|
||||
'front_bottom' => $source->front_bottom,
|
||||
'inspection_door' => $source->inspection_door,
|
||||
'length_code' => $source->length_code,
|
||||
'length_mm' => $source->length_mm,
|
||||
'bending_data' => $source->bending_data,
|
||||
'options' => $source->options,
|
||||
'is_active' => true,
|
||||
'created_by' => $this->apiUserId(),
|
||||
]);
|
||||
}
|
||||
|
||||
public function delete(int $id): bool
|
||||
{
|
||||
$item = BendingItem::findOrFail($id);
|
||||
|
||||
Reference in New Issue
Block a user