package com.kxs.store.biz.controller.kxsapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.common.security.util.SecurityUtils;
import com.kxs.store.api.dto.kxsapp.store.StoreSearchListDTO;
import com.kxs.store.api.vo.kxsapp.store.*;
import com.kxs.store.biz.service.*;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 仓库模块(Store)控制层
 *
 * @author 系统
 * @since 2024-01-08 10:33:20
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("store")
public class StoreController {

    /**
     * 服务对象
     */
    private final KxsWarehouseService kxsWarehouseService;
    private final KxsWarehouseStockService kxsWarehouseStockService;
    private final KxsMachineAdvanceService kxsMachineAdvanceService;
    private final KxsSendTotalService kxsSendTotalService;
    private final KxsMachineRecycleService kxsMachineRecycleService;



    /**
     * 搜索仓库列表
     *
     * @param param 查询参数
     * @return 搜索仓库列表
     */
    @GetMapping("/searchList")
    public R searchList(@ParameterObject Page<StoreSearchListVO> page, @Valid @ParameterObject StoreSearchListDTO param) {

        return R.ok(kxsWarehouseService.searchList(page, param));
    }


    /**
     * 用户所属仓库
     *
     * @return 用户所属仓库
     */
    @GetMapping("/list")
    public R list() {
        return R.ok(kxsWarehouseService.userStoreList());
    }


    /**
     * 仓库数据
     *
     * @param warehouseId 仓库ID
     * @return 仓库数据
     */
    @GetMapping("/storeData")
    public R storeData(@RequestParam("warehouseId") Integer warehouseId) {

        return R.ok(kxsWarehouseService.storeData(warehouseId));
    }


    /**
     * 仓库预发机列表
     *
     * @param page 分页对象
     * @return 仓库预发机
     */
    @GetMapping("/getAdvanceMachine")
    public R getAdvanceMachine(@ParameterObject Page<StoreAdvanceMachineVO> page,
                               @RequestParam("warehouseId") Integer warehouseId,
                               @RequestParam("brandId") Integer brandId){

        return R.ok(kxsMachineAdvanceService.getByPage(page, warehouseId, brandId));
    }







}

