2024-01-24 17:07:44 +08:00
|
|
|
package com.gunshi.project.xyt.service;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-01-24 17:14:06 +08:00
|
|
|
import com.gunshi.project.xyt.model.BzProtocolInfo;
|
|
|
|
|
import com.gunshi.project.xyt.model.BzProtocolInfoAutoDao;
|
|
|
|
|
import com.gunshi.project.xyt.so.BzProtocolInfoSo;
|
2024-01-24 17:07:44 +08:00
|
|
|
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
|
2024-01-24 17:14:06 +08:00
|
|
|
private BzProtocolInfoAutoDao dao;
|
2024-01-24 17:07:44 +08:00
|
|
|
|
|
|
|
|
|
2024-01-24 17:14:06 +08:00
|
|
|
public Page<BzProtocolInfo> page(BzProtocolInfoSo so) {
|
2024-01-24 17:07:44 +08:00
|
|
|
if (StringUtils.isNotEmpty(so.getId())) {
|
2024-01-24 17:14:06 +08:00
|
|
|
BzProtocolInfo entity = dao.getById(so.getId());
|
2024-01-24 17:07:44 +08:00
|
|
|
if (entity == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2024-01-24 17:14:06 +08:00
|
|
|
List<BzProtocolInfo> records = List.of(entity);
|
|
|
|
|
return new Page<BzProtocolInfo>(1, 1, 1).setRecords(records);
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
|
2024-01-24 17:14:06 +08:00
|
|
|
LambdaQueryWrapper<BzProtocolInfo> query = new LambdaQueryWrapper<>();
|
2024-01-24 17:07:44 +08:00
|
|
|
if (StringUtils.isNotEmpty(so.getName())) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.like(StringUtils.isNotEmpty(so.getName()), BzProtocolInfo::getName, so.getName());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(so.getIp())) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.like(BzProtocolInfo::getIp, so.getIp());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
if (so.getPort() != null) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.eq(BzProtocolInfo::getPort, so.getPort());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(so.getStd())) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.like(BzProtocolInfo::getStd, so.getStd());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotEmpty(so.getTrans())) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.like(BzProtocolInfo::getTrans, so.getTrans());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
|
|
|
|
if (so.getEnable() != null) {
|
2024-01-24 17:14:06 +08:00
|
|
|
query.eq(BzProtocolInfo::getEnable, so.getEnable());
|
2024-01-24 17:07:44 +08:00
|
|
|
}
|
2024-01-24 17:14:06 +08:00
|
|
|
query.orderByDesc(BzProtocolInfo::getCreateTm);
|
2024-01-24 17:07:44 +08:00
|
|
|
|
|
|
|
|
return dao.page(so.getPageSo().toPage(), query);
|
|
|
|
|
}
|
|
|
|
|
}
|