...
|
...
|
@@ -8,16 +8,33 @@ const mysqlCli = global.yoho.utils.mysqlCli; |
|
|
|
|
|
const TABLE_ACT_ARTICLE = 'act_article';
|
|
|
|
|
|
class Article {
|
|
|
static allArticles() {
|
|
|
class ArticleModel extends global.yoho.BaseModel {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取所有文章
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
allArticles() {
|
|
|
return mysqlCli.query(`select * from ${TABLE_ACT_ARTICLE}`);
|
|
|
}
|
|
|
|
|
|
static createArticle({userName, content}) {
|
|
|
/**
|
|
|
* 发表文章
|
|
|
* @param userName
|
|
|
* @param content
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
createArticle({userName, content}) {
|
|
|
return mysqlCli.insert(
|
|
|
`insert into ${TABLE_ACT_ARTICLE} (user_name, content) values ('${userName}', '${content}');`
|
|
|
);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = Article; |
|
|
module.exports = ArticleModel;
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|