服务管理
This commit is contained in:
+1
-1
@@ -79,7 +79,7 @@ public class KeyInfoAsymController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/createCsr")
|
||||
public R<KeyInfoDTO.CreateCSRResp> createCsr(KeyInfoDTO.CreateCsr createCsr) {
|
||||
public R<KeyInfoDTO.CreateCSRResp> createCsr(@Valid @RequestBody KeyInfoDTO.CreateCsr createCsr) {
|
||||
|
||||
String csr = keyInfoService.createCsr(createCsr);
|
||||
|
||||
|
||||
+40
-7
@@ -8,10 +8,12 @@ import com.sunyard.chsm.dto.CryptoServiceDTO;
|
||||
import com.sunyard.chsm.enums.ApiFunEnum;
|
||||
import com.sunyard.chsm.enums.EnableStatus;
|
||||
import com.sunyard.chsm.mapper.CryptoServiceApiMapper;
|
||||
import com.sunyard.chsm.mapper.CryptoServiceDeviceGroupMapper;
|
||||
import com.sunyard.chsm.mapper.CryptoServiceMapper;
|
||||
import com.sunyard.chsm.mapper.SpDeviceGroupMapper;
|
||||
import com.sunyard.chsm.model.entity.CryptoService;
|
||||
import com.sunyard.chsm.model.entity.CryptoServiceApi;
|
||||
import com.sunyard.chsm.model.entity.CryptoServiceDeviceGroup;
|
||||
import com.sunyard.chsm.model.entity.DeviceGroup;
|
||||
import com.sunyard.chsm.service.CryptoServiceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -47,6 +49,8 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
@Resource
|
||||
private CryptoServiceApiMapper cryptoServiceApiMapper;
|
||||
@Resource
|
||||
private CryptoServiceDeviceGroupMapper cryptoServiceDeviceGroupMapper;
|
||||
@Resource
|
||||
private SpDeviceGroupMapper spDeviceGroupMapper;
|
||||
|
||||
@Override
|
||||
@@ -64,8 +68,12 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
return new Page<>(servicePage.getCurrent(), servicePage.getSize(), servicePage.getTotal());
|
||||
}
|
||||
|
||||
// service api
|
||||
List<Long> ids = records.stream().map(CryptoService::getId).collect(Collectors.toList());
|
||||
|
||||
List<CryptoServiceDeviceGroup> dgs = cryptoServiceDeviceGroupMapper.selectByServiceIds(ids);
|
||||
Map<Long, List<CryptoServiceDeviceGroup>> serviceDgMap = dgs.stream().collect(Collectors.groupingBy(CryptoServiceDeviceGroup::getServiceId));
|
||||
|
||||
// service ap
|
||||
LambdaQueryWrapper<CryptoServiceApi> apiQuery = new LambdaQueryWrapper<CryptoServiceApi>()
|
||||
.in(CryptoServiceApi::getCryptoServiceId, ids);
|
||||
List<CryptoServiceApi> allServiceApis = cryptoServiceApiMapper.selectList(apiQuery);
|
||||
@@ -73,7 +81,6 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
Map<Long, List<CryptoServiceApi>> serviceApiMap = allServiceApis.stream()
|
||||
.collect(Collectors.groupingBy(CryptoServiceApi::getCryptoServiceId));
|
||||
|
||||
|
||||
List<CryptoServiceDTO.CSView> viewList = records.stream()
|
||||
.map(it -> {
|
||||
CryptoServiceDTO.CSView view = new CryptoServiceDTO.CSView();
|
||||
@@ -81,6 +88,13 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
Optional.ofNullable(EnableStatus.of(it.getStatus()))
|
||||
.map(EnableStatus::getDesc)
|
||||
.ifPresent(view::setStatusDesc);
|
||||
List<CryptoServiceDeviceGroup> dgList = serviceDgMap.getOrDefault(it.getId(), Collections.emptyList());
|
||||
if (!CollectionUtils.isEmpty(dgList)) {
|
||||
CryptoServiceDeviceGroup next = dgList.iterator().next();
|
||||
view.setDeviceGroupId(next.getDeviceGroupId());
|
||||
view.setDeviceGroupName(next.getDeviceGroupName());
|
||||
}
|
||||
|
||||
List<CryptoServiceApi> serviceApis = serviceApiMap.getOrDefault(it.getId(), Collections.emptyList());
|
||||
List<String> groupCodes = serviceApis.stream().map(CryptoServiceApi::getApiGroup)
|
||||
.distinct().collect(Collectors.toList());
|
||||
@@ -112,8 +126,16 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
|
||||
DeviceGroup deviceGroup = spDeviceGroupMapper.selectById(save.getDeviceGroupId());
|
||||
Assert.notNull(deviceGroup, "设备组不存在");
|
||||
service.setDeviceGroupId(save.getDeviceGroupId());
|
||||
service.setDeviceGroupName(deviceGroup.getName());
|
||||
|
||||
CryptoServiceDeviceGroup csDg = new CryptoServiceDeviceGroup();
|
||||
csDg.setId(IdWorker.getId());
|
||||
csDg.setServiceId(service.getId());
|
||||
csDg.setDeviceGroupId(deviceGroup.getId());
|
||||
csDg.setDeviceGroupName(deviceGroup.getName());
|
||||
cryptoServiceDeviceGroupMapper.insert(csDg);
|
||||
|
||||
// service.setDeviceGroupId(save.getDeviceGroupId());
|
||||
// service.setDeviceGroupName(deviceGroup.getName());
|
||||
|
||||
service.setStatus(EnableStatus.ENABLED.getCode());
|
||||
service.setRemark(save.getRemark());
|
||||
@@ -135,11 +157,21 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
CryptoService up = new CryptoService();
|
||||
up.setId(update.getId());
|
||||
up.setName(update.getName());
|
||||
if (!Objects.equals(update.getDeviceGroupId(), exist.getDeviceGroupId())) {
|
||||
|
||||
CryptoServiceDeviceGroup existDg = cryptoServiceDeviceGroupMapper.selectByServiceId(exist.getId());
|
||||
if (existDg == null || !Objects.equals(update.getDeviceGroupId(), existDg.getDeviceGroupId())) {
|
||||
DeviceGroup deviceGroup = spDeviceGroupMapper.selectById(update.getDeviceGroupId());
|
||||
Assert.notNull(deviceGroup, "设备组不存在");
|
||||
up.setDeviceGroupId(update.getDeviceGroupId());
|
||||
up.setDeviceGroupName(deviceGroup.getName());
|
||||
|
||||
cryptoServiceDeviceGroupMapper.deleteByServiceId(exist.getId());
|
||||
CryptoServiceDeviceGroup csDg = new CryptoServiceDeviceGroup();
|
||||
csDg.setId(IdWorker.getId());
|
||||
csDg.setServiceId(exist.getId());
|
||||
csDg.setDeviceGroupId(deviceGroup.getId());
|
||||
csDg.setDeviceGroupName(deviceGroup.getName());
|
||||
cryptoServiceDeviceGroupMapper.insert(csDg);
|
||||
// up.setDeviceGroupId(update.getDeviceGroupId());
|
||||
// up.setDeviceGroupName(deviceGroup.getName());
|
||||
}
|
||||
|
||||
up.setRemark(update.getRemark());
|
||||
@@ -193,6 +225,7 @@ public class CryptoServiceServiceImpl implements CryptoServiceService {
|
||||
LambdaQueryWrapper<CryptoServiceApi> wrapper = new LambdaQueryWrapper<CryptoServiceApi>()
|
||||
.eq(CryptoServiceApi::getCryptoServiceId, id);
|
||||
cryptoServiceApiMapper.delete(wrapper);
|
||||
cryptoServiceDeviceGroupMapper.deleteByServiceId(id);
|
||||
cryptoServiceMapper.deleteById(id);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user