More development
This commit is contained in:
parent
dd02e98c91
commit
a666e1d351
7 changed files with 25 additions and 12 deletions
0
api/article/model.mjs
Normal file
0
api/article/model.mjs
Normal file
|
@ -38,9 +38,11 @@ export function initPool(core, config) {
|
||||||
core.log.info('Attempting to connect to MSSQL server')
|
core.log.info('Attempting to connect to MSSQL server')
|
||||||
pool.open()
|
pool.open()
|
||||||
|
|
||||||
|
// const sp = pool.procedureMgr()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
safeCallProc: function(name, params, options) {
|
safeCallProc: function(name, params, options) {
|
||||||
return pool.promises.callProc(name, params, options)
|
return pool.promises.callProc(config.schema + '.' + name, params, options)
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
let message = err.message
|
let message = err.message
|
||||||
if (err.lineNumber && err.procName) {
|
if (err.lineNumber && err.procName) {
|
||||||
|
|
|
@ -43,3 +43,9 @@ export async function getTree(ctx) {
|
||||||
tree: out
|
tree: out
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getPage(ctx, path, page = 0, per_page = 10) {
|
||||||
|
let res = await ctx.db.safeCallProc('pages_getpage', [path, page, per_page])
|
||||||
|
console.log([path, page, per_page])
|
||||||
|
console.log(res.results)
|
||||||
|
}
|
||||||
|
|
|
@ -13,4 +13,14 @@ export default class PageRoutes {
|
||||||
async getPageTree(ctx) {
|
async getPageTree(ctx) {
|
||||||
ctx.body = await this.Page.getTree(ctx)
|
ctx.body = await this.Page.getTree(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** GET: /api/page/[path] */
|
||||||
|
async getPage(ctx) {
|
||||||
|
ctx.body = await this.Page.getPage(
|
||||||
|
ctx,
|
||||||
|
ctx.params.path || null,
|
||||||
|
ctx.query.get('page') || 1,
|
||||||
|
ctx.query.get('per_page') || 10
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,8 @@ export function run(http, port, core) {
|
||||||
|
|
||||||
const page = new PageRoutes()
|
const page = new PageRoutes()
|
||||||
flaska.get('/api/pagetree', page.getPageTree.bind(page))
|
flaska.get('/api/pagetree', page.getPageTree.bind(page))
|
||||||
// flaska.get('/api/pages', page.getAllPages.bind(page))
|
flaska.get('/api/frontpage', page.getPage.bind(page))
|
||||||
|
flaska.get('/api/pages/:path', page.getPage.bind(page))
|
||||||
// flaska.get('/api/pages/:pageId', page.getSinglePage.bind(page))
|
// flaska.get('/api/pages/:pageId', page.getSinglePage.bind(page))
|
||||||
|
|
||||||
// const article = new ArticleRoutes()
|
// const article = new ArticleRoutes()
|
||||||
|
|
|
@ -11,9 +11,9 @@ exports.getTree = function() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getPage = function(id) {
|
exports.getPage = function(path, page) {
|
||||||
return common.sendRequest({
|
return common.sendRequest({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: '/api/pages/' + id + '?includes=media,banner,children,parent',
|
url: '/api/' + (path ? 'pages/' + path : 'frontpage') + '?page=' + (page || 1),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,15 +55,9 @@ const Frontpage = {
|
||||||
document.title = 'NFP Moe - Anime/Manga translation group'
|
document.title = 'NFP Moe - Anime/Manga translation group'
|
||||||
}
|
}
|
||||||
|
|
||||||
return Pagination.fetchPage(Article.getAllArticlesPagination({
|
return Page.getPage(null, this.lastpage)
|
||||||
per_page: 10,
|
|
||||||
page: this.lastpage,
|
|
||||||
includes: ['parent', 'files', 'media', 'banner', 'staff'],
|
|
||||||
}))
|
|
||||||
.then(function(result) {
|
.then(function(result) {
|
||||||
vnode.state.articles = result.data
|
console.log(result)
|
||||||
vnode.state.links = result.links
|
|
||||||
Frontpage.processFeatured(vnode, result.data)
|
|
||||||
})
|
})
|
||||||
.catch(function(err) {
|
.catch(function(err) {
|
||||||
vnode.state.error = err.message
|
vnode.state.error = err.message
|
||||||
|
|
Loading…
Reference in a new issue