package com.hys.app.raycoswebapi.controller.product;

import com.hys.app.framework.context.user.AdminUserContext;
import com.hys.app.framework.database.WebPage;
import com.hys.app.model.support.LogClient;
import com.hys.app.model.support.validator.annotation.Log;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockplusDao;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockvirtualskuDao;
import com.hys.app.raycoswebapi.model.dto.product.StockVirtualSkuDto;
import com.hys.app.raycoswebapi.model.dto.product.StockplusDto;
import com.hys.app.raycoswebapi.service.product.StockVirtualSkuManager;
import com.hys.app.raycoswebapi.service.product.StockplusInfoManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * stock相关api
 *
 * @author 崔晓冬
 * @since 2024年8月9日12:20:17
 */
@RestController
@RequestMapping("/admin/webapi/virtualSku")
@Api(tags = "stock商品相关API")
@Validated
public class StockVirtualSkuManagerController {

    @Autowired
    private StockVirtualSkuManager stockVirtualSkuManager;



    @ApiOperation(value = "分页列表")
    @GetMapping("/list")
    public WebPage<RaycosStockvirtualskuDao> list(StockVirtualSkuDto stockVirtualSkuDto) {
        AdminUserContext.hasSuperAdminQuery(stockVirtualSkuDto.getCompanyId());
        return stockVirtualSkuManager.list(stockVirtualSkuDto);
    }

    @ApiOperation(value = "添加")
    @PostMapping("/insert")
    @Log(client = LogClient.admin, detail = "新增sku主表")
    public Long add(@RequestBody @Valid StockVirtualSkuDto stockVirtualSkuDto) {
        AdminUserContext.hasCompany();
        return stockVirtualSkuManager.add(stockVirtualSkuDto);
    }

    @ApiOperation(value = "修改")
    @PutMapping("/update/{id}")
    @Log(client = LogClient.admin, detail = "编辑ID为[${id}]的入库单")
    public void updateInfo(@PathVariable Long id, @RequestBody @Valid StockVirtualSkuDto stockVirtualSkuDto) {
        AdminUserContext.hasCompany();
        stockVirtualSkuDto.setId(id);
        stockVirtualSkuManager.updateInfo(stockVirtualSkuDto);
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("/delete/{id}")
    @Log(client = LogClient.admin, detail = "删除ID为[${ids}]的入库单")
    public void delete(@PathVariable Long id) {
        stockVirtualSkuManager.delete(id);
    }

}

