【提取功能代码】

This commit is contained in:
weizhihong 2023-06-08 17:51:30 +08:00
parent 86826cdfb3
commit 5aac47bbac
2 changed files with 16 additions and 31 deletions

View File

@ -31,19 +31,19 @@ public class LineInfoRepository extends ServiceImpl<LineInfoMapper, LineInfo> im
*/ */
@Override @Override
public Page<LineInfo> pageQuery(LineInfoQueryDto query) { public Page<LineInfo> pageQuery(LineInfoQueryDto query) {
LambdaQueryWrapper<LineInfo> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<LineInfo> wrapper = getQueryWrapper(query);
if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(LineInfo::getName, query.getName());
}
if (query.getLineId() != null) {
wrapper.eq(LineInfo::getLineId, query.getLineId());
}
wrapper.select(LineInfo.class, info -> !info.getColumn().equals("config")); wrapper.select(LineInfo.class, info -> !info.getColumn().equals("config"));
return page(query, wrapper); return page(query, wrapper);
} }
@Override @Override
public List<LineInfo> list(LineInfoQueryDto query) { public List<LineInfo> list(LineInfoQueryDto query) {
LambdaQueryWrapper<LineInfo> wrapper = getQueryWrapper(query);
wrapper.select(LineInfo.class, info -> !info.getColumn().equals("config"));
return list(wrapper);
}
private static LambdaQueryWrapper<LineInfo> getQueryWrapper(LineInfoQueryDto query) {
LambdaQueryWrapper<LineInfo> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<LineInfo> wrapper = Wrappers.lambdaQuery();
if (StringUtils.isNotEmpty(query.getName())) { if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(LineInfo::getName, query.getName()); wrapper.like(LineInfo::getName, query.getName());
@ -51,7 +51,6 @@ public class LineInfoRepository extends ServiceImpl<LineInfoMapper, LineInfo> im
if (query.getLineId() != null) { if (query.getLineId() != null) {
wrapper.eq(LineInfo::getLineId, query.getLineId()); wrapper.eq(LineInfo::getLineId, query.getLineId());
} }
wrapper.select(LineInfo.class, info -> !info.getColumn().equals("config")); return wrapper;
return list(wrapper);
} }
} }

View File

@ -1,7 +1,6 @@
package club.joylink.xiannccda.repository.impl; package club.joylink.xiannccda.repository.impl;
import club.joylink.xiannccda.dto.PublishedGIQueryDto; import club.joylink.xiannccda.dto.PublishedGIQueryDto;
import club.joylink.xiannccda.entity.LineInfo;
import club.joylink.xiannccda.entity.PublishedGi; import club.joylink.xiannccda.entity.PublishedGi;
import club.joylink.xiannccda.mapper.PublishedGiMapper; import club.joylink.xiannccda.mapper.PublishedGiMapper;
import club.joylink.xiannccda.repository.IPublishedGiRepository; import club.joylink.xiannccda.repository.IPublishedGiRepository;
@ -27,38 +26,25 @@ public class PublishedGiRepository extends ServiceImpl<PublishedGiMapper, Publis
@Override @Override
public Page<PublishedGi> paging(PublishedGIQueryDto query) { public Page<PublishedGi> paging(PublishedGIQueryDto query) {
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<PublishedGi> wrapper = getQueryWrapper(query);
if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(PublishedGi::getName, query.getName());
}
if (StringUtils.isNotEmpty(query.getType())) {
wrapper.eq(PublishedGi::getType, query.getType());
}
if (query.getLineId() != null) {
wrapper.eq(PublishedGi::getLineId, query.getLineId());
}
wrapper.select(PublishedGi.class, publishedGi -> !publishedGi.getColumn().equals("proto")); wrapper.select(PublishedGi.class, publishedGi -> !publishedGi.getColumn().equals("proto"));
return page(query, wrapper); return page(query, wrapper);
} }
@Override @Override
public List<PublishedGi> list(PublishedGIQueryDto query) { public List<PublishedGi> list(PublishedGIQueryDto query) {
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<PublishedGi> wrapper = getQueryWrapper(query);
if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(PublishedGi::getName, query.getName());
}
if (StringUtils.isNotEmpty(query.getType())) {
wrapper.eq(PublishedGi::getType, query.getType());
}
if (query.getLineId() != null) {
wrapper.eq(PublishedGi::getLineId, query.getLineId());
}
wrapper.select(PublishedGi.class, publishedGi -> !publishedGi.getColumn().equals("proto")); wrapper.select(PublishedGi.class, publishedGi -> !publishedGi.getColumn().equals("proto"));
return list(wrapper); return list(wrapper);
} }
@Override @Override
public PublishedGi queryByDto(PublishedGIQueryDto query) { public PublishedGi queryByDto(PublishedGIQueryDto query) {
LambdaQueryWrapper<PublishedGi> wrapper = getQueryWrapper(query);
return getOne(wrapper);
}
private static LambdaQueryWrapper<PublishedGi> getQueryWrapper(PublishedGIQueryDto query) {
LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<PublishedGi> wrapper = Wrappers.lambdaQuery();
if (StringUtils.isNotEmpty(query.getName())) { if (StringUtils.isNotEmpty(query.getName())) {
wrapper.like(PublishedGi::getName, query.getName()); wrapper.like(PublishedGi::getName, query.getName());
@ -69,6 +55,6 @@ public class PublishedGiRepository extends ServiceImpl<PublishedGiMapper, Publis
if (query.getLineId() != null) { if (query.getLineId() != null) {
wrapper.eq(PublishedGi::getLineId, query.getLineId()); wrapper.eq(PublishedGi::getLineId, query.getLineId());
} }
return getOne(wrapper); return wrapper;
} }
} }