feat(后端): 联调修改10
parent
c1ddd33cf4
commit
3ed1ee5549
|
@ -14,6 +14,7 @@ import com.unisinsight.project.service.DeviceImageMappingService;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -47,10 +48,20 @@ public class DeviceImageMappingController {
|
|||
}
|
||||
log.info("终端镜像映射新增请求参数为:{}", JSONUtil.toJsonStr(deviceImageMappingReq));
|
||||
|
||||
QueryWrapper<DeviceImageMapping> wrapper = new QueryWrapper<>();
|
||||
if (CollectionUtil.isEmpty(deviceImageMappingReq.getData()) && ObjectUtils.isNotEmpty(deviceImageMappingReq.getDeviceId())) {
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceId, deviceImageMappingReq.getDeviceId());
|
||||
List<DeviceImageMapping> list = deviceImageMappingService.list(wrapper);
|
||||
List<Long> collect = list.stream().map(DeviceImageMapping::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
boolean removedByIds = deviceImageMappingService.removeByIds(collect);
|
||||
log.info("终端镜像映射新增接口删除了 {} 条旧数据,ID列表: {}", removedByIds, collect);
|
||||
}
|
||||
return Result.successResult();
|
||||
}
|
||||
List<DeviceImageMappingReq> reqData = deviceImageMappingReq.getData();
|
||||
List<DeviceImageMappingReq> addList = reqData.stream().distinct().filter(e -> Objects.isNull(e.getId())).collect(Collectors.toList());
|
||||
|
||||
QueryWrapper<DeviceImageMapping> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DeviceImageMapping::getDeviceId, reqData.get(0).getDeviceId());
|
||||
List<DeviceImageMapping> list = deviceImageMappingService.list(wrapper);
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.unisinsight.project.service.DeviceUserMappingService;
|
|||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
@ -46,10 +47,20 @@ public class DeviceUserMappingController {
|
|||
return Result.errorResult(BaseErrorCode.PARAMETERS_INVALID);
|
||||
}
|
||||
log.info("终端用户映射新增请求参数为:{}", JSONUtil.toJsonStr(deviceUserMappingReq));
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
if (CollectionUtil.isEmpty(deviceUserMappingReq.getData()) && ObjectUtils.isNotEmpty(deviceUserMappingReq.getDeviceId())) {
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, deviceUserMappingReq.getDeviceId());
|
||||
List<DeviceUserMapping> list = deviceUserMappingService.list(wrapper);
|
||||
List<Long> collect = list.stream().map(DeviceUserMapping::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
boolean removedByIds = deviceUserMappingService.removeByIds(collect);
|
||||
log.info("终端用户映射新增接口删除了 {} 条旧数据,ID列表: {}", removedByIds, collect);
|
||||
}
|
||||
return Result.successResult();
|
||||
}
|
||||
List<DeviceUserMappingReq> userMappingReqData = deviceUserMappingReq.getData();
|
||||
List<DeviceUserMappingReq> addList = userMappingReqData.stream().distinct().filter(e -> Objects.isNull(e.getId())).collect(Collectors.toList());
|
||||
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, userMappingReqData.get(0).getDeviceId());
|
||||
List<DeviceUserMapping> list = deviceUserMappingService.list(wrapper);
|
||||
|
||||
|
|
|
@ -20,4 +20,12 @@ public class ListReq<T> {
|
|||
@JsonProperty("data")
|
||||
private List<T> data;
|
||||
|
||||
/**
|
||||
* 序列号
|
||||
*/
|
||||
@ApiModelProperty("序列号")
|
||||
@JsonProperty("device_id")
|
||||
private String deviceId;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|||
import com.unisinsight.project.entity.dao.DeviceImageMapping;
|
||||
import com.unisinsight.project.entity.dao.Image;
|
||||
import com.unisinsight.project.entity.res.ImageRes;
|
||||
import com.unisinsight.project.exception.BaseErrorCode;
|
||||
import com.unisinsight.project.exception.Result;
|
||||
import com.unisinsight.project.mapper.DeviceImageMappingMapper;
|
||||
import com.unisinsight.project.mapper.ImageMapper;
|
||||
|
@ -18,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -44,12 +44,13 @@ public class ClientServiceImpl implements ClientService {
|
|||
|
||||
@Override
|
||||
public Result<?> getImageList(String deviceId, String token) {
|
||||
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
QueryWrapper<DeviceImageMapping> deviceImageMappingQueryWrapper = new QueryWrapper<>();
|
||||
deviceImageMappingQueryWrapper.lambda().eq(DeviceImageMapping::getDeviceId, deviceId);
|
||||
List<DeviceImageMapping> deviceImageMappings = deviceImageMappingMapper.selectList(deviceImageMappingQueryWrapper);
|
||||
if (CollectionUtil.isEmpty(deviceImageMappings)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "请先配置终端镜像");
|
||||
hashMap.put("list", new ArrayList<>());
|
||||
return Result.successResult(hashMap);
|
||||
}
|
||||
List<Long> imageIdList = deviceImageMappings.stream().map(DeviceImageMapping::getImageId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(imageIdList)) {
|
||||
|
@ -59,25 +60,28 @@ public class ClientServiceImpl implements ClientService {
|
|||
log.info("用户登录查询镜像结果:{}", JSONUtil.toJsonStr(images));
|
||||
List<ImageRes> imageRes = BeanUtil.copyToList(images, ImageRes.class);
|
||||
List<HashMap<String, Object>> collect = imageRes.stream().distinct().map(e -> {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
if (StringUtils.isNotBlank(e.getImageName())) {
|
||||
hashMap.put("name", e.getImageName());
|
||||
map.put("name", e.getImageName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(e.getBtPath())) {
|
||||
if (e.getBtPath().contains("http://") || e.getBtPath().contains("https://")) {
|
||||
hashMap.put("torrent", e.getBtPath());
|
||||
map.put("torrent", e.getBtPath());
|
||||
} else {
|
||||
String fileName = e.getBtPath().substring(Math.max(e.getBtPath().lastIndexOf("\\"), e.getBtPath().lastIndexOf("/")) + 1);
|
||||
hashMap.put("torrent", btUrl + "/api/vdi/file/down/" + fileName);
|
||||
map.put("torrent", btUrl + "/api/vdi/file/down/" + fileName);
|
||||
}
|
||||
}
|
||||
return hashMap;
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("list", collect);
|
||||
return Result.successResult(hashMap);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(collect)) {
|
||||
hashMap.put("list", collect);
|
||||
} else {
|
||||
hashMap.put("list", new ArrayList<>());
|
||||
}
|
||||
}
|
||||
return Result.successResult();
|
||||
return Result.successResult(hashMap);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -119,12 +119,20 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
|
||||
@Override
|
||||
public Result<?> loginUser(DeviceUserReq deviceUserReq) {
|
||||
|
||||
QueryWrapper<User> userQueryWrapper = new QueryWrapper<>();
|
||||
userQueryWrapper.lambda().in(User::getUserName, deviceUserReq.getUserName());
|
||||
List<User> userList1 = userMapper.selectList(userQueryWrapper);
|
||||
log.info("登录查询用户结果:{}", JSONUtil.toJsonStr(userList1));
|
||||
if (CollectionUtil.isEmpty(userList1)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "用户不存在");
|
||||
}
|
||||
QueryWrapper<DeviceUserMapping> wrapper = new QueryWrapper<>();
|
||||
wrapper.lambda().eq(DeviceUserMapping::getDeviceId, deviceUserReq.getDeviceId());
|
||||
List<DeviceUserMapping> deviceUserMappings = deviceUserMappingMapper.selectList(wrapper);
|
||||
log.info("用户登录查询映射结果:{}", JSONUtil.toJsonStr(deviceUserMappings));
|
||||
List<User> users = new ArrayList<>();
|
||||
|
||||
List<User> users = new ArrayList<>();
|
||||
List<Long> userIdList = deviceUserMappings.stream().map(DeviceUserMapping::getUserId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
log.info("用户登录查询用户id结果:{}", JSONUtil.toJsonStr(userIdList));
|
||||
if (CollectionUtil.isNotEmpty(userIdList)) {
|
||||
|
@ -152,11 +160,11 @@ public class DeviceUserMappingServiceImpl extends ServiceImpl<DeviceUserMappingM
|
|||
}
|
||||
log.info("用户登录查询结果:{}", JSONUtil.toJsonStr(users));
|
||||
if (CollectionUtil.isEmpty(users)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "用户不存在,请重试");
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "当前用户无权限登录终端,请联系管理员");
|
||||
}
|
||||
users = users.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isEmpty(users)) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "用户不存在,请重试");
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "当前用户无权限登录终端,请联系管理员");
|
||||
}
|
||||
if (!users.get(0).getPassword().equals(deviceUserReq.getPassword())) {
|
||||
return Result.errorResultMessage(BaseErrorCode.PARAMS_CHK_ERROR, "密码错误,请重新输入");
|
||||
|
|
Loading…
Reference in New Issue