Browse Source

完成ApiService体系设计,准备接入具体的平台

dev_shibei_match
wxz 5 years ago
parent
commit
0d4a1ee11e
  1. 9
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 11
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ApiServiceActions.java
  3. 15
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ProjectAssistFormDTO.java
  4. 20
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/TPFDemoFormDTO.java
  5. 63
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java
  6. 31
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java
  7. 19
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java
  8. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java
  9. 8
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java
  10. 54
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/BizController.java
  11. 33
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java
  12. 36
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java
  13. 33
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformDao.java
  14. 51
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformActionEntity.java
  15. 51
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformCustomerRegisterEntity.java
  16. 61
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformEntity.java
  17. 46
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ApiServiceSelector.java
  18. 15
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ProjectService.java
  19. 40
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java
  20. 19
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml
  21. 36
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml
  22. 21
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformDao.xml
  23. 9
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  24. 5
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  25. 13
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  26. 10
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
  27. 9
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java
  28. 19
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java
  29. 14
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml

9
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -370,4 +370,13 @@ public class RedisKeys {
public static String getCustomerApiServiceKey(String customerId) { public static String getCustomerApiServiceKey(String customerId) {
return rootPrefix.concat("customer:thirdplat:apiservice:").concat(customerId); return rootPrefix.concat("customer:thirdplat:apiservice:").concat(customerId);
} }
/**
* 一个客户对应多个第三方平台多个ApiService的key
* @param customerId
* @return
*/
public static String listCustomerApiServiceListKey(String customerId) {
return rootPrefix.concat("customer:thirdplat:apiservicelist:").concat(customerId);
}
} }

11
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ApiServiceActions.java

@ -0,0 +1,11 @@
package com.epmet.constant;
/**
* api service 常量列表
*/
public interface ApiServiceActions {
// 测试动作
String DEMO_ACTION = "demoAction";
}

15
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/ProjectAssistFormDTO.java

@ -0,0 +1,15 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class ProjectAssistFormDTO {
private String customerId;
@NotBlank(message = "平台ID不能为空")
private String platformId;
}

20
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/TPFDemoFormDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.form;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 第三方平台-demo form dto
*/
@Data
public class TPFDemoFormDTO {
private String demoString;
@NotBlank(message = "客户ID不能为空")
private String customerId;
@NotBlank(message = "平台ID不能为空")
private String platformId;
}

63
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java

@ -0,0 +1,63 @@
package com.epmet.apiservice;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dao.ThirdplatformCustomerRegisterDao;
import com.epmet.dto.form.ProjectAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
/**
* ApiService对接第三方平台的抽象类
* 每一个具体平台的ApiService都是该抽象类的子类选择性实现抽象类中的某些方法提供具体业务逻辑
*/
public abstract class ApiService {
/**
* @Description 判断该客户是否注册了该平台
* @return true:已注册该平台可以使用false:未注册无法使用
* @author wxz
* @date 2021.03.15 11:09
*/
public boolean isRegistered(String customerId, String platformId) {
ThirdplatformCustomerRegisterDao tpcRegDao = SpringContextUtils.getBean(ThirdplatformCustomerRegisterDao.class);
ThirdplatformCustomerRegisterEntity tpcReg = tpcRegDao.getByCustomerIdAndPlatformId(customerId, platformId);
if (tpcReg == null) {
return false;
}
return true;
}
/**
* @Description 判断客户是否注册了指定的平台如果没有注册则抛出异常
* @return
* @author wxz
* @date 2021.03.15 21:39
*/
public void judgeRegistered(String customerId, String platformId) {
if (!isRegistered(customerId, platformId)) {
throw new RenException(String.format("客户:%s没有配置第三方平台:%s", customerId, platformId));
}
}
/**
* @Description demo示例方法
* @return
* @author wxz
* @date 2021.03.15 10:46
*/
public String demoAction(TPFDemoFormDTO tpfDemoFormDTO) {
return "do success !!";
}
/**
* @Description 项目协同处理
* @return 项目协同处理的Result具体的平台返回的结果最终都要转化为这个ProjectAssistResult返回
* @author wxz
* @date 2021.03.16 09:28
*/
public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) {
return null;
}
}

31
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java

@ -0,0 +1,31 @@
package com.epmet.apiservice.impl;
import com.epmet.apiservice.ApiService;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.constant.ApiServiceActions;
import com.epmet.dto.form.ProjectAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* demo api service
*/
@Component(value = "demoApiService")
public class DemoApiService extends ApiService {
Logger logger = LoggerFactory.getLogger(DemoApiService.class);
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Override
public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) {
logger.info("DemoApiService发送项目协助到第三方平台成功");
return null;
}
}

19
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java

@ -0,0 +1,19 @@
package com.epmet.apiservice.impl;
import com.epmet.apiservice.ApiService;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.dto.form.ProjectAssistFormDTO;
import org.springframework.stereotype.Component;
/**
* 泸州网格化平台ApiService
*/
@Component("luzhouGridPlatformApiService")
public class LuzhouGridPlatformApiService extends ApiService {
@Override
public ProjectAssistResult projectAssist(ProjectAssistFormDTO formDTO) {
System.out.println("泸州网格化平台项目协助发送成功");
return null;
}
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/LZGridPlatformProjectAssistResult.java

@ -0,0 +1,4 @@
package com.epmet.apiservice.result;
public class LZGridPlatformProjectAssistResult {
}

8
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/result/ProjectAssistResult.java

@ -0,0 +1,8 @@
package com.epmet.apiservice.result;
import lombok.Data;
@Data
public class ProjectAssistResult {
}

54
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/BizController.java

@ -0,0 +1,54 @@
package com.epmet.controller;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.form.ProjectAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.service.ProjectService;
import org.springframework.beans.factory.annotation.Autowired;
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;
import java.lang.management.MemoryManagerMXBean;
/**
* 对接第三方平台业务相关的controller
* 我们系统当中每一个需要发送到第三方平台的操作只对应这里的一个方法根据参数传入platformId内部根据配置获取指定的APiService进行具体平台的调用
* 每一个平台都有自己的ApiSerivce
*/
@RestController
@RequestMapping("biz")
public class BizController {
@Autowired
private ProjectService projectService;
/**
* @Description demo方法
* @return
* @author wxz
* @date 2021.03.15 21:11
*/
@PostMapping("demo-action")
public Result demoAction(@RequestBody TPFDemoFormDTO tpfDemoFormDTO) {
ValidatorUtils.validateEntity(tpfDemoFormDTO);
String r = projectService.demoAction(tpfDemoFormDTO);
return new Result().ok(r);
}
/**
* @Description 发送项目协同处理方法
* @return
* @author wxz
* @date 2021.03.15 21:13
*/
@PostMapping("project-assist")
public Result projectAssist(@RequestBody ProjectAssistFormDTO formDTO) {
ValidatorUtils.validateEntity(formDTO);
projectService.projectAssist(formDTO);
return new Result();
}
}

33
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java

@ -0,0 +1,33 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.ThirdplatformActionEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Mapper
public interface ThirdplatformActionDao extends BaseDao<ThirdplatformActionEntity> {
}

36
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java

@ -0,0 +1,36 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.constant.ThirdPlatformConstant;
import com.epmet.entity.ThirdplatformCustomerRegisterEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Mapper
public interface ThirdplatformCustomerRegisterDao extends BaseDao<ThirdplatformCustomerRegisterEntity> {
ThirdplatformCustomerRegisterEntity getByCustomerIdAndPlatformId(@Param("customerId") String customerId, @Param("platformId") String platformId);
}

33
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformDao.java

@ -0,0 +1,33 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.entity.ThirdplatformEntity;
import org.apache.ibatis.annotations.Mapper;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Mapper
public interface ThirdplatformDao extends BaseDao<ThirdplatformEntity> {
}

51
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformActionEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("thirdplatform_action")
public class ThirdplatformActionEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String platformId;
/**
*
*/
private String actionKey;
}

51
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformCustomerRegisterEntity.java

@ -0,0 +1,51 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("thirdplatform_customer_register")
public class ThirdplatformCustomerRegisterEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
private String customerId;
/**
*
*/
private String platformId;
}

61
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/ThirdplatformEntity.java

@ -0,0 +1,61 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
*
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2021-03-15
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("thirdplatform")
public class ThirdplatformEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 平台名称
*/
private String platformName;
/**
* 平台唯一KEY
*/
private String platformKey;
/**
*
*/
private String platformSecret;
/**
* apiservice
*/
private String apiService;
}

46
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ApiServiceSelector.java

@ -0,0 +1,46 @@
package com.epmet.service;
import com.epmet.apiservice.ApiService;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.SpringContextUtils;
import com.epmet.dao.ThirdplatformDao;
import com.epmet.entity.ThirdplatformEntity;
/**
* ApiService选择器
*/
public interface ApiServiceSelector {
/**
* @Description 根据platformId查找platform对应的ApiService如果找不到对应的api service则返回null
* @return ApiService
* @author wxz
* @date 2021.03.15 20:59
*/
default ApiService trySelectApiService(String platformId) {
ThirdplatformDao thirdplatformDao = SpringContextUtils.getBean(ThirdplatformDao.class);
ThirdplatformEntity thirdplatform = thirdplatformDao.selectById(platformId);
if (thirdplatform == null) {
return null;
}
return (ApiService)SpringContextUtils.getBean(thirdplatform.getApiService());
}
/**
* @Description 根据platformId查找platform对应的ApiService如果找不到对应的api service则抛出RenException异常
* @return ApiService
* @author wxz
* @date 2021.03.15 21:08
*/
default ApiService selectApiService(String platformId) {
ThirdplatformDao thirdplatformDao = SpringContextUtils.getBean(ThirdplatformDao.class);
ThirdplatformEntity thirdplatform = thirdplatformDao.selectById(platformId);
if (thirdplatform == null) {
throw new RenException(String.format("ID为%s的第三方平台不存在", platformId));
}
return (ApiService)SpringContextUtils.getBean(thirdplatform.getApiService());
}
}

15
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ProjectService.java

@ -0,0 +1,15 @@
package com.epmet.service;
import com.epmet.dto.form.ProjectAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import org.springframework.stereotype.Service;
/**
* 该service用于封装project相关的代码
*/
public interface ProjectService {
String demoAction(TPFDemoFormDTO formDTO);
void projectAssist(ProjectAssistFormDTO formDTO);
}

40
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java

@ -0,0 +1,40 @@
package com.epmet.service.impl;
import com.epmet.apiservice.ApiService;
import com.epmet.apiservice.result.ProjectAssistResult;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.dto.form.ProjectAssistFormDTO;
import com.epmet.dto.form.TPFDemoFormDTO;
import com.epmet.service.ApiServiceSelector;
import com.epmet.service.ProjectService;
import org.springframework.stereotype.Service;
@Service
public class ProjectServiceImpl implements ProjectService, ApiServiceSelector {
@Override
public String demoAction(TPFDemoFormDTO formDTO) {
String customerId = formDTO.getCustomerId();
String platformId = formDTO.getPlatformId();
// 注意,此处会如果找不到对应的ApiService会抛出异常
ApiService apiService = selectApiService(platformId);
apiService.judgeRegistered(customerId, platformId);
return apiService.demoAction(formDTO);
}
@Override
public void projectAssist(ProjectAssistFormDTO formDTO) {
String customerId = formDTO.getCustomerId();
String platformId = formDTO.getPlatformId();
// 注意,此处会如果找不到对应的ApiService会抛出异常
ApiService apiService = selectApiService(platformId);
apiService.judgeRegistered(customerId, platformId);
System.out.println(apiService);
ProjectAssistResult projectAssistResult = apiService.projectAssist(formDTO);
}
}

19
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ThirdplatformActionDao">
<resultMap type="com.epmet.entity.ThirdplatformActionEntity" id="thirdplatformActionMap">
<result property="id" column="ID"/>
<result property="platformId" column="PLATFORM_ID"/>
<result property="actionKey" column="ACTION_KEY"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

36
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ThirdplatformCustomerRegisterDao">
<resultMap type="com.epmet.entity.ThirdplatformCustomerRegisterEntity" id="thirdplatformCustomerRegisterMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="platformId" column="PLATFORM_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getByCustomerIdAndPlatformId"
resultType="com.epmet.entity.ThirdplatformCustomerRegisterEntity">
select tcr.id,
customer_id,
platform_id,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from thirdplatform_customer_register tcr
where CUSTOMER_ID = #{customerId}
and PLATFORM_ID = #{platformId}
and DEL_FLAG = 0
</select>
</mapper>

21
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformDao.xml

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.ThirdplatformDao">
<resultMap type="com.epmet.entity.ThirdplatformEntity" id="thirdplatformMap">
<result property="id" column="ID"/>
<result property="platformName" column="PLATFORM_NAME"/>
<result property="platformKey" column="PLATFORM_KEY"/>
<result property="platformSecret" column="PLATFORM_SECRET"/>
<result property="apiService" column="API_SERVICE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
</mapper>

9
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java

@ -122,4 +122,13 @@ public interface OperCrmOpenFeignClient {
**/ **/
@GetMapping("/oper/crm/customer/getallsubcustomerids/{customerId}") @GetMapping("/oper/crm/customer/getallsubcustomerids/{customerId}")
Result<List<String>> getAllSubCustomerIds(@PathVariable("customerId") String customerId); Result<List<String>> getAllSubCustomerIds(@PathVariable("customerId") String customerId);
/**
* @Description 根据客户id列出该客户所有的apiService
* @return
* @author wxz
* @date 2021.03.15 15:13
*/
@PostMapping("list-apiservice-by-customerid")
Result<List<ThirdplatApiserviceResultDTO>> listApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form);
} }

5
epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java

@ -95,4 +95,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient {
public Result<List<String>> getAllSubCustomerIds(String customerId) { public Result<List<String>> getAllSubCustomerIds(String customerId) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getAllSubCustomerIds", customerId); return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getAllSubCustomerIds", customerId);
} }
@Override
public Result<List<ThirdplatApiserviceResultDTO>> listApiServiceByCustomerId(ApiServiceFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "listApiServiceByCustomerId", form);
}
} }

13
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java

@ -376,4 +376,17 @@ public class CustomerController {
} }
return new Result<>(); return new Result<>();
} }
/**
* @Description 根据客户id列出该客户所有的apiService
* @return
* @author wxz
* @date 2021.03.15 15:13
*/
@PostMapping("list-apiservice-by-customerid")
public Result<List<ThirdplatApiserviceResultDTO>> listApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form) {
ValidatorUtils.validateEntity(form, ApiServiceFormDTO.GetByCustomerId.class);
String customerId = form.getCustomerId();
return new Result<List<ThirdplatApiserviceResultDTO>>().ok(customerThirdplatApiServiceService.listByCustomerId(customerId));
}
} }

10
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java

@ -23,6 +23,8 @@ import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 客户所属的第三方平台的apiService列表 * 客户所属的第三方平台的apiService列表
* *
@ -33,4 +35,12 @@ import org.apache.ibatis.annotations.Param;
public interface CustomerThirdplatApiserviceDao extends BaseDao<CustomerThirdplatApiserviceEntity> { public interface CustomerThirdplatApiserviceDao extends BaseDao<CustomerThirdplatApiserviceEntity> {
ThirdplatApiserviceResultDTO getByCustomerId(@Param("customerId") String customerId); ThirdplatApiserviceResultDTO getByCustomerId(@Param("customerId") String customerId);
/**
* @Description 列出该客户所有的ApiService
* @return
* @author wxz
* @date 2021.03.15 15:07
*/
List<ThirdplatApiserviceResultDTO> listByCustomerId(String customerId);
} }

9
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java

@ -3,6 +3,8 @@ package com.epmet.service;
import com.epmet.dto.result.ThirdplatApiserviceResultDTO; import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.entity.CustomerThirdplatApiserviceEntity; import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import java.util.List;
public interface CustomerThirdplatApiServiceService { public interface CustomerThirdplatApiServiceService {
/** /**
@ -13,4 +15,11 @@ public interface CustomerThirdplatApiServiceService {
*/ */
ThirdplatApiserviceResultDTO getByCustomerId(String customerId); ThirdplatApiserviceResultDTO getByCustomerId(String customerId);
/**
* 根据客户id列出第三方平台列表
* @param customerId
* @return
*/
List<ThirdplatApiserviceResultDTO> listByCustomerId(String customerId);
} }

19
epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java

@ -8,9 +8,12 @@ import com.epmet.dto.result.ThirdplatApiserviceResultDTO;
import com.epmet.entity.CustomerThirdplatApiserviceEntity; import com.epmet.entity.CustomerThirdplatApiserviceEntity;
import com.epmet.service.CustomerThirdplatApiServiceService; import com.epmet.service.CustomerThirdplatApiServiceService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
@Service @Service
@ -22,6 +25,10 @@ public class CustomerThirdplatApiServiceServiceImpl implements CustomerThirdplat
@Autowired @Autowired
private CustomerThirdplatApiserviceDao thirdplatApiserviceDao; private CustomerThirdplatApiserviceDao thirdplatApiserviceDao;
@Autowired
private RedisTemplate<String, ThirdplatApiserviceResultDTO> tpasRedisTemplate;
@Override @Override
public ThirdplatApiserviceResultDTO getByCustomerId(String customerId) { public ThirdplatApiserviceResultDTO getByCustomerId(String customerId) {
ThirdplatApiserviceResultDTO apiService = null; ThirdplatApiserviceResultDTO apiService = null;
@ -39,4 +46,16 @@ public class CustomerThirdplatApiServiceServiceImpl implements CustomerThirdplat
return apiService; return apiService;
} }
@Override
public List<ThirdplatApiserviceResultDTO> listByCustomerId(String customerId) {
List<ThirdplatApiserviceResultDTO> apiServices = tpasRedisTemplate.opsForList().range(RedisKeys.listCustomerApiServiceListKey(customerId), 0, -1);
if (!CollectionUtils.isEmpty(apiServices)) {
return apiServices;
}
apiServices = thirdplatApiserviceDao.listByCustomerId(customerId);
tpasRedisTemplate.opsForList().rightPushAll(RedisKeys.listCustomerApiServiceListKey(customerId), apiServices);
return apiServices;
}
} }

14
epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml

@ -29,5 +29,19 @@
where cta.CUSTOMER_ID = #{customerId} where cta.CUSTOMER_ID = #{customerId}
</select> </select>
<select id="listByCustomerId" resultType="com.epmet.dto.result.ThirdplatApiserviceResultDTO">
select id,
customer_id,
api_service_name,
del_flag,
revision,
created_by,
created_time,
updated_by,
updated_time
from customer_thirdplat_apiservice cta
where cta.CUSTOMER_ID = #{customerId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save