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.ImporterEntitySearch;
import com.trade.service.enterprise.companyrelated.service.IImporterEntityService;
import org.springframework.web.bind.annotation.RestController;

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

    @Resource
    private IImporterEntityService importerEntityService;

    /**
     * 获取进口商信息列表
     */
    @RequestMapping("/queryList")
    @PreAuthorize("@ss.hasPermi('customer:rel:companyImporter:list')")
    public Object queryList(ImporterEntitySearch search) {
        search.setStatus("1");// 只查询启用状态的进口商
        return ResponseResult.success(importerEntityService.queryListBySearch(search));
    }

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

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