Browse Source

修改sso登录,使更灵活...

dev_shibei_match
wxz 5 years ago
parent
commit
3b2f78a0fd
  1. 14
      epmet-auth/src/main/java/com/epmet/controller/SsoController.java
  2. 2
      epmet-auth/src/main/java/com/epmet/redis/SsoRedis.java
  3. 75
      epmet-auth/src/main/java/com/epmet/service/impl/SsoServiceImpl.java
  4. 6
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/AbstractApiService.java
  5. 51
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/apiservice/jcet/JcetApiService.java
  6. 7
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/bean/ThirdPlatUserInfo.java
  7. 2
      epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/JcetUserInfoResultDTO.java
  8. 20
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/form/ApiServiceFormDTO.java
  9. 16
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/dto/result/ThirdplatApiserviceResultDTO.java
  10. 15
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/OperCrmOpenFeignClient.java
  11. 11
      epmet-module/oper-crm/oper-crm-client/src/main/java/com/epmet/feign/fallback/OperCrmOpenFeignClientFallback.java
  12. 22
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/controller/CustomerController.java
  13. 36
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/dao/CustomerThirdplatApiserviceDao.java
  14. 51
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/entity/CustomerThirdplatApiserviceEntity.java
  15. 16
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/CustomerThirdplatApiServiceService.java
  16. 20
      epmet-module/oper-crm/oper-crm-server/src/main/java/com/epmet/service/impl/CustomerThirdplatApiServiceServiceImpl.java
  17. 14
      epmet-module/oper-crm/oper-crm-server/src/main/resources/db/migration/V0.0.6__create_thirdplat_apiservice.sql
  18. 33
      epmet-module/oper-crm/oper-crm-server/src/main/resources/mapper/CustomerThirdplatApiserviceDao.xml

14
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<SsoLoginResultDTO>().ok(ssoService.ssoLogin(formDTO));
}
@PostMapping("testlogin")
public Result<UserInfoResultDTO> testssoLogin(){
UserInfoResultDTO userInfoByTicket = null;
@PostMapping("test")
public Result<ThirdPlatUserInfo> testssoLogin(){
ThirdPlatUserInfo userInfoByTicket = null;
try {
userInfoByTicket = jcetApiService.getUserInfoByTicket("ssoTicket-vYtMRuXAQZri3wpA2vyq5D8n3Q9oO7ui");
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
e.printStackTrace();
}
return new Result<UserInfoResultDTO>().ok(userInfoByTicket);
return new Result<ThirdPlatUserInfo>().ok(userInfoByTicket);
}
}

2
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<String, Object> map = BeanUtil.beanToMap(user, false, true);
redisUtils.hMSet(key, map, expire);

75
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<UserDTO> userDTOResult = epmetUserOpenFeignClient.saveUserInfo(userInfoFormDTO);
if (!userDTOResult.success()){
throw new RenException(SsoConstant.INSERT_UPDATE_USER_FAILURE);
}
userId = userDTOResult.getData().getId();
Result<ThirdplatApiserviceResultDTO> 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<UserDTO> 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);

6
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 解析请求结果

51
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<String, Object> paramMap = new HashMap<>();
paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token);
String domain = jcetThirdplatProps.getDomain();
Result<String> 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<String, Object> paramMap = new HashMap<>();
// paramMap.put(JcetConstants.PLAT_TOKEN_NAME, token);
//
// String domain = jcetThirdplatProps.getDomain();
//
// Result<String> 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;
//}
/**
* 获取请求所需要的头信息

7
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;
}

2
epmet-commons/epmet-commons-thirdplat/src/main/java/com/epmet/commons/thirdplat/dto/result/jcet/UserInfoResultDTO.java → 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;
/**
* 用户名称

20
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;
}

16
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;
}

15
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<CrmParameterResultDTO> formDTOS);
/**
* @Description 根据客户id查询配置的apiService
* @return
* @author wxz
* @date 2021.01.20 15:55
*/
@PostMapping("/oper/crm/customer/get-apiservice-by-customerid")
Result<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form);
}

11
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<CrmParameterResultDTO> formDTOS) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "updateParamInfo", formDTOS);
}
@Override
public Result<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(ApiServiceFormDTO form) {
return ModuleUtils.feignConError(ServiceConstant.OPER_CRM_SERVER, "getApiServiceByCustomerId", form);
}
}

22
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<PageData<CustomerDTO>> page(@RequestParam Map<String, Object> params) {
PageData<CustomerDTO> 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<ThirdplatApiserviceResultDTO> getApiServiceByCustomerId(@RequestBody ApiServiceFormDTO form) {
ValidatorUtils.validateEntity(form, ApiServiceFormDTO.GetByCustomerId.class);
String customerId = form.getCustomerId();
return new Result<ThirdplatApiserviceResultDTO>().ok(customerThirdplatApiServiceService.getByCustomerId(customerId));
}
}

36
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
* <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.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<CustomerThirdplatApiserviceEntity> {
ThirdplatApiserviceResultDTO getByCustomerId(@Param("customerId") String customerId);
}

51
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
* <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;
/**
* 客户所属的第三方平台的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;
}

16
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);
}

20
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);
}
}

14
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列表';

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

@ -0,0 +1,33 @@
<?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.CustomerThirdplatApiserviceDao">
<resultMap type="com.epmet.entity.CustomerThirdplatApiserviceEntity" id="customerThirdplatApiserviceMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="apiServiceName" column="API_SERVICE_NAME"/>
<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="getByCustomerId" 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>
Loading…
Cancel
Save