forked from rongchao/epmet-cloud-rizhao
Browse Source
# Conflicts: # epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java # epmet-user/epmet-user-client/src/main/java/com/epmet/feign/EpmetUserOpenFeignClient.javadev
61 changed files with 3012 additions and 67 deletions
@ -0,0 +1,133 @@ |
|||
package com.epmet.commons.tools.redis.common.bean; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/10/19 14:26 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class CustomerStaffInfoDTOCache implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 6967736754443092229L; |
|||
|
|||
|
|||
/** |
|||
* ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 关联User表的主键Id |
|||
*/ |
|||
private String userId; |
|||
|
|||
/** |
|||
* 账户 |
|||
*/ |
|||
private String userAccount; |
|||
|
|||
/** |
|||
* 真实姓名 |
|||
*/ |
|||
private String realName; |
|||
|
|||
/** |
|||
* 性别0.未知,1男,2.女 |
|||
*/ |
|||
private Integer gender; |
|||
|
|||
/** |
|||
* 邮箱 |
|||
*/ |
|||
private String email; |
|||
|
|||
/** |
|||
* 手机号-唯一键 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
/** |
|||
* 地址 |
|||
*/ |
|||
private String address; |
|||
|
|||
/** |
|||
* 删除标识 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* fulltime专职parttime兼职 |
|||
*/ |
|||
private String workType; |
|||
|
|||
/** |
|||
* 头像 |
|||
*/ |
|||
private String headPhoto; |
|||
|
|||
/** |
|||
* inactive未激活,active已激活 |
|||
*/ |
|||
private String activeFlag; |
|||
|
|||
/** |
|||
* 激活时间 |
|||
*/ |
|||
private Date activeTime; |
|||
|
|||
/** |
|||
* 未禁用enable,已禁用diabled |
|||
*/ |
|||
private String enableFlag; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 角色名称 |
|||
*/ |
|||
private String roleName; |
|||
|
|||
/** |
|||
* 登录密码 |
|||
*/ |
|||
private String password; |
|||
|
|||
/** |
|||
* 身份证号 |
|||
*/ |
|||
private String idCard; |
|||
} |
@ -0,0 +1,79 @@ |
|||
|
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* desc:组织机构数据 实体类 |
|||
* @author liujianjun |
|||
*/ |
|||
@Data |
|||
public class OrgData implements Serializable { |
|||
|
|||
/** |
|||
* 联系人姓名 |
|||
*/ |
|||
private String contact; |
|||
/** |
|||
* 联系电话号码 |
|||
*/ |
|||
private String contactTelephoneNumber; |
|||
|
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String detailAddress; |
|||
|
|||
/** |
|||
* 组织机构第一名称 |
|||
*/ |
|||
private String firstNameOfOrganization; |
|||
|
|||
/** |
|||
* 组织机构全称 |
|||
*/ |
|||
private String nameOfOrganization; |
|||
|
|||
/** |
|||
* 排序号码 |
|||
*/ |
|||
private String orderNumber; |
|||
|
|||
/** |
|||
* 组织机构简称 |
|||
*/ |
|||
private String organizatioNabbreviation; |
|||
|
|||
/** |
|||
* 组织机构ID |
|||
*/ |
|||
private String organizationId; |
|||
|
|||
/** |
|||
* 组织机构级别 |
|||
*/ |
|||
private String organizationLevel; |
|||
|
|||
/** |
|||
* 组织机构路径 |
|||
*/ |
|||
private String organizationPath; |
|||
|
|||
/** |
|||
* 组织机构类型 |
|||
*/ |
|||
private String organizationType; |
|||
/** |
|||
* 注册类型 |
|||
*/ |
|||
private String registrationType; |
|||
/** |
|||
* 统一社会信用代码 |
|||
*/ |
|||
private String unifiedSocialCreditId; |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,199 @@ |
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.apache.commons.codec.binary.Base64; |
|||
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
|||
|
|||
import javax.crypto.BadPaddingException; |
|||
import javax.crypto.Cipher; |
|||
import javax.crypto.IllegalBlockSizeException; |
|||
import javax.crypto.SecretKey; |
|||
import javax.crypto.spec.SecretKeySpec; |
|||
import java.nio.charset.Charset; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.security.InvalidKeyException; |
|||
import java.security.Security; |
|||
|
|||
/** |
|||
* 烟台的认证中心-国密sm4加解密 |
|||
*/ |
|||
public class SM4UtilsForYanTai { |
|||
private static String SM4_KEY = "yaweisoftware@xy"; |
|||
//编码格式
|
|||
private static final Charset encryptCharset = StandardCharsets.UTF_8; |
|||
|
|||
public enum Algorithm { |
|||
SM4("SM4","SM4","国密四,key长16byte"); |
|||
private String keyAlgorithm; |
|||
private String transformation; |
|||
private String description;//描述
|
|||
Algorithm(String keyAlgorithm, String transformation, String description) { |
|||
this.keyAlgorithm = keyAlgorithm; |
|||
this.transformation = transformation; |
|||
this.description = description; |
|||
} |
|||
public String getKeyAlgorithm() { |
|||
return this.keyAlgorithm; |
|||
} |
|||
public String getTransformation() { |
|||
return this.transformation; |
|||
} |
|||
public String getDescription() { |
|||
return this.description; |
|||
} |
|||
} |
|||
|
|||
private static final String PROVIDER_NAME = "BC"; |
|||
static { |
|||
Security.addProvider(new BouncyCastleProvider()); |
|||
} |
|||
|
|||
/** |
|||
* 自定字符串产生密钥 |
|||
* @param algorithm 加解密算法 |
|||
* @param keyStr 密钥字符串 |
|||
* @param charset 编码字符集 |
|||
* @return 密钥 |
|||
*/ |
|||
public static SecretKey genKeyByStr(Algorithm algorithm, String keyStr, Charset charset) { |
|||
return readKeyFromBytes(algorithm, keyStr.getBytes(charset)); |
|||
} |
|||
|
|||
/** |
|||
* 根据指定字节数组产生密钥 |
|||
* @param algorithm 加解密算法 |
|||
* @param keyBytes 密钥字节数组 |
|||
* @return 密钥 |
|||
*/ |
|||
public static SecretKey readKeyFromBytes(Algorithm algorithm, byte[] keyBytes) { |
|||
return new SecretKeySpec(keyBytes, algorithm.getKeyAlgorithm()); |
|||
} |
|||
|
|||
/****************************加密*********************************/ |
|||
/** |
|||
* 加密字符串,并进行base64编码 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 明文 |
|||
* @param charset 编码字符集 |
|||
* @return 密文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
*/ |
|||
public static String encryptBase64(Algorithm algorithm, SecretKey key, String data, Charset charset) throws InvalidKeyException { |
|||
return Base64.encodeBase64String(encrypt(algorithm, key, data.getBytes(charset))); |
|||
} |
|||
|
|||
/** |
|||
* 加密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 明文 |
|||
* @return 密文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
*/ |
|||
public static byte[] encrypt(Algorithm algorithm, SecretKey key, byte[] data) throws InvalidKeyException { |
|||
try { |
|||
return cipherDoFinal(algorithm, Cipher.ENCRYPT_MODE, key, data); |
|||
} catch (BadPaddingException e) { |
|||
throw new RuntimeException(e);//明文没有具体格式要求,不会出错。所以这个异常不需要外部捕获。
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 加解密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param opmode 操作:1加密,2解密 |
|||
* @param key 密钥 |
|||
* @param data 数据 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 解密密文错误(加密模式没有) |
|||
*/ |
|||
private static byte[] cipherDoFinal(Algorithm algorithm, int opmode, SecretKey key, byte[] data) throws InvalidKeyException, BadPaddingException { |
|||
Cipher cipher; |
|||
try { |
|||
cipher = Cipher.getInstance(algorithm.getTransformation(), PROVIDER_NAME); |
|||
} catch (Exception e) { |
|||
//NoSuchAlgorithmException:加密算法名是本工具类提供的,如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
//NoSuchProviderException:Provider是本工具类提供的,如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
//NoSuchPaddingException:没有特定的填充机制,与环境有关,业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
throw new RuntimeException(e); |
|||
} |
|||
cipher.init(opmode, key); |
|||
try { |
|||
return cipher.doFinal(data); |
|||
} catch (IllegalBlockSizeException e) { |
|||
throw new RuntimeException(e);//业务不需要将数据分块(好像由底层处理了),如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
} |
|||
} |
|||
|
|||
/****************************解密*********************************/ |
|||
/** |
|||
* 对字符串先进行base64解码,再解密 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 密文 |
|||
* @param charset 编码字符集 |
|||
* @return 明文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 密文错误 |
|||
*/ |
|||
public static String decryptBase64(Algorithm algorithm, SecretKey key, String data, Charset charset) |
|||
throws InvalidKeyException, BadPaddingException { |
|||
return new String(decrypt(algorithm, key, Base64.decodeBase64(data)), charset); |
|||
} |
|||
|
|||
/** |
|||
* 解密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 密文 |
|||
* @return 明文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 密文错误 |
|||
*/ |
|||
public static byte[] decrypt(Algorithm algorithm, SecretKey key, byte[] data) throws InvalidKeyException, BadPaddingException { |
|||
return cipherDoFinal(algorithm, Cipher.DECRYPT_MODE, key, data); |
|||
} |
|||
|
|||
public static String Encrypt(String data) throws InvalidKeyException { |
|||
SecretKey key = genKeyByStr(Algorithm.SM4, SM4_KEY, encryptCharset); |
|||
return encryptBase64(Algorithm.SM4, key, data, encryptCharset); |
|||
} |
|||
public static String Decrypt(String data) throws BadPaddingException, InvalidKeyException { |
|||
SecretKey key = genKeyByStr(Algorithm.SM4, SM4_KEY, encryptCharset); |
|||
return decryptBase64(Algorithm.SM4, key, data, encryptCharset); |
|||
} |
|||
//加密
|
|||
public static String dealEncryptData(Object data) throws JsonProcessingException, InvalidKeyException { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
String dataString = ""; |
|||
try { |
|||
if(data instanceof String){ |
|||
dataString = (String) data; |
|||
}else { |
|||
dataString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(data); |
|||
} |
|||
String dataEncrypt = Encrypt(dataString); |
|||
return dataEncrypt; |
|||
}catch (Exception e){ |
|||
return dataString; |
|||
} |
|||
} |
|||
//解密
|
|||
public static String dealDecryptData(Object data) throws JsonProcessingException, BadPaddingException, InvalidKeyException { |
|||
String dataString = ""; |
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
if (data instanceof String) { |
|||
dataString = (String) data; |
|||
} else { |
|||
dataString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(data); |
|||
} |
|||
String dataDecrypt = Decrypt(dataString); |
|||
return dataDecrypt; |
|||
}catch (Exception e){ |
|||
return dataString; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,184 @@ |
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
|
|||
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
|||
import org.bouncycastle.pqc.math.linearalgebra.ByteUtils; |
|||
|
|||
import javax.crypto.Cipher; |
|||
import javax.crypto.KeyGenerator; |
|||
import javax.crypto.spec.SecretKeySpec; |
|||
import java.security.*; |
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* sm4加密算法工具类 |
|||
* |
|||
* @explain sm4加密、解密与加密结果验证 可逆算法 |
|||
* @Autor:jingyao |
|||
*/ |
|||
public class TestMs4 { |
|||
static { |
|||
Security.addProvider(new BouncyCastleProvider()); |
|||
} |
|||
|
|||
private static final String ENCODING = "UTF-8"; |
|||
public static final String ALGORITHM_NAME = "SM4"; |
|||
// 加密算法/分组加密模式/分组填充方式
|
|||
// PKCS5Padding-以8个字节为一组进行分组加密
|
|||
// 定义分组加密模式使用:PKCS5Padding
|
|||
public static final String ALGORITHM_NAME_ECB_PADDING = "SM4/ECB/PKCS5Padding"; |
|||
// 128-32位16进制;256-64位16进制
|
|||
public static final int DEFAULT_KEY_SIZE = 128; |
|||
|
|||
/** |
|||
* 生成ECB暗号 |
|||
* |
|||
* @param algorithmName 算法名称 |
|||
* @param mode 模式 |
|||
* @param key |
|||
* @return |
|||
* @throws Exception |
|||
* @explain ECB模式(电子密码本模式:Electronic codebook) |
|||
*/ |
|||
private static Cipher generateEcbCipher(String algorithmName, int mode, byte[] key) throws Exception { |
|||
Cipher cipher = Cipher.getInstance(algorithmName, BouncyCastleProvider.PROVIDER_NAME); |
|||
Key sm4Key = new SecretKeySpec(key, ALGORITHM_NAME); |
|||
cipher.init(mode, sm4Key); |
|||
return cipher; |
|||
} |
|||
|
|||
/** |
|||
* 自动生成密钥 |
|||
* |
|||
* @return |
|||
* @throws NoSuchAlgorithmException |
|||
* @throws NoSuchProviderException |
|||
* @explain |
|||
*/ |
|||
public static byte[] generateKey() throws Exception { |
|||
return generateKey(DEFAULT_KEY_SIZE); |
|||
} |
|||
|
|||
|
|||
//加密******************************************
|
|||
|
|||
/** |
|||
* @param keySize |
|||
* @return |
|||
* @throws Exception |
|||
* @explain 系统产生秘钥 |
|||
*/ |
|||
public static byte[] generateKey(int keySize) throws Exception { |
|||
KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM_NAME, BouncyCastleProvider.PROVIDER_NAME); |
|||
kg.init(keySize, new SecureRandom()); |
|||
return kg.generateKey().getEncoded(); |
|||
} |
|||
|
|||
/** |
|||
* sm4加密 |
|||
* |
|||
* @param hexKey 16进制密钥(忽略大小写) |
|||
* @param paramStr 待加密字符串 |
|||
* @return 返回16进制的加密字符串 |
|||
* @throws Exception |
|||
* @explain 加密模式:ECB 密文长度不固定,会随着被加密字符串长度的变化而变化 |
|||
*/ |
|||
public static String encryptEcb(String hexKey, String paramStr) throws Exception { |
|||
String cipherText = ""; |
|||
// 16进制字符串-->byte[]
|
|||
byte[] keyData = ByteUtils.fromHexString(hexKey); |
|||
// String-->byte[]
|
|||
byte[] srcData = paramStr.getBytes(ENCODING); |
|||
// 加密后的数组
|
|||
byte[] cipherArray = encrypt_Ecb_Padding(keyData, srcData); |
|||
// byte[]-->hexString
|
|||
cipherText = ByteUtils.toHexString(cipherArray); |
|||
return cipherText; |
|||
} |
|||
|
|||
/** |
|||
* 加密模式之Ecb |
|||
* |
|||
* @param key |
|||
* @param data |
|||
* @return |
|||
* @throws Exception |
|||
*/ |
|||
public static byte[] encrypt_Ecb_Padding(byte[] key, byte[] data) throws Exception { |
|||
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.ENCRYPT_MODE, key);//声称Ecb暗号,通过第二个参数判断加密还是解密
|
|||
return cipher.doFinal(data); |
|||
} |
|||
|
|||
//解密****************************************
|
|||
|
|||
/** |
|||
* sm4解密 |
|||
* |
|||
* @param hexKey 16进制密钥 |
|||
* @param cipherText 16进制的加密字符串(忽略大小写) |
|||
* @return 解密后的字符串 |
|||
* @throws Exception |
|||
* @explain 解密模式:采用ECB |
|||
*/ |
|||
public static String decryptEcb(String hexKey, String cipherText) throws Exception { |
|||
// 用于接收解密后的字符串
|
|||
String decryptStr = ""; |
|||
// hexString-->byte[]
|
|||
byte[] keyData = ByteUtils.fromHexString(hexKey); |
|||
// hexString-->byte[]
|
|||
byte[] cipherData = ByteUtils.fromHexString(cipherText); |
|||
// 解密
|
|||
byte[] srcData = decrypt_Ecb_Padding(keyData, cipherData); |
|||
// byte[]-->String
|
|||
decryptStr = new String(srcData, ENCODING); |
|||
return decryptStr; |
|||
} |
|||
|
|||
/** |
|||
* 解密 |
|||
* |
|||
* @param key |
|||
* @param cipherText |
|||
* @return |
|||
* @throws Exception |
|||
* @explain |
|||
*/ |
|||
public static byte[] decrypt_Ecb_Padding(byte[] key, byte[] cipherText) throws Exception { |
|||
Cipher cipher = generateEcbCipher(ALGORITHM_NAME_ECB_PADDING, Cipher.DECRYPT_MODE, key);//生成Ecb暗号,通过第二个参数判断加密还是解密
|
|||
return cipher.doFinal(cipherText); |
|||
} |
|||
|
|||
/** |
|||
* 校验加密前后的字符串是否为同一数据 |
|||
* |
|||
* @param hexKey 16进制密钥(忽略大小写) |
|||
* @param cipherText 16进制加密后的字符串 |
|||
* @param paramStr 加密前的字符串 |
|||
* @return 是否为同一数据 |
|||
* @throws Exception |
|||
* @explain |
|||
*/ |
|||
public static boolean verifyEcb(String hexKey, String cipherText, String paramStr) throws Exception { |
|||
// 用于接收校验结果
|
|||
boolean flag = false; |
|||
// hexString-->byte[]
|
|||
byte[] keyData = ByteUtils.fromHexString(hexKey); |
|||
// 将16进制字符串转换成数组
|
|||
byte[] cipherData = ByteUtils.fromHexString(cipherText); |
|||
// 解密
|
|||
byte[] decryptData = decrypt_Ecb_Padding(keyData, cipherData); |
|||
// 将原字符串转换成byte[]
|
|||
byte[] srcData = paramStr.getBytes(ENCODING); |
|||
// 判断2个数组是否一致
|
|||
flag = Arrays.equals(decryptData, srcData); |
|||
return flag; |
|||
} |
|||
|
|||
public static void main(String[] args) throws Exception { |
|||
String text = "5d22ea44c7599a48f0d4446b1b7fbb4bb8353922df437d39c3a38549c0f2549cbd021ada00a8be83027ae06203c3daea2eedc5bd0875c7e509c7049045c5349577f2c21bcec328a5ea0bf341191e5bdba978566dddd16f1cf1928ff5cbd826dd33289fb45a8a04585f1f24ab04f59426371a5a0a0f2ee3e7b00d2bdfba7810524ce4c33130eda077546fa4c4191d0117f7a44e1cadac6c69a7d437653be1f958a459e0f025d471e09ab4636c38013032948ffb0827040ed6f3436be090f545186928a7b0b2bfc65782452606607ce8555ba130caacad73998da704428a07276a2699889c9872eebba5de8b72cdbe88705483293b00ab3ecb3aa57d283a4ecab40b71bc0a10e9ec626f07b2293255349fb2270d37e81c5c3d0de0b0f0706ed1872f60f039ce2e51effc39aef9747d67457e072cf3170a9c19589c1bab1a7d9d80"; |
|||
String s = TestMs4.decryptEcb("dbcff4c9f4774e6cb56080f279149d59", text); |
|||
System.out.println(s); |
|||
} |
|||
|
|||
} |
|||
|
@ -0,0 +1,50 @@ |
|||
|
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* desc:认证中心-用户信息 |
|||
* @author liujianjun |
|||
*/ |
|||
@Data |
|||
public class UserData implements Serializable { |
|||
|
|||
/** |
|||
* 性别:todo 不知道是什么值 |
|||
*/ |
|||
private String gender; |
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
private String mobileTelephoneNumber; |
|||
private String orderNumber; |
|||
/** |
|||
* 职务 |
|||
*/ |
|||
private String position; |
|||
/** |
|||
* 职级 |
|||
*/ |
|||
private String positionLevel; |
|||
/** |
|||
* 电话号码 |
|||
*/ |
|||
private String telephoneNumber; |
|||
/** |
|||
* 用户编码/id |
|||
*/ |
|||
private String userGuid; |
|||
/** |
|||
* 用户姓名 |
|||
*/ |
|||
private String userName; |
|||
/** |
|||
* 人员路径 |
|||
*/ |
|||
private String userPath; |
|||
|
|||
|
|||
} |
@ -0,0 +1,282 @@ |
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|||
import com.epmet.commons.tools.exception.EpmetException; |
|||
import com.epmet.commons.tools.utils.HttpClientManager; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.jetbrains.annotations.NotNull; |
|||
|
|||
import javax.crypto.BadPaddingException; |
|||
import java.security.InvalidKeyException; |
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* desc: |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2022/10/17 3:57 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
@Slf4j |
|||
public class YantaiApi { |
|||
private static final String SSO_SERVER = "http://172.20.46.155:8080/sso/"; |
|||
/** |
|||
* 相当于 appKey |
|||
*/ |
|||
private static final String CLIENT_ID = "1000009"; |
|||
/** |
|||
* 相当于 appSecret 用于解密 他们重定向回来的code 解密他们的token 获取用户嘻嘻 |
|||
*/ |
|||
private static final String CLIENT_SECRET = "a1f9879119bc4080ab5575f832b7d98b"; |
|||
/** |
|||
* 调用sso后台api接口的 秘钥 |
|||
*/ |
|||
private static final String SSO_API_TOKEN = "iJCDUgCBV/Zk5FkkaxLypA=="; |
|||
/** |
|||
* 政务网地址 |
|||
*/ |
|||
private static final String SSO_BACKGROUND_SERVER_URL = "http://172.20.46.155:8082/"; |
|||
/** |
|||
* 互联网地址 |
|||
*/ |
|||
//private static final String SSO_BACKGROUND_SERVER_URL = "http://120.220.248.247:8081/";
|
|||
|
|||
/** |
|||
* desc:根据组织id获取下级组织 |
|||
* |
|||
* @param organizationId |
|||
* @return |
|||
*/ |
|||
public static List<OrgData> getChildOuInfoByGuid(String organizationId) { |
|||
try { |
|||
if (StringUtils.isBlank(organizationId)) { |
|||
throw new EpmetException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|||
} |
|||
//加密
|
|||
String organizationIdEn = SM4UtilsForYanTai.dealEncryptData(organizationId); |
|||
//pwd = URLEncoder.encode(pwd, "UTF-8");
|
|||
String url = SSO_BACKGROUND_SERVER_URL + "person/ouinfo/getChildOuInfoByGuid"; |
|||
|
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
paramMap.put("organizationId",organizationIdEn); |
|||
|
|||
log.info("getChildOuInfoByGuid request param:{} url:{}",paramMap, url); |
|||
Result<String> result = HttpClientManager.getInstance().sendGet(url, paramMap, getApiHeaderMap()); |
|||
log.info("getChildOuInfoByGuid request result:{}", result); |
|||
if (!result.success()){ |
|||
return new ArrayList<>(); |
|||
} |
|||
JSONObject jsonObject = JSONObject.parseObject(result.getData()); |
|||
String secondCode = jsonObject.getString("code"); |
|||
String secondMessage = jsonObject.getString("message"); |
|||
if (!"200".equals(secondCode)) { |
|||
log.warn("getChildOuInfoByGuid 接口错误"); |
|||
return new ArrayList<>(); |
|||
} |
|||
//解密
|
|||
String data = SM4UtilsForYanTai.dealDecryptData(jsonObject.getString("data")); |
|||
List<OrgData> orgData = JSON.parseArray(data, OrgData.class); |
|||
log.info("getChildOuInfoByGuid request real result:{}", JSON.toJSONString(orgData)); |
|||
return orgData; |
|||
} catch (Exception e) { |
|||
log.error("getChildOuInfoByGuid exception", e); |
|||
} |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
/** |
|||
* desc:根据组织id获取下级组织 |
|||
* |
|||
* @param organizationId |
|||
* @return |
|||
*/ |
|||
public static List<UserData> getUserByOuGuid(String organizationId) { |
|||
try { |
|||
if (StringUtils.isBlank(organizationId)) { |
|||
throw new EpmetException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|||
} |
|||
//加密
|
|||
String organizationIdEn = SM4UtilsForYanTai.dealEncryptData(organizationId); |
|||
//pwd = URLEncoder.encode(pwd, "UTF-8");
|
|||
String url = SSO_BACKGROUND_SERVER_URL + "person/userInfo/getUserByOuGuid"; |
|||
|
|||
|
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
paramMap.put("organizationId",organizationIdEn); |
|||
log.info("getUserByOuGuid request param: url:{},param:{}", url, paramMap); |
|||
Result<String> result = HttpClientManager.getInstance().sendGet(url, paramMap, getApiHeaderMap()); |
|||
log.info("getUserByOuGuid request result:{}", result); |
|||
if (!result.success()){ |
|||
return new ArrayList<>(); |
|||
} |
|||
JSONObject jsonObject = JSONObject.parseObject(result.getData()); |
|||
String secondCode = jsonObject.getString("code"); |
|||
String secondMessage = jsonObject.getString("message"); |
|||
if (!"200".equals(secondCode)) { |
|||
log.warn("getUserByOuGuid 接口错误"); |
|||
return new ArrayList<>(); |
|||
} |
|||
//解密
|
|||
String data = SM4UtilsForYanTai.dealDecryptData(jsonObject.getString("data")); |
|||
List<UserData> userData = JSON.parseArray(data, UserData.class); |
|||
log.info("getUserByOuGuid request real result:{}", JSON.toJSONString(userData)); |
|||
return userData; |
|||
} catch (Exception e) { |
|||
log.error("getUserByOuGuid exception", e); |
|||
} |
|||
return new ArrayList<>(); |
|||
} |
|||
|
|||
/** |
|||
* desc:根据组织id获取下级组织 |
|||
* |
|||
* @param code |
|||
* @return |
|||
*/ |
|||
public static YantaiSSOUser getLoginToken(String code) { |
|||
try { |
|||
if (StringUtils.isBlank(code)) { |
|||
throw new EpmetException(EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getCode(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg(), EpmetErrorCode.INTERNAL_VALIDATE_ERROR.getMsg()); |
|||
} |
|||
//加密
|
|||
String organizationIdEn = SM4UtilsForYanTai.dealEncryptData(code); |
|||
//pwd = URLEncoder.encode(pwd, "UTF-8");
|
|||
log.info("getLoginToken加密组织Id = " + organizationIdEn); |
|||
String url = SSO_SERVER + "logintoken?client_id=" + CLIENT_ID + "&client_code=" + code; |
|||
|
|||
Map<String, Object> headerMap = new HashMap<>(); |
|||
Map<String, Object> paramMap = new HashMap<>(); |
|||
log.info("getUserByOuGuid request param: url:{},header:{}", url, headerMap); |
|||
Result<String> result = HttpClientManager.getInstance().sendGet(url, paramMap, headerMap); |
|||
if (!result.success() || StringUtils.isBlank(result.getData())) { |
|||
log.info("getUserByOuGuid fail result:{}", JSON.toJSONString(result)); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取token为空", "获取token为空"); |
|||
} |
|||
log.info("getUserByOuGuid request result:{}", result); |
|||
JSONObject jsonObject = JSONObject.parseObject(result.getData()); |
|||
//解密
|
|||
String errcode = jsonObject.getString("errcode"); |
|||
if (!NumConstant.ZERO_STR.equals(errcode)) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取token失败", "获取token失败"); |
|||
} |
|||
String sencondData = jsonObject.getString("data"); |
|||
log.info("getLoginToken jiami data:{}", sencondData); |
|||
//String data = SM4UtilsForYanTai.dealDecryptData(sencondData);
|
|||
|
|||
|
|||
String data = TestMs4.decryptEcb(CLIENT_SECRET, sencondData); |
|||
log.info("getLoginToken jiemi data:{}", sencondData); |
|||
YantaiSSOUser userData = JSON.parseObject(data, YantaiSSOUser.class); |
|||
log.info("getUserByOuGuid request real result:{}", JSON.toJSONString(userData)); |
|||
String userInfoMobile = getUserInfoMobile(userData.getUserGuid()); |
|||
userData.setMobile(userInfoMobile); |
|||
return userData; |
|||
} catch (Exception e) { |
|||
log.error("getUserByOuGuid exception", e); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static String getUserInfoMobile(String userId) { |
|||
try { |
|||
|
|||
String userIdEn = SM4UtilsForYanTai.dealEncryptData(userId); |
|||
|
|||
String serverUrl = SSO_BACKGROUND_SERVER_URL + "person/userInfo/getUserByUserGuid"; |
|||
//String serverUrl = "http://120.220.248.247:8081/person/userInfo/getUserByUserGuid";
|
|||
Map<String, Object> param = new HashMap<>(); |
|||
param.put("userGuid", userIdEn); |
|||
|
|||
Result<String> result = HttpClientManager.getInstance().sendGet(serverUrl, param, getApiHeaderMap()); |
|||
System.out.println(JSON.toJSONString(result)); |
|||
if (!result.success() || StringUtils.isBlank(result.getData())) { |
|||
log.info("getUserInfoMobile fail result:{}", JSON.toJSONString(result)); |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取用户信息失败", "获取用户信息失败"); |
|||
} |
|||
String data = result.getData(); |
|||
log.info("getUserInfoMobile jiami data:{}", JSON.parseObject(data)); |
|||
JSONObject jsonObject = JSON.parseObject(data); |
|||
String secondCode = jsonObject.getString("code"); |
|||
String secondMessage = jsonObject.getString("message"); |
|||
if (!"200".equals(secondCode)) { |
|||
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取人员信息接口返回失败" + secondMessage, "获取人员信息接口返回失败" + secondMessage); |
|||
} |
|||
String data1 = SM4UtilsForYanTai.dealDecryptData(jsonObject.getString("data")); |
|||
String telephoneNumber = JSON.parseObject(data1).getString("mobileTelephoneNumber"); |
|||
log.info("getUserInfoMobile jiemi data:{}", telephoneNumber); |
|||
return telephoneNumber; |
|||
} catch (Exception e) { |
|||
log.error("getUserInfoMobile exception", e); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@NotNull |
|||
private static Map<String, Object> getApiHeaderMap() { |
|||
Map<String, Object> headerMap = new HashMap<>(); |
|||
try { |
|||
JSONObject token = new JSONObject(); |
|||
token.put("token", SSO_API_TOKEN); |
|||
// token.put("token","iJCDUgCBV/Zk5FkkaxLypA==");
|
|||
token.put("expiration", System.currentTimeMillis()); |
|||
|
|||
String tokanStr = SM4UtilsForYanTai.dealEncryptData(token.toString()); |
|||
headerMap.put("Authorization", "Bearer " + tokanStr); |
|||
} catch (Exception e) { |
|||
log.error("getApiHeaderMap exception", e); |
|||
} |
|||
return headerMap; |
|||
} |
|||
|
|||
public static void main(String[] args) throws BadPaddingException, InvalidKeyException, JsonProcessingException { |
|||
|
|||
//testGetUserByUserId();
|
|||
|
|||
//code只能用一次
|
|||
//getLoginToken("0d554bccfbac4be3846d643252daf92b");
|
|||
|
|||
String organizationId = "44e05de9-34fa-48f6-b89f-02838d792cf9"; |
|||
List<OrgData> childOuInfoByGuid = getChildOuInfoByGuid(organizationId); |
|||
System.out.println("childOuInfoByGuid:"+JSON.toJSONString(childOuInfoByGuid)); |
|||
//先用他说的有人的组织id联调
|
|||
//String orgId = "2b271845-ed51-48aa-9935-00b9e7e06311";
|
|||
//orgId = "2b271845-ed51-48aa-9935-00b9e7e05778";
|
|||
List<UserData> userByOuGuid = getUserByOuGuid(organizationId); |
|||
System.out.println("getUserByOuGuid:"+JSON.toJSONString(userByOuGuid)); |
|||
|
|||
Map<String, Object> apiHeaderMap = getApiHeaderMap(); |
|||
System.out.println(apiHeaderMap); |
|||
//testGetUserByUserId();
|
|||
} |
|||
|
|||
private static void testGetUserByUserId() throws JsonProcessingException, InvalidKeyException, BadPaddingException { |
|||
String testUserId = "0ffd76e2-27b5-4b33-be9a-186f9f878bf1"; |
|||
|
|||
String serverUrl = SSO_BACKGROUND_SERVER_URL +"person/userInfo/getUserByUserGuid"; |
|||
//String serverUrl = "http://120.220.248.247:8081/person/userInfo/getUserByUserGuid";
|
|||
Map<String, Object> param = new HashMap<>(); |
|||
param.put("userGuid", SM4UtilsForYanTai.dealEncryptData(testUserId)); |
|||
Result<String> stringResult = HttpClientManager.getInstance().sendGet(serverUrl, param, getApiHeaderMap()); |
|||
System.out.println(JSON.toJSONString(stringResult)); |
|||
|
|||
String data = stringResult.getData(); |
|||
JSONObject jsonObject = JSON.parseObject(data); |
|||
String secondCode = jsonObject.getString("code"); |
|||
String secondMessage = jsonObject.getString("message"); |
|||
System.out.println(secondCode); |
|||
System.out.println(secondMessage); |
|||
String data1 = SM4UtilsForYanTai.dealDecryptData(jsonObject.getString("data")); |
|||
System.out.println("======" + data1); |
|||
String s = SM4UtilsForYanTai.dealDecryptData("EsOeQX+A8+GG26lzLnuKeuylkBDRFcTbF+gE/jURIzddlVI8RToQQhzK4EHy0WfpS/L4dSAJC93UyVLJhj+r/pup2RFq/GjpH7Md+1Mjg3dM+eyDuGql71bUrldQwJXYnHrQm3Mn7tk5m2eLhEVNkFvdELjuy3Kg8YihZXf2Sox+kxtmK4DSIn/gxhVCoUneWeL0cA6JGHI6jNuq97rzgcNK3Mwen8MxOoWP3n3r+kIpwZCwIlL70MrBjIZ6FHIhcxpqL82gpLSe1K0TFgeWw+9PMo1yv4cGZn7rU86TDlQFoDP86dVa1jrBoyUmW/vvLXrMKwfBaiv9/EUzcCLZWYxEwH93n0X/NYCYem3pfv4uXk5A7/D+Npgj9OKCEIz0ROn0UW5NiXI5Vibz0dywaq4sfsR/LiwjV81QOGY9tsHzN2+MnyTVpQg1l7looNnq1j+wwLneS0aDmbTqBLEn/baph/Hnr2L/9HYpWfXkhz93XRNAdsbxhXdG5ZIiJSwNasHinPR3e2Hmn/02GOsBPFUifbyNUtslt4RS/gwboonBoXz8wrmXi+PfzUXwN8f2CKdBNEHl72USp70NtBSJUPAkHdXZEQPgGRped63Z9GA="); |
|||
System.out.println("sssssss:" + s); |
|||
} |
|||
} |
@ -0,0 +1,35 @@ |
|||
|
|||
package com.epmet.commons.tools.utils.api.yt; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* sso:认证中心 用户信息 |
|||
* @author liujianjun |
|||
*/ |
|||
@Data |
|||
public class YantaiSSOUser implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -2794280342919451106L; |
|||
|
|||
/** |
|||
* 他说这个是手机号 |
|||
*/ |
|||
private String clientId; |
|||
private String departmentCode; |
|||
private String expirationTime; |
|||
private String ip; |
|||
private String issueTime; |
|||
private String registerGuid; |
|||
private String registerName; |
|||
private String userGuid; |
|||
private String userName; |
|||
|
|||
/** |
|||
* 二次请求结果 |
|||
*/ |
|||
private String mobile; |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.task; |
|||
|
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.feign.ThirdOpenFeignClient; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author zxc |
|||
* @dscription 拉取yt用户信息和组织信息 |
|||
*/ |
|||
@Slf4j |
|||
@Component("YTUserAndOrgPullTask") |
|||
public class YTUserAndOrgPullTask implements ITask { |
|||
|
|||
@Autowired |
|||
private ThirdOpenFeignClient thirdOpenFeignClient; |
|||
|
|||
@Override |
|||
public void run(String params) { |
|||
Result<Boolean> yanTaiOrgInfo = thirdOpenFeignClient.getYanTaiOrgInfo("44e05de9-34fa-48f6-b89f-02838d792cf9"); |
|||
if (yanTaiOrgInfo.success()) { |
|||
log.info("yt拉取组织信息定时任务执行成功"); |
|||
} else { |
|||
log.error("yt拉取组织信息定时任务执行失败:" + yanTaiOrgInfo.getMsg()); |
|||
} |
|||
|
|||
Result<Boolean> yanTaiUserInfo = thirdOpenFeignClient.getYanTaiUserInfo("44e05de9-34fa-48f6-b89f-02838d792cf9"); |
|||
if (yanTaiUserInfo.success()) { |
|||
log.info("yt拉取用户信息定时任务执行成功"); |
|||
} else { |
|||
log.error("yt拉取用户信息定时任务执行失败:" + yanTaiUserInfo.getMsg()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,139 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Data |
|||
public class DataSyncOrgDataDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 联系人姓名 |
|||
*/ |
|||
private String contact; |
|||
|
|||
/** |
|||
* 联系电话号码 |
|||
*/ |
|||
private String contacttelephoneNumber; |
|||
|
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String detailAddress; |
|||
|
|||
/** |
|||
* 组织机构第一名称 |
|||
*/ |
|||
private String firstnameofOrganization; |
|||
|
|||
/** |
|||
* 组织机构全称 |
|||
*/ |
|||
private String nameofOrganization; |
|||
|
|||
/** |
|||
* 排序号码 |
|||
*/ |
|||
private String orderNumber; |
|||
|
|||
/** |
|||
* 组织机构简称 |
|||
*/ |
|||
private String organizatioNabbreviation; |
|||
|
|||
/** |
|||
* 组织机构ID |
|||
*/ |
|||
private String organizationId; |
|||
|
|||
/** |
|||
* 组织机构级别 |
|||
*/ |
|||
private String organizationLevel; |
|||
|
|||
/** |
|||
* 组织机构路径 |
|||
*/ |
|||
private String organizationPath; |
|||
|
|||
/** |
|||
* 组织机构类型 |
|||
*/ |
|||
private String organizationType; |
|||
|
|||
/** |
|||
* 注册类型 |
|||
*/ |
|||
private String registrationType; |
|||
|
|||
/** |
|||
* 统一社会信用代码 |
|||
*/ |
|||
private String unifiedsocialcreditId; |
|||
|
|||
/** |
|||
* 删除标识 0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 客户id;烟台id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级组织机构id:ORGANIZATION_ID; 根级组织赋值0 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 上级组织机构名称:ORGANIZATIO_NABBREVIATION |
|||
*/ |
|||
private String parentOrgName; |
|||
|
|||
/** |
|||
* 所有上级组织。不包含本身! |
|||
*/ |
|||
private String pids; |
|||
|
|||
} |
@ -0,0 +1,124 @@ |
|||
package com.epmet.dto; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
import lombok.Data; |
|||
|
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Data |
|||
public class DataSyncUserDataDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键ID |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 性别:0未知1男2女 |
|||
*/ |
|||
private String gender; |
|||
|
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
private String mobileTelephoneNumber; |
|||
|
|||
/** |
|||
* 排序号码 |
|||
*/ |
|||
private String orderNumber; |
|||
|
|||
/** |
|||
* 职务 |
|||
*/ |
|||
private String position; |
|||
|
|||
/** |
|||
* 职级 |
|||
*/ |
|||
private String positionLevel; |
|||
|
|||
/** |
|||
* 电话号码 |
|||
*/ |
|||
private String telephoneNumber; |
|||
|
|||
/** |
|||
* 统一用户编码 |
|||
*/ |
|||
private String userGuid; |
|||
|
|||
/** |
|||
* 用户姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 人员路径 |
|||
*/ |
|||
private String userPath; |
|||
|
|||
/** |
|||
* data_sync_org_data.组织机构ID; |
|||
*/ |
|||
private String organizationId; |
|||
|
|||
/** |
|||
* 删除标识 0.未删除 1.已删除 |
|||
*/ |
|||
private Integer delFlag; |
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 0未创建、1已创建 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* customer_staff.userId |
|||
*/ |
|||
private String staffId; |
|||
|
|||
/** |
|||
* 备注;目前为空 |
|||
*/ |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,36 @@ |
|||
package com.epmet.dto.form.yantai; |
|||
|
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
|
|||
/** |
|||
* @Description 工作端新增完用户后,需要调用此接口,更新data_sync_user_data |
|||
* @Author yzm |
|||
* @Date 2022/10/18 13:54 |
|||
*/ |
|||
@Data |
|||
public class YtSyncStaffIdFormDTO { |
|||
/** |
|||
* 客户ID |
|||
*/ |
|||
@NotBlank(message = "customerId不能为空",groups = AddGroup.class) |
|||
private String customerId; |
|||
/** |
|||
* 人员ID |
|||
*/ |
|||
@NotBlank(message = "staffId不能为空",groups = AddGroup.class) |
|||
private String staffId; |
|||
|
|||
@NotBlank(message = "name不能为空",groups = AddGroup.class) |
|||
private String name; |
|||
|
|||
@NotBlank(message = "mobile不能为空",groups = AddGroup.class) |
|||
private String mobile; |
|||
|
|||
@NotBlank(message = "当前操作人id不能为空",groups = AddGroup.class) |
|||
private String operUserId; |
|||
|
|||
} |
|||
|
@ -0,0 +1,36 @@ |
|||
package com.epmet.dto.form.yantai; |
|||
|
|||
import com.epmet.commons.tools.dto.form.PageFormDTO; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 运营端,统一认证 列表查询入参 |
|||
* @Author yzm |
|||
* @Date 2022/10/18 11:12 |
|||
*/ |
|||
@Data |
|||
public class YtUserPageFormDTO extends PageFormDTO { |
|||
/** |
|||
* 0本机 |
|||
* 1本级及下级 |
|||
*/ |
|||
private String type; |
|||
/** |
|||
* 组织id |
|||
* data_sync_org_data.ORGANIZATION_ID |
|||
*/ |
|||
private String orgId; |
|||
/** |
|||
* 姓名 |
|||
*/ |
|||
private String name; |
|||
/** |
|||
* 手机号 |
|||
*/ |
|||
private String mobile; |
|||
/** |
|||
* 0未创建、已创建 |
|||
*/ |
|||
private String status; |
|||
} |
|||
|
@ -0,0 +1,23 @@ |
|||
package com.epmet.dto.result.yantai; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @Description |
|||
* @Author yzm |
|||
* @Date 2022/10/18 14:21 |
|||
*/ |
|||
@Data |
|||
public class DataSyncOrgDataDTO implements Serializable { |
|||
private static final long serialVersionUID = -3011177998045994250L; |
|||
private String orgId; |
|||
private String orgName; |
|||
private String pid; |
|||
/** |
|||
* true代表有下级 |
|||
*/ |
|||
private Boolean haveChild; |
|||
} |
|||
|
@ -0,0 +1,56 @@ |
|||
package com.epmet.dto.result.yantai; |
|||
|
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Description 运营端,统一认证 列表返参 |
|||
* @Author yzm |
|||
* @Date 2022/10/18 11:53 |
|||
*/ |
|||
@Data |
|||
public class YtUserPageResDTO { |
|||
/** |
|||
* 统一用户编码 |
|||
*/ |
|||
private String userGuid; |
|||
/** |
|||
* data_sync_org_data.组织机构ID; |
|||
*/ |
|||
private String organizationId; |
|||
/** |
|||
* XXX-XXX |
|||
*/ |
|||
private String orgName; |
|||
/** |
|||
* 用户姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 电话号码 |
|||
*/ |
|||
private String telephoneNumber; |
|||
|
|||
/** |
|||
* 性别:0未知1男2女 |
|||
*/ |
|||
private String gender; |
|||
|
|||
/** |
|||
* 0未创建、已创建 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* customer_staff.userId |
|||
*/ |
|||
private String staffId; |
|||
|
|||
/** |
|||
* 备注;目前为空 |
|||
*/ |
|||
private String remark; |
|||
|
|||
private String customerId; |
|||
} |
|||
|
@ -0,0 +1,12 @@ |
|||
package com.epmet.constant; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/10/18 16:43 |
|||
* @DESC |
|||
*/ |
|||
public interface YanTaiConstant { |
|||
|
|||
String YT_CUSTOMER_ID = "1535072605621841922"; |
|||
|
|||
} |
@ -0,0 +1,84 @@ |
|||
package com.epmet.controller.yantai; |
|||
|
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.Result; |
|||
import com.epmet.commons.tools.validator.ValidatorUtils; |
|||
import com.epmet.commons.tools.validator.group.AddGroup; |
|||
import com.epmet.dto.form.yantai.YtSyncStaffIdFormDTO; |
|||
import com.epmet.dto.form.yantai.YtUserPageFormDTO; |
|||
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; |
|||
import com.epmet.dto.result.yantai.YtUserPageResDTO; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* desc: 从各个平台-同步用户和组织数据到本地 用于生成本系统账号 |
|||
* |
|||
* @author LiuJanJun |
|||
* @date 2022/10/17 3:41 下午 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("dataSync") |
|||
public class DataSyncUserAndOrgController { |
|||
|
|||
@Autowired |
|||
private DataSyncUserAndOrgService dataSyncUserAndOrgService; |
|||
|
|||
/** |
|||
* desc:从统一认证中心 拉取用户信息 |
|||
* @return |
|||
*/ |
|||
@PostMapping("yanTai/sync/user") |
|||
public Result<Boolean> getYanTaiUserInfo(@RequestParam("orgId")String orgId) { |
|||
Boolean flag = dataSyncUserAndOrgService.yanTaiSyncUser(orgId); |
|||
return new Result<Boolean>().ok(flag); |
|||
} |
|||
|
|||
/** |
|||
* desc:从统一认证中心 拉取组织信息 |
|||
* @return |
|||
*/ |
|||
@PostMapping("yanTai/sync/org") |
|||
public Result<Boolean> getYanTaiOrgInfo(@RequestParam("orgId")String orgId) { |
|||
Boolean extJson = dataSyncUserAndOrgService.yanTaiSyncOrg(orgId); |
|||
return new Result<Boolean>().ok(extJson); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 运营端,统一认证 列表查询 |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("page-user") |
|||
public Result<PageData<YtUserPageResDTO>> pageUser(@RequestBody YtUserPageFormDTO formDTO) { |
|||
return new Result<PageData<YtUserPageResDTO>>().ok(dataSyncUserAndOrgService.pageUser(formDTO)); |
|||
} |
|||
|
|||
/** |
|||
* 工作端新增完用户后,需要调用此接口,更新data_sync_user_data |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("update-staff") |
|||
public Result updateStaff(@RequestBody YtSyncStaffIdFormDTO formDTO) { |
|||
ValidatorUtils.validateEntity(formDTO, AddGroup.class); |
|||
dataSyncUserAndOrgService.updateStaff(formDTO.getCustomerId(),formDTO.getOperUserId(),formDTO.getStaffId(),formDTO.getName(),formDTO.getMobile()); |
|||
return new Result(); |
|||
} |
|||
|
|||
/** |
|||
* 运营端,统一认证 列表查询条件 那颗树 调用此接口 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@PostMapping("ytorglist") |
|||
public Result<List<DataSyncOrgDataDTO>> ytOrgList(@RequestBody YtUserPageFormDTO formDTO){ |
|||
List<DataSyncOrgDataDTO> list=dataSyncUserAndOrgService.ytOrgList(formDTO.getOrgId()); |
|||
return new Result<List<DataSyncOrgDataDTO>>().ok(list); |
|||
} |
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.epmet.controller.yantai; |
|||
|
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.form.yantai.YtUserPageFormDTO; |
|||
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; |
|||
import com.epmet.dto.result.yantai.YtUserPageResDTO; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author liujianjun |
|||
*/ |
|||
public interface DataSyncUserAndOrgService { |
|||
Boolean yanTaiSyncUser(String organizationId); |
|||
|
|||
Boolean yanTaiSyncOrg(String organizationId); |
|||
|
|||
/** |
|||
* 运营端-统一认证 |
|||
* 用户列表 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
PageData<YtUserPageResDTO> pageUser(YtUserPageFormDTO formDTO); |
|||
|
|||
/** |
|||
* 工作端新增完用户后,需要调用此接口,更新data_sync_user_data |
|||
* @param customerId |
|||
* @param staffId |
|||
* @param name |
|||
* @param mobile |
|||
*/ |
|||
int updateStaff(String customerId,String operUserId, String staffId, String name, String mobile); |
|||
|
|||
/** |
|||
* 根据组织id查询下级组织 |
|||
* @param pid |
|||
* @return |
|||
*/ |
|||
List<DataSyncOrgDataDTO> ytOrgList(String pid); |
|||
} |
@ -0,0 +1,180 @@ |
|||
package com.epmet.controller.yantai; |
|||
|
|||
import com.epmet.commons.tools.constant.NumConstant; |
|||
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|||
import com.epmet.commons.tools.redis.common.bean.CustomerStaffInfoDTOCache; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.utils.api.yt.OrgData; |
|||
import com.epmet.commons.tools.utils.api.yt.UserData; |
|||
import com.epmet.commons.tools.utils.api.yt.YantaiApi; |
|||
import com.epmet.dao.yantai.DataSyncOrgDataDao; |
|||
import com.epmet.dao.yantai.DataSyncUserDataDao; |
|||
import com.epmet.dto.CustomerStaffDTO; |
|||
import com.epmet.dto.form.yantai.YtUserPageFormDTO; |
|||
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; |
|||
import com.epmet.dto.result.yantai.YtUserPageResDTO; |
|||
import com.epmet.entity.yantai.DataSyncOrgDataEntity; |
|||
import com.epmet.entity.yantai.DataSyncUserDataEntity; |
|||
import com.epmet.feign.EpmetUserOpenFeignClient; |
|||
import com.epmet.service.DataSyncOrgDataService; |
|||
import com.epmet.service.DataSyncUserDataService; |
|||
import com.github.pagehelper.PageHelper; |
|||
import com.github.pagehelper.PageInfo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.collections4.CollectionUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
import static com.epmet.constant.YanTaiConstant.YT_CUSTOMER_ID; |
|||
|
|||
/** |
|||
* desc:烟台 从认证中心同步组织和用户信息 到本地 |
|||
* |
|||
* @author: LiuJanJun |
|||
* @date: 2022/10/17 3:42 下午 |
|||
* @version: 1.0 |
|||
*/ |
|||
@Service |
|||
@Slf4j |
|||
public class DataSyncUserAndOrgServiceImpl implements DataSyncUserAndOrgService { |
|||
@Autowired |
|||
private DataSyncUserDataDao dataSyncUserDataDao; |
|||
@Autowired |
|||
private DataSyncOrgDataDao dataSyncOrgDataDao; |
|||
@Autowired |
|||
private DataSyncOrgDataService dataSyncOrgDataService; |
|||
@Autowired |
|||
private DataSyncUserDataService dataSyncUserDataService; |
|||
@Autowired |
|||
private EpmetUserOpenFeignClient epmetUserOpenFeignClient; |
|||
|
|||
/** |
|||
* Desc: 从org表查询组织,在根据组织去查询用户 |
|||
* @param organizationId |
|||
* @author zxc |
|||
* @date 2022/10/19 13:27 |
|||
*/ |
|||
@Override |
|||
public Boolean yanTaiSyncUser(String organizationId) { |
|||
String customerId = YT_CUSTOMER_ID; |
|||
// 缓存初始化staffs
|
|||
epmetUserOpenFeignClient.allCustomerStaffInCache(customerId); |
|||
Integer no = NumConstant.ONE; |
|||
Integer size; |
|||
do { |
|||
// 分批获取org
|
|||
PageInfo<com.epmet.dto.DataSyncOrgDataDTO> pageInfo = PageHelper.startPage(no, NumConstant.ONE_HUNDRED).doSelectPageInfo(() -> dataSyncOrgDataDao.getAllList(customerId)); |
|||
size = pageInfo.getList().size(); |
|||
if (CollectionUtils.isNotEmpty(pageInfo.getList())){ |
|||
List<DataSyncUserDataEntity> needInsert = new ArrayList<>(); |
|||
pageInfo.getList().forEach(org -> { |
|||
// 根据org查用户
|
|||
List<UserData> data = YantaiApi.getUserByOuGuid(org.getOrganizationId()); |
|||
if (CollectionUtils.isNotEmpty(data)){ |
|||
for (UserData u : data) { |
|||
CustomerStaffInfoDTOCache staffInfo = CustomerStaffRedis.getStaffInfoByMobile(customerId, u.getMobileTelephoneNumber()); |
|||
DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(u, DataSyncUserDataEntity.class); |
|||
entity.setCustomerId(customerId); |
|||
entity.setRemark(""); |
|||
if (null == staffInfo){ |
|||
entity.setStatus(NumConstant.ZERO_STR); |
|||
entity.setOrganizationId(""); |
|||
entity.setStaffId(""); |
|||
}else { |
|||
CustomerStaffInfoCacheResult staffInfo1 = CustomerStaffRedis.getStaffInfo(customerId, staffInfo.getUserId()); |
|||
entity.setStatus(NumConstant.ONE_STR); |
|||
entity.setOrganizationId(null == staffInfo1 ? "" : staffInfo1.getAgencyId()); |
|||
entity.setStaffId(staffInfo.getUserId()); |
|||
} |
|||
needInsert.add(entity); |
|||
} |
|||
} |
|||
}); |
|||
dataSyncUserDataService.insertBatch(needInsert,NumConstant.FIVE_HUNDRED); |
|||
} |
|||
no++; |
|||
}while (size == NumConstant.ONE_HUNDRED); |
|||
// 删除staffs缓存
|
|||
CustomerStaffRedis.delAllCustomerStaff(customerId); |
|||
return false; |
|||
} |
|||
|
|||
@Override |
|||
public Boolean yanTaiSyncOrg(String organizationId) { |
|||
List<OrgData> data = YantaiApi.getChildOuInfoByGuid(organizationId); |
|||
if (CollectionUtils.isNotEmpty(data)){ |
|||
List<OrgData> needInsert = new ArrayList<>(); |
|||
data.forEach(d -> { |
|||
needInsert.add(d); |
|||
disposeYanTaiSyncOrg(d.getOrganizationId(),needInsert); |
|||
}); |
|||
List<DataSyncOrgDataEntity> entities = needInsert.stream().map(m -> { |
|||
DataSyncOrgDataEntity entity = ConvertUtils.sourceToTarget(m, DataSyncOrgDataEntity.class); |
|||
entity.setCustomerId(YT_CUSTOMER_ID); |
|||
entity.setPid(""); |
|||
entity.setParentOrgName(""); |
|||
entity.setPids(""); |
|||
return entity; |
|||
}).collect(Collectors.toList()); |
|||
dataSyncOrgDataService.insertBatch(entities, NumConstant.ONE_HUNDRED); |
|||
} |
|||
return false; |
|||
} |
|||
|
|||
public void disposeYanTaiSyncOrg(String organizationId, List<OrgData> needInsert){ |
|||
List<OrgData> data = YantaiApi.getChildOuInfoByGuid(organizationId); |
|||
if (CollectionUtils.isNotEmpty(data)){ |
|||
needInsert.addAll(data); |
|||
data.forEach(d -> { |
|||
disposeYanTaiSyncOrg(d.getOrganizationId(),needInsert); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 运营端-统一认证 |
|||
* 用户列表 |
|||
* |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public PageData<YtUserPageResDTO> pageUser(YtUserPageFormDTO formDTO) { |
|||
PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.getIsPage()); |
|||
List<YtUserPageResDTO> list = dataSyncUserDataDao.pageUser(formDTO); |
|||
PageInfo<YtUserPageResDTO> pageInfo = new PageInfo<>(list); |
|||
return new PageData<>(list, pageInfo.getTotal()); |
|||
} |
|||
|
|||
/** |
|||
* 工作端新增完用户后,需要调用此接口,更新data_sync_user_data |
|||
* |
|||
* @param customerId |
|||
* @param staffId |
|||
* @param name |
|||
* @param mobile |
|||
*/ |
|||
@Override |
|||
public int updateStaff(String customerId, String operUserId,String staffId, String name, String mobile) { |
|||
return dataSyncUserDataDao.updateStaff(customerId,operUserId,staffId,name,mobile); |
|||
} |
|||
|
|||
/** |
|||
* 根据组织id查询下级组织 |
|||
* |
|||
* @param pid |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<DataSyncOrgDataDTO> ytOrgList(String pid) { |
|||
List<DataSyncOrgDataDTO> list=dataSyncOrgDataDao.queryList(pid); |
|||
return list; |
|||
} |
|||
} |
@ -0,0 +1,199 @@ |
|||
package com.epmet.controller.yantai; |
|||
|
|||
import com.fasterxml.jackson.core.JsonProcessingException; |
|||
import com.fasterxml.jackson.databind.ObjectMapper; |
|||
import org.apache.commons.codec.binary.Base64; |
|||
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
|||
|
|||
import javax.crypto.BadPaddingException; |
|||
import javax.crypto.Cipher; |
|||
import javax.crypto.IllegalBlockSizeException; |
|||
import javax.crypto.SecretKey; |
|||
import javax.crypto.spec.SecretKeySpec; |
|||
import java.nio.charset.Charset; |
|||
import java.nio.charset.StandardCharsets; |
|||
import java.security.InvalidKeyException; |
|||
import java.security.Security; |
|||
|
|||
/** |
|||
* 烟台的认证中心-国密sm4加解密 |
|||
*/ |
|||
public class SM4UtilsForYanTai { |
|||
private static String SM4_KEY = "yaweisoftware@xy"; |
|||
//编码格式
|
|||
private static final Charset encryptCharset = StandardCharsets.UTF_8; |
|||
|
|||
public enum Algorithm { |
|||
SM4("SM4","SM4","国密四,key长16byte"); |
|||
private String keyAlgorithm; |
|||
private String transformation; |
|||
private String description;//描述
|
|||
Algorithm(String keyAlgorithm, String transformation, String description) { |
|||
this.keyAlgorithm = keyAlgorithm; |
|||
this.transformation = transformation; |
|||
this.description = description; |
|||
} |
|||
public String getKeyAlgorithm() { |
|||
return this.keyAlgorithm; |
|||
} |
|||
public String getTransformation() { |
|||
return this.transformation; |
|||
} |
|||
public String getDescription() { |
|||
return this.description; |
|||
} |
|||
} |
|||
|
|||
private static final String PROVIDER_NAME = "BC"; |
|||
static { |
|||
Security.addProvider(new BouncyCastleProvider()); |
|||
} |
|||
|
|||
/** |
|||
* 自定字符串产生密钥 |
|||
* @param algorithm 加解密算法 |
|||
* @param keyStr 密钥字符串 |
|||
* @param charset 编码字符集 |
|||
* @return 密钥 |
|||
*/ |
|||
public static SecretKey genKeyByStr(Algorithm algorithm, String keyStr, Charset charset) { |
|||
return readKeyFromBytes(algorithm, keyStr.getBytes(charset)); |
|||
} |
|||
|
|||
/** |
|||
* 根据指定字节数组产生密钥 |
|||
* @param algorithm 加解密算法 |
|||
* @param keyBytes 密钥字节数组 |
|||
* @return 密钥 |
|||
*/ |
|||
public static SecretKey readKeyFromBytes(Algorithm algorithm, byte[] keyBytes) { |
|||
return new SecretKeySpec(keyBytes, algorithm.getKeyAlgorithm()); |
|||
} |
|||
|
|||
/****************************加密*********************************/ |
|||
/** |
|||
* 加密字符串,并进行base64编码 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 明文 |
|||
* @param charset 编码字符集 |
|||
* @return 密文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
*/ |
|||
public static String encryptBase64(Algorithm algorithm, SecretKey key, String data, Charset charset) throws InvalidKeyException { |
|||
return Base64.encodeBase64String(encrypt(algorithm, key, data.getBytes(charset))); |
|||
} |
|||
|
|||
/** |
|||
* 加密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 明文 |
|||
* @return 密文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
*/ |
|||
public static byte[] encrypt(Algorithm algorithm, SecretKey key, byte[] data) throws InvalidKeyException { |
|||
try { |
|||
return cipherDoFinal(algorithm, Cipher.ENCRYPT_MODE, key, data); |
|||
} catch (BadPaddingException e) { |
|||
throw new RuntimeException(e);//明文没有具体格式要求,不会出错。所以这个异常不需要外部捕获。
|
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 加解密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param opmode 操作:1加密,2解密 |
|||
* @param key 密钥 |
|||
* @param data 数据 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 解密密文错误(加密模式没有) |
|||
*/ |
|||
private static byte[] cipherDoFinal(Algorithm algorithm, int opmode, SecretKey key, byte[] data) throws InvalidKeyException, BadPaddingException { |
|||
Cipher cipher; |
|||
try { |
|||
cipher = Cipher.getInstance(algorithm.getTransformation(), PROVIDER_NAME); |
|||
} catch (Exception e) { |
|||
//NoSuchAlgorithmException:加密算法名是本工具类提供的,如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
//NoSuchProviderException:Provider是本工具类提供的,如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
//NoSuchPaddingException:没有特定的填充机制,与环境有关,业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
throw new RuntimeException(e); |
|||
} |
|||
cipher.init(opmode, key); |
|||
try { |
|||
return cipher.doFinal(data); |
|||
} catch (IllegalBlockSizeException e) { |
|||
throw new RuntimeException(e);//业务不需要将数据分块(好像由底层处理了),如果错了业务没有办法处理。所以这个异常不需要外部捕获。
|
|||
} |
|||
} |
|||
|
|||
/****************************解密*********************************/ |
|||
/** |
|||
* 对字符串先进行base64解码,再解密 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 密文 |
|||
* @param charset 编码字符集 |
|||
* @return 明文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 密文错误 |
|||
*/ |
|||
public static String decryptBase64(Algorithm algorithm, SecretKey key, String data, Charset charset) |
|||
throws InvalidKeyException, BadPaddingException { |
|||
return new String(decrypt(algorithm, key, Base64.decodeBase64(data)), charset); |
|||
} |
|||
|
|||
/** |
|||
* 解密字节数组 |
|||
* @param algorithm 加解密算法 |
|||
* @param key 密钥 |
|||
* @param data 密文 |
|||
* @return 明文 |
|||
* @throws InvalidKeyException 密钥错误 |
|||
* @throws BadPaddingException 密文错误 |
|||
*/ |
|||
public static byte[] decrypt(Algorithm algorithm, SecretKey key, byte[] data) throws InvalidKeyException, BadPaddingException { |
|||
return cipherDoFinal(algorithm, Cipher.DECRYPT_MODE, key, data); |
|||
} |
|||
|
|||
public static String Encrypt(String data) throws InvalidKeyException { |
|||
SecretKey key = genKeyByStr(Algorithm.SM4, SM4_KEY, encryptCharset); |
|||
return encryptBase64(Algorithm.SM4, key, data, encryptCharset); |
|||
} |
|||
public static String Decrypt(String data) throws BadPaddingException, InvalidKeyException { |
|||
SecretKey key = genKeyByStr(Algorithm.SM4, SM4_KEY, encryptCharset); |
|||
return decryptBase64(Algorithm.SM4, key, data, encryptCharset); |
|||
} |
|||
//加密
|
|||
public static String dealEncryptData(Object data) throws JsonProcessingException, InvalidKeyException { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
String dataString = ""; |
|||
try { |
|||
if(data instanceof String){ |
|||
dataString = (String) data; |
|||
}else { |
|||
dataString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(data); |
|||
} |
|||
String dataEncrypt = Encrypt(dataString); |
|||
return dataEncrypt; |
|||
}catch (Exception e){ |
|||
return dataString; |
|||
} |
|||
} |
|||
//解密
|
|||
public static String dealDecryptData(Object data) throws JsonProcessingException, BadPaddingException, InvalidKeyException { |
|||
String dataString = ""; |
|||
try { |
|||
ObjectMapper objectMapper = new ObjectMapper(); |
|||
if (data instanceof String) { |
|||
dataString = (String) data; |
|||
} else { |
|||
dataString = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(data); |
|||
} |
|||
String dataDecrypt = Decrypt(dataString); |
|||
return dataDecrypt; |
|||
}catch (Exception e){ |
|||
return dataString; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.epmet.dao.yantai; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.result.yantai.DataSyncOrgDataDTO; |
|||
import com.epmet.entity.yantai.DataSyncOrgDataEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Mapper |
|||
public interface DataSyncOrgDataDao extends BaseDao<DataSyncOrgDataEntity> { |
|||
/** |
|||
* 根据pid查询下一级组织列表 |
|||
* @param pid |
|||
* @return |
|||
*/ |
|||
List<DataSyncOrgDataDTO> queryList(@Param("pid") String pid); |
|||
|
|||
List<com.epmet.dto.DataSyncOrgDataDTO> getAllList(@Param("customerId") String customerId); |
|||
} |
@ -0,0 +1,41 @@ |
|||
package com.epmet.dao.yantai; |
|||
|
|||
import com.epmet.commons.mybatis.dao.BaseDao; |
|||
import com.epmet.dto.form.yantai.YtUserPageFormDTO; |
|||
import com.epmet.dto.result.yantai.YtUserPageResDTO; |
|||
import com.epmet.entity.yantai.DataSyncUserDataEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Mapper |
|||
public interface DataSyncUserDataDao extends BaseDao<DataSyncUserDataEntity> { |
|||
/** |
|||
* 运营端,统一认证 列表查询 |
|||
* @param formDTO |
|||
* @return |
|||
*/ |
|||
List<YtUserPageResDTO> pageUser(YtUserPageFormDTO formDTO); |
|||
|
|||
/** |
|||
* 更新data_sync_user_data 为已创建、记录staffId |
|||
* @param customerId |
|||
* @param operUserId |
|||
* @param staffId |
|||
* @param name |
|||
* @param mobile |
|||
* @return |
|||
*/ |
|||
int updateStaff(@Param("customerId") String customerId, |
|||
@Param("operUserId")String operUserId, |
|||
@Param("staffId")String staffId, |
|||
@Param("name")String name, |
|||
@Param("mobile")String mobile); |
|||
} |
@ -0,0 +1,106 @@ |
|||
package com.epmet.entity.yantai; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("data_sync_org_data") |
|||
public class DataSyncOrgDataEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 联系人姓名 |
|||
*/ |
|||
private String contact; |
|||
|
|||
/** |
|||
* 联系电话号码 |
|||
*/ |
|||
private String contacttelephoneNumber; |
|||
|
|||
/** |
|||
* 详细地址 |
|||
*/ |
|||
private String detailAddress; |
|||
|
|||
/** |
|||
* 组织机构第一名称 |
|||
*/ |
|||
private String firstnameofOrganization; |
|||
|
|||
/** |
|||
* 组织机构全称 |
|||
*/ |
|||
private String nameofOrganization; |
|||
|
|||
/** |
|||
* 排序号码 |
|||
*/ |
|||
private String orderNumber; |
|||
|
|||
/** |
|||
* 组织机构简称 |
|||
*/ |
|||
private String organizatioNabbreviation; |
|||
|
|||
/** |
|||
* 组织机构ID |
|||
*/ |
|||
private String organizationId; |
|||
|
|||
/** |
|||
* 组织机构级别 |
|||
*/ |
|||
private String organizationLevel; |
|||
|
|||
/** |
|||
* 组织机构路径 |
|||
*/ |
|||
private String organizationPath; |
|||
|
|||
/** |
|||
* 组织机构类型 |
|||
*/ |
|||
private String organizationType; |
|||
|
|||
/** |
|||
* 注册类型 |
|||
*/ |
|||
private String registrationType; |
|||
|
|||
/** |
|||
* 统一社会信用代码 |
|||
*/ |
|||
private String unifiedsocialcreditId; |
|||
|
|||
/** |
|||
* 客户id;烟台id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 上级组织机构id:ORGANIZATION_ID; 根级组织赋值0 |
|||
*/ |
|||
private String pid; |
|||
|
|||
/** |
|||
* 上级组织机构名称:ORGANIZATIO_NABBREVIATION |
|||
*/ |
|||
private String parentOrgName; |
|||
|
|||
/** |
|||
* 所有上级组织。不包含本身! |
|||
*/ |
|||
private String pids; |
|||
|
|||
} |
@ -0,0 +1,91 @@ |
|||
package com.epmet.entity.yantai; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.epmet.commons.mybatis.entity.BaseEpmetEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("data_sync_user_data") |
|||
public class DataSyncUserDataEntity extends BaseEpmetEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 性别:0未知1男2女 |
|||
*/ |
|||
private String gender; |
|||
|
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
private String mobileTelephoneNumber; |
|||
|
|||
/** |
|||
* 排序号码 |
|||
*/ |
|||
private String orderNumber; |
|||
|
|||
/** |
|||
* 职务 |
|||
*/ |
|||
private String position; |
|||
|
|||
/** |
|||
* 职级 |
|||
*/ |
|||
private String positionLevel; |
|||
|
|||
/** |
|||
* 电话号码 |
|||
*/ |
|||
private String telephoneNumber; |
|||
|
|||
/** |
|||
* 统一用户编码 |
|||
*/ |
|||
private String userGuid; |
|||
|
|||
/** |
|||
* 用户姓名 |
|||
*/ |
|||
private String userName; |
|||
|
|||
/** |
|||
* 人员路径 |
|||
*/ |
|||
private String userPath; |
|||
|
|||
/** |
|||
* data_sync_org_data.组织机构ID; |
|||
*/ |
|||
private String organizationId; |
|||
|
|||
/** |
|||
* 客户id |
|||
*/ |
|||
private String customerId; |
|||
|
|||
/** |
|||
* 0未创建、已创建 |
|||
*/ |
|||
private String status; |
|||
|
|||
/** |
|||
* customer_staff.userId |
|||
*/ |
|||
private String staffId; |
|||
|
|||
/** |
|||
* 备注;目前为空 |
|||
*/ |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.DataSyncOrgDataDTO; |
|||
import com.epmet.entity.yantai.DataSyncOrgDataEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
public interface DataSyncOrgDataService extends BaseService<DataSyncOrgDataEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<DataSyncOrgDataDTO> |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
PageData<DataSyncOrgDataDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<DataSyncOrgDataDTO> |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
List<DataSyncOrgDataDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return DataSyncOrgDataDTO |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
DataSyncOrgDataDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void save(DataSyncOrgDataDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void update(DataSyncOrgDataDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
@ -0,0 +1,78 @@ |
|||
package com.epmet.service; |
|||
|
|||
import com.epmet.commons.mybatis.service.BaseService; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.dto.DataSyncUserDataDTO; |
|||
import com.epmet.entity.yantai.DataSyncUserDataEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
public interface DataSyncUserDataService extends BaseService<DataSyncUserDataEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<DataSyncUserDataDTO> |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
PageData<DataSyncUserDataDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<DataSyncUserDataDTO> |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
List<DataSyncUserDataDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return DataSyncUserDataDTO |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
DataSyncUserDataDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void save(DataSyncUserDataDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void update(DataSyncUserDataDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2022-10-18 |
|||
*/ |
|||
void delete(String[] ids); |
|||
} |
@ -0,0 +1,83 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.dao.yantai.DataSyncOrgDataDao; |
|||
import com.epmet.dto.DataSyncOrgDataDTO; |
|||
import com.epmet.entity.yantai.DataSyncOrgDataEntity; |
|||
import com.epmet.service.DataSyncOrgDataService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Service |
|||
public class DataSyncOrgDataServiceImpl extends BaseServiceImpl<DataSyncOrgDataDao, DataSyncOrgDataEntity> implements DataSyncOrgDataService { |
|||
|
|||
@Override |
|||
public PageData<DataSyncOrgDataDTO> page(Map<String, Object> params) { |
|||
IPage<DataSyncOrgDataEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, DataSyncOrgDataDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<DataSyncOrgDataDTO> list(Map<String, Object> params) { |
|||
List<DataSyncOrgDataEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, DataSyncOrgDataDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<DataSyncOrgDataEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<DataSyncOrgDataEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public DataSyncOrgDataDTO get(String id) { |
|||
DataSyncOrgDataEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, DataSyncOrgDataDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(DataSyncOrgDataDTO dto) { |
|||
DataSyncOrgDataEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncOrgDataEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(DataSyncOrgDataDTO dto) { |
|||
DataSyncOrgDataEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncOrgDataEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,83 @@ |
|||
package com.epmet.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.epmet.commons.tools.page.PageData; |
|||
import com.epmet.commons.tools.utils.ConvertUtils; |
|||
import com.epmet.commons.tools.constant.FieldConstant; |
|||
import com.epmet.dao.yantai.DataSyncUserDataDao; |
|||
import com.epmet.dto.DataSyncUserDataDTO; |
|||
import com.epmet.entity.yantai.DataSyncUserDataEntity; |
|||
import com.epmet.service.DataSyncUserDataService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* |
|||
* |
|||
* @author generator generator@elink-cn.com |
|||
* @since v1.0.0 2022-10-18 |
|||
*/ |
|||
@Service |
|||
public class DataSyncUserDataServiceImpl extends BaseServiceImpl<DataSyncUserDataDao, DataSyncUserDataEntity> implements DataSyncUserDataService { |
|||
|
|||
@Override |
|||
public PageData<DataSyncUserDataDTO> page(Map<String, Object> params) { |
|||
IPage<DataSyncUserDataEntity> page = baseDao.selectPage( |
|||
getPage(params, FieldConstant.CREATED_TIME, false), |
|||
getWrapper(params) |
|||
); |
|||
return getPageData(page, DataSyncUserDataDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
public List<DataSyncUserDataDTO> list(Map<String, Object> params) { |
|||
List<DataSyncUserDataEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, DataSyncUserDataDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<DataSyncUserDataEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<DataSyncUserDataEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public DataSyncUserDataDTO get(String id) { |
|||
DataSyncUserDataEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, DataSyncUserDataDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(DataSyncUserDataDTO dto) { |
|||
DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncUserDataEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(DataSyncUserDataDTO dto) { |
|||
DataSyncUserDataEntity entity = ConvertUtils.sourceToTarget(dto, DataSyncUserDataEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,55 @@ |
|||
<?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.yantai.DataSyncOrgDataDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.yantai.DataSyncOrgDataEntity" id="dataSyncOrgDataMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="contact" column="CONTACT"/> |
|||
<result property="contacttelephoneNumber" column="CONTACTTELEPHONE_NUMBER"/> |
|||
<result property="detailAddress" column="DETAIL_ADDRESS"/> |
|||
<result property="firstnameofOrganization" column="FIRSTNAMEOF_ORGANIZATION"/> |
|||
<result property="nameofOrganization" column="NAMEOF_ORGANIZATION"/> |
|||
<result property="orderNumber" column="ORDER_NUMBER"/> |
|||
<result property="organizatioNabbreviation" column="ORGANIZATIO_NABBREVIATION"/> |
|||
<result property="organizationId" column="ORGANIZATION_ID"/> |
|||
<result property="organizationLevel" column="ORGANIZATION_LEVEL"/> |
|||
<result property="organizationPath" column="ORGANIZATION_PATH"/> |
|||
<result property="organizationType" column="ORGANIZATION_TYPE"/> |
|||
<result property="registrationType" column="REGISTRATION_TYPE"/> |
|||
<result property="unifiedsocialcreditId" column="UNIFIEDSOCIALCREDIT_ID"/> |
|||
<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"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="pid" column="PID"/> |
|||
<result property="parentOrgName" column="PARENT_ORG_NAME"/> |
|||
<result property="pids" column="PIDS"/> |
|||
</resultMap> |
|||
|
|||
<select id="queryList" parameterType="map" resultType="com.epmet.dto.result.yantai.DataSyncOrgDataDTO"> |
|||
select |
|||
d.ORGANIZATION_ID as orgId, |
|||
d.ORGANIZATIO_NABBREVIATION as orgName, |
|||
d.PID, |
|||
( |
|||
case when (select count(1) from data_sync_org_data d1 where d1.pid=d.ORGANIZATION_ID)>0 then 1 else 0 |
|||
end |
|||
)as haveChild |
|||
From data_sync_org_data d |
|||
where d.del_flag='0' |
|||
<if test='null != pid and "" != pid'> |
|||
and d.pid = #{pid} |
|||
</if> |
|||
order by d.ORDER_NUMBER asc |
|||
</select> |
|||
<select id="getAllList" resultType="com.epmet.dto.DataSyncOrgDataDTO"> |
|||
select * from data_sync_org_data |
|||
where del_flag = '0' |
|||
and CUSTOMER_ID = #{customerId} |
|||
order by ORDER_NUMBER asc |
|||
</select> |
|||
</mapper> |
@ -0,0 +1,90 @@ |
|||
<?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.yantai.DataSyncUserDataDao"> |
|||
|
|||
<resultMap type="com.epmet.entity.yantai.DataSyncUserDataEntity" id="dataSyncUserDataMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="gender" column="GENDER"/> |
|||
<result property="mobileTelephoneNumber" column="MOBILE_TELEPHONE_NUMBER"/> |
|||
<result property="orderNumber" column="ORDER_NUMBER"/> |
|||
<result property="position" column="POSITION"/> |
|||
<result property="positionLevel" column="POSITION_LEVEL"/> |
|||
<result property="telephoneNumber" column="TELEPHONE_NUMBER"/> |
|||
<result property="userGuid" column="USER_GUID"/> |
|||
<result property="userName" column="USER_NAME"/> |
|||
<result property="userPath" column="USER_PATH"/> |
|||
<result property="organizationId" column="ORGANIZATION_ID"/> |
|||
<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"/> |
|||
<result property="customerId" column="CUSTOMER_ID"/> |
|||
<result property="status" column="STATUS"/> |
|||
<result property="staffId" column="STAFF_ID"/> |
|||
<result property="remark" column="REMARK"/> |
|||
</resultMap> |
|||
|
|||
<!-- 运营端,统一认证 列表返参 --> |
|||
<select id="pageUser" parameterType="com.epmet.dto.form.yantai.YtUserPageFormDTO" resultType="com.epmet.dto.result.yantai.YtUserPageResDTO"> |
|||
SELECT |
|||
u.USER_GUID AS userGuid, |
|||
u.ORGANIZATION_ID AS organizationId, |
|||
(case when o.PARENT_ORG_NAME is not null and LENGTH(o.PARENT_ORG_NAME)>0 |
|||
then concat(o.PARENT_ORG_NAME,'-',o.ORGANIZATIO_NABBREVIATION) |
|||
else o.ORGANIZATIO_NABBREVIATION |
|||
end)as orgName, |
|||
u.USER_NAME AS userName, |
|||
u.TELEPHONE_NUMBER AS telephoneNumber, |
|||
u.GENDER AS gender, |
|||
u.`STATUS` AS status, |
|||
IFNULL(u.STAFF_ID,'') AS staffId, |
|||
IFNULL(u.REMARK, '' ) AS remark, |
|||
u.CUSTOMER_ID as customerId |
|||
FROM |
|||
data_sync_user_data u |
|||
LEFT JOIN data_sync_org_data o ON ( u.ORGANIZATION_ID = o.ORGANIZATION_ID ) |
|||
WHERE |
|||
u.DEL_FLAG = '0' |
|||
AND o.DEL_FLAG = '0' |
|||
<if test="null != type and type ==0"> |
|||
<if test='null != orgId and "" != orgId'> |
|||
AND u.ORGANIZATION_ID = #{orgId} |
|||
</if> |
|||
</if> |
|||
|
|||
<if test="null != type and type ==1"> |
|||
<if test='null != orgId and "" != orgId'> |
|||
AND (o.ORGANIZATION_ID = #{orgId} OR o.pids LIKE concat( '%', #{orgId}, '%' ) ) |
|||
</if> |
|||
</if> |
|||
|
|||
<if test='null != name and "" != name'> |
|||
AND u.USER_NAME LIKE concat( '%', #{name}, '%' ) |
|||
</if> |
|||
|
|||
<if test='null != mobile and "" != mobile'> |
|||
AND u.MOBILE_TELEPHONE_NUMBER LIKE concat( '%', #{mobile}, '%' ) |
|||
</if> |
|||
|
|||
<if test='null != status and "" != status'> |
|||
AND u.`STATUS` = #{status} |
|||
</if> |
|||
order by o.ORDER_NUMBER asc,u.ORDER_NUMBER asc |
|||
</select> |
|||
|
|||
<update id="updateStaff" parameterType="map"> |
|||
UPDATE data_sync_user_data |
|||
SET UPDATED_BY = #{operUserId}, |
|||
UPDATED_TIME = NOW(), |
|||
`STATUS` = '1', |
|||
STAFF_ID = #{staffId}, |
|||
CUSTOMER_ID = #{customerId} |
|||
WHERE |
|||
MOBILE_TELEPHONE_NUMBER = #{mobile} |
|||
AND USER_NAME = #{name} |
|||
AND del_flag = '0' |
|||
</update> |
|||
</mapper> |
Loading…
Reference in new issue