|
@@ -593,6 +593,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
if (vciInfo == null) {
|
|
if (vciInfo == null) {
|
|
return Result.error().message("VCI设备不存在").result(ResultCode.SERVICE_HANDLE_ERROR);
|
|
return Result.error().message("VCI设备不存在").result(ResultCode.SERVICE_HANDLE_ERROR);
|
|
}
|
|
}
|
|
|
|
+ UserVci one = userVciService.lambdaQuery()
|
|
|
|
+ .eq(UserVci::getUserId, userId)
|
|
|
|
+ .eq(UserVci::getVciInfoId, vciInfo.getId())
|
|
|
|
+ .one();
|
|
|
|
+ if (BeanUtil.isNotEmpty(one)) {
|
|
|
|
+ throw new BadReqException("该vci设备已被该用户绑定");
|
|
|
|
+ }
|
|
|
|
+
|
|
UserVci userVci = new UserVci();
|
|
UserVci userVci = new UserVci();
|
|
userVci.setUserId(userId);
|
|
userVci.setUserId(userId);
|
|
userVci.setVciInfoId(vciInfo.getId());
|
|
userVci.setVciInfoId(vciInfo.getId());
|
|
@@ -613,11 +621,39 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
List<UserVci> list = userVciService.lambdaQuery()
|
|
List<UserVci> list = userVciService.lambdaQuery()
|
|
.eq(UserVci::getUserId, userId)
|
|
.eq(UserVci::getUserId, userId)
|
|
.list();
|
|
.list();
|
|
- if (list.isEmpty()) {
|
|
|
|
- return Result.ok();
|
|
|
|
|
|
+ List<VciInfo> vciInfoList = new ArrayList<>();
|
|
|
|
+ if (!list.isEmpty()) {
|
|
|
|
+ List<Integer> vciIds = list.stream().map(c -> c.getVciInfoId()).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ vciInfoList = vciInfoService.listByIds(vciIds);
|
|
|
|
+ }
|
|
|
|
+ return Result.ok(vciInfoList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result relieveVci(AppBindVO bindVO) {
|
|
|
|
+ if (BeanUtil.isEmpty(bindVO)) {
|
|
|
|
+ return Result.error().message("参数为空").result(ResultCode.NO_DATA);
|
|
|
|
+ }
|
|
|
|
+ Integer userId = bindVO.getUserId();
|
|
|
|
+ String vciNum = bindVO.getVciSn();
|
|
|
|
+ LambdaQueryWrapper<VciInfo> vciInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ vciInfoLambdaQueryWrapper.eq(VciInfo::getVciNum, vciNum);
|
|
|
|
+ VciInfo vciInfo = vciInfoService.getOne(vciInfoLambdaQueryWrapper);
|
|
|
|
+ if (vciInfo == null) {
|
|
|
|
+ return Result.error().message("VCI设备不存在").result(ResultCode.SERVICE_HANDLE_ERROR);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ UserVci one = userVciService.lambdaQuery()
|
|
|
|
+ .eq(UserVci::getUserId, userId)
|
|
|
|
+ .eq(UserVci::getVciInfoId, vciInfo.getId())
|
|
|
|
+ .one();
|
|
|
|
+ if (BeanUtil.isEmpty(one)) {
|
|
|
|
+ throw new BadReqException("该客户端账号没有绑定该vci设备");
|
|
|
|
+ }
|
|
|
|
+ this.removeById(one.getId());
|
|
|
|
|
|
- return null;
|
|
|
|
|
|
+ return Result.ok();
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|