61 lines
2.0 KiB
Java
61 lines
2.0 KiB
Java
|
|
package com.gunshi.project.xyt.service;
|
||
|
|
|
||
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||
|
|
import com.gunshi.project.xyt.so.ProtocolInfoSo;
|
||
|
|
import com.gunshi.project.xyt.model.ProtocolInfo;
|
||
|
|
import com.gunshi.project.xyt.model.ProtocolInfoAutoDao;
|
||
|
|
import org.apache.commons.lang3.StringUtils;
|
||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
import org.springframework.stereotype.Service;
|
||
|
|
|
||
|
|
import java.util.List;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 类描述
|
||
|
|
*
|
||
|
|
* @author lyf
|
||
|
|
* @version 1.0.0
|
||
|
|
* @since 2024-01-23
|
||
|
|
*/
|
||
|
|
@Service
|
||
|
|
public class ProtocolInfoService {
|
||
|
|
@Autowired
|
||
|
|
private ProtocolInfoAutoDao dao;
|
||
|
|
|
||
|
|
|
||
|
|
public Page<ProtocolInfo> page(ProtocolInfoSo so) {
|
||
|
|
if (StringUtils.isNotEmpty(so.getId())) {
|
||
|
|
ProtocolInfo entity = dao.getById(so.getId());
|
||
|
|
if (entity == null) {
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
List<ProtocolInfo> records = List.of(entity);
|
||
|
|
return new Page<ProtocolInfo>(1, 1, 1).setRecords(records);
|
||
|
|
}
|
||
|
|
|
||
|
|
LambdaQueryWrapper<ProtocolInfo> query = new LambdaQueryWrapper<>();
|
||
|
|
if (StringUtils.isNotEmpty(so.getName())) {
|
||
|
|
query.like(StringUtils.isNotEmpty(so.getName()),ProtocolInfo::getName, so.getName());
|
||
|
|
}
|
||
|
|
if (StringUtils.isNotEmpty(so.getIp())) {
|
||
|
|
query.like(ProtocolInfo::getIp, so.getIp());
|
||
|
|
}
|
||
|
|
if (so.getPort() != null) {
|
||
|
|
query.eq(ProtocolInfo::getPort, so.getPort());
|
||
|
|
}
|
||
|
|
if (StringUtils.isNotEmpty(so.getStd())) {
|
||
|
|
query.like(ProtocolInfo::getStd, so.getStd());
|
||
|
|
}
|
||
|
|
if (StringUtils.isNotEmpty(so.getTrans())) {
|
||
|
|
query.like(ProtocolInfo::getTrans, so.getTrans());
|
||
|
|
}
|
||
|
|
if (so.getEnable() != null) {
|
||
|
|
query.eq(ProtocolInfo::getEnable, so.getEnable());
|
||
|
|
}
|
||
|
|
query.orderByDesc(ProtocolInfo::getCreateTm);
|
||
|
|
|
||
|
|
return dao.page(so.getPageSo().toPage(), query);
|
||
|
|
}
|
||
|
|
}
|