package com.trade.admin.enterprise.companyrelated;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

import com.trade.common.core.domain.ResponseResult;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;

import com.trade.service.enterprise.companyrelated.domain.vo.VendorEntitySearch;
import com.trade.service.enterprise.companyrelated.service.IVendorEntityService;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 供应商企业信息 B端控制器
 * </p>
 *
 * @author zhangchenm
 * @since 2024-09-03
 */
@RestController
@RequestMapping("/customer/rel/vendorEntity")
@Validated
public class VendorEntityBController {

    @Resource
    private IVendorEntityService vendorEntityService;

    /**
     * 获取供应商信息列表
     */
    @RequestMapping("/queryList")
    @PreAuthorize("@ss.hasPermi('customer:rel:vendor:list')")
    public Object queryList(VendorEntitySearch search) {
        return ResponseResult.success(vendorEntityService.queryListBySearch(search));
    }

    /**
     * 根据供应商ID获取进口商信息
     */
    @RequestMapping("/getByEntityId")
    @PreAuthorize("@ss.hasPermi('customer:rel:vendor:detail')")
    public Object getByEntityId(@NotNull(message = "进口商ID不能为空") Long entityId) {
        return ResponseResult.success(vendorEntityService.getVOByEntityId(entityId));
    }

    /**
     * 获取供应商信息列表 - 用于下拉框
     */
    @RequestMapping("/getList4Dict")
    public Object getList4Dict() {
        return ResponseResult.success(vendorEntityService.getList4Dict());
    }
}
