From 280dc96d9d49ad45927b34b80239c7dfb9290669 Mon Sep 17 00:00:00 2001 From: "wenbo.dong" Date: Tue, 29 Aug 2017 10:15:52 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=96=87=E6=A1=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/doc/api.html | 42 ++++++------- .../server/controllers/interface.js.html | 5 +- .../server/controllers/interfaceCol.js.html | 59 +++++++++++++++++-- .../static/server/controllers/project.js.html | 40 +++++++------ .../static/server/controllers/user.js.html | 2 +- 5 files changed, 101 insertions(+), 47 deletions(-) diff --git a/static/doc/api.html b/static/doc/api.html index 05e99a99..d890c991 100644 --- a/static/doc/api.html +++ b/static/doc/api.html @@ -2092,7 +2092,7 @@

源码位置: - ./server/controllers/project.js:149 + ./server/controllers/project.js:148

@@ -2176,7 +2176,7 @@

源码位置: - ./server/controllers/project.js:202 + ./server/controllers/project.js:201

@@ -2260,7 +2260,7 @@

源码位置: - ./server/controllers/project.js:265 + ./server/controllers/project.js:264

@@ -2338,7 +2338,7 @@

源码位置: - ./server/controllers/project.js:290 + ./server/controllers/project.js:289

@@ -2421,7 +2421,7 @@

源码位置: - ./server/controllers/project.js:322 + ./server/controllers/project.js:321

@@ -3032,7 +3032,7 @@

源码位置: - ./server/controllers/project.js:581 + ./server/controllers/project.js:585

@@ -3127,7 +3127,7 @@

源码位置: - ./server/controllers/project.js:635 + ./server/controllers/project.js:639

@@ -3192,7 +3192,7 @@

源码位置: - ./server/controllers/interface.js:15 + ./server/controllers/interface.js:18

@@ -3513,7 +3513,7 @@

源码位置: - ./server/controllers/interface.js:134 + ./server/controllers/interface.js:137

@@ -3578,7 +3578,7 @@

源码位置: - ./server/controllers/interface.js:159 + ./server/controllers/interface.js:162

@@ -3643,7 +3643,7 @@

源码位置: - ./server/controllers/interface.js:221 + ./server/controllers/interface.js:224

@@ -3876,7 +3876,7 @@

源码位置: - ./server/controllers/interface.js:376 + ./server/controllers/interface.js:379

@@ -4181,7 +4181,7 @@

源码位置: - ./server/controllers/interfaceCol.js:12 + ./server/controllers/interfaceCol.js:16

@@ -4243,7 +4243,7 @@

源码位置: - ./server/controllers/interfaceCol.js:37 + ./server/controllers/interfaceCol.js:41

@@ -4329,7 +4329,7 @@

源码位置: - ./server/controllers/interfaceCol.js:94 + ./server/controllers/interfaceCol.js:98

@@ -4391,7 +4391,7 @@

源码位置: - ./server/controllers/interfaceCol.js:116 + ./server/controllers/interfaceCol.js:128

@@ -4573,7 +4573,7 @@

源码位置: - ./server/controllers/interfaceCol.js:192 + ./server/controllers/interfaceCol.js:208

@@ -4743,7 +4743,7 @@

源码位置: - ./server/controllers/interfaceCol.js:259 + ./server/controllers/interfaceCol.js:277

@@ -4805,7 +4805,7 @@

源码位置: - ./server/controllers/interfaceCol.js:280 + ./server/controllers/interfaceCol.js:327

@@ -4879,7 +4879,7 @@

源码位置: - ./server/controllers/interfaceCol.js:321 + ./server/controllers/interfaceCol.js:368

@@ -4939,7 +4939,7 @@

源码位置: - ./server/controllers/interfaceCol.js:363 + ./server/controllers/interfaceCol.js:410

diff --git a/static/doc/static/server/controllers/interface.js.html b/static/doc/static/server/controllers/interface.js.html index a0bf1943..de099954 100644 --- a/static/doc/static/server/controllers/interface.js.html +++ b/static/doc/static/server/controllers/interface.js.html @@ -27,6 +27,8 @@
                 import interfaceModel from '../models/interface.js';
 import interfaceCatModel from '../models/interfaceCat.js';
+import interfaceCaseModel from '../models/interfaceCase.js'
+
 import baseController from './base.js';
 import yapi from '../yapi.js';
 import userModel from '../models/user.js';
@@ -38,6 +40,7 @@ class interfaceController extends baseController {
         this.Model = yapi.getInst(interfaceModel);
         this.catModel = yapi.getInst(interfaceCatModel);
         this.projectModel = yapi.getInst(projectModel);
+        this.caseModel = yapi.getInst(interfaceCaseModel);
     }
 
     /**
@@ -431,7 +434,7 @@ class interfaceController extends baseController {
 
             let inter = await this.Model.get(id);
             let result = await this.Model.del(id);
-
+            await this.caseModel.delByInterfaceId(id);
             let username = this.getUsername();
             this.catModel.get(inter.catid).then((cate)=>{
                 yapi.commons.saveLog({
diff --git a/static/doc/static/server/controllers/interfaceCol.js.html b/static/doc/static/server/controllers/interfaceCol.js.html
index b1063703..ec7a7c0c 100644
--- a/static/doc/static/server/controllers/interfaceCol.js.html
+++ b/static/doc/static/server/controllers/interfaceCol.js.html
@@ -27,6 +27,8 @@
                 
                 import interfaceColModel from '../models/interfaceCol.js';
 import interfaceCaseModel from '../models/interfaceCase.js';
+import interfaceModel from '../models/interface.js';
+import projectModel from '../models/project.js';
 import baseController from './base.js';
 import yapi from '../yapi.js';
 
@@ -35,6 +37,8 @@ class interfaceColController extends baseController{
         super(ctx);
         this.colModel = yapi.getInst(interfaceColModel);
         this.caseModel = yapi.getInst(interfaceCaseModel);
+        this.interfaceModel = yapi.getInst(interfaceModel);
+        this.projectModel = yapi.getInst(projectModel);
     }
 
     /**
@@ -135,6 +139,14 @@ class interfaceColController extends baseController{
             let id = ctx.query.col_id;
             let inst = yapi.getInst(interfaceCaseModel);
             let result = await inst.list(id, 'all');
+            for(let index=0; index< result.length; index++){
+                
+                result[index] = result[index].toObject();
+                let interfaceData = await this.interfaceModel.getBaseinfo(result[index].interface_id);
+                let projectData = await this.projectModel.getBaseInfo(interfaceData.project_id);
+                result[index].path = projectData.basepath +  interfaceData.path;
+                result[index].method = interfaceData.method;
+            }
             ctx.body = yapi.commons.resReturn(result);
         } catch (e) {
             ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -169,8 +181,8 @@ class interfaceColController extends baseController{
                 casename: 'string',
                 project_id: 'number',
                 col_id: 'number',
-                domain: 'string',
-                method: 'string'
+                interface_id: 'number',
+                case_env: 'string'
             });
 
 
@@ -178,7 +190,11 @@ class interfaceColController extends baseController{
                 return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
             }
 
-            let auth = await this.checkAuth(params.project_id, 'project', 'edit')
+            if(!params.interface_id){
+                return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
+            }
+
+            let auth = await this.checkAuth(params.project_id, 'project', 'edit');
             if (!auth) {
                 return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
             }
@@ -242,9 +258,7 @@ class interfaceColController extends baseController{
             let params = ctx.request.body;
             params = yapi.commons.handleParams(params, {
                 id: 'number',
-                casename: 'string',
-                domain: 'string',
-                method: 'string'
+                casename: 'string'
             });
 
             if (!params.id) {
@@ -263,6 +277,10 @@ class interfaceColController extends baseController{
 
             params.uid = this.getUid();
 
+            delete params.interface_id;
+            delete params.project_id;
+            delete params.col_id;
+
             let result = await this.caseModel.up(params.id, params);
             let username = this.getUsername();
             this.colModel.get(caseData.col_id).then((col)=>{
@@ -299,12 +317,41 @@ class interfaceColController extends baseController{
         try{
             let id = ctx.query.caseid;
             let result = await this.caseModel.get(id);
+            if(!result){
+                return ctx.body = yapi.commons.resReturn(null, 400, '不存在的case');
+            }
+            result = result.toObject();
+            let data = await this.interfaceModel.get(result.interface_id);
+            let projectData = await this.projectModel.getBaseInfo(data.project_id);
+            result.path = projectData.basepath + data.path;
+            result.method = data.method;
+            result.req_body_type = data.req_body_type;
+            result.req_headers = data.req_headers;
+
+            result.req_body_form = this.handleParamsValue(data.req_body_form, result.req_body_form)
+            result.req_query = this.handleParamsValue(data.req_query, result.req_query)
+            result.req_params = this.handleParamsValue(data.req_params, result.req_params)
+
             ctx.body = yapi.commons.resReturn(result);
         }catch(e){
             ctx.body = yapi.commons.resReturn(null, 400, e.message)
         }
     }
 
+    handleParamsValue(params, val){
+        let value = {};
+        if(params.length === 0 || val.length === 0){
+            return params;
+        }
+        val.forEach((item, index)=>{
+            value[item.name] = item;
+        })
+        params.forEach((item, index)=>{
+            params[index].value = value[item.name].value;
+        })
+        return params;
+    }
+
     /**
      * 更新一个接口集name或描述
      * @interface /col/up_col
diff --git a/static/doc/static/server/controllers/project.js.html b/static/doc/static/server/controllers/project.js.html
index 338b0d42..2b194681 100644
--- a/static/doc/static/server/controllers/project.js.html
+++ b/static/doc/static/server/controllers/project.js.html
@@ -165,8 +165,7 @@ class projectController extends baseController {
                 type: 'project',
                 uid: this.getUid(),
                 username: username,
-                typeid: params.group_id,
-                typename: params.group_name
+                typeid: params.group_id
             });
             ctx.body = yapi.commons.resReturn(result);
         } catch (e) {
@@ -359,7 +358,7 @@ class projectController extends baseController {
      */
 
     async list(ctx) {
-        let group_id = ctx.request.query.group_id
+        let group_id = ctx.request.query.group_id, project_list = [];
 
         if (!group_id) {
             return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
@@ -367,30 +366,31 @@ class projectController extends baseController {
 
         let auth = await this.checkAuth(group_id, 'group', 'edit')
         try {
-            let result = await this.Model.list(group_id, auth);
+            let result = await this.Model.list(group_id);
             let follow = await this.followModel.list(this.getUid());
-            let uids = [];
-            result.forEach((item, index) => {
-                result[index] = item.toObject();
+            for(let index=0, item, r =  1; index< result.length; index++){
+                item = result[index].toObject();
+                if(item.project_type === 'private' && auth === false){
+                    r = await this.Model.checkMemberRepeat(this.getUid());
+                    if(r === 0){
+                        continue;
+                    }
+                }
+                
                 let f = _.find(follow, (fol) => {
                     return fol.projectid === item._id
                 })
                 if (f) {
-                    result[index].follow = true;
+                    item.follow = true;
                 } else {
-                    result[index].follow = false;
-                }
-                if (uids.indexOf(item.uid) === -1) {
-                    uids.push(item.uid);
+                    item.follow = false;
                 }
+                project_list.push(item);
+
+            };
 
-            });
-            let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
-            users.forEach((item) => {
-                _users[item._id] = item;
-            });
             ctx.body = yapi.commons.resReturn({
-                list: result
+                list: project_list
             });
         } catch (e) {
             ctx.body = yapi.commons.resReturn(null, 402, e.message);
@@ -579,9 +579,13 @@ class projectController extends baseController {
                 }
             }
 
+
             let data = {
                 up_time: yapi.commons.time()
             };
+            if(params.project_type){
+                data.project_type = params.project_type
+            }
 
             if (params.name) data.name = params.name;
             if (params.desc) data.desc = params.desc;
diff --git a/static/doc/static/server/controllers/user.js.html b/static/doc/static/server/controllers/user.js.html
index f2a57a5b..3a896902 100644
--- a/static/doc/static/server/controllers/user.js.html
+++ b/static/doc/static/server/controllers/user.js.html
@@ -175,7 +175,7 @@ class userController extends baseController {
                 user = await userInst.save(data);
                 yapi.commons.sendMail({
                     to: email,
-                    contents: `

亲爱的用户:

您好,感谢使用YApi平台.

` + contents: `

亲爱的用户:

您好,感谢使用YApi平台,你的邮箱账号是:${email}

` }); }