diff --git a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java index 0d63d18538..6d17e1a9a0 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/SsoController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/SsoController.java @@ -1,7 +1,7 @@ package com.epmet.controller; import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; -import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; +import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.form.SsoLoginFormDTO; @@ -13,8 +13,6 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.io.UnsupportedEncodingException; - /** * @Author zxc * @DateTime 2021/1/18 下午4:33 @@ -41,15 +39,15 @@ public class SsoController { return new Result().ok(ssoService.ssoLogin(formDTO)); } - @PostMapping("testlogin") - public Result testssoLogin(){ - UserInfoResultDTO userInfoByTicket = null; + @PostMapping("test") + public Result testssoLogin(){ + ThirdPlatUserInfo userInfoByTicket = null; try { userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui"); - } catch (UnsupportedEncodingException e) { + } catch (Exception e) { e.printStackTrace(); } - return new Result().ok(userInfoByTicket); + return new Result().ok(userInfoByTicket); } } diff --git a/epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java b/epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java index 4bd3f1e0fb..16ee7ab3ce 100644 --- a/epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java +++ b/epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java @@ -30,7 +30,7 @@ public class SsoRedis { if (user == null) { return; } - String key = RedisKeys.getCpUserKey(user.getApp(), "wxmp", user.getUserId()); + String key = RedisKeys.getCpUserKey(user.getApp(), user.getClient(), user.getUserId()); //bean to map Map map = BeanUtil.beanToMap(user, false, true); redisUtils.hMSet(key, map, expire); diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java index 75c463d94b..ede5acd988 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java @@ -3,19 +3,20 @@ package com.epmet.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.epmet.commons.thirdplat.apiservice.AbstractApiService; -import com.epmet.commons.thirdplat.apiservice.jcet.JcetApiService; -import com.epmet.commons.thirdplat.constants.ApiServiceBeansConstants; -import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; +import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.*; -import com.epmet.constant.SsoConstant; import com.epmet.dto.PaCustomerDTO; import com.epmet.dto.UserDTO; +import com.epmet.dto.form.ApiServiceFormDTO; import com.epmet.dto.form.SsoLoginFormDTO; import com.epmet.dto.form.UserInfoFormDTO; import com.epmet.dto.result.SsoLoginResultDTO; +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; import com.epmet.feign.EpmetUserOpenFeignClient; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.jwt.JwtTokenProperties; import com.epmet.jwt.JwtTokenUtils; import com.epmet.redis.SsoRedis; @@ -27,7 +28,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; @@ -53,6 +53,9 @@ public class SsoServiceImpl implements SsoService { @Autowired private EpmetUserOpenFeignClient epmetUserOpenFeignClient; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; + /** * @Description 0、入口:得到token * @Param formDTO @@ -61,39 +64,51 @@ public class SsoServiceImpl implements SsoService { */ @Override public SsoLoginResultDTO ssoLogin(SsoLoginFormDTO formDTO) { + String customerId = getCustomerId(formDTO.getAppId()); String userId = ""; - if (formDTO.getAppId().equals(SsoConstant.WINE_CITY_E_OPEN_APP_ID)) { - UserInfoResultDTO userInfo = null; - try { - AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(ApiServiceBeansConstants.JCET_API_SERVICE); - userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); - } catch (Exception e) { - logger.error("调用第三方平台,根据用户ticket查询用户信息失败,错误信息"); - e.printStackTrace(); - } - if (null == userInfo){ - throw new RenException(SsoConstant.USER_INFO_IS_NULL); - } - UserInfoFormDTO userInfoFormDTO = ConvertUtils.sourceToTarget(userInfo, UserInfoFormDTO.class); - userInfoFormDTO.setApp(formDTO.getApp()); - userInfoFormDTO.setUid(userInfo.getId()); - userInfoFormDTO.setName(userInfo.getName()); - userInfoFormDTO.setMobile(userInfo.getMobile()); - Result userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO); - if (!userDTOResult.success()){ - throw new RenException(SsoConstant.INSERT_UPDATE_USER_FAILURE); - } - userId = userDTOResult.getData().getId(); + + Result apiServiceResult = operCrmOpenFeignClient.getApiServiceByCustomerId(new ApiServiceFormDTO(customerId)); + if (!apiServiceResult.success()) { + throw new RenException("【SSO登录】调用OperCrm获取ApiService接口失败:", apiServiceResult.getInternalMsg()); + } + + if (apiServiceResult.getData() == null || StringUtils.isBlank(apiServiceResult.getData().getApiServiceName())) { + throw new RenException("【SSO登录】调用OperCrm获取ApiService,查询到的结果为空:", apiServiceResult.toString()); + } + + ThirdPlatUserInfo userInfo; + try { + AbstractApiService apiService = (AbstractApiService) SpringContextUtils.getBean(apiServiceResult.getData().getApiServiceName()); + userInfo = apiService.getUserInfoByTicket(formDTO.getTicket()); + } catch (Exception e) { + throw new RenException(e.getMessage()); } + + if (null == userInfo){ + throw new RenException(EpmetErrorCode.THIRD_PLAT_REQUEST_ERROR.getCode(), + "【SSO登录】调用第三方平台查询用户信息失败,用户信息为空"); + } + UserInfoFormDTO userInfoFormDTO = new UserInfoFormDTO(); + userInfoFormDTO.setApp(formDTO.getApp()); + userInfoFormDTO.setUid(userInfo.getOpenId()); + userInfoFormDTO.setName(userInfo.getName()); + userInfoFormDTO.setMobile(userInfo.getMobile()); + + Result userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO); + if (!userDTOResult.success()){ + throw new RenException("【SSO登录】新增或更新user_weChat失败"); + } + userId = userDTOResult.getData().getId(); + if (StringUtils.isBlank(userId)){ - throw new RenException(SsoConstant.USER_ID_IS_NULL); + throw new RenException("【SSO登录】userId为空,生成token失败"); } //生成业务token String token = this.generateToken(formDTO.getApp(),formDTO.getClient(), userId); //存放Redis - String customerId = getCustomerId(formDTO.getAppId()); + if (StringUtils.isBlank(customerId)){ - throw new RenException(SsoConstant.CUSTOMER_ID_IS_NULL); + throw new RenException("【SSO登录】customerId为空,缓存放置token失败"); } this.disposeTokenDto(formDTO, userId, token, customerId); return new SsoLoginResultDTO(token); diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java index 3209a9ea44..fbf0f7781e 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java @@ -2,15 +2,13 @@ package com.epmet.commons.thirdplat.apiservice; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; import com.epmet.commons.thirdplat.dto.result.jcet.JcetResult; -import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; import com.epmet.commons.thirdplat.properties.ThirdplatProps; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.Result; -import java.io.UnsupportedEncodingException; - public abstract class AbstractApiService { protected ThirdplatProps thirdplatProps; @@ -21,7 +19,7 @@ public abstract class AbstractApiService { * @return * @throws Exception */ - public abstract UserInfoResultDTO getUserInfoByTicket(String ticket) throws Exception; + public abstract ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws Exception; /** * @Description 解析请求结果 diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java index b24803fa09..a975dc6a27 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java @@ -2,10 +2,10 @@ package com.epmet.commons.thirdplat.apiservice.jcet; import com.alibaba.fastjson.JSON; import com.epmet.commons.thirdplat.apiservice.AbstractApiService; +import com.epmet.commons.thirdplat.bean.ThirdPlatUserInfo; import com.epmet.commons.thirdplat.constants.JcetConstants; import com.epmet.commons.thirdplat.dto.form.jcet.SsoTicketFormDTO; -import com.epmet.commons.thirdplat.dto.form.jcet.SsoTokenFormDTO; -import com.epmet.commons.thirdplat.dto.result.jcet.UserInfoResultDTO; +import com.epmet.commons.thirdplat.dto.result.jcet.JcetUserInfoResultDTO; import com.epmet.commons.thirdplat.encrypt.SignUtils; import com.epmet.commons.thirdplat.properties.JcetThirdplatProps; import com.epmet.commons.thirdplat.properties.ThirdplatProps; @@ -31,7 +31,7 @@ public class JcetApiService extends AbstractApiService { * @author wxz * @date 2021.01.19 10:26 */ - public UserInfoResultDTO getUserInfoByTicket(String ticket) throws UnsupportedEncodingException { + public ThirdPlatUserInfo getUserInfoByTicket(String ticket) throws UnsupportedEncodingException { SsoTicketFormDTO ssoTicket = new SsoTicketFormDTO(); ssoTicket.setSsoTicket(ticket); @@ -42,8 +42,13 @@ public class JcetApiService extends AbstractApiService { JSON.toJSONString(ssoTicket), getHeaders(ssoTicket)); - UserInfoResultDTO resultDTO = parseResult(result, UserInfoResultDTO.class); - return resultDTO; + JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class); + + ThirdPlatUserInfo userInfo = new ThirdPlatUserInfo(); + userInfo.setOpenId(resultDTO.getId()); + userInfo.setName(resultDTO.getName()); + userInfo.setMobile(resultDTO.getMobile()); + return userInfo; } /** @@ -52,24 +57,24 @@ public class JcetApiService extends AbstractApiService { * @author wxz * @date 2021.01.19 10:28 */ - public UserInfoResultDTO getUserInfoByToken(String token) throws UnsupportedEncodingException { - SsoTokenFormDTO ssoToken = new SsoTokenFormDTO(); - ssoToken.setSsoToken(token); - - HashMap paramMap = new HashMap<>(); - paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token); - - String domain = jcetThirdplatProps.getDomain(); - - Result result = HttpClientManager.getInstance().sendGet( - domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN), - domain.startsWith("https://"), - paramMap, - getHeaders(ssoToken)); - - UserInfoResultDTO resultDTO = parseResult(result, UserInfoResultDTO.class); - return resultDTO; - } + //public JcetUserInfoResultDTO getUserInfoByToken(String token) throws UnsupportedEncodingException { + // SsoTokenFormDTO ssoToken = new SsoTokenFormDTO(); + // ssoToken.setSsoToken(token); + // + // HashMap paramMap = new HashMap<>(); + // paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token); + // + // String domain = jcetThirdplatProps.getDomain(); + // + // Result result = HttpClientManager.getInstance().sendGet( + // domain.concat(JcetConstants.URL_GET_USER_BY_TOKEN), + // domain.startsWith("https://"), + // paramMap, + // getHeaders(ssoToken)); + // + // JcetUserInfoResultDTO resultDTO = parseResult(result, JcetUserInfoResultDTO.class); + // return resultDTO; + //} /** * 获取请求所需要的头信息 diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java index 365e142a0f..f1539efba7 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java @@ -1,5 +1,10 @@ package com.epmet.commons.thirdplat.bean; -public class ThirdPlatUserInfo { +import lombok.Data; +@Data +public class ThirdPlatUserInfo { + private String openId; + private String name; + private String mobile; } diff --git a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java similarity index 92% rename from epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java rename to epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java index 09fc1bcace..8c025e5b9b 100644 --- a/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java +++ b/epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java @@ -3,7 +3,7 @@ package com.epmet.commons.thirdplat.dto.result.jcet; import lombok.Data; @Data -public class UserInfoResultDTO { +public class JcetUserInfoResultDTO { private String id; /** * 用户名称 diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java new file mode 100644 index 0000000000..a111ca87c6 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.form; + +import com.epmet.commons.tools.dto.form.PageFormDTO; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import javax.validation.constraints.NotBlank; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ApiServiceFormDTO { + + public interface GetByCustomerId extends PageFormDTO.AddUserShowGroup {} + + @NotBlank(message = "客户ID不能为空", groups = { GetByCustomerId.class }) + private String customerId; + +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java new file mode 100644 index 0000000000..4737bf32d4 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java @@ -0,0 +1,16 @@ +package com.epmet.dto.result; + +import lombok.Data; + +@Data +public class ThirdplatApiserviceResultDTO { + /** + * 客户id + */ + private String customerId; + + /** + * aipService名称 + */ + private String apiServiceName; +} diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java index 496dcd636a..4c733ab45a 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java @@ -4,12 +4,10 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; -import com.epmet.dto.form.CrmParameterFormDTO; -import com.epmet.dto.form.CustomerAppSecretFormDTO; -import com.epmet.dto.form.CustomerManagerFormDTO; -import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CrmParameterResultDTO; import com.epmet.dto.result.GridCountResultDTO; +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; import com.epmet.feign.fallback.OperCrmOpenFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; @@ -94,4 +92,13 @@ public interface OperCrmOpenFeignClient { */ @PostMapping("/oper/crm/parameter/parameterupdate") Result updateParamInfo(@RequestBody List formDTOS); + + /** + * @Description 根据客户id查询配置的apiService + * @return + * @author wxz + * @date 2021.01.20 15:55 + */ + @PostMapping("/oper/crm/customer/get-apiservice-by-customerid") + Result getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form); } diff --git a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java index d18f98065a..8a3a1483f5 100644 --- a/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java +++ b/epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java @@ -5,12 +5,10 @@ import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.CustomerAppDTO; import com.epmet.dto.CustomerDTO; -import com.epmet.dto.form.CrmParameterFormDTO; -import com.epmet.dto.form.CustomerAppSecretFormDTO; -import com.epmet.dto.form.CustomerManagerFormDTO; -import com.epmet.dto.form.GridCountFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.CrmParameterResultDTO; import com.epmet.dto.result.GridCountResultDTO; +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; import com.epmet.feign.OperCrmOpenFeignClient; import org.springframework.stereotype.Component; @@ -69,4 +67,9 @@ public class OperCrmOpenFeignClientFallback implements OperCrmOpenFeignClient { public Result updateParamInfo(List formDTOS) { return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS); } + + @Override + public Result getApiServiceByCustomerId(ApiServiceFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getApiServiceByCustomerId", form); + } } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java index e4ae80fc6e..51cc0fa29c 100644 --- a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java @@ -31,13 +31,11 @@ import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.CustomerDTO; import com.epmet.dto.form.*; -import com.epmet.dto.result.CustomerDetailResultDTO; -import com.epmet.dto.result.CustomerInfoResultDTO; -import com.epmet.dto.result.GridCountResultDTO; -import com.epmet.dto.result.ValidCustomerResultDTO; +import com.epmet.dto.result.*; import com.epmet.excel.CustomerExcel; import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.CustomerService; +import com.epmet.service.CustomerThirdplatApiServiceService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -67,6 +65,9 @@ public class CustomerController { @Autowired private GovOrgFeignClient govOrgFeignClient; + @Autowired + private CustomerThirdplatApiServiceService customerThirdplatApiServiceService; + @GetMapping("page") public Result> page(@RequestParam Map params) { PageData page = customerService.page(params); @@ -330,4 +331,17 @@ public class CustomerController { return new Result(); } + /** + * @Description 根据客户id查询配置的apiService + * @return + * @author wxz + * @date 2021.01.20 15:55 + */ + @PostMapping("get-apiservice-by-customerid") + public Result getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form) { + ValidatorUtils.validateEntity(form, ApiServiceFormDTO.GetByCustomerId.class); + String customerId = form.getCustomerId(); + return new Result().ok(customerThirdplatApiServiceService.getByCustomerId(customerId)); + } + } diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java new file mode 100644 index 0000000000..52f05556b1 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java @@ -0,0 +1,36 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; +import com.epmet.entity.CustomerThirdplatApiserviceEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +/** + * 客户所属的第三方平台的apiService列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-20 + */ +@Mapper +public interface CustomerThirdplatApiserviceDao extends BaseDao { + + ThirdplatApiserviceResultDTO getByCustomerId(@Param("customerId") String customerId); +} \ No newline at end of file diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java new file mode 100644 index 0000000000..59be94ffb9 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java @@ -0,0 +1,51 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * 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. + *

+ * 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. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +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; + +/** + * 客户所属的第三方平台的apiService列表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-01-20 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("customer_thirdplat_apiservice") +public class CustomerThirdplatApiserviceEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户id + */ + private String customerId; + + /** + * aipService名称 + */ + private String apiServiceName; + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java new file mode 100644 index 0000000000..a1f9fa91e9 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java @@ -0,0 +1,16 @@ +package com.epmet.service; + +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; +import com.epmet.entity.CustomerThirdplatApiserviceEntity; + +public interface CustomerThirdplatApiServiceService { + + /** + * @Description 根据客户id查询客户第三方平台的ApiService + * @return + * @author wxz + * @date 2021.01.20 15:47 + */ + ThirdplatApiserviceResultDTO getByCustomerId(String customerId); + +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java new file mode 100644 index 0000000000..410fd1aa3f --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java @@ -0,0 +1,20 @@ +package com.epmet.service.impl; + +import com.epmet.dao.CustomerThirdplatApiserviceDao; +import com.epmet.dto.result.ThirdplatApiserviceResultDTO; +import com.epmet.entity.CustomerThirdplatApiserviceEntity; +import com.epmet.service.CustomerThirdplatApiServiceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CustomerThirdplatApiServiceServiceImpl implements CustomerThirdplatApiServiceService { + + @Autowired + private CustomerThirdplatApiserviceDao thirdplatApiserviceDao; + + @Override + public ThirdplatApiserviceResultDTO getByCustomerId(String customerId) { + return thirdplatApiserviceDao.getByCustomerId(customerId); + } +} diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql new file mode 100644 index 0000000000..491d1d14c9 --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql @@ -0,0 +1,14 @@ +create table customer_thirdplat_apiservice +( + `ID` varchar(64) NOT NULL COMMENT '唯一标识', + `CUSTOMER_ID` varchar(64) not null comment '客户id', + `API_SERVICE_NAME` varchar(64) not null comment 'aipService名称', + `DEL_FLAG` int(11) NOT NULL COMMENT '删除标识:0.未删除 1.已删除', + `REVISION` int(11) NOT NULL COMMENT '乐观锁', + `CREATED_BY` varchar(32) NOT NULL COMMENT '创建人', + `CREATED_TIME` datetime NOT NULL COMMENT '创建时间', + `UPDATED_BY` varchar(32) NOT NULL COMMENT '更新人', + `UPDATED_TIME` datetime NOT NULL COMMENT '更新时间' +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + collate utf8mb4_general_ci COMMENT ='客户所属的第三方平台的apiService列表'; diff --git a/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml new file mode 100644 index 0000000000..8390e5647f --- /dev/null +++ b/epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file