|
|
@@ -1,14 +1,26 @@
|
|
|
package com.xunmei.iot.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.lang.UUID;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xunmei.common.core.constant.SecurityConstants;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotServerInfo;
|
|
|
import com.xunmei.common.core.web.page.TableDataInfo;
|
|
|
+import com.xunmei.common.security.utils.SecurityUtils;
|
|
|
+import com.xunmei.iot.dto.serverInfo.IotServerInfoAddDto;
|
|
|
import com.xunmei.iot.dto.serverInfo.IotServerInfoPageDto;
|
|
|
import com.xunmei.iot.mapper.IotServerInfoMapper;
|
|
|
import com.xunmei.iot.service.IotServerInfoService;
|
|
|
import com.xunmei.iot.vo.serverInfo.IotServerInfoPageVo;
|
|
|
+import com.xunmei.system.api.RemoteOrgService;
|
|
|
+import com.xunmei.system.api.domain.SysOrg;
|
|
|
+import lombok.val;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -21,10 +33,36 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class IotServerInfoServiceImpl extends ServiceImpl<IotServerInfoMapper, IotServerInfo> implements IotServerInfoService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RemoteOrgService orgService;
|
|
|
|
|
|
@Override
|
|
|
public TableDataInfo<IotServerInfoPageVo> serverPage(IotServerInfoPageDto request) {
|
|
|
+ if (request.getCheckSub()){
|
|
|
+ SysOrg sysOrg = orgService.selectOrgById(request.getOrgId(), SecurityConstants.INNER);
|
|
|
+ request.setOrgPath(sysOrg.getPath());
|
|
|
+ }
|
|
|
Page<IotServerInfoPageVo> page = baseMapper.selectServerPage(request.getPageRequest(),request);
|
|
|
return TableDataInfo.build(page);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public int addIotServer(IotServerInfoAddDto req) {
|
|
|
+ SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
+ val serverInfo = new IotServerInfo();
|
|
|
+ serverInfo.setIotCode(UUID.fastUUID().toString());
|
|
|
+ serverInfo.setIotName(req.getIotName());
|
|
|
+ serverInfo.setIotStatus(0);
|
|
|
+ serverInfo.setOrgPath(sysOrg.getPath());
|
|
|
+ serverInfo.setOrgName(sysOrg.getShortName());
|
|
|
+ serverInfo.setOrgId(sysOrg.getId());
|
|
|
+ serverInfo.setId(IdWorker.getId());
|
|
|
+ serverInfo.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
|
|
|
+ serverInfo.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getId().toString());
|
|
|
+ serverInfo.setCreateTime(LocalDateTime.now());
|
|
|
+ serverInfo.setUpdateTime(LocalDateTime.now());
|
|
|
+ return baseMapper.insert(serverInfo);
|
|
|
+ }
|
|
|
}
|