Browse Source

third接口 根据客户查询Token

master
wangchao 5 years ago
parent
commit
b59e2a1a9f
  1. 33
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java
  2. 27
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java
  3. 26
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java
  4. 41
      epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java
  5. 4
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java
  6. 14
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java
  7. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java
  8. 9
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java
  9. 21
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java
  10. 49
      epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java
  11. 12
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml
  12. 11
      epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml

33
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdAndSrcFormDTO.java

@ -0,0 +1,33 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 公众号客户删除入参DTO
* @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482
* @ClassName CommonCustomerIdAndSrcFormDTO
* @Auth wangc
* @Date 2020-08-25 11:02
*/
@Data
public class CommonCustomerIdAndSrcFormDTO implements Serializable {
private static final long serialVersionUID = -2945388338786885295L;
public interface CustomerAndSrcGroup extends CustomerClientShowGroup{}
/**
* 客户Id
* */
@NotBlank(message = "客户Id不能为空",groups = CustomerAndSrcGroup.class)
private String customerId;
/**
* 数据来源(dev:开发 test:体验 prod:生产)
* */
@NotBlank(message = "数据来源不能为空",groups = CustomerAndSrcGroup.class)
private String source;
}

27
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/CommonCustomerIdFormDTO.java

@ -0,0 +1,27 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* @Description 获取客户第三方token 入参DTO
* @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323480
* @ClassName CommonCustomerIdFormDTO
* @Auth wangc
* @Date 2020-08-25 10:57
*/
@Data
public class CommonCustomerIdFormDTO implements Serializable {
private static final long serialVersionUID = 3160741101286756024L;
public interface PaCustomerIdGroup extends CustomerClientShowGroup{}
/**
* 客户Id
* */
@NotBlank(message = "客户Id不能为空" , groups = PaCustomerIdGroup.class)
private String customerId;
}

26
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/AuthAccessTokenClientResultDTO.java

@ -0,0 +1,26 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description 授权accessToken和app端的查询返参
* @ClassName AuthAccessTokenClientResultDTO
* @Auth wangc
* @Date 2020-08-25 13:41
*/
@Data
public class AuthAccessTokenClientResultDTO implements Serializable {
private static final long serialVersionUID = -642465145534993509L;
/**
* 客户端类型
* */
private String clientType;
/**
* 调用令牌
* */
private String accessToken;
}

41
epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTokensResultDTO.java

@ -0,0 +1,41 @@
package com.epmet.dto.result;
import lombok.Data;
import java.io.Serializable;
/**
* @Description
* @ClassName CustomerTokensResultDTO
* @Auth wangc
* @Date 2020-08-25 11:16
*/
@Data
public class CustomerTokensResultDTO implements Serializable {
private static final long serialVersionUID = -6811282503588315365L;
/**
* 客户Id
* */
private String customerId = "";
/**
* 客户名称
* */
private String customerName = "";
/**
* 第三方token
* */
private String componentAccessToken = "";
/**
* 授权方居民端token
* */
private String resiAuthorizerToken = "";
/**
* 授权方工作端token
* */
private String workAuthorizerToken = "";
}

4
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/constant/ModuleConstant.java

@ -116,5 +116,9 @@ public interface ModuleConstant {
int EIGHTY_NINE_THOUSAND_AND_THREE = 89003;
int EIGHTY_NINE_THOUSAND_AND_FOUR = 89004;
/**
* 数据来源 生产环境
* */
String SRC_PROD = "prod";
}

14
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PaCustomerController.java

@ -192,5 +192,19 @@ public class PaCustomerController {
return new Result<PageData>().ok(pageData);
}
/**
* @Description 获取客户第三方token
* @NEI https://nei.netease.com/interface/detail/req/?pid=52285&id=323480
* @param param CommonCustomerIdFormDTO.class
* @return Result<CustomerTokensResultDTO>
* @author wangc
* @date 2020.08.25 15:39
**/
@PostMapping("tokenlist")
public Result<CustomerTokensResultDTO> tokenList(@RequestBody CommonCustomerIdFormDTO param){
ValidatorUtils.validateEntity(param, CustomerUserFormDTO.CustomerIdGroup.class);
return new Result<CustomerTokensResultDTO>().ok(paCustomerService.tokenList(param));
}
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java

@ -22,6 +22,7 @@ import com.epmet.dto.AuthorizationInfoDTO;
import com.epmet.dto.form.AuthorizationInfoFormDTO;
import com.epmet.dto.form.AuthorizerAccessTokenFormDTO;
import com.epmet.dto.form.CustomerAccessTokenInfoFormDTO;
import com.epmet.dto.result.AuthAccessTokenClientResultDTO;
import com.epmet.dto.result.AuthCodeResultDTO;
import com.epmet.dto.result.CustomerAccessTokenInfoResultDTO;
import com.epmet.dto.result.WillOverDueResultDTO;
@ -109,4 +110,12 @@ public interface AuthorizationInfoDao extends BaseDao<AuthorizationInfoEntity> {
*/
List<CustomerAccessTokenInfoResultDTO> getCustomerAccessTokenInfo(CustomerAccessTokenInfoFormDTO customerAccessTokenInfoFormDTO);
/**
* @Description 查询来源端对应的accessToken
* @param customerId
* @return List<AuthAccessTokenClientResultDTO>
* @author wangc
* @date 2020.08.25 15:24
**/
List<AuthAccessTokenClientResultDTO> selectClientToken(@Param("customerId") String customerId);
}

9
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ComponentAccessTokenDao.java

@ -69,4 +69,13 @@ public interface ComponentAccessTokenDao extends BaseDao<ComponentAccessTokenEnt
*/
String getComponentAccessToken();
/**
* @Description 查询ComponentAccessToken唯一
* @param
* @return String
* @author wangc
* @date 2020.08.25 15:14
**/
String selectComponentAccessToken();
}

21
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java

@ -213,4 +213,25 @@ public interface PaCustomerService extends BaseService<PaCustomerEntity> {
* @return com.epmet.commons.tools.page.PageData
*/
PageData getCustomerList(UploadListFormDTO formDTO);
/**
* @Description 获取客户第三方token
* @NEI https://nei.netease.com/interface/detail/res/?pid=52285&id=323480
* @param param
* @return
* @author wangc
* @date 2020.08.25 14:51
**/
CustomerTokensResultDTO tokenList(CommonCustomerIdFormDTO param);
/**
* @Description 公众号客户删除
* @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482
* @param token
* @param param
* @return
* @author wangc
* @date 2020.08.25 15:46
**/
void deletePublicCustomer(TokenDto token,CommonCustomerIdAndSrcFormDTO param);
}

49
epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java

@ -31,6 +31,8 @@ import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.CpUserDetailRedis;
import com.epmet.constant.CodeConstant;
import com.epmet.constant.ModuleConstant;
import com.epmet.constant.PaConstant;
import com.epmet.dao.*;
import com.epmet.dto.*;
@ -102,6 +104,8 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
private WxMaCodeService wxMaCodeService;
@Autowired
private AuthorizationInfoDao authorizationInfoDao;
@Autowired
private ComponentAccessTokenDao componentAccessTokenDao;
@Override
public PageData<PaCustomerDTO> page(Map<String, Object> params) {
@ -641,4 +645,49 @@ public class PaCustomerServiceImpl extends BaseServiceImpl<PaCustomerDao, PaCust
return new PageData<>(list, pageInfo.getTotal());
}
/**
* @Description 获取客户第三方token
* @NEI https://nei.netease.com/interface/detail/res/?pid=52285&id=323480
* @param param
* @return
* @author wangc
* @date 2020.08.25 14:51
**/
@Override
public CustomerTokensResultDTO tokenList(CommonCustomerIdFormDTO param) {
CustomerTokensResultDTO result = new CustomerTokensResultDTO();
String customerName = baseDao.selectCustomerName(param.getCustomerId());
String componentAccessToken = componentAccessTokenDao.selectComponentAccessToken();
List<AuthAccessTokenClientResultDTO> clientList = authorizationInfoDao.selectClientToken(param.getCustomerId());
result.setCustomerId(param.getCustomerId());
result.setComponentAccessToken(StringUtils.isBlank(componentAccessToken) ? "" : componentAccessToken);
result.setCustomerName(StringUtils.isBlank(customerName) ? "" : customerName);
if(null != clientList || !clientList.isEmpty()){
clientList.forEach(client -> {
if(StringUtils.equals(CodeConstant.WORK,client.getClientType())){
result.setWorkAuthorizerToken(client.getAccessToken());
}else if(StringUtils.equals(CodeConstant.RESI,client.getClientType())){
result.setResiAuthorizerToken(client.getAccessToken());
}
});
}
return result;
}
/**
* @Description 公众号客户删除
* @NEI https://nei.netease.com/interface/detail/?pid=52285&id=323482
* @param token
* @param param
* @return
* @author wangc
* @date 2020.08.25 15:46
**/
@Override
public void deletePublicCustomer(TokenDto token , CommonCustomerIdAndSrcFormDTO param) {
if(StringUtils.equals(ModuleConstant.SRC_PROD,param.getSource())){
logger.warn("有人试图删除用户生产数据,试图删除的客户Id:{},操作者Id:{}",param.getCustomerId(),token.getUserId());
}
}
}

12
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml

@ -121,4 +121,16 @@
</if>
</select>
<!-- 查询来源端对应的accessToken -->
<select id="selectClientToken" resultType="com.epmet.dto.result.AuthAccessTokenClientResultDTO">
SELECT
CLIENT_TYPE,
AUTHORIZER_ACCESS_TOKEN
FROM
authorization_info
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
</select>
</mapper>

11
epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ComponentAccessTokenDao.xml

@ -48,4 +48,15 @@
AND (UNIX_TIMESTAMP(expires_in_time) - UNIX_TIMESTAMP(NOW())) <![CDATA[ <= ]]> 900
</select>
<!-- 查询ComponentAccessToken【唯一】 -->
<select id="selectComponentAccessToken" resultType="java.lang.String">
SELECT
COMPONENT_ACCESS_TOKEN
FROM
component_access_token
WHERE
DEL_FLAG = '0'
ORDER BY UPDATED_TIME DESC
LIMIT 1
</select>
</mapper>
Loading…
Cancel
Save