<?php

namespace App\Http\Controllers\Api\MobileWeb;

use App\Services\Api\MobileWeb\InventoryService;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Requests\Validators\Api\MobileWeb\InventoryValidator;
use BlueCity\Core\Inc\ErrorInc;

// 移动端-技师管理
class InventoryController extends Controller
{
    // 列表每页显示数据个数
    protected $show_count = 10;

    public function __construct()
    {
        $this->dataValidator = new InventoryValidator();
    }

    // 列表
    public function index(Request $request)
    {
        // 验证数据
        $error_message = $this->dataValidator->indexValidator($request->all());
        if ($error_message) {
            return response()->json(['ErrorCode'=>ErrorInc::INVALID_PARAM, 'ErrorMessage'=>$error_message->first(), 'Data'=>[$error_message]]);
        }
        $return_data = InventoryService::index($request->all(), $this->show_count);
        return $return_data;
    }
    /**|---------------------------------------------------------------------------------
     * @name 获取品牌
     * @retrun \Illuminate\Http\JsonResponse /multitype:array
     * @author dou 2026/5/20 14:13
     * |---------------------------------------------------------------------------------
    */
    public function getBrand ( Request $request ){
        $return_data = InventoryService::getBrand($request->all());
        return $return_data;
    }
    /**|---------------------------------------------------------------------------------
     * @name 编辑商品数量
     * @param string goodid 商品id
     * @param string goodnum 库存数量
     * @retrun \Illuminate\Http\JsonResponse /multitype:array
     * @author dou 2026/5/20 15:56
     * |---------------------------------------------------------------------------------
    */
    public function edit ( Request $request ){
        // 验证数据
        $error_message = $this->dataValidator->editValidator($request->all());
        if ($error_message) {
            return response()->json(['ErrorCode'=>ErrorInc::INVALID_PARAM, 'ErrorMessage'=>$error_message->first(), 'Data'=>[$error_message]]);
        }
        $return_data = InventoryService::edit($request->all(),$request->ip());
        return $return_data;
    }

}
