|
|
@@ -1,20 +1,28 @@
|
|
|
package org.dromara.system.service.impl;
|
|
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
+import org.dromara.common.encrypt.utils.EncryptUtils;
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
+import org.dromara.system.domain.vo.SysRegisterInfoVo;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.dromara.system.domain.bo.SysRegisterinfoBo;
|
|
|
-import org.dromara.system.domain.vo.SysRegisterinfoVo;
|
|
|
import org.dromara.system.domain.SysRegisterinfo;
|
|
|
import org.dromara.system.mapper.SysRegisterinfoMapper;
|
|
|
-import org.dromara.system.service.ISysRegisterinfoService;
|
|
|
+import org.dromara.system.service.ISysRegisterInfoService;
|
|
|
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.Base64;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Collection;
|
|
|
@@ -27,8 +35,9 @@ import java.util.Collection;
|
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class SysRegisterinfoServiceImpl implements ISysRegisterinfoService {
|
|
|
+public class SysRegisterInfoServiceImpl implements ISysRegisterInfoService {
|
|
|
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(SysRegisterInfoServiceImpl.class);
|
|
|
private final SysRegisterinfoMapper baseMapper;
|
|
|
|
|
|
/**
|
|
|
@@ -38,7 +47,7 @@ public class SysRegisterinfoServiceImpl implements ISysRegisterinfoService {
|
|
|
* @return 注册信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public SysRegisterinfoVo queryById(Long registerId){
|
|
|
+ public SysRegisterInfoVo queryById(Long registerId){
|
|
|
return baseMapper.selectVoById(registerId);
|
|
|
}
|
|
|
|
|
|
@@ -50,9 +59,9 @@ public class SysRegisterinfoServiceImpl implements ISysRegisterinfoService {
|
|
|
* @return 注册信息分页列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public TableDataInfo<SysRegisterinfoVo> queryPageList(SysRegisterinfoBo bo, PageQuery pageQuery) {
|
|
|
+ public TableDataInfo<SysRegisterInfoVo> queryPageList(SysRegisterinfoBo bo, PageQuery pageQuery) {
|
|
|
LambdaQueryWrapper<SysRegisterinfo> lqw = buildQueryWrapper(bo);
|
|
|
- Page<SysRegisterinfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
+ Page<SysRegisterInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
|
|
return TableDataInfo.build(result);
|
|
|
}
|
|
|
|
|
|
@@ -63,7 +72,7 @@ public class SysRegisterinfoServiceImpl implements ISysRegisterinfoService {
|
|
|
* @return 注册信息列表
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<SysRegisterinfoVo> queryList(SysRegisterinfoBo bo) {
|
|
|
+ public List<SysRegisterInfoVo> queryList(SysRegisterinfoBo bo) {
|
|
|
LambdaQueryWrapper<SysRegisterinfo> lqw = buildQueryWrapper(bo);
|
|
|
return baseMapper.selectVoList(lqw);
|
|
|
}
|
|
|
@@ -132,4 +141,50 @@ public class SysRegisterinfoServiceImpl implements ISysRegisterinfoService {
|
|
|
}
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询注册信息
|
|
|
+ *
|
|
|
+ * @return 注册信息
|
|
|
+ */
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ @Override
|
|
|
+ public SysRegisterInfoVo queryRegisterInfo() {
|
|
|
+ List<SysRegisterinfo> list = baseMapper.selectList();
|
|
|
+ SysRegisterInfoVo vo = new SysRegisterInfoVo();
|
|
|
+ list.stream().findFirst().ifPresent(p-> {
|
|
|
+
|
|
|
+ String base64Info = p.getRegisterInfo();
|
|
|
+ byte[] result = Base64.getDecoder().decode(base64Info.getBytes());
|
|
|
+ JSONObject obj = JSONObject.parseObject(new String(result, StandardCharsets.UTF_8));
|
|
|
+ Map<String, Object> dataMap = (Map<String, Object>) obj.get("data");
|
|
|
+ // 经销商编号
|
|
|
+ String dealerNo = dataMap.get("dealerNo").toString();
|
|
|
+ // 经销商公钥(使用经销商编号对公钥进行3DES加密后的密文)
|
|
|
+ String dealerPublicKey3des = dataMap.get("dealerPublicKey").toString();
|
|
|
+ log.info("dealerNo={}", dealerNo);
|
|
|
+ // 客户公钥(使用经销商私钥对客户公钥进行RSA加密后的密文)
|
|
|
+ String customerPublicKeyRsa = dataMap.get("customerPublicKey").toString();
|
|
|
+ // 客户ID,明文
|
|
|
+ String customerId = dataMap.get("customerId").toString();
|
|
|
+ // 授权加密信息(使用customId对客户的授权信息进行3DES加密,再使用客户的私钥分别对数据进行RAS加密)
|
|
|
+ String warrantInfoRsa = dataMap.get("warrantInfo").toString();
|
|
|
+
|
|
|
+ // 解密授权信息
|
|
|
+ String warrantInfo3DES = "";
|
|
|
+ // 解密经销商公钥
|
|
|
+ String dealerPubKey = EncryptUtils.decryptByDESede(dealerPublicKey3des,EncryptUtils.hex(dealerNo));
|
|
|
+ log.info("dealerPubKey={}", dealerPubKey);
|
|
|
+ // 解密客户公钥
|
|
|
+ String customerPublicKey = EncryptUtils.decryptByRsaPublicKey(customerPublicKeyRsa,dealerPubKey);
|
|
|
+
|
|
|
+ warrantInfo3DES = EncryptUtils.decryptByRsaPublicKey(warrantInfoRsa,customerPublicKey);
|
|
|
+
|
|
|
+ String warrantInfo = EncryptUtils.decryptByDESede(customerId, warrantInfo3DES);
|
|
|
+ log.info("warrantInfo={}", warrantInfo);
|
|
|
+ vo.setDealerNo(dealerNo);
|
|
|
+
|
|
|
+ });
|
|
|
+ return vo;
|
|
|
+ }
|
|
|
}
|