|
@@ -1,15 +1,16 @@
|
|
|
package com.sckw.system.repository;
|
|
package com.sckw.system.repository;
|
|
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.sckw.system.dao.SysDictTypeDao;
|
|
import com.sckw.system.dao.SysDictTypeDao;
|
|
|
import com.sckw.system.model.SysDictType;
|
|
import com.sckw.system.model.SysDictType;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Repository;
|
|
import org.springframework.stereotype.Repository;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 字典类型服务层(MyBatis-Plus 版本)
|
|
* 字典类型服务层(MyBatis-Plus 版本)
|
|
@@ -23,11 +24,11 @@ public class SysDictTypeRepository extends ServiceImpl<SysDictTypeDao, SysDictTy
|
|
|
* 根据类型查询字典类型
|
|
* 根据类型查询字典类型
|
|
|
*/
|
|
*/
|
|
|
public SysDictType selectByType(String type,String name) {
|
|
public SysDictType selectByType(String type,String name) {
|
|
|
- LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(SysDictType::getType, type)
|
|
|
|
|
|
|
+ return getOne(Wrappers.<SysDictType>lambdaQuery()
|
|
|
|
|
+ .eq(SysDictType::getType, type)
|
|
|
.eq(SysDictType::getName, name)
|
|
.eq(SysDictType::getName, name)
|
|
|
- .eq(SysDictType::getDelFlag, 0);
|
|
|
|
|
- return this.getOne(wrapper);
|
|
|
|
|
|
|
+ .eq(SysDictType::getDelFlag, 0)
|
|
|
|
|
+ .last("LIMIT 1"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -47,45 +48,27 @@ public class SysDictTypeRepository extends ServiceImpl<SysDictTypeDao, SysDictTy
|
|
|
/**
|
|
/**
|
|
|
* 分页查询字典类型
|
|
* 分页查询字典类型
|
|
|
*/
|
|
*/
|
|
|
- public Page<SysDictType> selectPage(int pageNum, int pageSize, String name, String type, Integer status) {
|
|
|
|
|
- Page<SysDictType> page = new Page<>(pageNum, pageSize);
|
|
|
|
|
-
|
|
|
|
|
- LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.eq(SysDictType::getDelFlag, 0);
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(name)) {
|
|
|
|
|
- wrapper.like(SysDictType::getName, name);
|
|
|
|
|
- }
|
|
|
|
|
- if (StringUtils.isNotBlank(type)) {
|
|
|
|
|
- wrapper.like(SysDictType::getType, type);
|
|
|
|
|
- }
|
|
|
|
|
- if (status != null) {
|
|
|
|
|
- wrapper.eq(SysDictType::getStatus, status);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- wrapper.orderByDesc(SysDictType::getCreateTime);
|
|
|
|
|
-
|
|
|
|
|
- return this.page(page, wrapper);
|
|
|
|
|
|
|
+ public IPage<SysDictType> selectPage(int pageNum, int pageSize, String name, String type, Integer status) {
|
|
|
|
|
+ return this.page(new Page<>(pageNum, pageSize), Wrappers.<SysDictType>lambdaQuery()
|
|
|
|
|
+ .eq(SysDictType::getDelFlag, 0)
|
|
|
|
|
+ .eq(Objects.nonNull( status), SysDictType::getStatus, status)
|
|
|
|
|
+ .like(StringUtils.isNotBlank( name),SysDictType::getName, name)
|
|
|
|
|
+ .like(StringUtils.isNotBlank(type), SysDictType::getType, type)
|
|
|
|
|
+ .orderByDesc(SysDictType::getCreateTime)
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 搜索字典类型(支持下拉选择)
|
|
* 搜索字典类型(支持下拉选择)
|
|
|
*/
|
|
*/
|
|
|
public List<SysDictType> searchForSelect(String keyword) {
|
|
public List<SysDictType> searchForSelect(String keyword) {
|
|
|
- LambdaQueryWrapper<SysDictType> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.select(SysDictType::getId, SysDictType::getName, SysDictType::getType)
|
|
|
|
|
- .eq(SysDictType::getDelFlag, 0)
|
|
|
|
|
- .eq(SysDictType::getStatus, 0);
|
|
|
|
|
-
|
|
|
|
|
- if (StringUtils.isNotBlank(keyword)) {
|
|
|
|
|
- wrapper.and(w -> w.like(SysDictType::getName, keyword)
|
|
|
|
|
- .or()
|
|
|
|
|
- .like(SysDictType::getType, keyword));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- wrapper.orderByDesc(SysDictType::getCreateTime)
|
|
|
|
|
- .last("LIMIT 100");
|
|
|
|
|
-
|
|
|
|
|
- return this.list(wrapper);
|
|
|
|
|
|
|
+ return list(Wrappers.<SysDictType>lambdaQuery()
|
|
|
|
|
+ .select(SysDictType::getId, SysDictType::getName, SysDictType::getType)
|
|
|
|
|
+ .eq(SysDictType::getDelFlag, 0)
|
|
|
|
|
+ .eq(SysDictType::getStatus, 0)
|
|
|
|
|
+ .and(StringUtils.isNotBlank(keyword),w -> w.like(SysDictType::getName, keyword)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .like(SysDictType::getType, keyword))
|
|
|
|
|
+ .last("LIMIT 100"));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|