Browse Source

c端增加当前企业贸易平台匹配接口

liangbo.huang 2 months ago
parent
commit
c3d6639e6f

+ 22 - 0
trade-client/src/main/java/com/trade/client/tradingPlatform/TradingPlatformService.java

@@ -0,0 +1,22 @@
+package com.trade.client.tradingPlatform;
+
+
+import com.trade.service.tradingPlatform.dto.TradingPlatformDto;
+
+import java.util.List;
+
+/**
+ * 贸易平台服务接口
+ *
+ * @author hlb
+ */
+public interface TradingPlatformService {
+
+    /**
+     * 查询当前企业可匹配的贸易平台列表
+     ** @return
+     */
+    List<TradingPlatformDto> queryCanMatchTradingPlatforms();
+
+}
+

+ 38 - 0
trade-client/src/main/java/com/trade/client/tradingPlatform/controller/TradingPlatformController.java

@@ -0,0 +1,38 @@
+package com.trade.client.tradingPlatform.controller;
+
+import javax.annotation.Resource;
+
+import com.trade.client.tradingPlatform.TradingPlatformService;
+import org.springframework.web.bind.annotation.*;
+
+import com.trade.common.core.domain.ResponseResult;
+import com.trade.service.tradingPlatform.dto.TradingPlatformDto;
+
+import java.util.List;
+
+/**
+ * 贸易平台接口
+ *
+ * @author hlb
+ */
+@RestController
+@RequestMapping("/tradingPlatform")
+public class TradingPlatformController {
+
+    /**
+     * 服务对象
+     */
+    @Resource
+    private TradingPlatformService tradingPlatformService;
+
+    /**
+     * 查询当前企业可匹配的贸易平台列表
+     *
+     * @return 贸易平台
+     */
+    @GetMapping("/can/match")
+    public ResponseResult<List<TradingPlatformDto>> queryCanMatchTradingPlatforms() {
+        List<TradingPlatformDto> tradingPlatformDtoList = tradingPlatformService.queryCanMatchTradingPlatforms();
+        return ResponseResult.success(tradingPlatformDtoList);
+    }
+}

+ 59 - 0
trade-client/src/main/java/com/trade/client/tradingPlatform/service/TradingPlatformServiceImpl.java

@@ -0,0 +1,59 @@
+package com.trade.client.tradingPlatform.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.annotation.Resource;
+
+import com.trade.client.consumer.domain.model.LoginUserInfo;
+import com.trade.client.security.utils.UserUtils;
+import com.trade.client.tradingPlatform.TradingPlatformService;
+import com.trade.common.exception.ServiceException;
+import com.trade.common.utils.bean.BeanCopyUtils;
+import com.trade.service.enterprise.domain.Enterprise;
+import com.trade.service.enterprise.service.EnterpriseBaseService;
+import org.slf4j.Logger;
+import org.springframework.stereotype.Service;
+
+import com.trade.common.constant.HttpStatus;
+import com.trade.common.utils.LoggerUtil;
+import com.trade.service.tradingPlatform.domain.TradingPlatform;
+import com.trade.service.tradingPlatform.dto.*;
+import com.trade.service.tradingPlatform.service.TradingPlatformBaseService;
+
+import cn.hutool.core.util.StrUtil;
+
+/**
+ * 贸易平台服务实现类
+ *
+ * @author hlb
+ * @since 2024-06-05 17:00:44
+ */
+@Service("tradingPlatformService")
+public class TradingPlatformServiceImpl implements TradingPlatformService {
+
+    private static final Logger log = LoggerUtil.logger(LoggerUtil.LogFileNameEnum.SERVICES_LOG);
+    @Resource
+    private TradingPlatformBaseService tradingPlatformBaseService;
+    @Resource
+    private EnterpriseBaseService enterpriseBaseService;
+
+    @Override
+    public List<TradingPlatformDto> queryCanMatchTradingPlatforms() {
+        LoginUserInfo loginUserInfo = UserUtils.getLoginUser();
+        if (loginUserInfo == null) {
+            throw new ServiceException("请您重新登录", HttpStatus.BAD_REQUEST);
+        }
+        Enterprise enterprise = enterpriseBaseService.getEnterpriseByCustomerId(loginUserInfo.getCustomerUserId());
+        if (enterprise == null) {
+            throw new ServiceException("您没有关联的企业信息,请联系管理员", HttpStatus.BAD_REQUEST);
+        }
+        if (StrUtil.isEmpty(enterprise.getProxyDistrictCode())) {
+            return new ArrayList<>();
+        }
+        return tradingPlatformBaseService.lambdaQuery()
+                .eq(TradingPlatform::getDistrictCode, enterprise.getProxyDistrictCode()).list().stream()
+                .map(o -> BeanCopyUtils.copy(o, TradingPlatformDto.class)).collect(Collectors.toList());
+    }
+}