|
@@ -0,0 +1,26 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
|
|
|
+const { Secret } = require('naf-framework-mongoose/lib/model/schema');
|
|
|
+
|
|
|
+const UserSchema = {
|
|
|
+ name: { type: String, required: false, maxLength: 200 },
|
|
|
+ phone: { type: String, required: true, maxLength: 64 },
|
|
|
+ passwd: { type: Secret, select: false },
|
|
|
+ openid: { type: String, required: false },
|
|
|
+ uid: { type: String, required: false },
|
|
|
+ role: { type: String, required: false },
|
|
|
+ menus: { type: [ String ], required: false },
|
|
|
+ deptname: { type: String, required: false },
|
|
|
+ remark: { type: String, required: false },
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
+const schema = new Schema(UserSchema, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('User', schema, 'user');
|
|
|
+};
|