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.service.SysConfigService;
|
||||
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.SuccessResponseData;
|
||||
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
|
||||
|
@ -100,13 +101,13 @@ public class SysConfigController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 分页查询配置列表
|
||||
* 分页查询配置列表,查询配置列表时候,必须带上配置分类的标识
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2020/4/14 11:10
|
||||
*/
|
||||
@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));
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ public class SysConfigParam extends BaseRequest {
|
|||
/**
|
||||
* 配置所属分类的编码,来自于字典编码“config_group”字典
|
||||
*/
|
||||
@NotBlank(message = "配置所属分类的编码不能为空", groups = {add.class})
|
||||
@NotBlank(message = "配置所属分类的编码不能为空", groups = {add.class, page.class})
|
||||
@ChineseDescription("配置所属分类的编码")
|
||||
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 com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 系统参数配置service接口
|
||||
*
|
||||
|
@ -89,16 +87,6 @@ public interface SysConfigService extends IService<SysConfig>, InitConfigApi {
|
|||
*/
|
||||
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.db.api.factory.PageFactory;
|
||||
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.rule.callback.ConfigUpdateCallback;
|
||||
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
|
||||
|
@ -148,17 +149,11 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
|
||||
@Override
|
||||
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);
|
||||
return PageResultFactory.createPageResult(page);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysConfig> findList(SysConfigParam sysConfigParam) {
|
||||
LambdaQueryWrapper<SysConfig> wrapper = createWrapper(sysConfigParam);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void initConfig(ConfigInitRequest configInitRequest) {
|
||||
|
@ -295,29 +290,22 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
|||
private LambdaQueryWrapper<SysConfig> createWrapper(SysConfigParam sysConfigParam) {
|
||||
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 查询未删除的
|
||||
queryWrapper.ne(SysConfig::getDelFlag, YesOrNotEnum.Y.getCode());
|
||||
|
||||
// 按类型升序排列,同类型的排在一起
|
||||
queryWrapper.orderByDesc(SysConfig::getGroupCode);
|
||||
|
||||
if (ObjectUtil.isEmpty(sysConfigParam)) {
|
||||
return queryWrapper;
|
||||
// 根据查询名称搜索
|
||||
String searchText = sysConfigParam.getSearchText();
|
||||
if (ObjectUtil.isNotEmpty(searchText)) {
|
||||
queryWrapper.like(SysConfig::getConfigName, searchText);
|
||||
queryWrapper.or().like(SysConfig::getConfigCode, searchText);
|
||||
queryWrapper.or().like(SysConfig::getConfigValue, searchText);
|
||||
queryWrapper.or().like(SysConfig::getRemark, searchText);
|
||||
}
|
||||
|
||||
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.orderByDesc(BaseEntity::getCreateTime);
|
||||
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue