forked from rzdata/demo-empty
Update from upstream #3
18
common/src/main/java/net/rzdata/demo/config/DemoConfig.java
Normal file
18
common/src/main/java/net/rzdata/demo/config/DemoConfig.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package net.rzdata.demo.config;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全局配置
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@ConfigurationProperties(prefix = "demo")
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class DemoConfig {
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package net.rzdata.demo.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加插件
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
// 分页插件
|
||||||
|
interceptor.addInnerInterceptor(paginationInnerInterceptor());
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaginationInnerInterceptor paginationInnerInterceptor() {
|
||||||
|
return new PaginationInnerInterceptor();
|
||||||
|
}
|
||||||
|
}
|
29
common/src/main/java/net/rzdata/demo/trait/GetReq.java
Normal file
29
common/src/main/java/net/rzdata/demo/trait/GetReq.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package net.rzdata.demo.trait;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@ToString
|
||||||
|
public class GetReq<T> {
|
||||||
|
|
||||||
|
private Integer pageSize = 15;
|
||||||
|
private Integer pageNum = 1;
|
||||||
|
private String orderBy;
|
||||||
|
private Boolean asc = true;
|
||||||
|
|
||||||
|
public IPage<T> into() {
|
||||||
|
Page<T> page = new Page<>();
|
||||||
|
page.setSize(pageSize);
|
||||||
|
page.setCurrent(pageNum);
|
||||||
|
if (orderBy != null) {
|
||||||
|
page.addOrder(this.asc ? OrderItem.asc(orderBy) : OrderItem.desc(orderBy));
|
||||||
|
}
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
}
|
@ -1 +1,3 @@
|
|||||||
net.rzdata.demo.exception.GlobalExceptionHandler
|
net.rzdata.demo.exception.GlobalExceptionHandler
|
||||||
|
net.rzdata.demo.config.DemoConfig
|
||||||
|
net.rzdata.demo.config.MybatisPlusConfig
|
||||||
|
@ -54,6 +54,10 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.mysql</groupId>
|
<groupId>com.mysql</groupId>
|
||||||
<artifactId>mysql-connector-j</artifactId>
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
@ -19,3 +19,11 @@ spring:
|
|||||||
maximum-pool-size: 20
|
maximum-pool-size: 20
|
||||||
idle-timeout: 30000
|
idle-timeout: 30000
|
||||||
max-lifetime: 1800000
|
max-lifetime: 1800000
|
||||||
|
mybatis-plus:
|
||||||
|
configuration:
|
||||||
|
log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
root: info
|
||||||
|
net.rzdata: debug
|
||||||
|
com.baomidou.example.mapper: debug
|
||||||
|
Loading…
x
Reference in New Issue
Block a user