/**
 * Inventory Controller
 *
 * REST endpoints for DoMG, UnDoMG
 */
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
import { InventoryService } from './inventory.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@Controller('inventory')
@UseGuards(JwtAuthGuard)
export class InventoryController {
  constructor(private inventoryService: InventoryService) {}

  /**
   * POST /api/inventory/do-mg
   * Maps to: DoMG(N, kind, ref)
   */
  @Post('do-mg')
  async doMG(@Body() body: { n: number; kind: number; ref: number }) {
    const { n, kind, ref } = body;
    if (n == null || kind == null || ref == null) {
      return { success: false, error: 'n, kind, ref are required' };
    }
    return this.inventoryService.doMG(n, kind, ref);
  }

  /**
   * POST /api/inventory/undo-mg
   * Maps to: UnDoMG(N, kind, ref)
   */
  @Post('undo-mg')
  async unDoMG(@Body() body: { n: number; kind: number; ref: number }) {
    const { n, kind, ref } = body;
    if (n == null || kind == null || ref == null) {
      return { success: false, error: 'n, kind, ref are required' };
    }
    return this.inventoryService.unDoMG(n, kind, ref);
  }
}
