From 800f7e8d82c8d9af90764ad19663e0ada9f3e734 Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 27 Jun 2019 19:07:33 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=98=E9=92=A5=E7=AE=A1=E7=90=86=E6=94=B9?= =?UTF-8?q?=E9=80=A0=EF=BC=8C=E6=9C=8D=E5=8A=A1=E7=AB=AF=E8=BF=94=E5=9B=9E?= =?UTF-8?q?sign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sop/gateway/entity/IsvDetailDTO.java | 29 +++++++++++++++++++ .../sop/gateway/manager/DbIsvManager.java | 10 ++----- .../sop/gateway/mapper/IsvInfoMapper.java | 15 ++++++++++ 3 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 sop-gateway/src/main/java/com/gitee/sop/gateway/entity/IsvDetailDTO.java diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/entity/IsvDetailDTO.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/entity/IsvDetailDTO.java new file mode 100644 index 00000000..d5aff2b1 --- /dev/null +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/entity/IsvDetailDTO.java @@ -0,0 +1,29 @@ +package com.gitee.sop.gateway.entity; + +import lombok.Data; + +/** + * @author tanghc + */ +@Data +public class IsvDetailDTO { + + /** appKey, 数据库字段:app_key */ + private String appKey; + + /** 0启用,1禁用, 数据库字段:status */ + private Byte status; + + // keys + + /** secret, 数据库字段:secret */ + private String secret; + + /** 开发者生成的公钥, 数据库字段:public_key_isv */ + private String publicKeyIsv; + + /** 平台生成的私钥, 数据库字段:private_key_platform */ + private String privateKeyPlatform; + + private Byte signType; +} diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java index 6d81e7d0..89a32508 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/manager/DbIsvManager.java @@ -1,14 +1,12 @@ package com.gitee.sop.gateway.manager; import com.alibaba.fastjson.JSON; -import com.gitee.fastmybatis.core.query.Query; -import com.gitee.sop.gateway.entity.IsvInfo; +import com.gitee.sop.gateway.entity.IsvDetailDTO; import com.gitee.sop.gateway.mapper.IsvInfoMapper; import com.gitee.sop.gatewaycommon.bean.ChannelMsg; import com.gitee.sop.gatewaycommon.bean.IsvDefinition; import com.gitee.sop.gatewaycommon.manager.ZookeeperContext; import com.gitee.sop.gatewaycommon.secret.CacheIsvManager; -import com.gitee.sop.gatewaycommon.secret.SecretContext; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +14,6 @@ import org.springframework.core.env.Environment; import javax.annotation.PostConstruct; import java.util.List; -import java.util.function.Function; /** * @author tanghc @@ -33,14 +30,11 @@ public class DbIsvManager extends CacheIsvManager { @Override public void load() { - List isvInfoList = isvInfoMapper.list(new Query()); - Function secretGetter = SecretContext.getSecretGetter(); + List isvInfoList = isvInfoMapper.listIsvDetail(); isvInfoList.stream() .forEach(isvInfo -> { IsvDefinition isvDefinition = new IsvDefinition(); BeanUtils.copyProperties(isvInfo, isvDefinition); - String secret = secretGetter.apply(isvDefinition); - isvDefinition.setSecret(secret); this.getIsvCache().put(isvDefinition.getAppKey(), isvDefinition); }); } diff --git a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java index 4c59809b..eb308772 100644 --- a/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java +++ b/sop-gateway/src/main/java/com/gitee/sop/gateway/mapper/IsvInfoMapper.java @@ -1,11 +1,26 @@ package com.gitee.sop.gateway.mapper; import com.gitee.fastmybatis.core.mapper.CrudMapper; +import com.gitee.sop.gateway.entity.IsvDetailDTO; import com.gitee.sop.gateway.entity.IsvInfo; +import org.apache.ibatis.annotations.Select; + +import java.util.List; /** * @author tanghc */ public interface IsvInfoMapper extends CrudMapper { + + @Select("SELECT " + + " t.app_key appKey " + + " ,t.status " + + " ,t2.sign_type signType " + + " ,t2.secret " + + " ,t2.public_key_isv publicKeyIsv " + + " ,t2.private_key_platform privateKeyPlatform " + + "FROM isv_info t " + + "INNER JOIN isv_keys t2 ON t.app_key = t2.app_key") + List listIsvDetail(); }