diff --git a/static/doc/api.html b/static/doc/api.html
index fb2d2110..fca964f6 100644
--- a/static/doc/api.html
+++ b/static/doc/api.html
@@ -138,12 +138,20 @@
/user/update
+
+ /user/upload_avatar
+
+
+
+ /user/avatar
+
+
/user/search
- /user/nav
+ /user/project
@@ -1242,6 +1250,130 @@
+
+
+
+
+
+
+
+ 描述:
+ 上传用户头像
+
+
+
+ 源码位置:
+ ./server/controllers/user.js:452
+
+
+
+
+ 参数:
+
+
+
+
+
+
+
+
+
+
+
+ 参数名 |
+ 类型 |
+ 描述 |
+ 必选 |
+ 支持版本 |
+
+
+
+
+ basecode |
+ * |
+ base64编码,通过h5 api传给后端 |
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 描述:
+ 根据用户uid头像
+
+
+
+ 源码位置:
+ ./server/controllers/user.js:495
+
+
+
+
+ 参数:
+
+
+
+
+
+
+
+
+
+
+
+ 参数名 |
+ 类型 |
+ 描述 |
+ 必选 |
+ 支持版本 |
+
+
+
+
+ uid |
+ * |
+ |
+
+
+
+
+ |
+ |
+
+
+
+
+
+
+
@@ -1262,7 +1394,7 @@
源码位置:
- ./server/controllers/user.js:511
+ ./server/controllers/user.js:527
@@ -1324,23 +1456,23 @@
-
示例:
-
{
- "errcode": 0,
- "errmsg": "success",
- "data": {
- "interface_id": 2746,
- "interface_name": "/a/c",
- "project_id": 2481,
- "project_name": "www.xxx.com/api",
- "group_id": 181,
- "group_name": "YMFE"
- }
-}
-
diff --git a/static/doc/static/server/controllers/base.js.html b/static/doc/static/server/controllers/base.js.html
index e52fd60b..960f78ff 100644
--- a/static/doc/static/server/controllers/base.js.html
+++ b/static/doc/static/server/controllers/base.js.html
@@ -47,13 +47,13 @@ class baseController {
async init(ctx) {
this.$user = null;
let ignoreRouter = [
- '/user/login_by_token',
- '/user/login',
- '/user/reg',
- '/user/status',
- '/user/logout'
+ '/api/user/login_by_token',
+ '/api/user/login',
+ '/api/user/reg',
+ '/api/user/status',
+ '/api/user/logout'
];
- if (ignoreRouter.indexOf(ctx.path) > -1) {
+ if (ignoreRouter.indexOf(ctx.path) > -1) {
this.$auth = true;
} else {
await this.checkLogin(ctx);
@@ -88,10 +88,14 @@ class baseController {
}
}
+ /**
+ *
+ * @param {*} ctx
+ */
async getLoginStatus(ctx) {
if (await this.checkLogin(ctx) === true) {
- let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role']);
+ let result = yapi.commons.fieldSelect(this.$user, ['_id', 'username', 'email', 'up_time', 'add_time', 'role', 'type']);
result.server_ip = yapi.WEBCONFIG.server_ip;
return ctx.body = yapi.commons.resReturn(result);
}
diff --git a/static/doc/static/server/controllers/project.js.html b/static/doc/static/server/controllers/project.js.html
index 4f2559c2..56916288 100644
--- a/static/doc/static/server/controllers/project.js.html
+++ b/static/doc/static/server/controllers/project.js.html
@@ -603,7 +603,7 @@ class projectController extends baseController {
}, 500);
});
}
- module.exports = run;`;
+ module.exports = run;`
.trim();
return ctx.body = res;
}
diff --git a/static/doc/static/server/controllers/user.js.html b/static/doc/static/server/controllers/user.js.html
index 6c0fe69c..bff02828 100644
--- a/static/doc/static/server/controllers/user.js.html
+++ b/static/doc/static/server/controllers/user.js.html
@@ -81,8 +81,8 @@ class userController extends baseController {
email: result.email,
add_time: result.add_time,
up_time: result.up_time,
- server_ip: yapi.WEBCONFIG.server_ip
-
+ server_ip: yapi.WEBCONFIG.server_ip,
+ type: 'site'
}, 0, 'logout success...');
} else {
return ctx.body = yapi.commons.resReturn(null, 405, '密码错误');
@@ -478,8 +478,13 @@ class userController extends baseController {
}
/**
- *
+ * 上传用户头像
+ * @interface /user/upload_avatar
+ * @method POST
* @param {*} basecode base64编码,通过h5 api传给后端
+ * @category user
+ * @returns {Object}
+ * @example
*/
async uploadAvatar(ctx) {
@@ -515,11 +520,22 @@ class userController extends baseController {
}
+ /**
+ * 根据用户uid头像
+ * @interface /user/avatar
+ * @method GET
+ * @param {*} uid
+ * @category user
+ * @returns {Object}
+ * @example
+ */
+
async avatar(ctx) {
try{
+ let uid = ctx.query.uid ? ctx.query.uid: this.getUid();
let avatarInst = yapi.getInst(avatarModel);
- let data = await avatarInst.get(this.getUid());
+ let data = await avatarInst.get(uid);
let dataBuffer, type;
if(!data || !data.basecode){
dataBuffer = yapi.fs.readFileSync(yapi.path.join(yapi.WEBROOT, 'static/image/avatar.png'));
@@ -582,26 +598,24 @@ class userController extends baseController {
}
/**
- * 根据路由id获取面包屑数据
- * @interface /user/nav
+ * 根据路由id初始化项目数据
+ * @interface /user/project
* @method GET
* @category user
* @foldnumber 10
* @param {String} type 可选group|interface|project
* @param {Number} id
* @return {Object}
- * @example ./api/user/nav.json
+ * @example
*/
- async nav(ctx) {
+ async project(ctx) {
let { id, type } = ctx.request.query;
let result = {};
try {
if (type === 'interface') {
let interfaceInst = yapi.getInst(interfaceModel);
let interfaceData = await interfaceInst.get(id)
- result["interface_id"] = interfaceData._id;
- result["interface_name"] = interfaceData.path;
-
+ result.interface = interfaceData;
type = 'project';
id = interfaceData.project_id;
}
@@ -609,17 +623,38 @@ class userController extends baseController {
if (type === 'project') {
let projectInst = yapi.getInst(projectModel);
let projectData = await projectInst.get(id);
- result["project_id"] = projectData._id;
- result["project_name"] = projectData.prd_host + projectData.basepath;
+ result.project = projectData.toObject();
+ let ownerAuth = await this.checkAuth(id, 'project', 'danger'), devAuth;
+ if(ownerAuth){
+ result.project.role = 'owner'
+ }else{
+ devAuth = await this.checkAuth(id, 'project', 'site');
+ if(devAuth){
+ result.project.role = 'dev'
+ }else{
+ result.project.role = 'member'
+ }
+ }
type = 'group';
- id = projectData.group_id
+ id = projectData.group_id;
}
if (type === 'group') {
let groupInst = yapi.getInst(groupModel);
let groupData = await groupInst.get(id);
- result["group_id"] = groupData._id;
- result["group_name"] = groupData.group_name;
+ result.group = groupData.toObject();
+ let ownerAuth = await this.checkAuth(id, 'group', 'danger'), devAuth;
+ if(ownerAuth){
+ result.group.role = 'owner'
+ }else{
+ devAuth = await this.checkAuth(id, 'group', 'site');
+ if(devAuth){
+ result.group.role = 'dev'
+ }else{
+ result.group.role = 'member'
+ }
+ }
+
}
return ctx.body = yapi.commons.resReturn(result)
diff --git a/ydoc.json b/ydoc.json
index fe8d4fdb..39bede36 100644
--- a/ydoc.json
+++ b/ydoc.json
@@ -73,7 +73,7 @@
"description": "高效、易用、功能强大、的api管理平台,旨在为开发、产品、测试人员提供更优雅的接口管理服务。"
},
"content": "./README/README-mock.md" // 内容(这里以markdown文件举例)
-
+
},{
"name": "api",
"title": "",
@@ -85,8 +85,8 @@
"options": {
"type": "interface", // 类型,可选 component 和 lib,默认 component
"source": true, // 是否生成源文件预览,默认 false
- "categories":["group","user","project", "interface"]
-
+ "categories":["group","user","project", "interface","follow"]
+
}
}]
}