mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
!64 新建LambdaQueryWrapperX,改成使用lambda的方式选择字段
Merge pull request !64 from keep/style/use_lambda_query_wapper
This commit is contained in:
commit
fcf13bb67c
@ -4,7 +4,7 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.definition.vo.group.B
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -18,15 +18,15 @@ import java.util.List;
|
||||
public interface BpmUserGroupMapper extends BaseMapperX<BpmUserGroupDO> {
|
||||
|
||||
default PageResult<BpmUserGroupDO> selectPage(BpmUserGroupPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<BpmUserGroupDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmUserGroupDO>()
|
||||
.likeIfPresent(BpmUserGroupDO::getName, reqVO.getName())
|
||||
.eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(BpmUserGroupDO::getId));
|
||||
}
|
||||
|
||||
default List<BpmUserGroupDO> selectListByStatus(Integer status) {
|
||||
return selectList("status", status);
|
||||
return selectList(BpmUserGroupDO::getStatus, status);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.adminserver.modules.bpm.dal.mysql.task;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -12,11 +12,11 @@ import java.util.List;
|
||||
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
||||
|
||||
default void updateByTaskId(BpmTaskExtDO entity) {
|
||||
update(entity, new QueryWrapper<BpmTaskExtDO>().eq("task_id", entity.getTaskId()));
|
||||
update(entity, new LambdaQueryWrapper<BpmTaskExtDO>().eq(BpmTaskExtDO::getTaskId, entity.getTaskId()));
|
||||
}
|
||||
|
||||
default List<BpmTaskExtDO> selectListByTaskIds(Collection<String> taskIds) {
|
||||
return selectList("task_id", taskIds);
|
||||
return selectList(BpmTaskExtDO::getTaskId, taskIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.infra.dal.mysql.job;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.controller.job.vo.job.InfJobExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.controller.job.vo.job.InfJobPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.infra.dal.dataobject.job.InfJobDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,22 +19,22 @@ import java.util.List;
|
||||
public interface InfJobMapper extends BaseMapperX<InfJobDO> {
|
||||
|
||||
default InfJobDO selectByHandlerName(String handlerName) {
|
||||
return selectOne("handler_name", handlerName);
|
||||
return selectOne(InfJobDO::getHandlerName, handlerName);
|
||||
}
|
||||
|
||||
default PageResult<InfJobDO> selectPage(InfJobPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||
);
|
||||
}
|
||||
|
||||
default List<InfJobDO> selectList(InfJobExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
||||
return selectList(new LambdaQueryWrapperX<InfJobDO>()
|
||||
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.dept;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.tool.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.dept.vo.dept.SysDeptListReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@ -14,22 +17,22 @@ import java.util.List;
|
||||
public interface SysDeptMapper extends BaseMapperX<SysDeptDO> {
|
||||
|
||||
default List<SysDeptDO> selectList(SysDeptListReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysDeptDO>().likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus()));
|
||||
return selectList(new LambdaQueryWrapperX<SysDeptDO>().likeIfPresent(SysDeptDO::getName, reqVO.getName())
|
||||
.eqIfPresent(SysDeptDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default SysDeptDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(new QueryWrapper<SysDeptDO>().eq("parent_id", parentId)
|
||||
.eq("name", name));
|
||||
return selectOne(new LambdaQueryWrapper<SysDeptDO>().eq(SysDeptDO::getParentId, parentId)
|
||||
.eq(SysDeptDO::getParentId, name));
|
||||
}
|
||||
|
||||
default Integer selectCountByParentId(Long parentId) {
|
||||
return selectCount("parent_id", parentId);
|
||||
return selectCount(SysDeptDO::getParentId, parentId);
|
||||
}
|
||||
|
||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||
return selectOne(new QueryWrapper<SysDeptDO>().select("id")
|
||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
||||
return selectOne(new LambdaQueryWrapper<SysDeptDO>().select(SysDeptDO::getId)
|
||||
.gt(SysDeptDO::getUpdateTime, maxUpdateTime).last(SqlConstants.LIMIT1)) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,13 +2,15 @@ package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.dict;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.tool.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -17,36 +19,36 @@ import java.util.List;
|
||||
public interface SysDictDataMapper extends BaseMapperX<SysDictDataDO> {
|
||||
|
||||
default SysDictDataDO selectByDictTypeAndValue(String dictType, String value) {
|
||||
return selectOne(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType)
|
||||
.eq("value", value));
|
||||
return selectOne(new LambdaQueryWrapper<SysDictDataDO>().eq(SysDictDataDO::getDictType, dictType)
|
||||
.eq(SysDictDataDO::getValue, value));
|
||||
}
|
||||
|
||||
default List<SysDictDataDO> selectByDictTypeAndValues(String dictType, Collection<String> values) {
|
||||
return selectList(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType)
|
||||
.in("value", values));
|
||||
return selectList(new LambdaQueryWrapper<SysDictDataDO>().eq(SysDictDataDO::getDictType, dictType)
|
||||
.in(SysDictDataDO::getValue, values));
|
||||
}
|
||||
|
||||
default int selectCountByDictType(String dictType) {
|
||||
return selectCount("dict_type", dictType);
|
||||
return selectCount(SysDictDataDO::getDictType, dictType);
|
||||
}
|
||||
|
||||
default PageResult<SysDictDataDO> selectPage(SysDictDataPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysDictDataDO>()
|
||||
.likeIfPresent("label", reqVO.getLabel())
|
||||
.likeIfPresent("dict_type", reqVO.getDictType())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.orderByAsc("dict_type", "sort"));
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SysDictDataDO>()
|
||||
.likeIfPresent(SysDictDataDO::getLabel, reqVO.getLabel())
|
||||
.likeIfPresent(SysDictDataDO::getDictType, reqVO.getDictType())
|
||||
.eqIfPresent(SysDictDataDO::getStatus, reqVO.getStatus())
|
||||
.orderByAsc(Arrays.asList(SysDictDataDO::getDictType, SysDictDataDO::getSort)));
|
||||
}
|
||||
|
||||
default List<SysDictDataDO> selectList(SysDictDataExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysDictDataDO>().likeIfPresent("label", reqVO.getLabel())
|
||||
.likeIfPresent("dict_type", reqVO.getDictType())
|
||||
.eqIfPresent("status", reqVO.getStatus()));
|
||||
return selectList(new LambdaQueryWrapperX<SysDictDataDO>().likeIfPresent(SysDictDataDO::getLabel, reqVO.getLabel())
|
||||
.likeIfPresent(SysDictDataDO::getDictType, reqVO.getDictType())
|
||||
.eqIfPresent(SysDictDataDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||
return selectOne(new QueryWrapper<SysDictDataDO>().select("id")
|
||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
||||
return selectOne(new LambdaQueryWrapper<SysDictDataDO>().select(SysDictDataDO::getId)
|
||||
.gt(SysDictDataDO::getUpdateTime, maxUpdateTime).last(SqlConstants.LIMIT1)) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.permission;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.permission.vo.menu.SysMenuListReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.iocoder.yudao.adminserver.modules.tool.enums.SqlConstants;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Date;
|
||||
@ -14,22 +15,22 @@ import java.util.List;
|
||||
public interface SysMenuMapper extends BaseMapperX<SysMenuDO> {
|
||||
|
||||
default SysMenuDO selectByParentIdAndName(Long parentId, String name) {
|
||||
return selectOne(new QueryWrapper<SysMenuDO>().eq("parent_id", parentId)
|
||||
.eq("name", name));
|
||||
return selectOne(new LambdaQueryWrapper<SysMenuDO>().eq(SysMenuDO::getParentId, parentId)
|
||||
.eq(SysMenuDO::getName, name));
|
||||
}
|
||||
|
||||
default Integer selectCountByParentId(Long parentId) {
|
||||
return selectCount("parent_id", parentId);
|
||||
return selectCount(SysMenuDO::getParentId, parentId);
|
||||
}
|
||||
|
||||
default List<SysMenuDO> selectList(SysMenuListReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysMenuDO>().likeIfPresent("name", reqVO.getName())
|
||||
.eqIfPresent("status", reqVO.getStatus()));
|
||||
return selectList(new LambdaQueryWrapperX<SysMenuDO>().likeIfPresent(SysMenuDO::getParentId, reqVO.getName())
|
||||
.eqIfPresent(SysMenuDO::getStatus, reqVO.getStatus()));
|
||||
}
|
||||
|
||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||
return selectOne(new QueryWrapper<SysMenuDO>().select("id")
|
||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
||||
return selectOne(new LambdaQueryWrapper<SysMenuDO>().select(SysMenuDO::getId)
|
||||
.gt(SysMenuDO::getUpdateTime, maxUpdateTime).last(SqlConstants.LIMIT1)) != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.sms.vo.template.Sy
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -14,35 +14,36 @@ import java.util.List;
|
||||
public interface SysSmsTemplateMapper extends BaseMapperX<SysSmsTemplateDO> {
|
||||
|
||||
default SysSmsTemplateDO selectByCode(String code) {
|
||||
return selectOne("code", code);
|
||||
return selectOne(SysSmsTemplateDO::getCode, code);
|
||||
}
|
||||
|
||||
// TODO 这种参数都一样的得想办法封装一下
|
||||
default PageResult<SysSmsTemplateDO> selectPage(SysSmsTemplatePageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysSmsTemplateDO>()
|
||||
.eqIfPresent("type", reqVO.getType())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.likeIfPresent("code", reqVO.getCode())
|
||||
.likeIfPresent("content", reqVO.getContent())
|
||||
.likeIfPresent("api_template_id", reqVO.getApiTemplateId())
|
||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SysSmsTemplateDO>()
|
||||
.eqIfPresent(SysSmsTemplateDO::getType, reqVO.getType())
|
||||
.eqIfPresent(SysSmsTemplateDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(SysSmsTemplateDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(SysSmsTemplateDO::getContent, reqVO.getContent())
|
||||
.likeIfPresent(SysSmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||
.eqIfPresent(SysSmsTemplateDO::getChannelId, reqVO.getChannelId())
|
||||
.betweenIfPresent(SysSmsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(SysSmsTemplateDO::getId));
|
||||
}
|
||||
|
||||
default List<SysSmsTemplateDO> selectList(SysSmsTemplateExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysSmsTemplateDO>()
|
||||
.eqIfPresent("type", reqVO.getType())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.likeIfPresent("code", reqVO.getCode())
|
||||
.likeIfPresent("content", reqVO.getContent())
|
||||
.likeIfPresent("api_template_id", reqVO.getApiTemplateId())
|
||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
return selectList(new LambdaQueryWrapperX<SysSmsTemplateDO>()
|
||||
.eqIfPresent(SysSmsTemplateDO::getType, reqVO.getType())
|
||||
.eqIfPresent(SysSmsTemplateDO::getStatus, reqVO.getStatus())
|
||||
.likeIfPresent(SysSmsTemplateDO::getCode, reqVO.getCode())
|
||||
.likeIfPresent(SysSmsTemplateDO::getContent, reqVO.getContent())
|
||||
.likeIfPresent(SysSmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||
.eqIfPresent(SysSmsTemplateDO::getChannelId, reqVO.getChannelId())
|
||||
.betweenIfPresent(SysSmsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(SysSmsTemplateDO::getId));
|
||||
}
|
||||
|
||||
default Integer selectCountByChannelId(Long channelId) {
|
||||
return selectCount("channel_id", channelId);
|
||||
return selectCount(SysSmsTemplateDO::getChannelId, channelId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import cn.iocoder.yudao.adminserver.modules.system.controller.tenant.vo.SysTenan
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.tenant.SysTenantDO;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
@ -19,26 +19,26 @@ import java.util.List;
|
||||
public interface SysTenantMapper extends BaseMapperX<SysTenantDO> {
|
||||
|
||||
default PageResult<SysTenantDO> selectPage(SysTenantPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysTenantDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("contact_name", reqVO.getContactName())
|
||||
.likeIfPresent("contact_mobile", reqVO.getContactMobile())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SysTenantDO>()
|
||||
.likeIfPresent(SysTenantDO::getName, reqVO.getName())
|
||||
.likeIfPresent(SysTenantDO::getContactName, reqVO.getContactName())
|
||||
.likeIfPresent(SysTenantDO::getContactMobile, reqVO.getContactMobile())
|
||||
.eqIfPresent(SysTenantDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(SysTenantDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(SysTenantDO::getId));
|
||||
}
|
||||
|
||||
default List<SysTenantDO> selectList(SysTenantExportReqVO reqVO) {
|
||||
return selectList(new QueryWrapperX<SysTenantDO>()
|
||||
.likeIfPresent("name", reqVO.getName())
|
||||
.likeIfPresent("contact_name", reqVO.getContactName())
|
||||
.likeIfPresent("contact_mobile", reqVO.getContactMobile())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc("id"));
|
||||
return selectList(new LambdaQueryWrapperX<SysTenantDO>()
|
||||
.likeIfPresent(SysTenantDO::getName, reqVO.getName())
|
||||
.likeIfPresent(SysTenantDO::getContactName, reqVO.getContactName())
|
||||
.likeIfPresent(SysTenantDO::getContactMobile, reqVO.getContactMobile())
|
||||
.eqIfPresent(SysTenantDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(SysTenantDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||
.orderByDesc(SysTenantDO::getId));
|
||||
}
|
||||
|
||||
default SysTenantDO selectByName(String name) {
|
||||
return selectOne("name", name);
|
||||
return selectOne(SysTenantDO::getName, name);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.user;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserExportReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserPageReqVO;
|
||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import jodd.util.StringPool;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -19,57 +19,58 @@ import java.util.Optional;
|
||||
public interface SysUserMapper extends BaseMapperX<SysUserDO> {
|
||||
|
||||
default SysUserDO selectByUsername(String username) {
|
||||
return selectOne(new QueryWrapper<SysUserDO>().eq("username", username));
|
||||
return selectOne(new LambdaQueryWrapper<SysUserDO>().eq(SysUserDO::getUsername, username));
|
||||
}
|
||||
|
||||
default SysUserDO selectByEmail(String email) {
|
||||
return selectOne(new QueryWrapper<SysUserDO>().eq("email", email));
|
||||
return selectOne(new LambdaQueryWrapper<SysUserDO>().eq(SysUserDO::getEmail, email));
|
||||
}
|
||||
|
||||
default SysUserDO selectByMobile(String mobile) {
|
||||
return selectOne(new QueryWrapper<SysUserDO>().eq("mobile", mobile));
|
||||
return selectOne(new LambdaQueryWrapper<SysUserDO>().eq(SysUserDO::getMobile, mobile));
|
||||
}
|
||||
|
||||
default PageResult<SysUserDO> selectPage(SysUserPageReqVO reqVO, Collection<Long> deptIds) {
|
||||
return selectPage(reqVO, new QueryWrapperX<SysUserDO>()
|
||||
.likeIfPresent("username", reqVO.getUsername())
|
||||
.likeIfPresent("mobile", reqVO.getMobile())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime())
|
||||
.inIfPresent("dept_id", deptIds));
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<SysUserDO>()
|
||||
.likeIfPresent(SysUserDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(SysUserDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(SysUserDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(SysUserDO::getCreateTime, reqVO.getBeginTime(), reqVO.getEndTime())
|
||||
.inIfPresent(SysUserDO::getDeptId, deptIds));
|
||||
}
|
||||
|
||||
default List<SysUserDO> selectList(SysUserExportReqVO reqVO, Collection<Long> deptIds) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>().likeIfPresent("username", reqVO.getUsername())
|
||||
.likeIfPresent("mobile", reqVO.getMobile())
|
||||
.eqIfPresent("status", reqVO.getStatus())
|
||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime())
|
||||
.inIfPresent("dept_id", deptIds));
|
||||
return selectList(new LambdaQueryWrapperX<SysUserDO>()
|
||||
.likeIfPresent(SysUserDO::getUsername, reqVO.getUsername())
|
||||
.likeIfPresent(SysUserDO::getMobile, reqVO.getMobile())
|
||||
.eqIfPresent(SysUserDO::getStatus, reqVO.getStatus())
|
||||
.betweenIfPresent(SysUserDO::getCreateTime, reqVO.getBeginTime(), reqVO.getEndTime())
|
||||
.inIfPresent(SysUserDO::getDeptId, deptIds));
|
||||
}
|
||||
|
||||
default List<SysUserDO> selectListByNickname(String nickname) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>().like("nickname", nickname));
|
||||
return selectList(new LambdaQueryWrapperX<SysUserDO>().like(SysUserDO::getNickname, nickname));
|
||||
}
|
||||
|
||||
default List<SysUserDO> selectListByUsername(String username) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>().like("username", username));
|
||||
return selectList(new LambdaQueryWrapperX<SysUserDO>().like(SysUserDO::getUsername, username));
|
||||
}
|
||||
|
||||
// TODO 芋艿:可废弃该方法
|
||||
default List<SysUserDO> selectListByDepartIdAndPostId(Long departId, Long postId) {
|
||||
return selectList(new QueryWrapperX<SysUserDO>()
|
||||
.eq("status", CommonStatusEnum.ENABLE.getStatus())
|
||||
.eq("dept_id", departId)
|
||||
return selectList(new LambdaQueryWrapperX<SysUserDO>()
|
||||
.eq(SysUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||
.eq(SysUserDO::getDeptId, departId)
|
||||
// TODO @jason: 封装一个 StringUtils .toString 。如果空的时候,设置为 null。会更简洁
|
||||
.likeIfPresent("post_ids", Optional.ofNullable(postId).map(t -> String.valueOf(postId)).orElse("")));
|
||||
.likeIfPresent(SysUserDO::getPostIds, Optional.ofNullable(postId).map(t -> String.valueOf(postId)).orElse(StringPool.EMPTY)));
|
||||
}
|
||||
|
||||
default List<SysUserDO> selectListByStatus(Integer status) {
|
||||
return selectList("status", status);
|
||||
return selectList(SysUserDO::getStatus, status);
|
||||
}
|
||||
|
||||
default List<SysUserDO> selectListByDeptIds(Collection<Long> deptIds) {
|
||||
return selectList("dept_id", deptIds);
|
||||
return selectList(SysUserDO::getDeptId, deptIds);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.tool.enums;
|
||||
|
||||
/**
|
||||
* SQL相关常量类
|
||||
*/
|
||||
public interface SqlConstants {
|
||||
|
||||
|
||||
String LIMIT1 = "LIMIT 1";
|
||||
|
||||
}
|
@ -9,7 +9,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface InfFileCoreMapper extends BaseMapperX<InfFileDO> {
|
||||
|
||||
default Integer selectCountById(String id) {
|
||||
return selectCount("id", id);
|
||||
return selectCount(InfFileDO::getId, id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ import java.util.Date;
|
||||
public interface PayChannelCoreMapper extends BaseMapperX<PayChannelDO> {
|
||||
|
||||
default PayChannelDO selectByAppIdAndCode(Long appId, String code) {
|
||||
return selectOne("app_id", appId, "code", code);
|
||||
return selectOne(PayChannelDO::getAppId, appId, PayChannelDO::getCode, code);
|
||||
}
|
||||
|
||||
@Select("SELECT id FROM pay_channel WHERE update_time > #{maxUpdateTime} LIMIT 1")
|
||||
|
@ -2,19 +2,19 @@ package cn.iocoder.yudao.coreservice.modules.pay.dal.mysql.order;
|
||||
|
||||
import cn.iocoder.yudao.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PayOrderExtensionCoreMapper extends BaseMapperX<PayOrderExtensionDO> {
|
||||
|
||||
default PayOrderExtensionDO selectByNo(String no) {
|
||||
return selectOne("no", no);
|
||||
return selectOne(PayOrderExtensionDO::getNo, no);
|
||||
}
|
||||
|
||||
default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) {
|
||||
return update(update, new QueryWrapper<PayOrderExtensionDO>()
|
||||
.eq("id", id).eq("status", status));
|
||||
return update(update, new LambdaQueryWrapper<PayOrderExtensionDO>()
|
||||
.eq(PayOrderExtensionDO::getId, id).eq(PayOrderExtensionDO::getStatus, status));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,9 +4,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -29,14 +31,26 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
return selectOne(new QueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default T selectOne(SFunction<T, ?> field, Object value) {
|
||||
return selectOne(new LambdaQueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default T selectOne(String field1, Object value1, String field2, Object value2) {
|
||||
return selectOne(new QueryWrapper<T>().eq(field1, value1).eq(field2, value2));
|
||||
}
|
||||
|
||||
default T selectOne(SFunction<T, ?> field1, Object value1, SFunction<T, ?> field2, Object value2) {
|
||||
return selectOne(new LambdaQueryWrapper<T>().eq(field1, value1).eq(field2, value2));
|
||||
}
|
||||
|
||||
default Integer selectCount(String field, Object value) {
|
||||
return selectCount(new QueryWrapper<T>().eq(field, value)).intValue();
|
||||
}
|
||||
|
||||
default Integer selectCount(SFunction<T, ?> field, Object value) {
|
||||
return selectCount(new LambdaQueryWrapper<T>().eq(field, value)).intValue();
|
||||
}
|
||||
|
||||
default List<T> selectList() {
|
||||
return selectList(new QueryWrapper<>());
|
||||
}
|
||||
@ -45,10 +59,18 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||
return selectList(new QueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default List<T> selectList(SFunction<T, ?> field, Object value) {
|
||||
return selectList(new LambdaQueryWrapper<T>().eq(field, value));
|
||||
}
|
||||
|
||||
default List<T> selectList(String field, Collection<?> values) {
|
||||
return selectList(new QueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
default List<T> selectList(SFunction<T, ?> field, Collection<?> values) {
|
||||
return selectList(new LambdaQueryWrapper<T>().in(field, values));
|
||||
}
|
||||
|
||||
default void insertBatch(Collection<T> entities) {
|
||||
// TODO 芋艿:修改成支持批量的
|
||||
entities.forEach(this::insert);
|
||||
|
@ -0,0 +1,129 @@
|
||||
package cn.iocoder.yudao.framework.mybatis.core.query;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 拓展 MyBatis Plus QueryWrapper 类,主要增加如下功能:
|
||||
*
|
||||
* 1. 拼接条件的方法,增加 xxxIfPresent 方法,用于判断值不存在的时候,不要拼接到条件中。
|
||||
*
|
||||
* @param <T> 数据类型
|
||||
*/
|
||||
public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> {
|
||||
|
||||
public LambdaQueryWrapperX<T> likeIfPresent(SFunction<T, ?> column, String val) {
|
||||
if (StringUtils.hasText(val)) {
|
||||
return (LambdaQueryWrapperX<T>) super.like(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Collection<?> values) {
|
||||
if (!CollectionUtils.isEmpty(values)) {
|
||||
return (LambdaQueryWrapperX<T>) super.in(column, values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) {
|
||||
if (!ArrayUtils.isEmpty(values)) {
|
||||
return (LambdaQueryWrapperX<T>) super.in(column, values);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> eqIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.eq(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> neIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.ne(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> gtIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.gt(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> geIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.ge(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> ltIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.lt(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> leIfPresent(SFunction<T, ?> column, Object val) {
|
||||
if (val != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.le(column, val);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public LambdaQueryWrapperX<T> betweenIfPresent(SFunction<T, ?> column, Object val1, Object val2) {
|
||||
if (val1 != null && val2 != null) {
|
||||
return (LambdaQueryWrapperX<T>) super.between(column, val1, val2);
|
||||
}
|
||||
if (val1 != null) {
|
||||
return (LambdaQueryWrapperX<T>) ge(column, val1);
|
||||
}
|
||||
if (val2 != null) {
|
||||
return (LambdaQueryWrapperX<T>) le(column, val2);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
// ========== 重写父类方法,方便链式调用 ==========
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapperX<T> eq(boolean condition, SFunction<T, ?> column, Object val) {
|
||||
super.eq(condition, column, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapperX<T> eq(SFunction<T, ?> column, Object val) {
|
||||
super.eq(column, val);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapperX<T> orderByDesc(SFunction<T, ?> column) {
|
||||
super.orderByDesc(true, column);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapperX<T> last(String lastSql) {
|
||||
super.last(lastSql);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LambdaQueryWrapperX<T> in(SFunction<T, ?> column, Collection<?> coll) {
|
||||
super.in(column, coll);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
public interface MbrUserMapper extends BaseMapperX<MbrUserDO> {
|
||||
|
||||
default MbrUserDO selectByMobile(String mobile) {
|
||||
return selectOne("mobile", mobile);
|
||||
return selectOne(MbrUserDO::getMobile, mobile);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user