news.js 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 信息表
  5. const NewsSchema = {
  6. col_name: { type: String, required: true, maxLength: 200 }, // 栏目名称
  7. title: { type: String, required: true, maxLength: 200 }, // 标题
  8. introduction: { type: String, required: true, maxLength: 200 }, // 简介
  9. content: { type: String, required: false }, // 内容
  10. publish_time: { type: String, required: false, maxLength: 200 }, // 发布时间
  11. publish_unit: { type: String, required: false, maxLength: 200 }, // 发布单位
  12. publisher: { type: String, required: true, maxLength: 200 }, // 发布人
  13. type: { type: String, required: false, maxLength: 200 }, // 0-自有,1-外链
  14. url: { type: String, required: false, maxLength: 200 }, // 链接地址
  15. img_url: { type: String, required: false, maxLength: 200 }, // 图片路径
  16. is_top: { type: String, required: false, maxLength: 200, default: '0' }, // 是否推荐,0-不推荐,1-推荐
  17. view_times: { type: String, required: false, maxLength: 200 }, // 浏览次数
  18. status: { type: String, required: false, maxLength: 200, default: '0' }, // 状态,0-草稿,1-未审核,2-已审核
  19. file_url: { type: String, required: false }, // 文件路径
  20. };
  21. const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('News', schema, 'news');
  27. };