Commit f59952e6 by luyt

feat:调整分页逻辑

1 parent 627d0175
......@@ -35,19 +35,21 @@ class TrackService extends Service {
// console.log('params: ', params);
const { app } = this;
// 分页
const page = +params.page || 1;
const pageSize = +params.pageSize || 10;
const blogPageList = await app.model.Track.findAll({
// order: [
// [ 'id', 'desc' ],
// ],
limit: +params.pageSize || 10,
offset: +params.page || 1,
limit: pageSize,
offset: (page - 1) * pageSize,
});
const blogListAndCount = await app.model.Track.findAndCountAll();
return {
code: 200,
message: '查询成功',
data: blogPageList || [],
total: blogListAndCount,
total: blogListAndCount.count,
};
}
}
......
......@@ -27,7 +27,7 @@ module.exports = appInfo => {
config.sequelize = {
dialect: 'mysql', // support: mysql, mariadb, postgres, mssql
timezone: '+08:00', // 时区问题
// timezone: '+08:00', // 时区问题
database: 'track_info',
host: '192.168.3.210',
port: 3308,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!