|
@@ -12,17 +12,17 @@ class NewsService extends CrudService {
|
|
this.model = this.ctx.model.News;
|
|
this.model = this.ctx.model.News;
|
|
}
|
|
}
|
|
|
|
|
|
- async create({ column, site }, { title, content, picurl, top, tags, attachment, issuer }) {
|
|
|
|
|
|
+ async create({ site }, { title, pic, content, type, parent_id, parent, attachment, is_use }) {
|
|
// 检查数据
|
|
// 检查数据
|
|
- assert(_.isString(column), 'column不能为空');
|
|
|
|
assert(_.isString(site), 'site不能为空');
|
|
assert(_.isString(site), 'site不能为空');
|
|
assert(_.isString(title), 'title不能为空');
|
|
assert(_.isString(title), 'title不能为空');
|
|
- assert(_.isString(content), 'content不能为空');
|
|
|
|
- assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
|
|
|
|
- assert(_.isUndefined(top) || _.isNumber(top), 'top必须为数字');
|
|
|
|
- assert(!tags || _.isArray(tags), 'tags必须为数组');
|
|
|
|
|
|
+ assert(!pic || _.isString(pic), 'pic必须为字符串');
|
|
|
|
+ assert(!content || _.isString(content), 'content必须为字符串');
|
|
|
|
+ assert(!type || _.isString(type), 'type必须为字符串');
|
|
|
|
+ assert(!parent_id || _.isString(parent_id), 'parent_id必须为字符串');
|
|
|
|
+ assert(!parent || _.isString(parent), 'parent必须为字符串');
|
|
assert(!attachment || _.isArray(attachment), 'attachment必须为数组');
|
|
assert(!attachment || _.isArray(attachment), 'attachment必须为数组');
|
|
- assert(!issuer || _.isString(issuer), 'issuer必须为字符串');
|
|
|
|
|
|
+ assert(!is_use || _.isString(is_use), 'is_use必须为字符串');
|
|
|
|
|
|
// TODO: 检查用户信息
|
|
// TODO: 检查用户信息
|
|
const userid = this.ctx.userid;
|
|
const userid = this.ctx.userid;
|
|
@@ -30,7 +30,7 @@ class NewsService extends CrudService {
|
|
|
|
|
|
// TODO:保存数据
|
|
// TODO:保存数据
|
|
const data = {
|
|
const data = {
|
|
- site,column, title, content, picurl, top, tags, attachment, issuer,
|
|
|
|
|
|
+ site, title, pic, content, type, parent_id, parent, attachment, is_use,
|
|
meta: { createdBy: userid },
|
|
meta: { createdBy: userid },
|
|
};
|
|
};
|
|
|
|
|
|
@@ -40,16 +40,16 @@ class NewsService extends CrudService {
|
|
|
|
|
|
async update({ id }, payload) {
|
|
async update({ id }, payload) {
|
|
// 检查数据
|
|
// 检查数据
|
|
- const { title, content, picurl, top, tags, attachment, issuer } = payload;
|
|
|
|
|
|
+ const { title, pic, content, type, parent_id, parent, attachment, is_use } = payload;
|
|
assert(id, 'id不能为空');
|
|
assert(id, 'id不能为空');
|
|
assert(!title || _.isString(title), 'title必须为字符串');
|
|
assert(!title || _.isString(title), 'title必须为字符串');
|
|
- // assert(_.isString(site), 'site不能为空');
|
|
|
|
|
|
+ assert(!pic || _.isString(pic), 'pic必须为字符串');
|
|
assert(!content || _.isString(content), 'content必须为字符串');
|
|
assert(!content || _.isString(content), 'content必须为字符串');
|
|
- assert(!picurl || _.isString(picurl), 'picurl必须为字符串');
|
|
|
|
- assert(_.isUndefined(top) || _.isNumber(top), 'top必须为数字');
|
|
|
|
- assert(!tags || _.isArray(tags), 'tags必须为数组');
|
|
|
|
|
|
+ assert(!type || _.isString(type), 'type必须为字符串');
|
|
|
|
+ assert(!parent_id || _.isString(parent_id), 'parent_id必须为字符串');
|
|
|
|
+ assert(!parent || _.isString(parent), 'parent必须为字符串');
|
|
assert(!attachment || _.isArray(attachment), 'attachment必须为数组');
|
|
assert(!attachment || _.isArray(attachment), 'attachment必须为数组');
|
|
- assert(!issuer || _.isString(issuer), 'issuer必须为字符串');
|
|
|
|
|
|
+ assert(!is_use || _.isString(is_use), 'is_use必须为字符串');
|
|
|
|
|
|
// TODO: 检查用户信息
|
|
// TODO: 检查用户信息
|
|
const userid = this.ctx.userid;
|
|
const userid = this.ctx.userid;
|