feat 新建LambdaQueryWrapperX,改成使用lambda的方式选择字段
This commit is contained in:
parent
70fe3d31bd
commit
43ae3c8124
|
@ -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.adminserver.modules.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,15 +18,15 @@ import java.util.List;
|
||||||
public interface BpmUserGroupMapper extends BaseMapperX<BpmUserGroupDO> {
|
public interface BpmUserGroupMapper extends BaseMapperX<BpmUserGroupDO> {
|
||||||
|
|
||||||
default PageResult<BpmUserGroupDO> selectPage(BpmUserGroupPageReqVO reqVO) {
|
default PageResult<BpmUserGroupDO> selectPage(BpmUserGroupPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<BpmUserGroupDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<BpmUserGroupDO>()
|
||||||
.likeIfPresent("name", reqVO.getName())
|
.likeIfPresent(BpmUserGroupDO::getName, reqVO.getName())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(BpmUserGroupDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
.betweenIfPresent(BpmUserGroupDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
.orderByDesc("id"));
|
.orderByDesc(BpmUserGroupDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<BpmUserGroupDO> selectListByStatus(Integer status) {
|
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.adminserver.modules.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -12,11 +12,11 @@ import java.util.List;
|
||||||
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
|
||||||
|
|
||||||
default void updateByTaskId(BpmTaskExtDO entity) {
|
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) {
|
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;
|
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.InfJobExportReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.infra.controller.job.vo.job.InfJobPageReqVO;
|
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.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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,22 +19,22 @@ import java.util.List;
|
||||||
public interface InfJobMapper extends BaseMapperX<InfJobDO> {
|
public interface InfJobMapper extends BaseMapperX<InfJobDO> {
|
||||||
|
|
||||||
default InfJobDO selectByHandlerName(String handlerName) {
|
default InfJobDO selectByHandlerName(String handlerName) {
|
||||||
return selectOne("handler_name", handlerName);
|
return selectOne(InfJobDO::getHandlerName, handlerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<InfJobDO> selectPage(InfJobPageReqVO reqVO) {
|
default PageResult<InfJobDO> selectPage(InfJobPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<InfJobDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<InfJobDO>()
|
||||||
.likeIfPresent("name", reqVO.getName())
|
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<InfJobDO> selectList(InfJobExportReqVO reqVO) {
|
default List<InfJobDO> selectList(InfJobExportReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<InfJobDO>()
|
return selectList(new LambdaQueryWrapperX<InfJobDO>()
|
||||||
.likeIfPresent("name", reqVO.getName())
|
.likeIfPresent(InfJobDO::getName, reqVO.getName())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(InfJobDO::getStatus, reqVO.getStatus())
|
||||||
.likeIfPresent("handler_name", reqVO.getHandlerName())
|
.likeIfPresent(InfJobDO::getHandlerName, reqVO.getHandlerName())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.dept;
|
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.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
|
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.controller.dept.vo.dept.SysDeptListReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.dept.SysDeptDO;
|
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@ -14,22 +17,22 @@ import java.util.List;
|
||||||
public interface SysDeptMapper extends BaseMapperX<SysDeptDO> {
|
public interface SysDeptMapper extends BaseMapperX<SysDeptDO> {
|
||||||
|
|
||||||
default List<SysDeptDO> selectList(SysDeptListReqVO reqVO) {
|
default List<SysDeptDO> selectList(SysDeptListReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysDeptDO>().likeIfPresent("name", reqVO.getName())
|
return selectList(new LambdaQueryWrapperX<SysDeptDO>().likeIfPresent(SysDeptDO::getName, reqVO.getName())
|
||||||
.eqIfPresent("status", reqVO.getStatus()));
|
.eqIfPresent(SysDeptDO::getStatus, reqVO.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default SysDeptDO selectByParentIdAndName(Long parentId, String name) {
|
default SysDeptDO selectByParentIdAndName(Long parentId, String name) {
|
||||||
return selectOne(new QueryWrapper<SysDeptDO>().eq("parent_id", parentId)
|
return selectOne(new LambdaQueryWrapper<SysDeptDO>().eq(SysDeptDO::getParentId, parentId)
|
||||||
.eq("name", name));
|
.eq(SysDeptDO::getParentId, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Integer selectCountByParentId(Long parentId) {
|
default Integer selectCountByParentId(Long parentId) {
|
||||||
return selectCount("parent_id", parentId);
|
return selectCount(SysDeptDO::getParentId, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||||
return selectOne(new QueryWrapper<SysDeptDO>().select("id")
|
return selectOne(new LambdaQueryWrapper<SysDeptDO>().select(SysDeptDO::getId)
|
||||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
.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.SysDictDataExportReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.controller.dict.vo.data.SysDictDataPageReqVO;
|
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.coreservice.modules.system.dal.dataobject.dict.SysDictDataDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -17,36 +19,36 @@ import java.util.List;
|
||||||
public interface SysDictDataMapper extends BaseMapperX<SysDictDataDO> {
|
public interface SysDictDataMapper extends BaseMapperX<SysDictDataDO> {
|
||||||
|
|
||||||
default SysDictDataDO selectByDictTypeAndValue(String dictType, String value) {
|
default SysDictDataDO selectByDictTypeAndValue(String dictType, String value) {
|
||||||
return selectOne(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType)
|
return selectOne(new LambdaQueryWrapper<SysDictDataDO>().eq(SysDictDataDO::getDictType, dictType)
|
||||||
.eq("value", value));
|
.eq(SysDictDataDO::getValue, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysDictDataDO> selectByDictTypeAndValues(String dictType, Collection<String> values) {
|
default List<SysDictDataDO> selectByDictTypeAndValues(String dictType, Collection<String> values) {
|
||||||
return selectList(new QueryWrapper<SysDictDataDO>().eq("dict_type", dictType)
|
return selectList(new LambdaQueryWrapper<SysDictDataDO>().eq(SysDictDataDO::getDictType, dictType)
|
||||||
.in("value", values));
|
.in(SysDictDataDO::getValue, values));
|
||||||
}
|
}
|
||||||
|
|
||||||
default int selectCountByDictType(String dictType) {
|
default int selectCountByDictType(String dictType) {
|
||||||
return selectCount("dict_type", dictType);
|
return selectCount(SysDictDataDO::getDictType, dictType);
|
||||||
}
|
}
|
||||||
|
|
||||||
default PageResult<SysDictDataDO> selectPage(SysDictDataPageReqVO reqVO) {
|
default PageResult<SysDictDataDO> selectPage(SysDictDataPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<SysDictDataDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<SysDictDataDO>()
|
||||||
.likeIfPresent("label", reqVO.getLabel())
|
.likeIfPresent(SysDictDataDO::getLabel, reqVO.getLabel())
|
||||||
.likeIfPresent("dict_type", reqVO.getDictType())
|
.likeIfPresent(SysDictDataDO::getDictType, reqVO.getDictType())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysDictDataDO::getStatus, reqVO.getStatus())
|
||||||
.orderByAsc("dict_type", "sort"));
|
.orderByAsc(Arrays.asList(SysDictDataDO::getDictType, SysDictDataDO::getSort)));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysDictDataDO> selectList(SysDictDataExportReqVO reqVO) {
|
default List<SysDictDataDO> selectList(SysDictDataExportReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysDictDataDO>().likeIfPresent("label", reqVO.getLabel())
|
return selectList(new LambdaQueryWrapperX<SysDictDataDO>().likeIfPresent(SysDictDataDO::getLabel, reqVO.getLabel())
|
||||||
.likeIfPresent("dict_type", reqVO.getDictType())
|
.likeIfPresent(SysDictDataDO::getDictType, reqVO.getDictType())
|
||||||
.eqIfPresent("status", reqVO.getStatus()));
|
.eqIfPresent(SysDictDataDO::getStatus, reqVO.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||||
return selectOne(new QueryWrapper<SysDictDataDO>().select("id")
|
return selectOne(new LambdaQueryWrapper<SysDictDataDO>().select(SysDictDataDO::getId)
|
||||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
.gt(SysDictDataDO::getUpdateTime, maxUpdateTime).last(SqlConstants.LIMIT1)) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
package cn.iocoder.yudao.adminserver.modules.system.dal.mysql.permission;
|
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.controller.permission.vo.menu.SysMenuListReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.dal.dataobject.permission.SysMenuDO;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -14,22 +15,22 @@ import java.util.List;
|
||||||
public interface SysMenuMapper extends BaseMapperX<SysMenuDO> {
|
public interface SysMenuMapper extends BaseMapperX<SysMenuDO> {
|
||||||
|
|
||||||
default SysMenuDO selectByParentIdAndName(Long parentId, String name) {
|
default SysMenuDO selectByParentIdAndName(Long parentId, String name) {
|
||||||
return selectOne(new QueryWrapper<SysMenuDO>().eq("parent_id", parentId)
|
return selectOne(new LambdaQueryWrapper<SysMenuDO>().eq(SysMenuDO::getParentId, parentId)
|
||||||
.eq("name", name));
|
.eq(SysMenuDO::getName, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Integer selectCountByParentId(Long parentId) {
|
default Integer selectCountByParentId(Long parentId) {
|
||||||
return selectCount("parent_id", parentId);
|
return selectCount(SysMenuDO::getParentId, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysMenuDO> selectList(SysMenuListReqVO reqVO) {
|
default List<SysMenuDO> selectList(SysMenuListReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysMenuDO>().likeIfPresent("name", reqVO.getName())
|
return selectList(new LambdaQueryWrapperX<SysMenuDO>().likeIfPresent(SysMenuDO::getParentId, reqVO.getName())
|
||||||
.eqIfPresent("status", reqVO.getStatus()));
|
.eqIfPresent(SysMenuDO::getStatus, reqVO.getStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
default boolean selectExistsByUpdateTimeAfter(Date maxUpdateTime) {
|
||||||
return selectOne(new QueryWrapper<SysMenuDO>().select("id")
|
return selectOne(new LambdaQueryWrapper<SysMenuDO>().select(SysMenuDO::getId)
|
||||||
.gt("update_time", maxUpdateTime).last("LIMIT 1")) != null;
|
.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.coreservice.modules.system.dal.dataobject.sms.SysSmsTemplateDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -14,35 +14,36 @@ import java.util.List;
|
||||||
public interface SysSmsTemplateMapper extends BaseMapperX<SysSmsTemplateDO> {
|
public interface SysSmsTemplateMapper extends BaseMapperX<SysSmsTemplateDO> {
|
||||||
|
|
||||||
default SysSmsTemplateDO selectByCode(String code) {
|
default SysSmsTemplateDO selectByCode(String code) {
|
||||||
return selectOne("code", code);
|
return selectOne(SysSmsTemplateDO::getCode, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO 这种参数都一样的得想办法封装一下
|
||||||
default PageResult<SysSmsTemplateDO> selectPage(SysSmsTemplatePageReqVO reqVO) {
|
default PageResult<SysSmsTemplateDO> selectPage(SysSmsTemplatePageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<SysSmsTemplateDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<SysSmsTemplateDO>()
|
||||||
.eqIfPresent("type", reqVO.getType())
|
.eqIfPresent(SysSmsTemplateDO::getType, reqVO.getType())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysSmsTemplateDO::getStatus, reqVO.getStatus())
|
||||||
.likeIfPresent("code", reqVO.getCode())
|
.likeIfPresent(SysSmsTemplateDO::getCode, reqVO.getCode())
|
||||||
.likeIfPresent("content", reqVO.getContent())
|
.likeIfPresent(SysSmsTemplateDO::getContent, reqVO.getContent())
|
||||||
.likeIfPresent("api_template_id", reqVO.getApiTemplateId())
|
.likeIfPresent(SysSmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
.eqIfPresent(SysSmsTemplateDO::getChannelId, reqVO.getChannelId())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
.betweenIfPresent(SysSmsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
.orderByDesc("id"));
|
.orderByDesc(SysSmsTemplateDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysSmsTemplateDO> selectList(SysSmsTemplateExportReqVO reqVO) {
|
default List<SysSmsTemplateDO> selectList(SysSmsTemplateExportReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysSmsTemplateDO>()
|
return selectList(new LambdaQueryWrapperX<SysSmsTemplateDO>()
|
||||||
.eqIfPresent("type", reqVO.getType())
|
.eqIfPresent(SysSmsTemplateDO::getType, reqVO.getType())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysSmsTemplateDO::getStatus, reqVO.getStatus())
|
||||||
.likeIfPresent("code", reqVO.getCode())
|
.likeIfPresent(SysSmsTemplateDO::getCode, reqVO.getCode())
|
||||||
.likeIfPresent("content", reqVO.getContent())
|
.likeIfPresent(SysSmsTemplateDO::getContent, reqVO.getContent())
|
||||||
.likeIfPresent("api_template_id", reqVO.getApiTemplateId())
|
.likeIfPresent(SysSmsTemplateDO::getApiTemplateId, reqVO.getApiTemplateId())
|
||||||
.eqIfPresent("channel_id", reqVO.getChannelId())
|
.eqIfPresent(SysSmsTemplateDO::getChannelId, reqVO.getChannelId())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
.betweenIfPresent(SysSmsTemplateDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
.orderByDesc("id"));
|
.orderByDesc(SysSmsTemplateDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default Integer selectCountByChannelId(Long channelId) {
|
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.coreservice.modules.system.dal.dataobject.tenant.SysTenantDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -19,26 +19,26 @@ import java.util.List;
|
||||||
public interface SysTenantMapper extends BaseMapperX<SysTenantDO> {
|
public interface SysTenantMapper extends BaseMapperX<SysTenantDO> {
|
||||||
|
|
||||||
default PageResult<SysTenantDO> selectPage(SysTenantPageReqVO reqVO) {
|
default PageResult<SysTenantDO> selectPage(SysTenantPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<SysTenantDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<SysTenantDO>()
|
||||||
.likeIfPresent("name", reqVO.getName())
|
.likeIfPresent(SysTenantDO::getName, reqVO.getName())
|
||||||
.likeIfPresent("contact_name", reqVO.getContactName())
|
.likeIfPresent(SysTenantDO::getContactName, reqVO.getContactName())
|
||||||
.likeIfPresent("contact_mobile", reqVO.getContactMobile())
|
.likeIfPresent(SysTenantDO::getContactMobile, reqVO.getContactMobile())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysTenantDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
.betweenIfPresent(SysTenantDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
.orderByDesc("id"));
|
.orderByDesc(SysTenantDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysTenantDO> selectList(SysTenantExportReqVO reqVO) {
|
default List<SysTenantDO> selectList(SysTenantExportReqVO reqVO) {
|
||||||
return selectList(new QueryWrapperX<SysTenantDO>()
|
return selectList(new LambdaQueryWrapperX<SysTenantDO>()
|
||||||
.likeIfPresent("name", reqVO.getName())
|
.likeIfPresent(SysTenantDO::getName, reqVO.getName())
|
||||||
.likeIfPresent("contact_name", reqVO.getContactName())
|
.likeIfPresent(SysTenantDO::getContactName, reqVO.getContactName())
|
||||||
.likeIfPresent("contact_mobile", reqVO.getContactMobile())
|
.likeIfPresent(SysTenantDO::getContactMobile, reqVO.getContactMobile())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysTenantDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
.betweenIfPresent(SysTenantDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
|
||||||
.orderByDesc("id"));
|
.orderByDesc(SysTenantDO::getId));
|
||||||
}
|
}
|
||||||
|
|
||||||
default SysTenantDO selectByName(String name) {
|
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;
|
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.SysUserExportReqVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.controller.user.vo.user.SysUserPageReqVO;
|
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.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import jodd.util.StringPool;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -19,57 +19,58 @@ import java.util.Optional;
|
||||||
public interface SysUserMapper extends BaseMapperX<SysUserDO> {
|
public interface SysUserMapper extends BaseMapperX<SysUserDO> {
|
||||||
|
|
||||||
default SysUserDO selectByUsername(String username) {
|
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) {
|
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) {
|
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) {
|
default PageResult<SysUserDO> selectPage(SysUserPageReqVO reqVO, Collection<Long> deptIds) {
|
||||||
return selectPage(reqVO, new QueryWrapperX<SysUserDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<SysUserDO>()
|
||||||
.likeIfPresent("username", reqVO.getUsername())
|
.likeIfPresent(SysUserDO::getUsername, reqVO.getUsername())
|
||||||
.likeIfPresent("mobile", reqVO.getMobile())
|
.likeIfPresent(SysUserDO::getMobile, reqVO.getMobile())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.eqIfPresent(SysUserDO::getStatus, reqVO.getStatus())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime())
|
.betweenIfPresent(SysUserDO::getCreateTime, reqVO.getBeginTime(), reqVO.getEndTime())
|
||||||
.inIfPresent("dept_id", deptIds));
|
.inIfPresent(SysUserDO::getDeptId, deptIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysUserDO> selectList(SysUserExportReqVO reqVO, Collection<Long> deptIds) {
|
default List<SysUserDO> selectList(SysUserExportReqVO reqVO, Collection<Long> deptIds) {
|
||||||
return selectList(new QueryWrapperX<SysUserDO>().likeIfPresent("username", reqVO.getUsername())
|
return selectList(new LambdaQueryWrapperX<SysUserDO>()
|
||||||
.likeIfPresent("mobile", reqVO.getMobile())
|
.likeIfPresent(SysUserDO::getUsername, reqVO.getUsername())
|
||||||
.eqIfPresent("status", reqVO.getStatus())
|
.likeIfPresent(SysUserDO::getMobile, reqVO.getMobile())
|
||||||
.betweenIfPresent("create_time", reqVO.getBeginTime(), reqVO.getEndTime())
|
.eqIfPresent(SysUserDO::getStatus, reqVO.getStatus())
|
||||||
.inIfPresent("dept_id", deptIds));
|
.betweenIfPresent(SysUserDO::getCreateTime, reqVO.getBeginTime(), reqVO.getEndTime())
|
||||||
|
.inIfPresent(SysUserDO::getDeptId, deptIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysUserDO> selectListByNickname(String nickname) {
|
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) {
|
default List<SysUserDO> selectListByUsername(String username) {
|
||||||
return selectList(new QueryWrapperX<SysUserDO>().like("username", username));
|
return selectList(new LambdaQueryWrapperX<SysUserDO>().like(SysUserDO::getUsername, username));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO 芋艿:可废弃该方法
|
// TODO 芋艿:可废弃该方法
|
||||||
default List<SysUserDO> selectListByDepartIdAndPostId(Long departId, Long postId) {
|
default List<SysUserDO> selectListByDepartIdAndPostId(Long departId, Long postId) {
|
||||||
return selectList(new QueryWrapperX<SysUserDO>()
|
return selectList(new LambdaQueryWrapperX<SysUserDO>()
|
||||||
.eq("status", CommonStatusEnum.ENABLE.getStatus())
|
.eq(SysUserDO::getStatus, CommonStatusEnum.ENABLE.getStatus())
|
||||||
.eq("dept_id", departId)
|
.eq(SysUserDO::getDeptId, departId)
|
||||||
// TODO @jason: 封装一个 StringUtils .toString 。如果空的时候,设置为 null。会更简洁
|
// 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) {
|
default List<SysUserDO> selectListByStatus(Integer status) {
|
||||||
return selectList("status", status);
|
return selectList(SysUserDO::getStatus, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
default List<SysUserDO> selectListByDeptIds(Collection<Long> deptIds) {
|
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> {
|
public interface InfFileCoreMapper extends BaseMapperX<InfFileDO> {
|
||||||
|
|
||||||
default Integer selectCountById(String id) {
|
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> {
|
public interface PayChannelCoreMapper extends BaseMapperX<PayChannelDO> {
|
||||||
|
|
||||||
default PayChannelDO selectByAppIdAndCode(Long appId, String code) {
|
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")
|
@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.coreservice.modules.pay.dal.dataobject.order.PayOrderExtensionDO;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
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 org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface PayOrderExtensionCoreMapper extends BaseMapperX<PayOrderExtensionDO> {
|
public interface PayOrderExtensionCoreMapper extends BaseMapperX<PayOrderExtensionDO> {
|
||||||
|
|
||||||
default PayOrderExtensionDO selectByNo(String no) {
|
default PayOrderExtensionDO selectByNo(String no) {
|
||||||
return selectOne("no", no);
|
return selectOne(PayOrderExtensionDO::getNo, no);
|
||||||
}
|
}
|
||||||
|
|
||||||
default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) {
|
default int updateByIdAndStatus(Long id, Integer status, PayOrderExtensionDO update) {
|
||||||
return update(update, new QueryWrapper<PayOrderExtensionDO>()
|
return update(update, new LambdaQueryWrapper<PayOrderExtensionDO>()
|
||||||
.eq("id", id).eq("status", status));
|
.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.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
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.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -29,14 +31,26 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||||
return selectOne(new QueryWrapper<T>().eq(field, value));
|
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) {
|
default T selectOne(String field1, Object value1, String field2, Object value2) {
|
||||||
return selectOne(new QueryWrapper<T>().eq(field1, value1).eq(field2, 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) {
|
default Integer selectCount(String field, Object value) {
|
||||||
return selectCount(new QueryWrapper<T>().eq(field, value)).intValue();
|
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() {
|
default List<T> selectList() {
|
||||||
return selectList(new QueryWrapper<>());
|
return selectList(new QueryWrapper<>());
|
||||||
}
|
}
|
||||||
|
@ -45,10 +59,18 @@ public interface BaseMapperX<T> extends BaseMapper<T> {
|
||||||
return selectList(new QueryWrapper<T>().eq(field, value));
|
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) {
|
default List<T> selectList(String field, Collection<?> values) {
|
||||||
return selectList(new QueryWrapper<T>().in(field, 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) {
|
default void insertBatch(Collection<T> entities) {
|
||||||
// TODO 芋艿:修改成支持批量的
|
// TODO 芋艿:修改成支持批量的
|
||||||
entities.forEach(this::insert);
|
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> {
|
public interface MbrUserMapper extends BaseMapperX<MbrUserDO> {
|
||||||
|
|
||||||
default MbrUserDO selectByMobile(String mobile) {
|
default MbrUserDO selectByMobile(String mobile) {
|
||||||
return selectOne("mobile", mobile);
|
return selectOne(MbrUserDO::getMobile, mobile);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue