Commit 9e936a75 by 王昆

gsb

parent c4874ae9
...@@ -9,18 +9,8 @@ class APIBase extends DocBase { ...@@ -9,18 +9,8 @@ class APIBase extends DocBase {
this.cacheManager = system.getObject("db.common.cacheManager"); this.cacheManager = system.getObject("db.common.cacheManager");
this.logCtl = system.getObject("web.common.oplogCtl"); this.logCtl = system.getObject("web.common.oplogCtl");
this.oplogSve = system.getObject("service.common.oplogSve"); this.oplogSve = system.getObject("service.common.oplogSve");
this.merchantappletuserSve = system.getObject("service.uc.merchantappletuserSve");
}
async getLoginUser(merchant_id, openid, forceUpdate) {
return await this.merchantappletuserSve.getLoginUser({merchant_id: merchant_id, openid: openid, forceUpdate: forceUpdate});
} }
async getMerchant(merchant_id) {
return await this.merchantSve.getMerchantWithCache({id: merchant_id, forceUpdate: true});
}
getUUID() { getUUID() {
var uuid = uuidv4(); var uuid = uuidv4();
var u = uuid.replace(/\-/g, ""); var u = uuid.replace(/\-/g, "");
......
...@@ -5,8 +5,8 @@ class ADUserAPI extends APIBase { ...@@ -5,8 +5,8 @@ class ADUserAPI extends APIBase {
super(); super();
this.userSve = system.getObject("service.uc.userSve"); this.userSve = system.getObject("service.uc.userSve");
} }
async registerInner(pobj, query, req) { async addAdminUser(pobj, query, req) {
var result = await this.userSve.registerInner(pobj); let result = await this.userSve.saveAdminUser(pobj);
return result; return result;
} }
async resetPasswordInner(pobj, query, req) { async resetPasswordInner(pobj, query, req) {
......
...@@ -16,33 +16,18 @@ class UserCtl extends CtlBase { ...@@ -16,33 +16,18 @@ class UserCtl extends CtlBase {
var loginName = this.trim(pobj.loginName); var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password); var password = this.trim(pobj.password);
try { try {
var loginUser = await this.userSve.login({ let loginUser = await this.userSve.login({
ucname: loginName, ucname: loginName,
password: password, password: password,
uctype: 1,
}); });
if (loginUser.status != 0) { if (loginUser.status != 0) {
return loginUser; return loginUser;
} }
loginUser = loginUser.data; loginUser = loginUser.data;
let rs = this.loginDTO(loginUser)
let channel = await this.merchantSve.info({id:loginUser.saas_merchant_id}); rs.key = await this.setLogin(loginUser);
if (channel.status != 0) {
return system.getResult(null, `渠道【${loginName}】不存在`);
}
channel = channel.data;
loginUser.contact_man = channel.contact_man;
loginUser.contact_mobile = channel.contact_mobile;
loginUser.contact_email = channel.contact_email;
loginUser.contact_addr = channel.contact_addr;
var loginsid = await this.setLogin(loginUser);
let rs = {
key: loginsid,
loginname: loginUser.ucname,
menus: await this.getMenu(loginUser)
};
return system.getResultSuccess(rs); return system.getResultSuccess(rs);
} catch (error) { } catch (error) {
console.log(error); console.log(error);
...@@ -51,10 +36,10 @@ class UserCtl extends CtlBase { ...@@ -51,10 +36,10 @@ class UserCtl extends CtlBase {
} }
async setLogin(user) { async setLogin(user) {
let loginsid = "saasmcth_" + uuidv4(); let loginsid = "esa_" + uuidv4();
// if (settings.env = "dev") { if (settings.env = "dev") {
// loginsid = "saasmcth_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7"; loginsid = "esa_" + "2cb49932-fa02-44f0-90db-9f06fe02e5c7";
// } }
await this.redisClient.setWithEx(loginsid, JSON.stringify(user), 60 * 60 * 5); await this.redisClient.setWithEx(loginsid, JSON.stringify(user), 60 * 60 * 5);
return loginsid; return loginsid;
} }
...@@ -91,16 +76,15 @@ class UserCtl extends CtlBase { ...@@ -91,16 +76,15 @@ class UserCtl extends CtlBase {
} }
async currentUser(qobj, pobj, req) { async currentUser(qobj, pobj, req) {
let saas_merchant_id = req.loginUser.saas_merchant_id; return system.getResultSuccess(this.loginDTO(req.loginUser));
if(!saas_merchant_id){ }
return system.getResult(null, `登录失效,请重新登录`);
} loginDTO(user) {
let _merchant = await this.merchantSve.info({id:saas_merchant_id}); return {
if(_merchant.status!=0 ){ loginName: user.ucname,
return system.getResult(null, `商户不存在`); mobile: user.mobile,
real_name: user.real_name,
} }
req.loginUser.saas_merchant_name = _merchant.data.name;
return system.getResultSuccess(req.loginUser);
} }
/** /**
......
...@@ -30,7 +30,7 @@ module.exports = (db, DataTypes) => { ...@@ -30,7 +30,7 @@ module.exports = (db, DataTypes) => {
updatedAt: false, updatedAt: false,
//freezeTableName: true, //freezeTableName: true,
// define the table's name // define the table's name
tableName: 'xgg_op_log', tableName: 'op_log',
validate: { validate: {
}, },
......
...@@ -6,6 +6,22 @@ class UserService extends ServiceBase { ...@@ -6,6 +6,22 @@ class UserService extends ServiceBase {
super(); super();
} }
async saveAdminUser(params) {
try {
return await this.callms("sve_uc", "saveAdminUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async saveMerchantUser(params) {
try {
return await this.callms("sve_uc", "saveMerchantUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async login(params) { async login(params) {
try { try {
return await this.callms("sve_uc", "login", params); return await this.callms("sve_uc", "login", params);
......
...@@ -194,7 +194,7 @@ class System { ...@@ -194,7 +194,7 @@ class System {
engine_sign: local + ":3103" + path, engine_sign: local + ":3103" + path,
// 用户服务 // 用户服务
sve_uc: dev + ":3651" + path, sve_uc: local + ":3651" + path,
// 商户服务 // 商户服务
sve_merchant: dev + ":3103" + path, sve_merchant: dev + ":3103" + path,
// 订单服务 // 订单服务
......
...@@ -7,7 +7,7 @@ const redisClient = system.getObject("util.redisClient"); ...@@ -7,7 +7,7 @@ const redisClient = system.getObject("util.redisClient");
module.exports = function (app) { module.exports = function (app) {
app.all("/web/*", async function (req, res, next) { app.all("/web/*", async function (req, res, next) {
var loginsid; var loginsid;
// var jsonUser = null; var jsonUser = null;
if(!jsonUser) { if(!jsonUser) {
loginsid = req.headers["esignadminsid"] || ""; loginsid = req.headers["esignadminsid"] || "";
jsonUser = await redisClient.get(loginsid); jsonUser = await redisClient.get(loginsid);
...@@ -61,8 +61,6 @@ module.exports = function (app) { ...@@ -61,8 +61,6 @@ module.exports = function (app) {
if(req.loginUser) { if(req.loginUser) {
req.query = req.query || {}; req.query = req.query || {};
req.query.saas_id = req.loginUser.saas_id;
req.query.saas_merchant_id = req.loginUser.saas_merchant_id;
} }
params.push(methodName); params.push(methodName);
params.push(req.body); params.push(req.body);
...@@ -93,8 +91,6 @@ module.exports = function (app) { ...@@ -93,8 +91,6 @@ module.exports = function (app) {
req.body.classname = classPath; req.body.classname = classPath;
if(req.loginUser) { if(req.loginUser) {
req.body.saas_id = req.loginUser.saas_id;
req.body.saas_merchant_id = req.loginUser.saas_merchant_id;
} }
params.push(methodName); params.push(methodName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment