|
@@ -47,6 +47,16 @@ module.exports = app => {
|
|
username: { type: 'string', required: true, min: 2 },
|
|
username: { type: 'string', required: true, min: 2 },
|
|
password: { type: 'string', required: true, min: 4 },
|
|
password: { type: 'string', required: true, min: 4 },
|
|
};
|
|
};
|
|
|
|
+ break;
|
|
|
|
+ case 'profileBase':
|
|
|
|
+ rule = {
|
|
|
|
+ name: { type: 'string', allowEmpty: true, max: 10 },
|
|
|
|
+ company: { type: 'string', allowEmpty: true, max: 30 },
|
|
|
|
+ role: { type: 'string', allowEmpty: true, max: 10 },
|
|
|
|
+ mobile: { type: 'mobile', allowEmpty: true },
|
|
|
|
+ telephone: { type: 'string', allowEmpty: true, max: 12 },
|
|
|
|
+ };
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -132,6 +142,7 @@ module.exports = app => {
|
|
// 存入session
|
|
// 存入session
|
|
this.ctx.session.sessionUser = {
|
|
this.ctx.session.sessionUser = {
|
|
account: accountData.account,
|
|
account: accountData.account,
|
|
|
|
+ name: accountData.name,
|
|
accountId: accountData.id,
|
|
accountId: accountData.id,
|
|
loginTime: currentTime,
|
|
loginTime: currentTime,
|
|
sessionToken,
|
|
sessionToken,
|
|
@@ -203,6 +214,33 @@ module.exports = app => {
|
|
|
|
|
|
return projectInfo;
|
|
return projectInfo;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 修改用户数据
|
|
|
|
+ *
|
|
|
|
+ * @param {Object} data - post过来的数据
|
|
|
|
+ * @param {Number} accountId - 账号id
|
|
|
|
+ * @return {Boolean} - 返回修改结果
|
|
|
|
+ */
|
|
|
|
+ async save(data, accountId) {
|
|
|
|
+ if (data._csrf !== undefined) {
|
|
|
|
+ delete data._csrf;
|
|
|
|
+ }
|
|
|
|
+ accountId = parseInt(accountId);
|
|
|
|
+ accountId = isNaN(accountId) ? 0 : accountId;
|
|
|
|
+ let result = false;
|
|
|
|
+
|
|
|
|
+ if (accountId <= 0) {
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ data.id = accountId;
|
|
|
|
+
|
|
|
|
+ // 更新数据
|
|
|
|
+ const operate = await this.db.update(this.tableName, data);
|
|
|
|
+ result = operate.affectedRows > 0;
|
|
|
|
+
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
return ProjectAccount;
|
|
return ProjectAccount;
|