|
|
@@ -41,7 +41,7 @@ class UserController extends BaseController {
|
|
|
companyScaleList: userModel.companyScale,
|
|
|
compilationName: request.session.sessionCompilation.name,
|
|
|
versionName: request.session.compilationVersion,
|
|
|
- title:getTitle(request.headers.host)
|
|
|
+ title: getTitle(request.headers.host)
|
|
|
};
|
|
|
response.render('users/html/user-info', renderData);
|
|
|
}
|
|
|
@@ -63,14 +63,19 @@ class UserController extends BaseController {
|
|
|
company_type: request.body.company_type ? request.body.company_type : null,
|
|
|
company_scale: request.body.company_scale ? request.body.company_scale : null,
|
|
|
};
|
|
|
+ for (const prop in updateData) {
|
|
|
+ if (updateData[prop] === undefined) {
|
|
|
+ delete updateData[prop];
|
|
|
+ }
|
|
|
+ }
|
|
|
let sessionUser = request.session.sessionUser;
|
|
|
// 切换验证场景
|
|
|
let userModel = new UserModel();
|
|
|
- let condition = {ssoId: sessionUser.ssoId};
|
|
|
+ let condition = { ssoId: sessionUser.ssoId };
|
|
|
userModel.setScene('saveInfo');
|
|
|
let result = await userModel.updateUser(condition, updateData);
|
|
|
//更新session
|
|
|
- for(let attr in sessionUser){
|
|
|
+ for (let attr in sessionUser) {
|
|
|
sessionUser[attr] = updateData[attr] ? updateData[attr] : sessionUser[attr];
|
|
|
}
|
|
|
if (result.ok !== 1) {
|
|
|
@@ -125,7 +130,7 @@ class UserController extends BaseController {
|
|
|
pages: pageData,
|
|
|
compilationName: request.session.sessionCompilation.name,
|
|
|
versionName: request.session.compilationVersion,
|
|
|
- title:getTitle(request.headers.host)
|
|
|
+ title: getTitle(request.headers.host)
|
|
|
};
|
|
|
response.render('users/html/user-safe', renderData);
|
|
|
}
|
|
|
@@ -162,7 +167,7 @@ class UserController extends BaseController {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
console.log(error);
|
|
|
}
|
|
|
|
|
|
@@ -171,7 +176,7 @@ class UserController extends BaseController {
|
|
|
compilationList: compilationList,
|
|
|
compilationName: request.session.sessionCompilation.name,
|
|
|
versionName: request.session.compilationVersion,
|
|
|
- title:getTitle(request.headers.host)
|
|
|
+ title: getTitle(request.headers.host)
|
|
|
};
|
|
|
response.render('users/html/user-buy', renderData);
|
|
|
}
|
|
|
@@ -196,7 +201,7 @@ class UserController extends BaseController {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
compilationList = await compilationModel.getList(request.headers.host, false);
|
|
|
|
|
|
- } catch(error) {
|
|
|
+ } catch (error) {
|
|
|
console.log(error);
|
|
|
}
|
|
|
|
|
|
@@ -205,7 +210,7 @@ class UserController extends BaseController {
|
|
|
compilationList: compilationList,
|
|
|
compilationName: request.session.sessionCompilation.name,
|
|
|
versionName: request.session.compilationVersion,
|
|
|
- title:getTitle(request.headers.host)
|
|
|
+ title: getTitle(request.headers.host)
|
|
|
};
|
|
|
response.render('users/html/user-set', renderData);
|
|
|
}
|
|
|
@@ -241,7 +246,7 @@ class UserController extends BaseController {
|
|
|
let compilationData = await compilationModel.getCompilationById(selectVersion);
|
|
|
// 判断当前用户的是使用免费版还是专业版
|
|
|
let userModel = new UserModel();
|
|
|
- let compilationVersion = await userModel.getVersionFromUpgrade(sessionUserData.ssoId, compilationData._id,request);
|
|
|
+ let compilationVersion = await userModel.getVersionFromUpgrade(sessionUserData.ssoId, compilationData._id, request);
|
|
|
request.session.compilationVersion = compilationVersion.version;
|
|
|
request.session.sessionUser.compilationLock = compilationVersion.lock;
|
|
|
request.session.sessionCompilation = compilationData;
|
|
|
@@ -256,15 +261,15 @@ class UserController extends BaseController {
|
|
|
/*
|
|
|
* 版本激活
|
|
|
* */
|
|
|
- async activateVersion(request, response){
|
|
|
- try{
|
|
|
+ async activateVersion(request, response) {
|
|
|
+ try {
|
|
|
let userModel = new UserModel();
|
|
|
let sessionUser = request.session.sessionUser;
|
|
|
let data = JSON.parse(request.body.data);
|
|
|
let activateCode = data.activateCode,
|
|
|
compilationId = data.compilationId;
|
|
|
let isActivated = true;//调激活接口
|
|
|
- if(!isActivated){
|
|
|
+ if (!isActivated) {
|
|
|
throw '激活失败';
|
|
|
}
|
|
|
//激活成功,更新入库
|
|
|
@@ -274,81 +279,81 @@ class UserController extends BaseController {
|
|
|
versionInfo.activatedDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
|
|
|
//失效信息{invalid: boolean, invalidDate: String}
|
|
|
versionInfo.invalidInfo = null;
|
|
|
- await userModel.addVersion({_id: userObjId}, versionInfo);
|
|
|
- response.json({error: 0, msg: 'success'});
|
|
|
+ await userModel.addVersion({ _id: userObjId }, versionInfo);
|
|
|
+ response.json({ error: 0, msg: 'success' });
|
|
|
}
|
|
|
- catch (error){
|
|
|
- response.json({error: 1, msg: error})
|
|
|
+ catch (error) {
|
|
|
+ response.json({ error: 1, msg: error })
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
* 更新版本状态
|
|
|
* */
|
|
|
- async updateVersionState(request, response){
|
|
|
- try{
|
|
|
+ async updateVersionState(request, response) {
|
|
|
+ try {
|
|
|
let userModel = new UserModel();
|
|
|
let activated = request.body.activated,
|
|
|
userId = request.body.userId,
|
|
|
compilationId = request.body.compilationId;
|
|
|
- if(activated){
|
|
|
+ if (activated) {
|
|
|
let versionInfo = {};
|
|
|
versionInfo.compilationId = compilationId;
|
|
|
versionInfo.activatedDate = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');
|
|
|
versionInfo.invalidInfo = null;
|
|
|
- await userModel.addVersion({_id: mongoose.Types.ObjectId(userId)}, versionInfo);
|
|
|
+ await userModel.addVersion({ _id: mongoose.Types.ObjectId(userId) }, versionInfo);
|
|
|
}
|
|
|
- else{
|
|
|
+ else {
|
|
|
await userModel.removeVersion(userId, compilationId);
|
|
|
}
|
|
|
- response.json({error: 0, msg: 'success'});
|
|
|
+ response.json({ error: 0, msg: 'success' });
|
|
|
}
|
|
|
- catch (error){
|
|
|
- response.json({error: 1, msg: error});
|
|
|
+ catch (error) {
|
|
|
+ response.json({ error: 1, msg: error });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 获取用户版本信息
|
|
|
* */
|
|
|
- async getVersionInfo(request, response){
|
|
|
- try{
|
|
|
+ async getVersionInfo(request, response) {
|
|
|
+ try {
|
|
|
let userModel = new UserModel();
|
|
|
let userId = request.session.sessionUser.id;
|
|
|
let userData = await userModel.findDataById(userId);
|
|
|
let versionInfo = userData ? userData.versionInfo ? userData.versionInfo : [] : [];
|
|
|
- response.json({error: 0, msg: 'success', data: versionInfo});
|
|
|
+ response.json({ error: 0, msg: 'success', data: versionInfo });
|
|
|
}
|
|
|
- catch(error){
|
|
|
- response.json({error: 1, msg: error, data: null});
|
|
|
+ catch (error) {
|
|
|
+ response.json({ error: 1, msg: error, data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* 获取用户信息
|
|
|
* */
|
|
|
- async getUserByMobile(req, res){
|
|
|
- try{
|
|
|
+ async getUserByMobile(req, res) {
|
|
|
+ try {
|
|
|
let userModel = new UserModel();
|
|
|
let data = JSON.parse(req.body.data);
|
|
|
let userData = await userModel.findDataByMobile(data.mobile);
|
|
|
- res.json({error: 0, msg: 'success', data: userData});
|
|
|
+ res.json({ error: 0, msg: 'success', data: userData });
|
|
|
}
|
|
|
- catch (err){
|
|
|
- res.json({error: 1, msg: err, data: null});
|
|
|
+ catch (err) {
|
|
|
+ res.json({ error: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
- async getUsers(req, res){
|
|
|
- try{
|
|
|
+ async getUsers(req, res) {
|
|
|
+ try {
|
|
|
let data = JSON.parse(req.body.data);
|
|
|
let userObjIDs = [];
|
|
|
- for(let userID of data.userIDs){
|
|
|
+ for (let userID of data.userIDs) {
|
|
|
userObjIDs.push(mongoose.Types.ObjectId(userID));
|
|
|
}
|
|
|
- let users = await userData.find({_id: {$in: userObjIDs}});
|
|
|
- res.json({error: 0, msg: 'success', data: users});
|
|
|
+ let users = await userData.find({ _id: { $in: userObjIDs } });
|
|
|
+ res.json({ error: 0, msg: 'success', data: users });
|
|
|
}
|
|
|
- catch (err){
|
|
|
- res.json({error: 1, msg: err, data: null});
|
|
|
+ catch (err) {
|
|
|
+ res.json({ error: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -356,19 +361,19 @@ class UserController extends BaseController {
|
|
|
* 更改用户账号登录方式
|
|
|
* */
|
|
|
async changeIsSmsLogin(request, response) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
let status = request.body.status;
|
|
|
let userModel = new UserModel();
|
|
|
let userId = request.session.sessionUser.id;
|
|
|
let result = await userModel.updateUser({ _id: userId }, { isSmsLogin: status });
|
|
|
if (result) {
|
|
|
- response.json({error: 0, msg: 'success', data: null});
|
|
|
+ response.json({ error: 0, msg: 'success', data: null });
|
|
|
} else {
|
|
|
throw '更新失败';
|
|
|
}
|
|
|
}
|
|
|
- catch(error){
|
|
|
- response.json({error: 1, msg: error, data: null});
|
|
|
+ catch (error) {
|
|
|
+ response.json({ error: 1, msg: error, data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -376,19 +381,19 @@ class UserController extends BaseController {
|
|
|
* 更改异常登录通知
|
|
|
* */
|
|
|
async changeIsLoginValid(request, response) {
|
|
|
- try{
|
|
|
+ try {
|
|
|
let status = request.body.status;
|
|
|
let userModel = new UserModel();
|
|
|
let userId = request.session.sessionUser.id;
|
|
|
let result = await userModel.updateUser({ _id: userId }, { isLoginValid: status });
|
|
|
if (result) {
|
|
|
- response.json({error: 0, msg: 'success', data: null});
|
|
|
+ response.json({ error: 0, msg: 'success', data: null });
|
|
|
} else {
|
|
|
throw '更新失败';
|
|
|
}
|
|
|
}
|
|
|
- catch(error){
|
|
|
- response.json({error: 1, msg: error, data: null});
|
|
|
+ catch (error) {
|
|
|
+ response.json({ error: 1, msg: error, data: null });
|
|
|
}
|
|
|
}
|
|
|
|