Commit 05e842ef by 王昆

gsb

parent 3669096c
......@@ -135,6 +135,19 @@ class UserCtl extends CtlBase {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
async updPassword(params, pobj2, req) {
params.saas_id = req.loginUser.saas_id;
params.password = this.trim(params.password);
if(!params.password) {
return system.getResult(null, `请填写密码`);
}
try {
return await this.userSve.updPassword(params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 根据pid查出子目录
......
......@@ -4,7 +4,7 @@ class UserService extends ServiceBase {
constructor() {
super();
this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");
this.opuserrelationDao = system.getObject("db.common.opuserrelationDao");
}
/**
......@@ -13,9 +13,22 @@ class UserService extends ServiceBase {
*/
async addUser(params) {
try {
// TODO 处理平台用户
// var puser = await this.platformUtils.userInfo(params.ucname, params.password);
params.ucid = await this.getBusUid("test");
var relation = await this.opuserrelationDao.findOne({ucname: params.ucname});
if(!relation) {
var rs = await this.platformUtils.createUserInfo(params.ucname, params.ucname, params.password);
if(!rs.data || !rs.data.account_id) {
return rs;
}
params.ucid = rs.data.account_id;
this.opuserrelationDao.model.create({
ucname: params.ucname,
ucid: rs.data.account_id,
});
} else {
params.ucid = relation.ucid;
}
system.getResultSuccess();
return await this.callms("uc", "addUser", params);
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
......@@ -75,5 +88,24 @@ class UserService extends ServiceBase {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
/**
* 修改密码
* @param {*} params
*/
async updPassword(params) {
try {
var user = await this.callms("uc", "userInfo", params);
user = user.data;
var rs = await this.platformUtils.modifyPassword(user.ucid, params.password);
if(rs.status !== 0) {
return rs;
}
await this.callms("uc", "updPassword", params);
return system.getResultSuccess();
} catch (error) {
return system.getResult(null, `系统错误 错误信息 ${error}`);
}
}
}
module.exports = UserService;
\ No newline at end of file
......@@ -7,6 +7,15 @@ class ServiceBase {
this.restClient = system.getObject("util.restClient");
this.micro = system.microsetting();
}
async getEncryptStr(str) {
if (!str) {
throw new Error("字符串不能为空");
}
var md5 = this.md5(str + "_" + settings.salt);
return md5.toString().toLowerCase();
}
/**
* 验证签名
* @param {*} params 要验证的参数
......
......@@ -9,10 +9,10 @@ class OpPlatformUtils {
this.cacheManager = system.getObject("db.common.cacheManager");
this.restClient = system.getObject("util.restClient");
this.createUserUrl = settings.paasUrl() + "api/auth/accessAuth/register";
this.passwordUrl = settings.paasUrl() + "api/auth/accessAuth/modifyPassword";
this.fetchDefaultVCodeUrl = settings.paasUrl() + "api/auth/accessAuth/fetchDefaultVCode";
this.loginUrl = settings.paasUrl() + "api/auth/accessAuth/login";
this.authByCodeUrl = settings.paasUrl() + "api/auth/accessAuth/authByCode";
}
getUUID() {
var uuid = uuidv4();
......@@ -50,7 +50,6 @@ class OpPlatformUtils {
userName: userName,
mobile: mobile,
password: password || settings.defaultPassWord,
}
//按照访问token
var restResult = await this.restClient.execPostWithAK(
......@@ -62,6 +61,21 @@ class OpPlatformUtils {
}
return system.getResultSuccess(restResult.data);
}
async modifyPassword(accountId, password) {
var reqApiAccessKey = await this.getReqApiAccessKey();
if (!reqApiAccessKey || !reqApiAccessKey.accessKey) {
return system.getResult(null, "获取请求token失败");
}
var param = {
account_id: accountId,
password: password,
}
//按照访问token
return await this.restClient.execPostWithAK(
param,
this.passwordUrl, reqApiAccessKey.accessKey);
}
async fetchVCode(mobile) {
var reqApiAccessKey = await this.getReqApiAccessKey();
if (!reqApiAccessKey || !reqApiAccessKey.accessKey) {
......
......@@ -37,7 +37,8 @@ var settings = {
},
paasUrl: function () {
if (this.env == "dev") {
return "http://192.168.18.237:4001/";
// return "http://192.168.18.237:4001/";
return "http://192.168.18.125:4001/";
} else {
return "http://open.gongsibao.com/";
}
......
......@@ -7,6 +7,7 @@
1. [删除](#del)
1. [明细](#queryById)
1. [列表页](#page)
1. [重置密码](#resetPassword)
## **<a name="add"> 添加</a>**
[返回到目录](#menu)
......@@ -191,7 +192,6 @@
```
1. [](#)
## **<a name="page"> 列表页</a>**
......@@ -235,3 +235,46 @@
}
```
## **<a name="resetPassword"> 重置密码</a>**
[返回到目录](#menu)
##### URL
[/web/uc/userCtl/resetPassword]
#### 参数格式 `JSON`
#### HTTP请求方式 `POST`
``` javascript
{
"id": "18", // 用户id
"password": "123123" // 新密码
}
```
#### 返回结果
```javascript
{
"status": 0,
"msg": "success",
"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"
}
```
\ No newline at end of file
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