添加分页插件支持
This commit is contained in:
parent
f80c3ef0c7
commit
863f81a3b3
@ -0,0 +1,18 @@
|
|||||||
|
package com.example.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
|
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 MybatisConfiguration {
|
||||||
|
@Bean
|
||||||
|
public MybatisPlusInterceptor mybatisPlusInterceptor(){
|
||||||
|
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||||
|
//添加分页插件
|
||||||
|
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||||
|
return interceptor;
|
||||||
|
}
|
||||||
|
}
|
@ -65,9 +65,9 @@ public class TopicServiceImpl extends ServiceImpl<TopicMapper, Topic> implements
|
|||||||
//无缓存从数据库读取
|
//无缓存从数据库读取
|
||||||
Page<Topic> page = Page.of(pageNumber, 10);
|
Page<Topic> page = Page.of(pageNumber, 10);
|
||||||
if(type == 0)
|
if(type == 0)
|
||||||
this.baseMapper.selectPage(page, null);
|
this.baseMapper.selectPage(page, Wrappers.<Topic>query().orderByDesc("time"));
|
||||||
else
|
else
|
||||||
this.baseMapper.selectPage(page, Wrappers.<Topic>query().eq("type", type));
|
this.baseMapper.selectPage(page, Wrappers.<Topic>query().eq("type", type).orderByDesc("time"));
|
||||||
List<Topic> topics = page.getRecords();
|
List<Topic> topics = page.getRecords();
|
||||||
if(topics.isEmpty()) return null;
|
if(topics.isEmpty()) return null;
|
||||||
list = topics.stream().map(this::resolveToPreview).toList();
|
list = topics.stream().map(this::resolveToPreview).toList();
|
||||||
|
@ -18,13 +18,13 @@ public class CacheUtils {
|
|||||||
public <T> T takeFromCache(String key, Class<T> dataType) {
|
public <T> T takeFromCache(String key, Class<T> dataType) {
|
||||||
String s = template.opsForValue().get(key);
|
String s = template.opsForValue().get(key);
|
||||||
if(s == null) return null;
|
if(s == null) return null;
|
||||||
return JSONObject.from(s).to(dataType);
|
return JSONObject.parseObject(s).to(dataType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> List<T> takeListFromCache(String key, Class<T> itemType) {
|
public <T> List<T> takeListFromCache(String key, Class<T> itemType) {
|
||||||
String s = template.opsForValue().get(key);
|
String s = template.opsForValue().get(key);
|
||||||
if(s == null) return null;
|
if(s == null) return null;
|
||||||
return JSONArray.from(s).toList(itemType);
|
return JSONArray.parseArray(s).toList(itemType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> void saveToCache(String key, T data, long expire) {
|
public <T> void saveToCache(String key, T data, long expire) {
|
||||||
|
@ -20,7 +20,7 @@ const today = computed(() => {
|
|||||||
const date = new Date()
|
const date = new Date()
|
||||||
return `${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`
|
return `${date.getFullYear()} 年 ${date.getMonth() + 1} 月 ${date.getDate()} 日`
|
||||||
})
|
})
|
||||||
get('/api/forum/list-topic?page=1&type=0', data => list.value = data)
|
get('/api/forum/list-topic?page=0&type=0', data => list.value = data)
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition(position => {
|
navigator.geolocation.getCurrentPosition(position => {
|
||||||
const latitude = position.coords.latitude
|
const latitude = position.coords.latitude
|
||||||
|
Loading…
x
Reference in New Issue
Block a user