|
@@ -8,15 +8,18 @@ import java.util.stream.Collectors;
|
|
|
|
|
|
import cn.dev33.satoken.spring.SpringMVCUtil;
|
|
import cn.dev33.satoken.spring.SpringMVCUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
+import cn.hutool.core.util.RandomUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.log.StaticLog;
|
|
import cn.hutool.log.StaticLog;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.pj.api.client.admin.AdminInterface;
|
|
import com.pj.api.client.admin.AdminInterface;
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
import com.pj.api.client.level_one_server.LevelOneServerInterface;
|
|
import com.pj.api.client.level_two_server.LevelTwoServerInterface;
|
|
import com.pj.api.client.level_two_server.LevelTwoServerInterface;
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
import com.pj.api.client.transport.TransportInterface;
|
|
import com.pj.api.dto.*;
|
|
import com.pj.api.dto.*;
|
|
import com.pj.common.core.exception.ServiceException;
|
|
import com.pj.common.core.exception.ServiceException;
|
|
|
|
+import com.pj.current.config.SystemObject;
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
import com.pj.current.dto.APPLoginUserInfo;
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
import com.pj.current.satoken.StpAPPUserUtil;
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
import com.pj.current.satoken.StpUserUtil;
|
|
@@ -32,7 +35,9 @@ import com.pj.project.app_user_login_log.AppUserLoginLogService;
|
|
import com.pj.project.re_role_menu.ReRoleMenu;
|
|
import com.pj.project.re_role_menu.ReRoleMenu;
|
|
import com.pj.project.re_role_menu.ReRoleMenuMapper;
|
|
import com.pj.project.re_role_menu.ReRoleMenuMapper;
|
|
import com.pj.retry.SmsRetryService;
|
|
import com.pj.retry.SmsRetryService;
|
|
|
|
+import com.pj.sms.factory.SmsFactory;
|
|
import com.pj.utils.cache.RedisUtil;
|
|
import com.pj.utils.cache.RedisUtil;
|
|
|
|
+import com.pj.utils.sg.AjaxError;
|
|
import com.pj.utils.sg.AjaxJson;
|
|
import com.pj.utils.sg.AjaxJson;
|
|
import com.pj.utils.sg.WebNbUtil;
|
|
import com.pj.utils.sg.WebNbUtil;
|
|
import com.pj.utils.so.SoMap;
|
|
import com.pj.utils.so.SoMap;
|
|
@@ -45,9 +50,12 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* Service: app_user -- 移动端账号
|
|
* Service: app_user -- 移动端账号
|
|
|
|
+ *
|
|
* @author qzy
|
|
* @author qzy
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@@ -84,6 +92,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
@Autowired
|
|
@Autowired
|
|
AppUserLoginLogService appUserLoginLogService;
|
|
AppUserLoginLogService appUserLoginLogService;
|
|
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 验证码前缀
|
|
* 验证码前缀
|
|
*/
|
|
*/
|
|
@@ -383,30 +392,41 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
return AjaxJson.getSuccess("密码找回成功!");
|
|
return AjaxJson.getSuccess("密码找回成功!");
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
|
|
|
|
|
|
+ return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- //验证码匹配错误
|
|
|
|
- return AjaxJson.getError("验证码输入错误,请检查!");
|
|
|
|
- }
|
|
|
|
|
|
+ //验证码匹配错误
|
|
|
|
+ return AjaxJson.getError("验证码输入错误,请检查!");
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* 获取验证码
|
|
* 获取验证码
|
|
*/
|
|
*/
|
|
- boolean getPhoneSmsCode(String phone) throws Exception {
|
|
|
|
|
|
+ boolean getPhoneSmsCode(String phone) {
|
|
|
|
+ AppUser appUser= this.findByPhone(phone);
|
|
|
|
+ if (appUser!=null){
|
|
|
|
+ throw new AjaxError("该手机号已注册");
|
|
|
|
+ }
|
|
//生成4位随机数
|
|
//生成4位随机数
|
|
- Random random = new Random();
|
|
|
|
- int randomNumber = random.nextInt(9000) + 1000;
|
|
|
|
|
|
+ String code=RandomUtil.randomNumbers(4);
|
|
//保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
|
|
//保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
|
|
- RedisUtil.setByMINUTES(PREFIX + phone, 123 + "", 1);
|
|
|
|
|
|
+ RedisUtil.setByMINUTES(PREFIX + phone, code, 5);
|
|
|
|
+ SystemObject.smsFactory.handler().sendSMS(phone,"您的验证码是"+code+"。如非本人操作,请忽略本短信");
|
|
//发送验证码短信
|
|
//发送验证码短信
|
|
return true;
|
|
return true;
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private AppUser findByPhone(String phone) {
|
|
|
|
+ QueryWrapper<AppUser>ew=new QueryWrapper<>();
|
|
|
|
+ ew.lambda().eq(AppUser::getPhone,phone);
|
|
|
|
+ List<AppUser>list=list(ew);
|
|
|
|
+ return list.isEmpty()?null:list.get(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 更换角色
|
|
* 更换角色
|
|
@@ -488,42 +508,46 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
|
|
return update == 1;
|
|
return update == 1;
|
|
}
|
|
}
|
|
|
|
|
|
- /** 远程调用: 当从航通导入数据时,自动给边民生成账号 */
|
|
|
|
- public boolean generatePeopleAccount(HtPeopleDto peopleDto) throws Exception {
|
|
|
|
- //检查是否重复注册
|
|
|
|
- List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, peopleDto.getBorderTel()));
|
|
|
|
- if(appUsers.size() != 0){
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 远程调用: 当从航通导入数据时,自动给边民生成账号
|
|
|
|
+ */
|
|
|
|
+ public boolean generatePeopleAccount(HtPeopleDto peopleDto) throws Exception {
|
|
|
|
+ //检查是否重复注册
|
|
|
|
+ List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, peopleDto.getBorderTel()));
|
|
|
|
+ if (appUsers.size() != 0) {
|
|
log.error("\n该用户已注册! phone = " + peopleDto.getBorderTel() + "\n");
|
|
log.error("\n该用户已注册! phone = " + peopleDto.getBorderTel() + "\n");
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
- //创建保存对象
|
|
|
|
- AppUser appUser = new AppUser();
|
|
|
|
- //设置基本属性
|
|
|
|
- appUser.setAuth(1 + ""); // 默认已认证
|
|
|
|
- appUser.setUserType(1); // 用户类型 1
|
|
|
|
- appUser.setCreateTime(new Date()); // 创建时间
|
|
|
|
- appUser.setPhone(peopleDto.getBorderTel()); // 电话
|
|
|
|
- appUser.setStatus("1"); // 可用状态
|
|
|
|
- appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
|
|
|
|
- appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
|
|
|
|
- appUser.setName(peopleDto.getBorderName()); // 昵称
|
|
|
|
- appUser.setFkId(peopleDto.getId()); // 外键
|
|
|
|
- appUser.setCreateUnit("航通");
|
|
|
|
- //随机生成6位数密码
|
|
|
|
-// int password = (int) (Math.random() * (999999 - 100000 + 1) + 100000);
|
|
|
|
- String password=appUser.getPhone();
|
|
|
|
- //密码加密
|
|
|
|
- String encodePassword = passwordEncoder.encode(password + "");
|
|
|
|
- //设置密码
|
|
|
|
- appUser.setPassword(encodePassword);
|
|
|
|
- //保存
|
|
|
|
- int insert = appUserMapper.insert(appUser);
|
|
|
|
- //发送短信
|
|
|
|
- if(insert == 1){
|
|
|
|
- //todo: 届时放开注释
|
|
|
|
|
|
+ //创建保存对象
|
|
|
|
+ AppUser appUser = new AppUser();
|
|
|
|
+ //设置基本属性
|
|
|
|
+ appUser.setAuth(1 + ""); // 默认已认证
|
|
|
|
+ appUser.setUserType(1); // 用户类型 1
|
|
|
|
+ appUser.setCreateTime(new Date()); // 创建时间
|
|
|
|
+ appUser.setPhone(peopleDto.getBorderTel()); // 电话
|
|
|
|
+ appUser.setStatus("1"); // 可用状态
|
|
|
|
+ appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
|
|
|
|
+ appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
|
|
|
|
+ appUser.setName(peopleDto.getBorderName()); // 昵称
|
|
|
|
+ appUser.setFkId(peopleDto.getId()); // 外键
|
|
|
|
+ appUser.setCreateUnit("航通");
|
|
|
|
+ //随机生成6位数密码
|
|
|
|
+ String password = RandomUtil.randomNumbers(8);
|
|
|
|
+// String password=appUser.getPhone();
|
|
|
|
+ //密码加密
|
|
|
|
+ String encodePassword = passwordEncoder.encode(password + "");
|
|
|
|
+ //设置密码
|
|
|
|
+ appUser.setPassword(encodePassword);
|
|
|
|
+ //保存
|
|
|
|
+ int insert = appUserMapper.insert(appUser);
|
|
|
|
+ //发送短信
|
|
|
|
+ if (insert == 1) {
|
|
|
|
+ //todo: 届时放开注释
|
|
|
|
+ String content="您好,您的[边民互市]app账号已生成。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改";
|
|
// boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
|
|
// boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
|
|
// return msg;
|
|
// return msg;
|
|
System.out.println("注册成功! 账户 = " + peopleDto.getBorderTel() + " password = " + password);
|
|
System.out.println("注册成功! 账户 = " + peopleDto.getBorderTel() + " password = " + password);
|
|
|
|
+ SystemObject.smsFactory.handler().sendSMS(peopleDto.getBorderTel(),content);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + peopleDto.getBorderTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
|
throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + peopleDto.getBorderTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|