|
@@ -0,0 +1,39 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const moment = require('moment');
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
|
|
|
+
|
|
|
+const zf = new Schema({
|
|
|
+ mobile: { type: String, maxLength: 200 },
|
|
|
+ account: { type: String, maxLength: 200 },
|
|
|
+ name: { type: String, maxLength: 200 },
|
|
|
+ remark: { type: String, maxLength: 200 },
|
|
|
+});
|
|
|
+
|
|
|
+
|
|
|
+const card = {
|
|
|
+ mobile: { type: String, required: true, maxLength: 11, unique: true },
|
|
|
+ password: { type: Secret, required: true, select: false },
|
|
|
+ province: { type: String, required: true },
|
|
|
+ set: { type: String, required: true },
|
|
|
+ pay_type: { type: String },
|
|
|
+ name: { type: String, required: true },
|
|
|
+ id_card: { type: String, required: true },
|
|
|
+ level: { type: String, required: true },
|
|
|
+ points: { type: String, required: true },
|
|
|
+ recommend: { type: String, required: true },
|
|
|
+ r_mobile: { type: String, required: true },
|
|
|
+ zf: { type: zf },
|
|
|
+ create_time: {
|
|
|
+ type: String,
|
|
|
+ default: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
+ },
|
|
|
+};
|
|
|
+const schema = new Schema(card, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('Card', schema, 'card');
|
|
|
+};
|