mirror of https://gitee.com/stylefeng/roses
【7.6.0】【config】更新分页查询的列表
parent
07479bef4c
commit
0a2f77729a
|
@ -28,6 +28,7 @@ import cn.stylefeng.roses.kernel.config.modular.entity.SysConfig;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigParam;
|
import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigParam;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
|
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
|
||||||
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
|
||||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||||
|
@ -100,13 +101,13 @@ public class SysConfigController {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询配置列表
|
* 分页查询配置列表,查询配置列表时候,必须带上配置分类的标识
|
||||||
*
|
*
|
||||||
* @author fengshuonan
|
* @author fengshuonan
|
||||||
* @since 2020/4/14 11:10
|
* @since 2020/4/14 11:10
|
||||||
*/
|
*/
|
||||||
@GetResource(name = "分页查询配置列表", path = "/sysConfig/page")
|
@GetResource(name = "分页查询配置列表", path = "/sysConfig/page")
|
||||||
public ResponseData<PageResult<SysConfig>> page(SysConfigParam sysConfigParam) {
|
public ResponseData<PageResult<SysConfig>> page(@Validated(value = BaseRequest.page.class) SysConfigParam sysConfigParam) {
|
||||||
return new SuccessResponseData<>(sysConfigService.findPage(sysConfigParam));
|
return new SuccessResponseData<>(sysConfigService.findPage(sysConfigParam));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class SysConfigParam extends BaseRequest {
|
||||||
/**
|
/**
|
||||||
* 配置所属分类的编码,来自于字典编码“config_group”字典
|
* 配置所属分类的编码,来自于字典编码“config_group”字典
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "配置所属分类的编码不能为空", groups = {add.class})
|
@NotBlank(message = "配置所属分类的编码不能为空", groups = {add.class, page.class})
|
||||||
@ChineseDescription("配置所属分类的编码")
|
@ChineseDescription("配置所属分类的编码")
|
||||||
private String groupCode;
|
private String groupCode;
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,6 @@ import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigParam;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统参数配置service接口
|
* 系统参数配置service接口
|
||||||
*
|
*
|
||||||
|
@ -89,16 +87,6 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
||||||
*/
|
*/
|
||||||
PageResult<SysConfig> findPage(SysConfigParam sysConfigParam);
|
PageResult<SysConfig> findPage(SysConfigParam sysConfigParam);
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询系统参数配置
|
|
||||||
*
|
|
||||||
* @param sysConfigParam 查询参数
|
|
||||||
* @return 系统参数配置列表
|
|
||||||
* @author fengshuonan
|
|
||||||
* @since 2020/4/14 11:14
|
|
||||||
*/
|
|
||||||
List<SysConfig> findList(SysConfigParam sysConfigParam);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化配置参数
|
* 初始化配置参数
|
||||||
*
|
*
|
||||||
|
|
|
@ -45,6 +45,7 @@ import cn.stylefeng.roses.kernel.config.modular.pojo.param.SysConfigParam;
|
||||||
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageFactory;
|
||||||
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
import cn.stylefeng.roses.kernel.db.api.factory.PageResultFactory;
|
||||||
|
import cn.stylefeng.roses.kernel.db.api.pojo.entity.BaseEntity;
|
||||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||||
import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback;
|
import cn.stylefeng.roses.kernel.rule.callback.ConfigUpdateCallback;
|
||||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||||
|
@ -148,17 +149,11 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<SysConfig> findPage(SysConfigParam sysConfigParam) {
|
public PageResult<SysConfig> findPage(SysConfigParam sysConfigParam) {
|
||||||
LambdaQueryWrapper<SysConfig> wrapper = createWrapper(sysConfigParam);
|
LambdaQueryWrapper<SysConfig> wrapper = this.createWrapper(sysConfigParam);
|
||||||
Page<SysConfig> page = this.page(PageFactory.defaultPage(), wrapper);
|
Page<SysConfig> page = this.page(PageFactory.defaultPage(), wrapper);
|
||||||
return PageResultFactory.createPageResult(page);
|
return PageResultFactory.createPageResult(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<SysConfig> findList(SysConfigParam sysConfigParam) {
|
|
||||||
LambdaQueryWrapper<SysConfig> wrapper = createWrapper(sysConfigParam);
|
|
||||||
return this.list(wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void initConfig(ConfigInitRequest configInitRequest) {
|
public void initConfig(ConfigInitRequest configInitRequest) {
|
||||||
|
@ -295,29 +290,22 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
private LambdaQueryWrapper<SysConfig> createWrapper(SysConfigParam sysConfigParam) {
|
private LambdaQueryWrapper<SysConfig> createWrapper(SysConfigParam sysConfigParam) {
|
||||||
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
// 查询未删除的
|
// 根据查询名称搜索
|
||||||
queryWrapper.ne(SysConfig::getDelFlag, YesOrNotEnum.Y.getCode());
|
String searchText = sysConfigParam.getSearchText();
|
||||||
|
if (ObjectUtil.isNotEmpty(searchText)) {
|
||||||
// 按类型升序排列,同类型的排在一起
|
queryWrapper.like(SysConfig::getConfigName, searchText);
|
||||||
queryWrapper.orderByDesc(SysConfig::getGroupCode);
|
queryWrapper.or().like(SysConfig::getConfigCode, searchText);
|
||||||
|
queryWrapper.or().like(SysConfig::getConfigValue, searchText);
|
||||||
if (ObjectUtil.isEmpty(sysConfigParam)) {
|
queryWrapper.or().like(SysConfig::getRemark, searchText);
|
||||||
return queryWrapper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String configName = sysConfigParam.getConfigName();
|
|
||||||
String configCode = sysConfigParam.getConfigCode();
|
|
||||||
String groupCode = sysConfigParam.getGroupCode();
|
|
||||||
|
|
||||||
// 如果名称不为空,则带上名称搜素搜条件
|
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(configName), SysConfig::getConfigName, configName);
|
|
||||||
|
|
||||||
// 如果常量编码不为空,则带上常量编码搜素搜条件
|
|
||||||
queryWrapper.like(ObjectUtil.isNotEmpty(configCode), SysConfig::getConfigCode, configCode);
|
|
||||||
|
|
||||||
// 如果分类编码不为空,则带上分类编码
|
// 如果分类编码不为空,则带上分类编码
|
||||||
|
String groupCode = sysConfigParam.getGroupCode();
|
||||||
queryWrapper.eq(ObjectUtil.isNotEmpty(groupCode), SysConfig::getGroupCode, groupCode);
|
queryWrapper.eq(ObjectUtil.isNotEmpty(groupCode), SysConfig::getGroupCode, groupCode);
|
||||||
|
|
||||||
|
// 根据时间排序
|
||||||
|
queryWrapper.orderByDesc(BaseEntity::getCreateTime);
|
||||||
|
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue