You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virtual-patient/virtual-patient-model/src/main/java/com/supervision/service/impl/RasaModeServiceImpl.java

56 lines
2.1 KiB
Java

package com.supervision.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.supervision.exception.BusinessException;
import com.supervision.mapper.RasaModelInfoMapper;
import com.supervision.model.RasaModelInfo;
import com.supervision.service.RasaModeService;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class RasaModeServiceImpl extends ServiceImpl<RasaModelInfoMapper,RasaModelInfo> implements RasaModeService {
@Override
public RasaModelInfo queryByModelId(String modelId){
LambdaQueryWrapper<RasaModelInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(RasaModelInfo::getModelId, modelId).last("LIMIT 1");
return getOne(queryWrapper);
}
@Override
public RasaModelInfo saveOrUpdateByModelId(RasaModelInfo rasaModelInfo) {
if (StrUtil.isEmpty(rasaModelInfo.getModelId())){
throw new BusinessException("modelId is not allow empty...");
}
RasaModelInfo dbModelInfo = this.queryByModelId(rasaModelInfo.getModelId());
if (null != dbModelInfo && StrUtil.isNotEmpty(dbModelInfo.getId())){
rasaModelInfo.setId(dbModelInfo.getId());
super.updateById(rasaModelInfo);
}else {
super.save(rasaModelInfo);
}
return rasaModelInfo;
}
@Override
public List<Integer> listActivePort() {
LambdaQueryChainWrapper<RasaModelInfo> queryWrapper = super.lambdaQuery().eq(RasaModelInfo::getServerStatus, "1");
return queryWrapper.list().stream().map(RasaModelInfo::getPort).collect(Collectors.toList());
}
@Override
public List<RasaModelInfo> listActive() {
LambdaQueryChainWrapper<RasaModelInfo> queryWrapper = super.lambdaQuery().eq(RasaModelInfo::getServerStatus, "1");
return queryWrapper.list();
}
}