refactor: group_id 네이밍 통일 (code_group='group', code='1')

- 마이그레이션: code_group='item_group' → 'group', code='ITEM' → '1'
- ItemService: group_id로 code 조회 후 parent_id 매칭
- API: /api/v1/items?group_id=1 → 품목 그룹 전체 조회
This commit is contained in:
2025-12-15 14:59:07 +09:00
parent b1bcad3be6
commit 23fd59dc88
2 changed files with 29 additions and 14 deletions

View File

@@ -82,14 +82,26 @@ private function newQuery(string $itemType)
/**
* group_id로 해당 그룹의 item_type 목록 조회
*
* @param int $groupId common_codes의 item_group id
* @param int $groupId 그룹 코드 (code_group='group', code='1' → group_id=1)
* @return array item_type 코드 배열 ['FG', 'PT', 'SM', 'RM', 'CS']
*/
private function getItemTypesByGroupId(int $groupId): array
{
// 1. group_id로 그룹 레코드 찾기 (code_group='group', code=group_id)
$group = \DB::table('common_codes')
->where('code_group', 'group')
->where('code', (string) $groupId)
->where('is_active', true)
->first();
if (! $group) {
return [];
}
// 2. 해당 그룹의 id를 parent_id로 가진 item_type 조회
return \DB::table('common_codes')
->where('code_group', 'item_type')
->where('parent_id', $groupId)
->where('parent_id', $group->id)
->where('is_active', true)
->pluck('code')
->toArray();