feat(): 增加分页模型,增加DDD模型概念
parent
3a875840ad
commit
fa29749b22
|
@ -1,32 +0,0 @@
|
||||||
package com.muyu.common.core.utils;
|
|
||||||
|
|
||||||
import com.github.pagehelper.PageHelper;
|
|
||||||
import com.muyu.common.core.utils.sql.SqlUtil;
|
|
||||||
import com.muyu.common.core.web.page.PageDomain;
|
|
||||||
import com.muyu.common.core.web.page.TableSupport;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页工具类
|
|
||||||
*
|
|
||||||
* @author muyu
|
|
||||||
*/
|
|
||||||
public class PageUtils extends PageHelper {
|
|
||||||
/**
|
|
||||||
* 设置请求分页数据
|
|
||||||
*/
|
|
||||||
public static void startPage () {
|
|
||||||
PageDomain pageDomain = TableSupport.buildPageRequest();
|
|
||||||
Integer pageNum = pageDomain.getPageNum();
|
|
||||||
Integer pageSize = pageDomain.getPageSize();
|
|
||||||
String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
|
|
||||||
Boolean reasonable = pageDomain.getReasonable();
|
|
||||||
PageHelper.startPage(pageNum, pageSize, orderBy).setReasonable(reasonable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理分页的线程变量
|
|
||||||
*/
|
|
||||||
public static void clearPage () {
|
|
||||||
PageHelper.clearPage();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,6 @@
|
||||||
package com.muyu.common.core.web.controller;
|
package com.muyu.common.core.web.controller;
|
||||||
|
|
||||||
import com.github.pagehelper.PageInfo;
|
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.core.utils.DateUtils;
|
||||||
import com.muyu.common.core.utils.PageUtils;
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.web.page.TableDataInfo;
|
import com.muyu.common.core.web.page.TableDataInfo;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -36,33 +34,6 @@ public class BaseController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置请求分页数据
|
|
||||||
*/
|
|
||||||
protected void startPage () {
|
|
||||||
PageUtils.startPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 清理分页的线程变量
|
|
||||||
*/
|
|
||||||
protected void clearPage () {
|
|
||||||
PageUtils.clearPage();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 响应请求分页数据
|
|
||||||
*/
|
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
|
||||||
protected <T> Result<TableDataInfo<T>> getDataTable (List<T> list) {
|
|
||||||
return Result.success(
|
|
||||||
TableDataInfo.<T>builder()
|
|
||||||
.total(new PageInfo(list).getTotal())
|
|
||||||
.rows(list)
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功
|
* 返回成功
|
||||||
*/
|
*/
|
||||||
|
@ -73,35 +44,35 @@ public class BaseController {
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*/
|
*/
|
||||||
public Result success (String message) {
|
public Result<String> success (String message) {
|
||||||
return Result.success(message);
|
return Result.success(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回成功消息
|
* 返回成功消息
|
||||||
*/
|
*/
|
||||||
public Result success (Object data) {
|
public Result success (Object data) {
|
||||||
return Result.success(data);
|
return Result.success(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public Result error () {
|
public Result<String> error () {
|
||||||
return Result.error();
|
return Result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回失败消息
|
* 返回失败消息
|
||||||
*/
|
*/
|
||||||
public Result error (String message) {
|
public Result<String> error (String message) {
|
||||||
return Result.error(message);
|
return Result.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回警告消息
|
* 返回警告消息
|
||||||
*/
|
*/
|
||||||
public Result warn (String message) {
|
public Result<String> warn (String message) {
|
||||||
return Result.warn(message);
|
return Result.warn(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,7 +83,7 @@ public class BaseController {
|
||||||
*
|
*
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected Result toAjax (int rows) {
|
protected Result<String> toAjax (int rows) {
|
||||||
return rows > 0 ? Result.success() : Result.error();
|
return rows > 0 ? Result.success() : Result.error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +94,7 @@ public class BaseController {
|
||||||
*
|
*
|
||||||
* @return 操作结果
|
* @return 操作结果
|
||||||
*/
|
*/
|
||||||
protected Result toAjax (boolean result) {
|
protected Result<String> toAjax (boolean result) {
|
||||||
return result ? success() : error();
|
return result ? success() : error();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.muyu.common.core.web.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.muyu.common.core.web.page.PageReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询模型
|
||||||
|
*
|
||||||
|
* @author DongZeLiang
|
||||||
|
* @date 2024-11-20 14:18
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class QueryModel<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前记录起始索引
|
||||||
|
*/
|
||||||
|
private Integer pageNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每页显示记录数
|
||||||
|
*/
|
||||||
|
private Integer pageSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序列
|
||||||
|
*/
|
||||||
|
private String orderByColumn;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 排序的方向desc或者asc
|
||||||
|
*/
|
||||||
|
private boolean isAsc = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建模型分页对象
|
||||||
|
* @param pageReq 分页参数
|
||||||
|
* @return 模型分页对象
|
||||||
|
*/
|
||||||
|
public T domainBuild(PageReq pageReq) {
|
||||||
|
this.pageNum = pageReq.getPageNum();
|
||||||
|
this.pageSize = pageReq.getPageSize();
|
||||||
|
this.orderByColumn = pageReq.getOrderByColumn();
|
||||||
|
this.isAsc = "asc".equals(pageReq.getIsAsc());
|
||||||
|
return (T) this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建查询分页对象
|
||||||
|
* @return 查询分页对象
|
||||||
|
*/
|
||||||
|
public <I> Page<I> buildPage(){
|
||||||
|
Page<I> page = Page.of(this.getPageNum(), this.getPageSize());
|
||||||
|
page.setOrders(List.of(this.isAsc()
|
||||||
|
? OrderItem.asc(this.getOrderByColumn()) : OrderItem.desc(this.getOrderByColumn())));
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,13 +1,21 @@
|
||||||
package com.muyu.common.core.web.page;
|
package com.muyu.common.core.web.page;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页数据
|
* 分页数据
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public class PageDomain {
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class PageReq {
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引
|
* 当前记录起始索引
|
||||||
*/
|
*/
|
||||||
|
@ -40,34 +48,6 @@ public class PageDomain {
|
||||||
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPageNum () {
|
|
||||||
return pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageNum (Integer pageNum) {
|
|
||||||
this.pageNum = pageNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPageSize () {
|
|
||||||
return pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPageSize (Integer pageSize) {
|
|
||||||
this.pageSize = pageSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOrderByColumn () {
|
|
||||||
return orderByColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOrderByColumn (String orderByColumn) {
|
|
||||||
this.orderByColumn = orderByColumn;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIsAsc () {
|
|
||||||
return isAsc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsAsc (String isAsc) {
|
public void setIsAsc (String isAsc) {
|
||||||
if (StringUtils.isNotEmpty(isAsc)) {
|
if (StringUtils.isNotEmpty(isAsc)) {
|
||||||
// 兼容前端排序类型
|
// 兼容前端排序类型
|
||||||
|
@ -87,7 +67,4 @@ public class PageDomain {
|
||||||
return reasonable;
|
return reasonable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReasonable (Boolean reasonable) {
|
|
||||||
this.reasonable = reasonable;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.common.core.web.page;
|
package com.muyu.common.core.web.page;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -32,14 +33,7 @@ public class TableDataInfo<T> implements Serializable {
|
||||||
*/
|
*/
|
||||||
private List<T> rows;
|
private List<T> rows;
|
||||||
|
|
||||||
/**
|
public static <T> TableDataInfo<T> of(Page<T> list) {
|
||||||
* 消息状态码
|
return new TableDataInfo<>(list.getTotal(), list.getRecords());
|
||||||
*/
|
}
|
||||||
private int code;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 消息内容
|
|
||||||
*/
|
|
||||||
private String msg;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,17 +37,17 @@ public class TableSupport {
|
||||||
/**
|
/**
|
||||||
* 封装分页对象
|
* 封装分页对象
|
||||||
*/
|
*/
|
||||||
public static PageDomain getPageDomain () {
|
public static PageReq getPageDomain () {
|
||||||
PageDomain pageDomain = new PageDomain();
|
PageReq pageReq = new PageReq();
|
||||||
pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
pageReq.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
|
||||||
pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
pageReq.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
|
||||||
pageDomain.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
|
pageReq.setOrderByColumn(ServletUtils.getParameter(ORDER_BY_COLUMN));
|
||||||
pageDomain.setIsAsc(ServletUtils.getParameter(IS_ASC));
|
pageReq.setIsAsc(ServletUtils.getParameter(IS_ASC));
|
||||||
pageDomain.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
|
pageReq.setReasonable(ServletUtils.getParameterToBool(REASONABLE));
|
||||||
return pageDomain;
|
return pageReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PageDomain buildPageRequest () {
|
public static PageReq buildPageRequest () {
|
||||||
return getPageDomain();
|
return getPageDomain();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.system.controller;
|
package com.muyu.system.controller;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
import com.muyu.common.core.web.controller.BaseController;
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
@ -9,6 +10,8 @@ import com.muyu.common.log.enums.BusinessType;
|
||||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.system.domain.SysConfig;
|
import com.muyu.system.domain.SysConfig;
|
||||||
|
import com.muyu.system.domain.model.SysConfigPageQueryModel;
|
||||||
|
import com.muyu.system.domain.rep.SysConfigListReq;
|
||||||
import com.muyu.system.service.SysConfigService;
|
import com.muyu.system.service.SysConfigService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
@ -39,10 +42,9 @@ public class SysConfigController extends BaseController {
|
||||||
@RequiresPermissions("system:config:list")
|
@RequiresPermissions("system:config:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@Operation(summary = "查询集合", description = "更新水果信息")
|
@Operation(summary = "查询集合", description = "更新水果信息")
|
||||||
public Result<TableDataInfo<SysConfig>> list (SysConfig config) {
|
public Result<TableDataInfo<SysConfig>> list (SysConfigListReq sysConfigListReq) {
|
||||||
startPage();
|
Page<SysConfig> list = configService.pageQuery(SysConfigPageQueryModel.reqBuild(sysConfigListReq));
|
||||||
List<SysConfig> list = configService.pageQuery(config);
|
return Result.success(TableDataInfo.of(list));
|
||||||
return getDataTable(list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.muyu.system.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.model.QueryModel;
|
||||||
|
import com.muyu.system.domain.rep.SysConfigListReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数配置 分页 模型
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
public class SysConfigPageQueryModel extends QueryModel<SysConfigPageQueryModel> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置名称
|
||||||
|
*/
|
||||||
|
private String configName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置Key
|
||||||
|
*/
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置类型
|
||||||
|
*/
|
||||||
|
private String configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private Date beginTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
|
||||||
|
public static SysConfigPageQueryModel reqBuild(SysConfigListReq sysConfigListReq) {
|
||||||
|
SysConfigPageQueryModel configPageQueryModel = SysConfigPageQueryModel.builder()
|
||||||
|
.configName(sysConfigListReq.getConfigName())
|
||||||
|
.configType(sysConfigListReq.getConfigType())
|
||||||
|
.configKey(sysConfigListReq.getConfigKey())
|
||||||
|
.beginTime(sysConfigListReq.getBeginTime())
|
||||||
|
.endTime(sysConfigListReq.getEndTime())
|
||||||
|
.build();
|
||||||
|
configPageQueryModel.domainBuild(sysConfigListReq);
|
||||||
|
return configPageQueryModel;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.muyu.system.domain.rep;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.page.PageReq;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数请求列表查询对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class SysConfigListReq extends PageReq {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置名称
|
||||||
|
*/
|
||||||
|
private String configName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置Key
|
||||||
|
*/
|
||||||
|
private String configKey;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配置类型
|
||||||
|
*/
|
||||||
|
private String configType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private Date beginTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private Date endTime;
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
package com.muyu.system.service;
|
package com.muyu.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.system.domain.SysConfig;
|
import com.muyu.system.domain.SysConfig;
|
||||||
|
import com.muyu.system.domain.model.SysConfigPageQueryModel;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -11,7 +13,9 @@ import java.util.List;
|
||||||
* @Date 2023-11-13 上午 10:06
|
* @Date 2023-11-13 上午 10:06
|
||||||
*/
|
*/
|
||||||
public interface SysConfigService extends IService<SysConfig> {
|
public interface SysConfigService extends IService<SysConfig> {
|
||||||
List<SysConfig> pageQuery (SysConfig config);
|
|
||||||
|
|
||||||
|
Page<SysConfig> pageQuery (SysConfigPageQueryModel pageQueryModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过Key进行查询值
|
* 通过Key进行查询值
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.muyu.system.service.impl;
|
package com.muyu.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
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.muyu.common.core.constant.CacheConstants;
|
import com.muyu.common.core.constant.CacheConstants;
|
||||||
import com.muyu.common.core.utils.StringUtils;
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
import com.muyu.common.redis.service.RedisService;
|
import com.muyu.common.redis.service.RedisService;
|
||||||
import com.muyu.system.domain.SysConfig;
|
import com.muyu.system.domain.SysConfig;
|
||||||
|
import com.muyu.system.domain.model.SysConfigPageQueryModel;
|
||||||
import com.muyu.system.mapper.SysConfigMapper;
|
import com.muyu.system.mapper.SysConfigMapper;
|
||||||
import com.muyu.system.service.SysConfigService;
|
import com.muyu.system.service.SysConfigService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -30,26 +32,27 @@ public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SysConfig> pageQuery (SysConfig config) {
|
public Page<SysConfig> pageQuery (SysConfigPageQueryModel pageQueryModel) {
|
||||||
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<SysConfig> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotEmpty(config.getConfigName())){
|
if (StringUtils.isNotEmpty(pageQueryModel.getConfigName())){
|
||||||
queryWrapper.like(SysConfig::getConfigName, config.getConfigName());
|
queryWrapper.like(SysConfig::getConfigName, pageQueryModel.getConfigName());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(config.getConfigType())){
|
if (StringUtils.isNotEmpty(pageQueryModel.getConfigType())){
|
||||||
queryWrapper.like(SysConfig::getConfigType, config.getConfigType());
|
queryWrapper.like(SysConfig::getConfigType, pageQueryModel.getConfigType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(config.getConfigKey())){
|
if (StringUtils.isNotEmpty(pageQueryModel.getConfigKey())){
|
||||||
queryWrapper.like(SysConfig::getConfigKey, config.getConfigKey());
|
queryWrapper.like(SysConfig::getConfigKey, pageQueryModel.getConfigKey());
|
||||||
}
|
}
|
||||||
Object beginTime = config.getParams().get("beginTime");
|
Date beginTime = pageQueryModel.getBeginTime();
|
||||||
if (Objects.nonNull(beginTime) && beginTime instanceof Date beginDate){
|
if (Objects.nonNull(beginTime)){
|
||||||
queryWrapper.gt(SysConfig::getCreateTime, beginDate);
|
queryWrapper.gt(SysConfig::getCreateTime, beginTime);
|
||||||
}
|
}
|
||||||
Object endTime = config.getParams().get("endTime");
|
Date endTime = pageQueryModel.getEndTime();
|
||||||
if (Objects.nonNull(endTime) && endTime instanceof Date endDate){
|
if (Objects.nonNull(endTime)){
|
||||||
queryWrapper.lt(SysConfig::getCreateTime, endDate);
|
queryWrapper.lt(SysConfig::getCreateTime, endTime);
|
||||||
}
|
}
|
||||||
return this.list(queryWrapper);
|
Page<SysConfig> configPage = this.page(pageQueryModel.buildPage(), queryWrapper);
|
||||||
|
return configPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue