|
@@ -10,10 +10,12 @@ import com.om.entity.dto.*;
|
|
|
import com.om.entity.po.*;
|
|
|
import com.om.entity.vo.*;
|
|
|
import com.om.exception.BadReqException;
|
|
|
+import com.om.exception.BizException;
|
|
|
import com.om.exception.CustomerAuthenticationException;
|
|
|
import com.om.mapper.UserMapper;
|
|
|
import com.om.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.om.utils.AesUtil;
|
|
|
import com.om.utils.JwtUtils;
|
|
|
import com.om.utils.Result;
|
|
|
import com.om.utils.UserContext;
|
|
@@ -96,7 +98,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
|
|
|
|
|
|
//密码加密
|
|
|
- password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
|
+ try {
|
|
|
+ password = AesUtil.Encrypt(password);
|
|
|
+ System.out.println(password);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("密码加密出错");
|
|
|
+ }
|
|
|
//判断密码是否正确
|
|
|
if (!password.equals(user.getPassword())) {
|
|
|
throw new BadReqException("密码错误");
|
|
@@ -121,8 +128,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
claims.put("deviceSn", deviceSn);
|
|
|
claims.put("appVersion", appVersion);
|
|
|
claims.put("clientNum", clientNum);
|
|
|
- String guid = jwtUtils.generateToken(claims);
|
|
|
|
|
|
+ String guid = AesUtil.generateGuid(claims);
|
|
|
//封装vo返回
|
|
|
UserLoginVO userLoginVO = new UserLoginVO();
|
|
|
// 查询 该用户所属的 维修厂
|
|
@@ -145,10 +152,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
userLoginVO.setVciSn(vciInfo.getVciNum());
|
|
|
}
|
|
|
vciInfoVO.setVciNum(vciInfo.getVciNum());
|
|
|
- vciInfoVO.setState(vciInfo.getState());
|
|
|
+ vciInfoVO.setState(String.valueOf(vciInfo.getState()));
|
|
|
vciInfoVO.setPairingPwd(vciInfo.getPairingPwd());
|
|
|
vciInfoVO.setBluetoothAddress(vciInfo.getBluetoothAddress());
|
|
|
- vciInfoVO.setIsDefault(userVci.getIsDefault());
|
|
|
+ vciInfoVO.setIsDefault(String.valueOf(userVci.getIsDefault()));
|
|
|
|
|
|
vciInfoVOList.add(vciInfoVO);
|
|
|
}
|
|
@@ -300,14 +307,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
throw new BadReqException("参数为空");
|
|
|
}
|
|
|
String guid = dto.getGuid();
|
|
|
- GuidDTO guidDTO = jwtUtils.getGuidDTOFromToken(guid);
|
|
|
+ GuidDTO guidDTO = AesUtil.getGuidDTOFromGuid(guid);
|
|
|
+
|
|
|
Integer userId = guidDTO.getUserId();
|
|
|
|
|
|
User user = getById(userId);
|
|
|
if (user == null) {
|
|
|
return Result.error();
|
|
|
}
|
|
|
- user.setPassword(DigestUtils.md5DigestAsHex(dto.getNewPassword().getBytes()));
|
|
|
+ try {
|
|
|
+ user.setPassword(AesUtil.Encrypt(dto.getNewPassword()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("密码加密出错");
|
|
|
+ }
|
|
|
this.updateById(user);
|
|
|
|
|
|
|
|
@@ -318,10 +330,17 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
public Result register(UserLoginDTO userLoginDTO) {
|
|
|
User user = new User();
|
|
|
if (userLoginDTO.getUsername() == null || userLoginDTO.getPassword() == null) {
|
|
|
- return Result.error();
|
|
|
+ return Result.error().message("用户名密码为空");
|
|
|
+ }
|
|
|
+ if (userLoginDTO.getPassword().equals(userLoginDTO.getRePassword())){
|
|
|
+ return Result.error().message("两次密码不一样");
|
|
|
}
|
|
|
user.setUsername(userLoginDTO.getUsername());
|
|
|
- user.setPassword(userLoginDTO.getPassword());
|
|
|
+ try {
|
|
|
+ user.setPassword(AesUtil.Encrypt(userLoginDTO.getPassword()));
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("密码加密出错");
|
|
|
+ }
|
|
|
boolean save = save(user);
|
|
|
if (!save) {
|
|
|
return Result.error();
|
|
@@ -332,7 +351,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Override
|
|
|
public Result updateUserName(AppBaseDTO dto) {
|
|
|
String guid = dto.getGuid();
|
|
|
- GuidDTO guidDTO = jwtUtils.getGuidDTOFromToken(guid);
|
|
|
+ GuidDTO guidDTO = AesUtil.getGuidDTOFromGuid(guid);
|
|
|
Integer userId = guidDTO.getUserId();
|
|
|
|
|
|
User user = getById(userId);
|
|
@@ -373,7 +392,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
throw new BadReqException("参数为空");
|
|
|
}
|
|
|
String guid = dto.getGuid();
|
|
|
- GuidDTO guidDTO = jwtUtils.getGuidDTOFromToken(guid);
|
|
|
+ GuidDTO guidDTO = AesUtil.getGuidDTOFromGuid(guid);
|
|
|
Integer userId = guidDTO.getUserId();
|
|
|
String vciSn = dto.getVciSn();
|
|
|
VciInfo vciInfo = vciInfoService.lambdaQuery()
|