|
|
|
@ -1,6 +1,13 @@
|
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
|
|
import cn.hutool.crypto.digest.DigestAlgorithm;
|
|
|
|
|
import cn.hutool.crypto.digest.Digester;
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse;
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import com.ruoyi.common.annotation.DataScope;
|
|
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
|
@ -24,13 +31,17 @@ import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Validator;
|
|
|
|
|
import java.time.Instant;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -55,7 +66,30 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|
|
|
|
private SysUserPostMapper userPostMapper;
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysConfigService configService;
|
|
|
|
|
@Value("${smsSend}")
|
|
|
|
|
private String smsSend;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${smsPhoneAdd}")
|
|
|
|
|
private String smsPhoneAdd;
|
|
|
|
|
|
|
|
|
|
@Value("${paaSID}")
|
|
|
|
|
private String paaSID;
|
|
|
|
|
|
|
|
|
|
@Value("${smsToken}")
|
|
|
|
|
private String smsToken;
|
|
|
|
|
|
|
|
|
|
@Value("${code}")
|
|
|
|
|
private String code;
|
|
|
|
|
|
|
|
|
|
@Value("${smsV}")
|
|
|
|
|
private String smsV;
|
|
|
|
|
|
|
|
|
|
@Value("${paramType}")
|
|
|
|
|
private String paramType;
|
|
|
|
|
|
|
|
|
|
@Value("${isTiming}")
|
|
|
|
|
private Boolean isTiming;
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件分页查询用户列表
|
|
|
|
|
*
|
|
|
|
@ -230,6 +264,27 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional
|
|
|
|
|
public int insertUser(SysUser user) {
|
|
|
|
|
if ("02".equals(user.getUserType()) & isTiming) {
|
|
|
|
|
if (user.getPhonenumber() != null) {
|
|
|
|
|
Digester sha256 = new Digester(DigestAlgorithm.SHA256);
|
|
|
|
|
String timestamp = String.valueOf(Instant.now().getEpochSecond());
|
|
|
|
|
String str = RandomUtil.randomString(30);
|
|
|
|
|
//请求头
|
|
|
|
|
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
|
|
|
|
|
headers.put("x-tif-paasid", paaSID);
|
|
|
|
|
headers.put("x-tif-signature", sha256.digestHex(timestamp + smsToken + str + timestamp).toUpperCase());
|
|
|
|
|
headers.put("x-tif-timestamp", timestamp);
|
|
|
|
|
headers.put("x-tif-nonce", str);
|
|
|
|
|
Map<String, Object> js1 = new HashMap<>();//存放参数
|
|
|
|
|
js1.put("orderId", code);
|
|
|
|
|
js1.put("nums", user.getPhonenumber());
|
|
|
|
|
HttpResponse response = HttpRequest.post(smsPhoneAdd)
|
|
|
|
|
.addHeaders(headers)
|
|
|
|
|
.form(js1)
|
|
|
|
|
.execute();
|
|
|
|
|
System.out.println(response.body());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 新增用户信息
|
|
|
|
|
int rows = userMapper.insertUser(user);
|
|
|
|
|
// 新增用户岗位关联
|
|
|
|
|