-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
17 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* 每位工程师都有保持代码优雅的义务 | ||
* Each engineer has a duty to keep the code elegant | ||
* | ||
* @author wangxiao | ||
*/ | ||
|
||
// 一些工具方法 | ||
|
||
'use strict'; | ||
|
||
const tool = require('./tool'); | ||
const AV = require('leanengine') | ||
|
||
let pub = {}; | ||
|
||
// 获取所有 tags | ||
pub.tags = async(req, res) => { | ||
const queryTags = () => { | ||
const query = new AV.Query('Tags') | ||
return query.find() | ||
} | ||
|
||
try { | ||
const data = await queryTags() | ||
|
||
if (data) { | ||
let arr = [] | ||
for (let item of data) { | ||
let result = {} | ||
result.objectId = item.get('objectId') | ||
result.tagName = item.get('tagName') | ||
arr.push(result) | ||
} | ||
res.send(arr) | ||
|
||
} else { | ||
throw new Error("can not find tags") | ||
} | ||
} catch (error) { | ||
tool.l(error) | ||
} | ||
} | ||
|
||
module.exports = pub; |