配置修改

This commit is contained in:
zhangchenbiao
2023-07-04 14:17:37 +08:00
parent 8b598aa962
commit d4a05a8164
7 changed files with 50 additions and 101 deletions

View File

@@ -13,15 +13,11 @@ import com.cool.store.enums.IDCardSideEnum;
import com.cool.store.exception.ApiException;
import com.cool.store.exception.ServiceException;
import com.cool.store.service.AliyunService;
import com.cool.store.utils.RedisConstantUtil;
import com.cool.store.utils.RedisUtilPool;
import com.cool.store.utils.UUIDUtils;
import com.cool.store.vo.cuser.IdentityCardInfoVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
@@ -30,7 +26,6 @@ import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Objects;
import java.util.Optional;
import java.util.Random;
/**
* @author zhangchenbiao
@@ -42,16 +37,24 @@ import java.util.Random;
@Service
public class AliyunServiceImpl implements AliyunService {
@Value("${aliyun.accessKeyId:null}")
private String accessKeyId;
@Value("${aliyun.accessKeySecret:null}")
private String accessKeySecret;
@Value("${aliyun.authCode:null}")
private String authCode;
@Override
public DescribePhoneNumberDTO getPhoneNumberAttribute(String phoneNumber) {
try {
Config config = new Config();
//todo zcb ak sk替换
config.accessKeyId = "LTAI5t9RaXvABZbHvoXjDFJ1";
config.accessKeySecret = "zhOK7WWo3yGoUWkOMaatty19k25CMd";
config.accessKeyId = accessKeyId;
config.accessKeySecret = accessKeySecret;
Client client = new Client(config);
DescribePhoneNumberOperatorAttributeRequest request = new DescribePhoneNumberOperatorAttributeRequest();
request.authCode = "Y81FVZepk6";
request.authCode = authCode;
request.inputNumber = phoneNumber;
request.mask = "NORMAL";
DescribePhoneNumberOperatorAttributeResponse response = client.describePhoneNumberOperatorAttribute(request);
@@ -71,15 +74,11 @@ public class AliyunServiceImpl implements AliyunService {
public IdentityCardInfoVO getIdentityCardInfo(String faceImageUrl, IDCardSideEnum sideEnum) throws ApiException {
//todo zcb ak sk替换
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
.setAccessKeyId("LTAI5t9RaXvABZbHvoXjDFJ1")
.setAccessKeySecret("zhOK7WWo3yGoUWkOMaatty19k25CMd");
.setAccessKeyId(accessKeyId)
.setAccessKeySecret(accessKeySecret);
// 访问的域名
config.endpoint = "ocr.cn-shanghai.aliyuncs.com";
try {
if(StringUtils.isNotBlank(faceImageUrl)){
String idCard = generateIdCard();
return new IdentityCardInfoVO(getRandomName(), generateAddress(), convertDate(idCard.substring(6, 14), "yyyyMMdd"), UUIDUtils.get8UUID().hashCode() % 2 == 0 ? "":"", idCard, "");
}
com.aliyun.ocr20191230.Client client = new com.aliyun.ocr20191230.Client(config);
URL url = new URL(faceImageUrl);
InputStream inputStream = url.openConnection().getInputStream();
@@ -129,85 +128,6 @@ public class AliyunServiceImpl implements AliyunService {
throw new ServiceException(ErrorCodeEnum.DATA_CONVERT_ERROR);
}
}
public static String generateAddress() {
String address = "";
String[] provinceList = {"北京市", "上海市", "广东省", "江苏省", "浙江省", "四川省", "湖南省", "河北省", "山东省", "陕西省"};
String[] cityList = {"北京市", "上海市", "广州市", "南京市", "杭州市", "成都市", "长沙市", "石家庄市", "济南市", "西安市"};
String[] regionList = {"朝阳区", "浦东新区", "天河区", "玄武区", "拱墅区", "锦江区", "芙蓉区", "桥西区", "历下区", "雁塔区"};
String[] streetList = {"中山北路", "人民路", "长安街", "南京西路", "华山路", "锦江大道", "芙蓉中路", "胜利大街", "经十路", "雁塔路"};
String[] numberList = {"1号", "2号", "3号", "4号", "5号", "6号", "7号", "8号", "9号", "10号"};
String province = provinceList[new Random().nextInt(provinceList.length)];
String city = cityList[new Random().nextInt(cityList.length)];
String region = regionList[new Random().nextInt(regionList.length)];
String street = streetList[new Random().nextInt(streetList.length)];
String number = numberList[new Random().nextInt(numberList.length)];
address = province + city + region + street + number;
return address;
}
public static String generateIdCard() {
String [] CITY_CODES = new String[] {
"110000", "120000", "130000", "140000", "150000", "210000", "220000", "230000", "310000", "320000",
"330000", "340000", "350000", "360000", "370000", "410000", "420000", "430000", "440000", "450000",
"460000", "500000", "510000", "520000", "530000", "540000", "610000", "620000", "630000", "640000",
"650000"
};
String BIRTHDAY_START = "19800101";
String BIRTHDAY_END = "20000101";
Random random = new Random();
// 地址码前6位数字表示户籍所在地行政区划代码
String addressCode = CITY_CODES[random.nextInt(CITY_CODES.length)];
// 出生日期码7到14位数字表示出生年月日
LocalDate birthday = LocalDate.ofEpochDay(random.nextInt(
(int)(LocalDate.parse(BIRTHDAY_END, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay() - LocalDate.parse(BIRTHDAY_START, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay())
) + LocalDate.parse(BIRTHDAY_START, DateTimeFormatter.BASIC_ISO_DATE).toEpochDay());
String birthdayCode = birthday.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
// 顺序码15到17位数字表示在同一地址码所在区域范围内对同年同月同日出生的人的顺序编号
String sequenceCode = String.format("%03d", random.nextInt(1000));
// 计算校验码
String body = addressCode + birthdayCode + sequenceCode;
int[] weight = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
String[] checkCode = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"};
int sum = 0;
for (int i = 0; i < body.length(); i++) {
sum += (body.charAt(i) - '0') * weight[i];
}
int remainder = sum % 11;
String checkCodeStr = checkCode[remainder];
// 构造身份证号码
return body + checkCodeStr;
}
private static char[] lastNames = { '赵', '钱', '孙', '李', '周', '吴', '郑', '王', '冯', '陈', '褚', '卫', '蒋', '沈', '韩', '杨', '朱', '秦', '尤', '许', '何', '吕', '施', '张', '孔', '曹', '严', '华', '金', '魏', '陶', '姜', '戚', '谢', '邹', '喻', '柏', '水', '窦', '章', '云', '苏', '潘', '葛', '奚', '范', '彭', '郎', '鲁', '韦', '昌', '马', '苗', '凤', '花', '方', '俞', '任', '袁', '柳', '酆', '鲍', '史', '唐', '费', '廉', '岑', '薛', '雷', '贺', '倪', '汤', '滕', '殷', '罗', '毕', '郝', '邬', '安', '常', '乐', '于', '时', '傅', '皮', '卞', '齐', '康', '伍', '余', '元', '卜', '顾', '孟', '平', '黄', '和', '穆', '肖', '尹', '营', '姚', '邵', '湛', '汪', '祁', '毛', '禹', '狄', '米', '贝', '明', '臧', '计', '伏', '成', '戴', '谈', '宋', '茅', '庞', '熊', '纪', '舒', '屈', '项', '祝', '董', '粱', '杜', '阮', '蓝', '闵', '席', '季', '麻', '强', '贾', '路', '娄', '危', '江', '童', '颜', '郭', '梅', '盛', '林', '刁', '钟', '徐', '邱', '骆', '高', '夏', '蔡', '田', '樊', '胡', '凌', '霍', '虞', '万', '支', '柯', '昝', '管', '卢', '莫', '经', '房', '裘', '缪', '干', '解', '应', '宗', '丁', '宣', '贲', '郁', '单', '杭', '洪', '包', '诸', '左', '石', '崔', '吉', '钮', '龚', '程', '嵇', '邢', '滑', '裴', '陆', '荣', '翁', '荀', '羊', '於', '惠', '甄', '加', '封', '芮', '麴', '井', '牟', '乘', '裘', '栾', '于', '冷', '甘', '归', '海', '嵩', '福', '景', '祖', '武', '符', '文', '御', '卫', '安', '柴', '颛', '段', '侯', '叶', '孟', '平', '呼', '南', '仇', '胥', '戊', '缑', '雍', '却', '璩', '桑', '桂', '濮', '閻', '充', '慕', '连', '茹', '习', '宦', '艾', '鱼', '容', '向', '古', '易', '慎', '戈', '廖', '庾', '终', '暨', '居', '衡', '步', '都', '耿', '满', '弘', '匡', '国', '文', '寇', '广', '禄', '阙', '东', '欧', '殳', '沃', '利', '蔚', '越', '夔', '隆', '师', '巩', '厍', '聂', '晁', '勾', '敖', '融', '冷', '訾', '辛', '阚', '那', '简', '饶', '空', '曾', '毋', '沙', '乜', '养', '鞠', '须', '丰', '巢', '关', '蒯', '相', '查', '后', '荆', '红', '游', '竺', '权', '逯', '盖', '益', '桓', '公', '牛', '应', '冉', '司', '马'};
private static char getRandomChar() {
Random rand = new Random();
return (char) (0x4e00 + rand.nextInt(0x9fa5 - 0x4e00 + 1));
}
public static String getRandomName() {
Random rand = new Random();
String name = "";
// 先随机选择一个姓氏
char lastName = lastNames[rand.nextInt(lastNames.length)];
name += lastName;
// 再随机生成1-2个名字
int nameLen = rand.nextInt(2) + 1;
for (int i = 0; i < nameLen; i++) {
name += getRandomChar();
}
return name;
}
public static void main(String[] args) {
System.out.println(generateIdCard().substring(6, 14));
System.out.println(getRandomName());
System.out.println(generateAddress());
}
}

View File

@@ -81,5 +81,9 @@ hs.sms.accessKeyId = LTAI4GEZKz9PBqqKa3hjup3W
hs.sms.accessKeySecret = iVOiK74k7C1wVbuUbipgJbfpAh1Zdb
hs.sms.templateCode = SMS_461530041
ec.baseUrl=https://oapi-gateway.shpr.top/basic
ec.baseUrl=https://oapi-gateway.shpr.top/basic
#阿里云ak sk
aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1
aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd
aliyun.authCode=Y81FVZepk6

View File

@@ -85,4 +85,9 @@ xxl.job.accessToken =
ec.baseUrl=http://127.0.0.1:8017
#飞书通知
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
#阿里云ak sk
aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1
aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd
aliyun.authCode=Y81FVZepk6

View File

@@ -57,4 +57,9 @@ trtc.video.callback.secretKey=1ECEAD34DBD84E838BF07FC7360EA4D8
weixin.appId=wx6f984e535e571818
weixin.appSecret=245a483747e6e9f8762d3e8539cf0318
signKey=d851f2a9ac90474abecdc2fbb148d4d7
signKey=d851f2a9ac90474abecdc2fbb148d4d7
#阿里云ak sk
aliyun.accessKeyId=
aliyun.accessKeySecret=
aliyun.authCode=

View File

@@ -63,4 +63,9 @@ weixin.appSecret=77abdcae754add92889566b543e5ad79
signKey=77fea013c3a6459685b83c21a2fc3411
#飞书通知
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
#阿里云ak sk
aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1
aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd
aliyun.authCode=Y81FVZepk6

View File

@@ -66,4 +66,9 @@ weixin.appSecret=77abdcae754add92889566b543e5ad79
signKey=77fea013c3a6459685b83c21a2fc3411
#飞书通知
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
feishu.notice.link.url = https://applink.feishu.cn/client/web_app/open?appId=cli_a4f3e24dc73a100c&lk_target_url=https%3A%2F%2Ftest-hsay-web.coolstore.cn%2F%23%2Fwork%2Fbench
#阿里云ak sk
aliyun.accessKeyId=LTAI5t9RaXvABZbHvoXjDFJ1
aliyun.accessKeySecret=zhOK7WWo3yGoUWkOMaatty19k25CMd
aliyun.authCode=Y81FVZepk6

View File

@@ -55,4 +55,9 @@ trtc.secretKey=4854bab106c2ca2a2fda16a8c966933e28a078a34e458999d6227e8cd8ab8219
weixin.appId=wxb2a0addf956ad4b7
weixin.appSecret=77abdcae754add92889566b543e5ad79
signKey=d851f2a9ac90474abecdc2fbb148d4d7
signKey=d851f2a9ac90474abecdc2fbb148d4d7
#阿里云ak sk
aliyun.accessKeyId=
aliyun.accessKeySecret=
aliyun.authCode=