|
@@ -0,0 +1,83 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+// 线路
|
|
|
+const route = {
|
|
|
+ item: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '项目', filter: 'select', required: true },
|
|
|
+ },
|
|
|
+ s_p: {
|
|
|
+ type: String,
|
|
|
+ required: true,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '起始地省份', filter: true, required: true },
|
|
|
+ },
|
|
|
+ s_c: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '起始地城市', filter: true, required: true },
|
|
|
+ },
|
|
|
+ e_p: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '目的地省份', filter: true, required: true },
|
|
|
+ }, // 存储内容
|
|
|
+ e_c: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '目的地城市', filter: true, required: true },
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '线路名称', filter: true, required: true },
|
|
|
+ },
|
|
|
+ start: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '起始地地点' },
|
|
|
+ },
|
|
|
+ end: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ field: { label: '目的地地点' },
|
|
|
+ },
|
|
|
+ status: {
|
|
|
+ type: String,
|
|
|
+ maxLength: 200,
|
|
|
+ default: '0',
|
|
|
+ field: {
|
|
|
+ label: '状态',
|
|
|
+ filter: 'select',
|
|
|
+ type: 'select',
|
|
|
+ format: (i => (i === '0' ? '使用' : '禁用')).toString(),
|
|
|
+ list: [
|
|
|
+ { label: '使用', value: '0' },
|
|
|
+ { label: '禁用', value: '1' },
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ }, // 状态:0=>使用;1禁用
|
|
|
+ owner: { type: String, required: true }, // 创建人
|
|
|
+};
|
|
|
+
|
|
|
+const schema = new Schema(route, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ s_p: 1 });
|
|
|
+schema.index({ s_c: 1 });
|
|
|
+schema.index({ e_p: 1 });
|
|
|
+schema.index({ e_c: 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ start: 1 });
|
|
|
+schema.index({ end: 1 });
|
|
|
+schema.index({ status: 1 });
|
|
|
+schema.index({ owner: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Route', schema, 'route');
|
|
|
+};
|