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