package com.fjhx.item.controller.product;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.fjhx.common.constant.SourceConstant;
import com.fjhx.item.entity.product.vo.ProductInfoVo;
import com.fjhx.item.service.product.ProductInfoService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 开放 产品库 前端控制器
 * </p>
 *
 * @since 2023-11-27
 */
@DS(SourceConstant.ITEM)
@RestController
@RequestMapping("/open/productInfo")
public class OpenProductInfoController {

    @Autowired
    private ProductInfoService productInfoService;

    @Value("${tenant.tenantId}")
    private String tenantId;

    /**
     * 产品库明细
     */
    @PostMapping("/detail")
    public ProductInfoVo detail(@RequestBody BaseSelectDto dto) {
        SecurityUtils.setTenantId(tenantId);
        ProductInfoVo detail = productInfoService.detail(dto.getId());
        SecurityUtils.clearTenantId();
        return detail;
    }
}
