package com.hxhq.business.controller;

import java.util.Arrays;
import java.util.List;

import com.hxhq.business.form.yq.StorageLocationSearchForm;
import com.hxhq.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.hxhq.business.domain.StorageLocation;
import com.hxhq.business.service.IStorageLocationService;
import com.hxhq.common.core.web.controller.BaseController;
import com.hxhq.common.core.web.domain.AjaxResult;
import com.hxhq.common.core.web.page.TableDataInfo;


/**
 * 存储位置Controller
 *
 * @author hxhq
 * @date 2026-03-02
 */
@RestController
@RequestMapping("/business/storageLocation")
public class StorageLocationController extends BaseController
{
    @Autowired
    private IStorageLocationService storageLocationService;

    /**
     * 查询存储位置列表
     */
    @GetMapping("/list")
    @RequiresPermissions("business:storageLocation:list")
    public TableDataInfo list(StorageLocationSearchForm form)
    {
        startPage();
        List<StorageLocation> list = storageLocationService.queryList(form);
        return getDataTable(list);
    }

    /**
     * 获取存储位置详细信息
     */
    @GetMapping(value = "/info")
    public AjaxResult getInfo(Long id)
    {
        return AjaxResult.success(storageLocationService.getById(id));
    }

    /**
     * 新增存储位置信息
     */
    @PostMapping("/save")
    @RequiresPermissions("business:storageLocation:add")
    public AjaxResult save(@RequestBody StorageLocation storageLocation)
    {
        return toAjax(storageLocationService.saveOrUpdate(storageLocation));
    }

    /**
     * 新增存储位置信息
     */
    @PostMapping("/edit")
    @RequiresPermissions("business:storageLocation:edit")
    public AjaxResult edit(@RequestBody StorageLocation storageLocation)
    {
        return toAjax(storageLocationService.saveOrUpdate(storageLocation));
    }
}
