|
@@ -4,6 +4,10 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import javax.validation.Validator;
|
|
import javax.validation.Validator;
|
|
|
|
|
+
|
|
|
|
|
+import com.ruoyi.logistics.config.GemaiyunSmsConfig;
|
|
|
|
|
+import com.ruoyi.logistics.util.GemaiyunSmsUtil;
|
|
|
|
|
+import com.ruoyi.logistics.util.PasswordUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -65,6 +69,9 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
@Autowired
|
|
@Autowired
|
|
|
protected Validator validator;
|
|
protected Validator validator;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private GemaiyunSmsConfig smsConfig;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据条件分页查询用户列表
|
|
* 根据条件分页查询用户列表
|
|
|
*
|
|
*
|
|
@@ -266,9 +273,43 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
insertUserPost(user);
|
|
insertUserPost(user);
|
|
|
// 新增用户与角色管理
|
|
// 新增用户与角色管理
|
|
|
insertUserRole(user);
|
|
insertUserRole(user);
|
|
|
|
|
+
|
|
|
|
|
+ String password=PasswordUtils.generate8PasswordWithSpecial();
|
|
|
|
|
+ user.setPassword(password);
|
|
|
|
|
+ if(rows>0){
|
|
|
|
|
+ sendCreateUserSms(user);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
return rows;
|
|
return rows;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private void sendCreateUserSms(SysUser user) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // ✅ 局部变量,每个请求独立,安全!
|
|
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
|
|
+ sb.append(user.getNickName()).append("##")
|
|
|
|
|
+ .append(user.getPassword());
|
|
|
|
|
+ String content = sb.toString();
|
|
|
|
|
+ // 调用短信接口
|
|
|
|
|
+ String result = GemaiyunSmsUtil.sendSms(
|
|
|
|
|
+ smsConfig.getUrl(),
|
|
|
|
|
+ smsConfig.getAccessKey(),
|
|
|
|
|
+ smsConfig.getAccessSecret(),
|
|
|
|
|
+ smsConfig.getSign(),
|
|
|
|
|
+ smsConfig.getTemplateId(),
|
|
|
|
|
+ user.getPhonenumber(),
|
|
|
|
|
+ content
|
|
|
|
|
+ );
|
|
|
|
|
+ System.out.println(result);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 注册用户信息
|
|
* 注册用户信息
|
|
|
*
|
|
*
|
|
@@ -362,6 +403,7 @@ public class SysUserServiceImpl implements ISysUserService
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public int resetPwd(SysUser user)
|
|
public int resetPwd(SysUser user)
|
|
|
|
|
+
|
|
|
{
|
|
{
|
|
|
return userMapper.updateUser(user);
|
|
return userMapper.updateUser(user);
|
|
|
}
|
|
}
|