|
@@ -26,45 +26,24 @@ class UserModel {
|
|
|
defaultSchema = {
|
|
|
username: {
|
|
|
type: String,
|
|
|
- required: true
|
|
|
},
|
|
|
email: {
|
|
|
type: String,
|
|
|
- required: true
|
|
|
},
|
|
|
mobile: {
|
|
|
type: String,
|
|
|
- required: true,
|
|
|
- validate: {
|
|
|
- validator: function(v) {
|
|
|
- return /^1([34578]\d)\d{8}$/.test(v);
|
|
|
- },
|
|
|
- message: '{VALUE} is not a valid phone number!'
|
|
|
- },
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存用户详情结构
|
|
|
- *
|
|
|
- * @var {object}
|
|
|
- */
|
|
|
- saveInfoSchema = {
|
|
|
+ },
|
|
|
real_name: {
|
|
|
type: String,
|
|
|
- required: true
|
|
|
},
|
|
|
company: {
|
|
|
type: String,
|
|
|
- required: true
|
|
|
},
|
|
|
province: {
|
|
|
type: String,
|
|
|
- required: true
|
|
|
},
|
|
|
area: {
|
|
|
type: Number,
|
|
|
- required: true
|
|
|
},
|
|
|
company_type: Number,
|
|
|
company_scale: Number,
|
|
@@ -75,21 +54,11 @@ class UserModel {
|
|
|
/**
|
|
|
* 构造函数
|
|
|
*
|
|
|
- * @param {string} scene
|
|
|
* @return {void}
|
|
|
*/
|
|
|
- constructor(scene = 'default') {
|
|
|
- let umDB = dbm.getCfgConnection("scConstruct");
|
|
|
- let schema = {};
|
|
|
- switch (scene) {
|
|
|
- case 'saveInfo':
|
|
|
- schema = this.saveInfoSchema;
|
|
|
- break;
|
|
|
- default:
|
|
|
- schema = this.defaultSchema;
|
|
|
- break;
|
|
|
- }
|
|
|
- let usersSchema = new mongoose.Schema(schema);
|
|
|
+ constructor() {
|
|
|
+ let umDB = dbm.getCfgConnection('scConstruct');
|
|
|
+ let usersSchema = new mongoose.Schema(this.defaultSchema);
|
|
|
this.model = umDB.model('users', usersSchema);
|
|
|
}
|
|
|
|
|
@@ -237,10 +206,10 @@ class UserModel {
|
|
|
}
|
|
|
let userModel = new this.model();
|
|
|
return new Promise(function(resolve, reject) {
|
|
|
- let validationError = userModel.validateSync();
|
|
|
- if (validationError) {
|
|
|
- reject(validationError);
|
|
|
- }
|
|
|
+ // let validationError = userModel.validateSync();
|
|
|
+ // if (validationError) {
|
|
|
+ // reject(validationError);
|
|
|
+ // }
|
|
|
userModel.update(condition, {$set: updateData}, function(error, result) {
|
|
|
if (error) {
|
|
|
reject(error);
|