update 代码生成ServiceImpl连表查询

master
yinq 2 weeks ago
parent 3ce6e94a8f
commit f14dcd15fe

@ -7,7 +7,8 @@ import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
#end
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@ -54,7 +55,7 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
*/
@Override
public TableDataInfo<${ClassName}Vo> queryPageList(${ClassName}Bo bo, PageQuery pageQuery) {
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
MPJLambdaWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
Page<${ClassName}Vo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
@ -68,13 +69,14 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
*/
@Override
public List<${ClassName}Vo> queryList(${ClassName}Bo bo) {
LambdaQueryWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
MPJLambdaWrapper<${ClassName}> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) {
private MPJLambdaWrapper<${ClassName}> buildQueryWrapper(${ClassName}Bo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<${ClassName}> lqw = Wrappers.lambdaQuery();
MPJLambdaWrapper<${ClassName}> lqw = JoinWrappers.lambda(${ClassName}.class)
.selectAll(${ClassName}.class)
#foreach($column in $columns)
#if($column.query)
#set($queryType=$column.queryType)
@ -89,13 +91,14 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
#else
#set($condition='bo.get'+$AttrName+'() != null')
#end
lqw.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName());
.$mpMethod($condition, ${ClassName}::get$AttrName, bo.get$AttrName())
#else
lqw.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"));
.between(params.get("begin$AttrName") != null && params.get("end$AttrName") != null,
${ClassName}::get$AttrName ,params.get("begin$AttrName"), params.get("end$AttrName"))
#end
#end
#end
.orderByDesc(${ClassName}::getCreateTime);
return lqw;
}

Loading…
Cancel
Save