# GetProductCategory

## Overview

GetProductCategory retrieves a single product category record by id or code. The input is a union type — callers specify exactly one lookup field. This serves as the core category lookup for existence checks, parent validation, and category management commands.

## Business Rules

- Accepts one of two lookup variants:
  - `{ id }` — retrieves by unique identifier (used for existence checks and tree operations)
  - `{ code }` — retrieves by category code (used for uniqueness validation during creation; code is immutable after creation)
- Returns the full category record including all fields (id, code, name, parentId, timestamps)
- Returns null if no matching category is found
- All comparisons are exact (case-sensitive)

## Process Flow

```mermaid
flowchart TD
    A[Receive input] --> B{Which field?}
    B -->|id| C[SELECT from ProductCategory where id = input.id]
    B -->|code| D[SELECT from ProductCategory where code = input.code]
    C --> E{Category found?}
    D --> E
    E -->|Yes| F[Return category record]
    E -->|No| G[Return null]
```

## External Dependencies

- None

## Error Scenarios

- **CATEGORY_NOT_FOUND**: Specified category ID does not exist

## Test Cases

- returns category when found
- returns null when not found
- returns category when found
- returns null when not found
