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.erp.dto.SaleChannelDTO;
import com.hys.app.model.support.LogClient;
import com.hys.app.model.support.validator.annotation.Log;
import com.hys.app.raycoswebapi.model.dao.product.RaycosStockDao;
import com.hys.app.raycoswebapi.service.product.StockInfoManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.hys.app.raycoswebapi.model.dto.product.StockInfoDto;
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/stockinfo")
@Api(tags = "stock信息相关API")
@Validated
public class StockInfoManagerController {

    @Autowired
    private StockInfoManager stockInfoManager;



    @ApiOperation(value = "分页列表")
    @GetMapping("/list")
    public WebPage<RaycosStockDao> list(StockInfoDto queryParams) {
        AdminUserContext.hasSuperAdminQuery(queryParams.getCompanyId());
        return stockInfoManager.list(queryParams);
    }

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

}

