代码补正
This commit is contained in:
parent
18b08959a9
commit
e18cf3aea2
@ -9,7 +9,10 @@ import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
|||||||
import cn.iocoder.yudao.module.rescue.core.redis.RedisCache;
|
import cn.iocoder.yudao.module.rescue.core.redis.RedisCache;
|
||||||
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
import cn.iocoder.yudao.module.rescue.domain.DriverInfo;
|
||||||
import cn.iocoder.yudao.module.rescue.domain.LoginBody;
|
import cn.iocoder.yudao.module.rescue.domain.LoginBody;
|
||||||
|
import cn.iocoder.yudao.module.rescue.domain.WxLoginBody;
|
||||||
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
import cn.iocoder.yudao.module.rescue.service.IDriverInfoService;
|
||||||
|
import cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService;
|
||||||
|
import cn.iocoder.yudao.module.rescue.utils.pay.WechatPayConfig;
|
||||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||||
@ -21,16 +24,24 @@ import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO;
|
|||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||||
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
|
||||||
import cn.iocoder.yudao.module.system.service.permission.MenuService;
|
import cn.iocoder.yudao.module.system.service.permission.MenuService;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import com.sun.org.apache.xerces.internal.impl.dv.util.Base64;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
|
import javax.crypto.spec.SecretKeySpec;
|
||||||
|
import java.security.spec.AlgorithmParameterSpec;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -70,12 +81,15 @@ public class SysLoginController {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RedisCache redisCache2;
|
private RedisCache redisCache2;
|
||||||
//
|
|
||||||
// @Autowired
|
@Resource
|
||||||
// private RestTemplate restTemplate;
|
private RescueSysLoginService rescueSysLoginService;
|
||||||
//
|
|
||||||
// @Resource
|
@Resource
|
||||||
// private WechatPayConfig wxConfig;
|
private WechatPayConfig wxConfig;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RestTemplate restTemplate;
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private IUserBalanceService balanceService;
|
// private IUserBalanceService balanceService;
|
||||||
// @Autowired
|
// @Autowired
|
||||||
@ -98,13 +112,11 @@ public class SysLoginController {
|
|||||||
*/
|
*/
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public CommonResult login(@RequestBody LoginBody loginBody) {
|
public CommonResult login(@RequestBody LoginBody loginBody) {
|
||||||
return null;
|
// 生成令牌
|
||||||
// ajax = success();
|
AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO();
|
||||||
// // 生成令牌
|
authLoginReqVO.setUsername(loginBody.getUsername());
|
||||||
// String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
authLoginReqVO.setPassword(loginBody.getPassword());
|
||||||
// loginBody.getUuid());
|
return success(loginService.login(authLoginReqVO));
|
||||||
// ajax.put(Constants.TOKEN, token);
|
|
||||||
// return ajax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/dict/data/type/{type}")
|
@GetMapping("/dict/data/type/{type}")
|
||||||
@ -157,15 +169,15 @@ public class SysLoginController {
|
|||||||
AuthLoginRespVO login = loginService.login(authLoginReqVO);
|
AuthLoginRespVO login = loginService.login(authLoginReqVO);
|
||||||
return success(login);
|
return success(login);
|
||||||
}
|
}
|
||||||
// /**
|
/**
|
||||||
// * 登录获取验证码
|
* 登录获取验证码
|
||||||
// *
|
*
|
||||||
// * @return 结果
|
* @return 结果
|
||||||
// */
|
*/
|
||||||
// @PostMapping("/loginSmsCode")
|
@PostMapping("/loginSmsCode")
|
||||||
// public CommonResult loginSmsCode(String phone) {
|
public CommonResult loginSmsCode(String phone) {
|
||||||
// return loginService.loginSmsCode(phone);
|
return rescueSysLoginService.loginSmsCode(phone);
|
||||||
// }
|
}
|
||||||
/**
|
/**
|
||||||
* 登录方法
|
* 登录方法
|
||||||
*
|
*
|
||||||
@ -185,15 +197,15 @@ public class SysLoginController {
|
|||||||
// public AjaxResult loginSmsCodeJx(String phone) {
|
// public AjaxResult loginSmsCodeJx(String phone) {
|
||||||
// return loginService.loginSmsCodeJx(phone);
|
// return loginService.loginSmsCodeJx(phone);
|
||||||
// }
|
// }
|
||||||
// /**
|
/**
|
||||||
// * 忘记密码获取验证码
|
* 忘记密码获取验证码
|
||||||
// *
|
*
|
||||||
// * @return 结果
|
* @return 结果
|
||||||
// */
|
*/
|
||||||
// @PostMapping("/pwdSmsCode")
|
@PostMapping("/pwdSmsCode")
|
||||||
// public CommonResult pwdSmsCode(String phone) {
|
public CommonResult pwdSmsCode(String phone) {
|
||||||
// return loginService.pwdSmsCode(phone);
|
return rescueSysLoginService.pwdSmsCode(phone);
|
||||||
// }
|
}
|
||||||
// /**
|
// /**
|
||||||
// * 更新密码
|
// * 更新密码
|
||||||
// *
|
// *
|
||||||
@ -204,7 +216,7 @@ public class SysLoginController {
|
|||||||
// if (!redisCache2.hasKey(phone+"-pwdCode")||!redisCache2.getCacheObject(phone+"-pwdCode").equals(msgCode)){
|
// if (!redisCache2.hasKey(phone+"-pwdCode")||!redisCache2.getCacheObject(phone+"-pwdCode").equals(msgCode)){
|
||||||
// return error(500, "验证码错误");
|
// return error(500, "验证码错误");
|
||||||
// }
|
// }
|
||||||
// AdminUserRespDTO sysUser = userService.getUserByUsername(phone);
|
// AdminUserRespDTO sysUser = userService.getUserByMobile(phone);
|
||||||
// if (userService.resetPassword(sysUser.getId(), SecurityFrameworkUtils.encryptPassword(password)); > 0)
|
// if (userService.resetPassword(sysUser.getId(), SecurityFrameworkUtils.encryptPassword(password)); > 0)
|
||||||
// {
|
// {
|
||||||
// // 更新缓存用户密码
|
// // 更新缓存用户密码
|
||||||
@ -232,8 +244,8 @@ public class SysLoginController {
|
|||||||
// 角色集合
|
// 角色集合
|
||||||
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(loginUser.getId());
|
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(loginUser.getId());
|
||||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||||
List<String> roleNames = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).map(item -> item.getName()).collect(Collectors.toList());
|
List<RoleReqDTO> role = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
||||||
map.put("roles", roleNames);
|
map.put("role", role);
|
||||||
// 权限集合
|
// 权限集合
|
||||||
List<MenuDO> menuList = menuService.getMenuList();
|
List<MenuDO> menuList = menuService.getMenuList();
|
||||||
// Set<String> permissions = permissionService.getMenuPermission(user);
|
// Set<String> permissions = permissionService.getMenuPermission(user);
|
||||||
@ -283,19 +295,19 @@ public class SysLoginController {
|
|||||||
// * @return 用户信息
|
// * @return 用户信息
|
||||||
// */
|
// */
|
||||||
// @GetMapping("/getAppInfo")
|
// @GetMapping("/getAppInfo")
|
||||||
// public AjaxResult getAppInfo()
|
// public CommonResult getAppInfo()
|
||||||
// {
|
// {
|
||||||
// SysUser user = SecurityUtils.getLoginUser().getUser();
|
// LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||||
// SysUser sysUser = userService.selectUserById(user.getUserId());
|
// AdminUserRespDTO user = userService.getUser(loginUser.getId());
|
||||||
// // 角色集合
|
// // 角色集合
|
||||||
// Set<String> roles = permissionService.getRolePermission(user);
|
// Set<String> roles = permissionService.getRolePermission(NamedObject.user);
|
||||||
// UserBalance userBalance = balanceService.selectShopUserBalanceByUserId(user.getUserId());
|
// UserBalance userBalance = balanceService.selectShopUserBalanceByUserId(NamedObject.user.getUserId());
|
||||||
// if (ObjectUtil.isNotEmpty(userBalance)) {
|
// if (ObjectUtil.isNotEmpty(userBalance)) {
|
||||||
// sysUser.setBalance(userBalance.getBalance());
|
// sysUser.setBalance(userBalance.getBalance());
|
||||||
// } else {
|
// } else {
|
||||||
// //新增用户积分表信息
|
// //新增用户积分表信息
|
||||||
// userBalance=new UserBalance();
|
// userBalance=new UserBalance();
|
||||||
// userBalance.setUserId(user.getUserId());
|
// userBalance.setUserId(NamedObject.user.getUserId());
|
||||||
// userBalance.setAllBalance(0L);
|
// userBalance.setAllBalance(0L);
|
||||||
// userBalance.setBalance(0L);
|
// userBalance.setBalance(0L);
|
||||||
// userBalance.setFrozenBalance(0L);
|
// userBalance.setFrozenBalance(0L);
|
||||||
@ -313,7 +325,7 @@ public class SysLoginController {
|
|||||||
// }
|
// }
|
||||||
// return ajax;
|
// return ajax;
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
/**
|
/**
|
||||||
* 获取App用户信息
|
* 获取App用户信息
|
||||||
*
|
*
|
||||||
@ -327,12 +339,12 @@ public class SysLoginController {
|
|||||||
// 角色集合
|
// 角色集合
|
||||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||||
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
||||||
List<RoleReqDTO> roles = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
List<RoleReqDTO> role = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
||||||
map.put("user", user);
|
map.put("user", user);
|
||||||
map.put("role", roles);
|
map.put("role", role);
|
||||||
if (CollectionUtil.isNotEmpty(roles)){
|
if (CollectionUtil.isNotEmpty(role)){
|
||||||
AtomicBoolean flag = new AtomicBoolean(false);
|
AtomicBoolean flag = new AtomicBoolean(false);
|
||||||
roles.forEach(it->{
|
role.forEach(it->{
|
||||||
if (it.getCode().equals("jcgf")){
|
if (it.getCode().equals("jcgf")){
|
||||||
flag.set(true);
|
flag.set(true);
|
||||||
}
|
}
|
||||||
@ -355,12 +367,12 @@ public class SysLoginController {
|
|||||||
// 角色集合
|
// 角色集合
|
||||||
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
List<RoleReqDTO> roleList = roleApi.getRoleList();
|
||||||
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
List<Long> roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId());
|
||||||
List<RoleReqDTO> roles = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
List<RoleReqDTO> role = roleList.stream().filter(item -> roleIdsByUserId.contains(item.getId())).collect(Collectors.toList());
|
||||||
map.put("user", user);
|
map.put("user", user);
|
||||||
map.put("role", roles);
|
map.put("role", role);
|
||||||
if (CollectionUtil.isNotEmpty(roles)){
|
if (CollectionUtil.isNotEmpty(role)){
|
||||||
AtomicBoolean flag = new AtomicBoolean(false);
|
AtomicBoolean flag = new AtomicBoolean(false);
|
||||||
roles.forEach(it->{
|
role.forEach(it->{
|
||||||
if (it.getCode().equals("jjdd")){
|
if (it.getCode().equals("jjdd")){
|
||||||
flag.set(true);
|
flag.set(true);
|
||||||
}
|
}
|
||||||
@ -454,14 +466,14 @@ public class SysLoginController {
|
|||||||
// * @return 路由信息
|
// * @return 路由信息
|
||||||
// */
|
// */
|
||||||
// @GetMapping("getRouters")
|
// @GetMapping("getRouters")
|
||||||
// public AjaxResult getRouters()
|
// public CommonResult getRouters()
|
||||||
// {
|
// {
|
||||||
// Long userId = SecurityUtils.getUserId();
|
// Long userId = SecurityFrameworkUtils.getLoginUserId();
|
||||||
// List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
// List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
|
||||||
// return AjaxResult.success(menuService.buildMenus(menus));
|
// return AjaxResult.success(menuService.buildMenus(menus));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// @ApiOperation("微信登录")
|
// @ApiOperation("微信登录")
|
||||||
//
|
|
||||||
// @ApiImplicitParams({
|
// @ApiImplicitParams({
|
||||||
// @ApiImplicitParam(name = "WxLoginBody",dataType = "WxLoginBody", value = "jscode", required = true, paramType = "body")
|
// @ApiImplicitParam(name = "WxLoginBody",dataType = "WxLoginBody", value = "jscode", required = true, paramType = "body")
|
||||||
// })
|
// })
|
||||||
@ -548,90 +560,91 @@ public class SysLoginController {
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// @PostMapping("/wxLoginRescue")
|
@PostMapping("/wxLoginRescue")
|
||||||
// public AjaxResult wxLoginRescue(@RequestBody WxLoginBody wxLoginBody) {
|
public CommonResult wxLoginRescue(@RequestBody WxLoginBody wxLoginBody) {
|
||||||
// String code = wxLoginBody.getCode();
|
String code = wxLoginBody.getCode();
|
||||||
// //秘钥
|
//秘钥
|
||||||
// String encryptedIv = wxLoginBody.getEncryptedIv();
|
String encryptedIv = wxLoginBody.getEncryptedIv();
|
||||||
// //加密数据
|
//加密数据
|
||||||
// String encryptedData = wxLoginBody.getEncryptedData();
|
String encryptedData = wxLoginBody.getEncryptedData();
|
||||||
//
|
|
||||||
//
|
|
||||||
// //想微信服务器发送请求获取用户信息
|
//想微信服务器发送请求获取用户信息
|
||||||
// String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + wxConfig.getAppId() + "&secret=" + wxConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";
|
||||||
// System.out.println(url);
|
System.out.println(url);
|
||||||
// String res = restTemplate.getForObject(url, String.class);
|
String res = restTemplate.getForObject(url, String.class);
|
||||||
// JSONObject jsonObject = JSONObject.parseObject(res);
|
JSONObject jsonObject = JSONObject.parseObject(res);
|
||||||
//
|
|
||||||
// //获取session_key和openid
|
//获取session_key和openid
|
||||||
// String sessionKey = jsonObject.getString("session_key");
|
String sessionKey = jsonObject.getString("session_key");
|
||||||
// String openId = jsonObject.getString("openid");
|
String openId = jsonObject.getString("openid");
|
||||||
//
|
|
||||||
// System.out.println(sessionKey);
|
System.out.println(sessionKey);
|
||||||
// System.out.println(openId);
|
System.out.println(openId);
|
||||||
// //解密
|
//解密
|
||||||
// String decryptResult = "";
|
String decryptResult = "";
|
||||||
// try {
|
try {
|
||||||
// //如果没有绑定微信开放平台,解析结果是没有unionid的。
|
//如果没有绑定微信开放平台,解析结果是没有unionid的。
|
||||||
// decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);
|
||||||
// } catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// return AjaxResult.error("微信登录失败!");
|
return error(500, "微信登录失败!");
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// if (StringUtils.hasText(decryptResult)) {
|
if (StringUtils.hasText(decryptResult)) {
|
||||||
|
// TODO 待完成
|
||||||
// //如果解析成功,获取token
|
// //如果解析成功,获取token
|
||||||
// String token = loginService.wxLoginRescue(decryptResult,openId,wxLoginBody.getInviteId());
|
// String token = loginService.wxLoginRescue(decryptResult,openId,wxLoginBody.getInviteId());
|
||||||
// AjaxResult ajax = AjaxResult.success();
|
// AjaxResult ajax = AjaxResult.success();
|
||||||
// ajax.put(Constants.TOKEN, token);
|
// ajax.put(Constants.TOKEN, token);
|
||||||
// return ajax;
|
return error(500, "待完成");
|
||||||
// } else {
|
} else {
|
||||||
// return AjaxResult.error("微信登录失败!");
|
return error(500, "微信登录失败!");
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
//
|
||||||
// /**
|
/**
|
||||||
// * AES解密
|
* AES解密
|
||||||
// */
|
*/
|
||||||
// private String decrypt(String sessionKey,String encryptedIv,String encryptedData) throws Exception{
|
private String decrypt(String sessionKey,String encryptedIv,String encryptedData) throws Exception{
|
||||||
// // 转化为字节数组
|
// 转化为字节数组
|
||||||
// byte[] key = Base64.decode(sessionKey);
|
byte[] key = Base64.decode(sessionKey);
|
||||||
// byte[] iv = Base64.decode(encryptedIv);
|
byte[] iv = Base64.decode(encryptedIv);
|
||||||
// byte[] encData = Base64.decode(encryptedData);
|
byte[] encData = Base64.decode(encryptedData);
|
||||||
// // 如果密钥不足16位,那么就补足
|
// 如果密钥不足16位,那么就补足
|
||||||
// int base =16;
|
int base =16;
|
||||||
// if (key.length % base !=0) {
|
if (key.length % base !=0) {
|
||||||
// int groups = key.length / base +(key.length % base != 0 ? 1 : 0);
|
int groups = key.length / base +(key.length % base != 0 ? 1 : 0);
|
||||||
// byte[] temp = new byte[groups * base];
|
byte[] temp = new byte[groups * base];
|
||||||
// Arrays.fill(temp,(byte) 0);
|
Arrays.fill(temp,(byte) 0);
|
||||||
// System.arraycopy(key,0,temp,0,key.length);
|
System.arraycopy(key,0,temp,0,key.length);
|
||||||
// key = temp;
|
key = temp;
|
||||||
// }
|
}
|
||||||
// // 如果初始向量不足16位,也补足
|
// 如果初始向量不足16位,也补足
|
||||||
// if (iv.length % base !=0) {
|
if (iv.length % base !=0) {
|
||||||
// int groups = iv.length / base +(iv.length % base != 0 ? 1 : 0);
|
int groups = iv.length / base +(iv.length % base != 0 ? 1 : 0);
|
||||||
// byte[] temp = new byte[groups * base];
|
byte[] temp = new byte[groups * base];
|
||||||
// Arrays.fill(temp,(byte) 0);
|
Arrays.fill(temp,(byte) 0);
|
||||||
// System.arraycopy(iv,0,temp,0,iv.length);
|
System.arraycopy(iv,0,temp,0,iv.length);
|
||||||
// iv = temp;
|
iv = temp;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// AlgorithmParameterSpec ivSpec = new IvParameterSpec(iv);
|
AlgorithmParameterSpec ivSpec = new IvParameterSpec(iv);
|
||||||
// String resultStr = null;
|
String resultStr = null;
|
||||||
//
|
|
||||||
// try {
|
try {
|
||||||
// Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
|
||||||
// SecretKeySpec keySpec = new SecretKeySpec(key,"AES");
|
SecretKeySpec keySpec = new SecretKeySpec(key,"AES");
|
||||||
// cipher.init(Cipher.DECRYPT_MODE,keySpec,ivSpec);
|
cipher.init(Cipher.DECRYPT_MODE,keySpec,ivSpec);
|
||||||
// resultStr = new String(cipher.doFinal(encData),"UTF-8");
|
resultStr = new String(cipher.doFinal(encData),"UTF-8");
|
||||||
// } catch (Exception e){
|
} catch (Exception e){
|
||||||
//// logger.info("解析错误");
|
// logger.info("解析错误");
|
||||||
// e.printStackTrace();
|
e.printStackTrace();
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // 解析加密后的字符串
|
// 解析加密后的字符串
|
||||||
// return resultStr;
|
return resultStr;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据
|
* 同步数据
|
||||||
|
@ -10,6 +10,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 【请填写功能名称】对象 rescue_info
|
* 【请填写功能名称】对象 rescue_info
|
||||||
@ -185,6 +186,6 @@ public class RescueInfo extends TenantBaseDO
|
|||||||
private String rescueStartMonth;
|
private String rescueStartMonth;
|
||||||
|
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Long[] roadIds;
|
private List<String> roadIds;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package cn.iocoder.yudao.module.rescue.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class WxLoginBody {
|
||||||
|
/**
|
||||||
|
* 临时登陆凭证 code 只能使用一次
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 偏移量
|
||||||
|
*/
|
||||||
|
private String encryptedIv;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密数据
|
||||||
|
*/
|
||||||
|
private String encryptedData;
|
||||||
|
|
||||||
|
// //邀请码
|
||||||
|
// private Long inviteId;
|
||||||
|
}
|
@ -47,6 +47,8 @@ import javax.annotation.Resource;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUser;
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserDeptId;
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserDeptId;
|
||||||
import static cn.iocoder.yudao.module.rescue.service.impl.RescueDriverInfoServiceImpl.Redis_Driver_Key;
|
import static cn.iocoder.yudao.module.rescue.service.impl.RescueDriverInfoServiceImpl.Redis_Driver_Key;
|
||||||
@ -394,21 +396,22 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
|
|||||||
|
|
||||||
// 自动通知对应路段司机
|
// 自动通知对应路段司机
|
||||||
List<RescueDictStaff> list = rescueDictStaffService.list(new LambdaQueryWrapper<RescueDictStaff>().in(RescueDictStaff::getDictId, rescueInfo.getRoadIds()));
|
List<RescueDictStaff> list = rescueDictStaffService.list(new LambdaQueryWrapper<RescueDictStaff>().in(RescueDictStaff::getDictId, rescueInfo.getRoadIds()));
|
||||||
if (CollectionUtil.isNotEmpty(list)){
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
Set<Long> driverIds = list.stream()
|
throw exception0(500, "该路段没有司机,请先配置");
|
||||||
.map(RescueDictStaff::getDriverIds)
|
|
||||||
.flatMap(item -> Arrays.stream(item.split(",")))
|
|
||||||
.map(Long::parseLong)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
driverIds.forEach(item -> {
|
|
||||||
SysAnnouncement sysAnnouncement = new SysAnnouncement();
|
|
||||||
sysAnnouncement.setType("救援信息");
|
|
||||||
sysAnnouncement.setToUserIds(Collections.singletonList(item));
|
|
||||||
sysAnnouncement.setTitle("有新的救援订单请立即处理");
|
|
||||||
sysAnnouncement.setContent("有新的救援订单请立即处理");
|
|
||||||
announcementService.insertSysAnnouncements(sysAnnouncement);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
Set<Long> driverIds = list.stream()
|
||||||
|
.map(RescueDictStaff::getDriverIds)
|
||||||
|
.flatMap(item -> Arrays.stream(item.split(",")))
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
driverIds.forEach(item -> {
|
||||||
|
SysAnnouncement sysAnnouncement = new SysAnnouncement();
|
||||||
|
sysAnnouncement.setType("救援信息");
|
||||||
|
sysAnnouncement.setToUserIds(Collections.singletonList(item));
|
||||||
|
sysAnnouncement.setTitle("有新的救援订单请立即处理");
|
||||||
|
sysAnnouncement.setContent("有新的救援订单请立即处理");
|
||||||
|
announcementService.insertSysAnnouncements(sysAnnouncement);
|
||||||
|
});
|
||||||
// 新增延迟消息,用于三分钟后没人接单通知
|
// 新增延迟消息,用于三分钟后没人接单通知
|
||||||
TaskDto taskDto = new TaskDto();
|
TaskDto taskDto = new TaskDto();
|
||||||
taskDto.setManageId(loginUser.getId());
|
taskDto.setManageId(loginUser.getId());
|
||||||
@ -430,7 +433,7 @@ public class RescueInfoServiceImpl extends ServiceImpl<RescueInfoMapper, RescueI
|
|||||||
rescueInfo.setRescueStatus(null);
|
rescueInfo.setRescueStatus(null);
|
||||||
}
|
}
|
||||||
// 取消订单时删除定时任务
|
// 取消订单时删除定时任务
|
||||||
if (rescueInfo.getRescueStatus().equals("0")){
|
if (rescueInfo.getRescueStatus().equals("0")) {
|
||||||
redissonDelayQueue.removeAllTasks(rescueInfo.getId());
|
redissonDelayQueue.removeAllTasks(rescueInfo.getId());
|
||||||
}
|
}
|
||||||
return baseMapper.updateById(rescueInfo);
|
return baseMapper.updateById(rescueInfo);
|
||||||
|
@ -83,6 +83,9 @@ public class RedissonDelayQueue {
|
|||||||
|
|
||||||
// TODO 还要通知总调度
|
// TODO 还要通知总调度
|
||||||
|
|
||||||
|
/** 两个值虽然一样,但避免无法删除一直存在问题,干脆重新来过 */
|
||||||
|
// 移除原来的
|
||||||
|
removeAllTasks(taskDto.getRescueInfoId());
|
||||||
// 在新创建定时任务
|
// 在新创建定时任务
|
||||||
offerTask(task, UserConstants.RESCUE_TIME);
|
offerTask(task, UserConstants.RESCUE_TIME);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -0,0 +1,146 @@
|
|||||||
|
package cn.iocoder.yudao.module.rescue.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.rescue.core.redis.RedisCache;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.api.user.dto.UserDTO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.thoughtworks.xstream.core.SecurityUtils;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RescueSysLoginService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AdminUserApi adminUserApi;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
@Lazy
|
||||||
|
private RedisCache redisCache2;
|
||||||
|
|
||||||
|
public CommonResult loginSmsCode(String phone){
|
||||||
|
String msg;
|
||||||
|
AdminUserDO userDO = new AdminUserDO();
|
||||||
|
userDO.setMobile(phone);
|
||||||
|
if (ObjectUtil.isEmpty(adminUserApi.getUserByMobile(phone))){
|
||||||
|
msg = "手机号'" + phone + "不存在请先注册";
|
||||||
|
return error(500, msg);
|
||||||
|
}
|
||||||
|
String msgCode = generateVerificationCode();
|
||||||
|
redisCache2.setCacheObject(phone+"-loginCode",msgCode,300, TimeUnit.SECONDS);
|
||||||
|
SendSmsUtil.sendMsg(msgCode,phone,"1400852709","机动车管家小程序","1917285");
|
||||||
|
return success("验证码成功生成");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String generateVerificationCode() {
|
||||||
|
// 设置验证码长度
|
||||||
|
int codeLength = 6;
|
||||||
|
// 设置验证码字符源
|
||||||
|
String codeSource = "0123456789";
|
||||||
|
// 生成随机数对象
|
||||||
|
Random random = new Random();
|
||||||
|
StringBuilder verificationCode = new StringBuilder();
|
||||||
|
|
||||||
|
// 随机生成验证码
|
||||||
|
for (int i = 0; i < codeLength; i++) {
|
||||||
|
int index = random.nextInt(codeSource.length());
|
||||||
|
char codeChar = codeSource.charAt(index);
|
||||||
|
verificationCode.append(codeChar);
|
||||||
|
}
|
||||||
|
|
||||||
|
return verificationCode.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommonResult pwdSmsCode(String phone) {
|
||||||
|
String msg;
|
||||||
|
AdminUserDO userDO = new AdminUserDO();
|
||||||
|
userDO.setMobile(phone);
|
||||||
|
if (ObjectUtil.isNotEmpty(adminUserApi.getUserByMobile(phone))){
|
||||||
|
msg = "手机号" + phone + "不存在";
|
||||||
|
return error(500, msg);
|
||||||
|
}
|
||||||
|
String msgCode = generateVerificationCode();
|
||||||
|
redisCache2.setCacheObject(phone+"-pwdCode",msgCode,300, TimeUnit.SECONDS);
|
||||||
|
SendSmsUtil.sendMsg(msgCode,phone,"1400852709","机动车管家小程序","1917285");
|
||||||
|
return success("验证码成功生成");
|
||||||
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 检测模块微信登录
|
||||||
|
// *
|
||||||
|
// * @param decryptResult 登录凭证 只能用一次
|
||||||
|
// * @return
|
||||||
|
// */
|
||||||
|
// public String wxLoginRescue(String decryptResult,String openId,Long inviteId){
|
||||||
|
// //字符串转json
|
||||||
|
// JSONObject jsonObject = JSONObject.parseObject(decryptResult);
|
||||||
|
// System.out.println(jsonObject);
|
||||||
|
// System.out.println("openId"+openId);
|
||||||
|
// String phoneNumber = jsonObject.getString("phoneNumber");
|
||||||
|
// //还可以获取其他信息
|
||||||
|
// //根据openid判断数据库中是否有该用户
|
||||||
|
// //根据openid查询用户信息
|
||||||
|
// AdminUserRespDTO wxUser = adminUserApi.getUserByMobile(phoneNumber);
|
||||||
|
// //如果查不到,则新增,查到了,则更新
|
||||||
|
// UserDTO user = new UserDTO();
|
||||||
|
// if (wxUser == null) {
|
||||||
|
// // 新增
|
||||||
|
// user.setUsername(phoneNumber);
|
||||||
|
// user.setNickname(phoneNumber);
|
||||||
|
// user.setMobile(phoneNumber);
|
||||||
|
// user.setPassword(SecurityUtils.encryptPassword("654321"));
|
||||||
|
// user.setRescueOpenId(openId);
|
||||||
|
// user.setCreateTime(DateUtils.getNowDate());
|
||||||
|
// if (null!=inviteId){
|
||||||
|
//
|
||||||
|
// //绑定上级
|
||||||
|
// user.setInviteId(inviteId);
|
||||||
|
// //给上级进行积分奖励
|
||||||
|
// userBalanceService.inviteRewards(inviteId);
|
||||||
|
// }
|
||||||
|
// //新增 用户
|
||||||
|
// SysRole role = roleService.selectRoleByCode("jcyh");
|
||||||
|
// user.setRoleIds(new Long[]{role.getRoleId()});
|
||||||
|
// user.setDeptId(100L);
|
||||||
|
// userService.insertUser(user);
|
||||||
|
// }else {
|
||||||
|
// //更新
|
||||||
|
// user = wxUser;
|
||||||
|
// user.setNickName(phoneNumber);
|
||||||
|
// user.setPhonenumber(phoneNumber);
|
||||||
|
// user.setRescueOpenId(openId);
|
||||||
|
// user.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
// if (ObjectUtil.isEmpty(user.getInviteId())){
|
||||||
|
// if (null!=inviteId){
|
||||||
|
// //绑定上级
|
||||||
|
// user.setInviteId(inviteId);
|
||||||
|
// //给上级进行积分奖励
|
||||||
|
// userBalanceService.inviteRewards(inviteId);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// userMapper.updateUser(user);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //组装token信息
|
||||||
|
// LoginUser loginUser = new LoginUser();
|
||||||
|
// loginUser.setOpenId(openId);
|
||||||
|
// //如果有的话设置
|
||||||
|
// loginUser.setUser(user);
|
||||||
|
// loginUser.setUserId(user.getUserId());
|
||||||
|
//
|
||||||
|
// // 生成token
|
||||||
|
// return tokenService.createToken(loginUser);
|
||||||
|
// }
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
package cn.iocoder.yudao.module.rescue.utils;
|
||||||
|
|
||||||
|
import com.tencentcloudapi.common.Credential;
|
||||||
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
||||||
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
||||||
|
import com.tencentcloudapi.common.profile.HttpProfile;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.SmsClient;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.models.SendSmsRequest;
|
||||||
|
import com.tencentcloudapi.sms.v20210111.models.SendSmsResponse;
|
||||||
|
|
||||||
|
public class SendSmsUtil {
|
||||||
|
public static void sendMsg(String code,String phoneNum,String sdkAppId,String signName,String templateId){
|
||||||
|
|
||||||
|
try{
|
||||||
|
Credential cred = new Credential("AKIDQlz4xdAaypV0MYkv1AMRRKSdw350qW2x", "oRv221ymOsBMOMBwAHF4f2GJC6tX6Wnv");
|
||||||
|
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||||
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
|
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
||||||
|
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||||
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
|
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||||
|
SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
||||||
|
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||||
|
SendSmsRequest req = new SendSmsRequest();
|
||||||
|
String[] phoneNumberSet1 = {phoneNum};
|
||||||
|
req.setPhoneNumberSet(phoneNumberSet1);
|
||||||
|
|
||||||
|
req.setSmsSdkAppId(sdkAppId);
|
||||||
|
req.setSignName(signName);
|
||||||
|
req.setTemplateId(templateId);
|
||||||
|
String[] templateParamSet1 = {code};
|
||||||
|
req.setTemplateParamSet(templateParamSet1);
|
||||||
|
// 返回的resp是一个SendSmsResponse的实例,与请求对象对应
|
||||||
|
SendSmsResponse resp = client.SendSms(req);
|
||||||
|
// 输出json格式的字符串回包
|
||||||
|
System.out.println(SendSmsResponse.toJsonString(resp));
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
System.out.println(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void sendMsgCommon(String[] templateParamSet,String phoneNum,String sdkAppId,String signName,String templateId){
|
||||||
|
|
||||||
|
try{
|
||||||
|
Credential cred = new Credential("AKIDQlz4xdAaypV0MYkv1AMRRKSdw350qW2x", "oRv221ymOsBMOMBwAHF4f2GJC6tX6Wnv");
|
||||||
|
// 实例化一个http选项,可选的,没有特殊需求可以跳过
|
||||||
|
HttpProfile httpProfile = new HttpProfile();
|
||||||
|
httpProfile.setEndpoint("sms.tencentcloudapi.com");
|
||||||
|
// 实例化一个client选项,可选的,没有特殊需求可以跳过
|
||||||
|
ClientProfile clientProfile = new ClientProfile();
|
||||||
|
clientProfile.setHttpProfile(httpProfile);
|
||||||
|
// 实例化要请求产品的client对象,clientProfile是可选的
|
||||||
|
SmsClient client = new SmsClient(cred, "ap-guangzhou", clientProfile);
|
||||||
|
// 实例化一个请求对象,每个接口都会对应一个request对象
|
||||||
|
SendSmsRequest req = new SendSmsRequest();
|
||||||
|
String[] phoneNumberSet1 = {phoneNum};
|
||||||
|
req.setPhoneNumberSet(phoneNumberSet1);
|
||||||
|
|
||||||
|
req.setSmsSdkAppId(sdkAppId);
|
||||||
|
req.setSignName(signName);
|
||||||
|
req.setTemplateId(templateId);
|
||||||
|
req.setTemplateParamSet(templateParamSet);
|
||||||
|
// 返回的resp是一个SendSmsResponse的实例,与请求对象对应
|
||||||
|
SendSmsResponse resp = client.SendSms(req);
|
||||||
|
// 输出json格式的字符串回包
|
||||||
|
System.out.println(SendSmsResponse.toJsonString(resp));
|
||||||
|
} catch (TencentCloudSDKException e) {
|
||||||
|
System.out.println(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user