Commit 4b1e1ebb by 王昆

gsb

parent 6d6c2b18
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
"type": "node", "type": "node",
"request": "launch", "request": "launch",
"name": "Launch Program", "name": "Launch Program",
"program": "${workspaceFolder}/xgg-admin/main.js" "program": "${workspaceFolder}/xgg-deliver/main.js"
} }
] ]
} }
\ No newline at end of file
...@@ -16,17 +16,17 @@ class UserCtl extends CtlBase { ...@@ -16,17 +16,17 @@ class UserCtl extends CtlBase {
async login(pobj, pobj2, req, res) { async login(pobj, pobj2, req, res) {
var loginName = this.trim(pobj.loginName); var loginName = this.trim(pobj.loginName);
var password = this.trim(pobj.password); var password = this.trim(pobj.password);
var captchaKey = this.trim(pobj.captchaKey); // var captchaKey = this.trim(pobj.captchaKey);
var captchaCode = this.trim(pobj.captchaCode); // var captchaCode = this.trim(pobj.captchaCode);
try { try {
var vrs = await this.captchaSve.valid({ // var vrs = await this.captchaSve.valid({
key: captchaKey, // key: captchaKey,
code: captchaCode, // code: captchaCode,
}); // });
if (vrs.status !== 0) { // if (vrs.status !== 0) {
// return vrs; // return vrs;
} // }
var loginUser = await this.userSve.login({ var loginUser = await this.userSve.login({
ucname: loginName, ucname: loginName,
...@@ -53,20 +53,23 @@ class UserCtl extends CtlBase { ...@@ -53,20 +53,23 @@ class UserCtl extends CtlBase {
return xggadminsid; return xggadminsid;
} }
async getMenu(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser.menus);
}
/** /**
* 添加 * 添加
* @param {*} params * @param {*} params
*/ */
async addUser(params, pobj2, req) { async addUser(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try { try {
var user = { var user = {
saas_id: params.saas_id, saas_id: params.saas_id,
org_id: Number(params.org_id || 0), org_id: Number(params.org_id || 0),
ucname: this.trim(params.ucname), ucname: this.trim(params.ucname),
password: this.trim(params.password), password: this.trim(params.password),
uctype: Number(params.uctype || 1), uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile), mobile: this.trim(params.mobile),
realName: this.trim(params.realName), realName: this.trim(params.realName),
roles: params.roles || [], roles: params.roles || [],
...@@ -83,9 +86,6 @@ class UserCtl extends CtlBase { ...@@ -83,9 +86,6 @@ class UserCtl extends CtlBase {
if (!user.realName) { if (!user.realName) {
return system.getResult(null, "请填写姓名"); return system.getResult(null, "请填写姓名");
} }
if (user.uctype == 1 && !user.org_id) {
return system.getResult(null, "请选择用户组织机构");
}
if (user.uctype != 1) { if (user.uctype != 1) {
user.org_id = null; user.org_id = null;
...@@ -102,13 +102,12 @@ class UserCtl extends CtlBase { ...@@ -102,13 +102,12 @@ class UserCtl extends CtlBase {
* @param {*} params * @param {*} params
*/ */
async updUser(params, pobj2, req) { async updUser(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
var user = { var user = {
id: Number(params.id || 0), id: Number(params.id || 0),
saas_id: params.saas_id, saas_id: params.saas_id,
org_id: Number(params.org_id || 0), org_id: Number(params.org_id || 0),
uctype: Number(params.uctype || 1), uctype: '3',
uctypeId: this.trim(params.deliverId),
mobile: this.trim(params.mobile), mobile: this.trim(params.mobile),
realName: this.trim(params.realName), realName: this.trim(params.realName),
roles: params.roles || [], roles: params.roles || [],
...@@ -126,10 +125,6 @@ class UserCtl extends CtlBase { ...@@ -126,10 +125,6 @@ class UserCtl extends CtlBase {
return system.getResult(null, "请填写姓名"); return system.getResult(null, "请填写姓名");
} }
if (user.uctype == 1 && !user.org_id) {
return system.getResult(null, "请选择用户组织机构");
}
if (user.uctype != 1) { if (user.uctype != 1) {
user.org_id = null; user.org_id = null;
user.roles = []; user.roles = [];
...@@ -142,6 +137,10 @@ class UserCtl extends CtlBase { ...@@ -142,6 +137,10 @@ class UserCtl extends CtlBase {
} }
} }
async currentUser(qobj, pobj, req) {
return system.getResultSuccess(req.loginUser);
}
/** /**
* 启用禁用 * 启用禁用
* @param {*} params * @param {*} params
...@@ -149,7 +148,6 @@ class UserCtl extends CtlBase { ...@@ -149,7 +148,6 @@ class UserCtl extends CtlBase {
* @param {*} req * @param {*} req
*/ */
async enabled(params, pobj2, req) { async enabled(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try { try {
params.id = Number(params.id || 0); params.id = Number(params.id || 0);
params.enabled = Number(params.enabled || 0); params.enabled = Number(params.enabled || 0);
...@@ -160,8 +158,6 @@ class UserCtl extends CtlBase { ...@@ -160,8 +158,6 @@ class UserCtl extends CtlBase {
} }
async delUser(params, pobj2, req) { async delUser(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try { try {
return await this.userSve.delUser(params); return await this.userSve.delUser(params);
} catch (error) { } catch (error) {
...@@ -174,8 +170,6 @@ class UserCtl extends CtlBase { ...@@ -174,8 +170,6 @@ class UserCtl extends CtlBase {
* @param {*} params * @param {*} params
*/ */
async queryById(params, pobj2, req) { async queryById(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try { try {
return await this.userSve.queryById(params); return await this.userSve.queryById(params);
} catch (error) { } catch (error) {
...@@ -183,7 +177,6 @@ class UserCtl extends CtlBase { ...@@ -183,7 +177,6 @@ class UserCtl extends CtlBase {
} }
} }
async updPassword(params, pobj2, req) { async updPassword(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
params.password = this.trim(params.password); params.password = this.trim(params.password);
if(!params.password) { if(!params.password) {
return system.getResult(null, `请填写密码`); return system.getResult(null, `请填写密码`);
...@@ -201,7 +194,6 @@ class UserCtl extends CtlBase { ...@@ -201,7 +194,6 @@ class UserCtl extends CtlBase {
* @param {*} params * @param {*} params
*/ */
async page(params, pobj2, req) { async page(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
try { try {
return await this.userSve.page(params); return await this.userSve.page(params);
} catch (error) { } catch (error) {
......
...@@ -6,10 +6,9 @@ const redisClient = system.getObject("util.redisClient"); ...@@ -6,10 +6,9 @@ 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 xggadminsid; var xggadminsid;
// var jsonUser = req.session.user; var jsonUser = req.session.user;
var jsonUser = null; // var jsonUser = null;
if(!jsonUser) { if(!jsonUser) {
xggadminsid = req.headers["xggadminsid"] || ""; xggadminsid = req.headers["xggadminsid"] || "";
jsonUser = await redisClient.get(xggadminsid); jsonUser = await redisClient.get(xggadminsid);
...@@ -19,6 +18,7 @@ module.exports = function (app) { ...@@ -19,6 +18,7 @@ module.exports = function (app) {
} }
if (req.url.indexOf("auth/userCtl/login") > 0 || if (req.url.indexOf("auth/userCtl/login") > 0 ||
req.url.indexOf("uc/userCtl/login") > 0 ||
req.url.indexOf("auth/userCtl/smsCode") > 0 || req.url.indexOf("auth/userCtl/smsCode") > 0 ||
req.url.indexOf("common/metaCtl/getApiDoc") > 0 || req.url.indexOf("common/metaCtl/getApiDoc") > 0 ||
req.url.indexOf("common/captchaCtl/captcha") > 0 || req.url.indexOf("common/captchaCtl/captcha") > 0 ||
...@@ -40,6 +40,12 @@ module.exports = function (app) { ...@@ -40,6 +40,12 @@ module.exports = function (app) {
if(xggadminsid) { if(xggadminsid) {
redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60 * 60); redisClient.setWithEx(xggadminsid, JSON.stringify(jsonUser), 60 * 60 * 60);
} }
req.loginUser = jsonUser;
if(req.loginUser.uctype != 3) {
res.end(JSON.stringify({ status: -99, msg: "no deliver user, kick off" }));
return;
}
req.loginUser = jsonUser; req.loginUser = jsonUser;
next(); next();
}); });
...@@ -61,6 +67,12 @@ module.exports = function (app) { ...@@ -61,6 +67,12 @@ module.exports = function (app) {
var gname = req.params["gname"]; var gname = req.params["gname"];
classPath = gname + "." + classPath; classPath = gname + "." + classPath;
var params = []; var params = [];
if(req.loginUser) {
req.query = req.query || {};
req.query.saas_id = req.loginUser.saas_id;
req.query.deliverId = req.loginUser.uctypeId || "";
}
params.push(methodName); params.push(methodName);
params.push(req.body); params.push(req.body);
params.push(req.query); params.push(req.query);
...@@ -88,6 +100,12 @@ module.exports = function (app) { ...@@ -88,6 +100,12 @@ module.exports = function (app) {
req.body.clientIp = tClientIp; req.body.clientIp = tClientIp;
req.body.agent = req.headers["user-agent"]; req.body.agent = req.headers["user-agent"];
req.body.classname = classPath; req.body.classname = classPath;
if(req.loginUser) {
req.body.saas_id = req.loginUser.saas_id;
req.body.deliverId = req.loginUser.uctypeId || "";
}
params.push(methodName); params.push(methodName);
params.push(req.body); params.push(req.body);
params.push(req.query); params.push(req.query);
......
...@@ -23,17 +23,8 @@ ...@@ -23,17 +23,8 @@
"isMain": 0, // 是否主管 "isMain": 0, // 是否主管
"ucname": "guodegang10", // 用户名/登录名 "ucname": "guodegang10", // 用户名/登录名
"password": "123", // 密码 "password": "123", // 密码
"uctype": "2", // 用户类型 1平台 2商户 3交付商 4个人
"mobile": "13811112222", // 手机号 "mobile": "13811112222", // 手机号
"realName": "郭德纲10", // 姓名 "realName": "郭德纲10", // 姓名
"roles": [ // 角色列表
{
"role_id": 1 // 角色id
},
{
"role_id": 2
}...
]
} }
``` ```
...@@ -64,17 +55,8 @@ ...@@ -64,17 +55,8 @@
"id": "17", // 用户id "id": "17", // 用户id
"org_id": 3, // 组织机构id "org_id": 3, // 组织机构id
"isMain": 0, // 是否主管 "isMain": 0, // 是否主管
"uctype": "2", // 用户类型 1平台 2商户 3交付商 4个人
"mobile": "13811112222", // 手机号 "mobile": "13811112222", // 手机号
"realName": "郭德纲10", // 姓名 "realName": "郭德纲10", // 姓名
"roles": [ // 角色列表
{
"role_id": 1 // 角色id
},
{
"role_id": 2
}...
]
} }
``` ```
...@@ -121,7 +103,7 @@ ...@@ -121,7 +103,7 @@
## **<a name="del"> 删除</a>** ## **<a name="del"> 删除</a>**
[返回到目录](#menu) [返回到目录](#menu)
##### URL ##### URL
[/web/uc/userCtl/delAuth] [/web/uc/userCtl/delUser]
#### 参数格式 `JSON` #### 参数格式 `JSON`
#### HTTP请求方式 `POST` #### HTTP请求方式 `POST`
...@@ -175,17 +157,6 @@ ...@@ -175,17 +157,6 @@
"created_at": "2019-11-29 10:43:32", // 创建时间 "created_at": "2019-11-29 10:43:32", // 创建时间
"mobile": "1381231332312", // 手机号 "mobile": "1381231332312", // 手机号
"realName": "郭德纲11", // 姓名 "realName": "郭德纲11", // 姓名
"roles": [ // 拥有角色
{
"role_id": "1" // 角色id
},
{
"role_id": "5"
},
{
"role_id": "6"
}
]
}, },
"requestid": "dd2731bca15c446595170e1ccf0b2b00" "requestid": "dd2731bca15c446595170e1ccf0b2b00"
} }
...@@ -258,22 +229,7 @@ ...@@ -258,22 +229,7 @@
{ {
"status": 0, "status": 0,
"msg": "success", "msg": "success",
"data": { "data": {},
"count": 8,
"rows": [
{
"id": 17, // id
"ucname": "guodegang10", // 登录名
"uctype": 2, // 用户类型 1平台 2商户 3交付商 4个人
"org_id": 3, // 组织机构id
"isMain": 0, // 是否主管
"isEnabled": 1, // 启用/禁用 0禁用 1启用
"created_at": "2019-11-29 10:43:32", // 创建时间
"mobile": "1381231332312", // 手机号
"realName": "郭德纲11", // 姓名
},
]
},
"requestid": "defbe7aa7b1045c4b644e1c9eb58fd88" "requestid": "defbe7aa7b1045c4b644e1c9eb58fd88"
} }
......
<a name="menu">目录</a> <a name="menu">目录</a>
1. [短信验证码](#smsCode)
1. [登录](#login) 1. [登录](#login)
1. [当前用户信息查询](#loginUser) 1. [当前用户信息查询](#currentUser)
1. [获取菜单](#getMenu)
## **<a name="smsCode"> 短信验证码</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/smsCode]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明|
| -------- | -------- | ------------|---------|
| **mobile** | 是 | String | 手机号码|
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
}
```
## **<a name="login"> 登录</a>** ## **<a name="login"> 登录</a>**
[返回到目录](#menu) [返回到目录](#menu)
##### URL ##### URL
[/web/auth/userCtl/login] [/web/uc/userCtl/login]
#### 参数格式 `JSON` #### 参数格式 `JSON`
#### HTTP请求方式 `POST` #### HTTP请求方式 `POST`
| 参数 | 必选 | 类型 | 说明| | 参数 | 必选 | 类型 | 说明|
...@@ -57,7 +33,7 @@ ...@@ -57,7 +33,7 @@
## **<a name="currentUser"> 当前用户信息查询</a>** ## **<a name="currentUser"> 当前用户信息查询</a>**
[返回到目录](#menu) [返回到目录](#menu)
##### URL ##### URL
[/web/auth/userCtl/currentUser] [/web/uc/userCtl/currentUser]
#### 参数格式 `JSON` #### 参数格式 `JSON`
#### HTTP请求方式 `POST` #### HTTP请求方式 `POST`
...@@ -70,42 +46,3 @@ ...@@ -70,42 +46,3 @@
} }
``` ```
## **<a name="getMenu"> 获取菜单</a>**
[返回到目录](#menu)
##### URL
[/web/auth/userCtl/getMenu]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
#### 返回结果
```javascript
[
{
"name": "首页",
"path": "/",
"submenu": []
},
{
"name": "商户中心",
"path": "/merchants",
"submenu": [
{
"name": "客户管理",
"team": [
{
"name": "商户信息",
"path": "/merchants/businessInformation"
},
...
]
}
]
},
...
]
```
{ {
"name": "bigdata", "name": "xgg-deliver",
"version": "1.0.0", "version": "1.0.0",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
......
{ {
"name": "bigdata", "name": "xgg-deliver",
"version": "1.0.0", "version": "1.0.0",
"description": "h5framework", "description": "h5framework",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "jy", "author": "sunyanan",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"MD5": "^1.3.0", "MD5": "^1.3.0",
......
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