From daefcada6f05302740aae4f3e4c5eb0b94f4e634 Mon Sep 17 00:00:00 2001 From: sean Date: Tue, 11 Jul 2017 18:22:20 +0800 Subject: [PATCH 1/2] add user and interface document --- doc/build/api.html | 832 +++++++++++++++++- .../static/server/controllers/base.js.html | 60 +- .../static/server/controllers/group.js.html | 12 +- .../server/controllers/interface.js.html | 72 +- .../static/server/controllers/project.js.html | 9 +- .../static/server/controllers/user.js.html | 202 +++-- exampleCode/api/user/login.json | 9 +- package.json | 2 + server/controllers/interface.js | 72 +- server/controllers/user.js | 88 +- server_dist/controllers/interface.js | 96 +- server_dist/controllers/user.js | 117 ++- 12 files changed, 1407 insertions(+), 164 deletions(-) diff --git a/doc/build/api.html b/doc/build/api.html index a053e243..2a505e60 100644 --- a/doc/build/api.html +++ b/doc/build/api.html @@ -93,8 +93,35 @@ user - - + + +
  • @@ -138,14 +165,27 @@ interface
  • - @@ -178,7 +218,7 @@

    源码位置: - ./server/controllers/group.js:12 + ./server/controllers/group.js:13

    @@ -261,7 +301,7 @@

    源码位置: - ./server/controllers/group.js:51 + ./server/controllers/group.js:52

    @@ -323,7 +363,7 @@

    源码位置: - ./server/controllers/group.js:71 + ./server/controllers/group.js:72

    @@ -395,7 +435,7 @@

    源码位置: - ./server/controllers/group.js:93 + ./server/controllers/group.js:103

    @@ -477,6 +517,371 @@ +
    +
    + +
    +

    + 描述: + 用户登录接口 +

    + +

    + 源码位置: + ./server/controllers/user.js:11 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    emailStringemail名称,不能为空 + + + +
    passwordString密码,不能为空 + + + +
    +
    + + +
    示例:
    +
    {
    +    "errcode": 0,
    +    "errmsg": "logout success...",
    +    "data": {
    +        "uid": 101,
    +        "email": "admin@admin.com",
    +        "add_time": 1499762848,
    +        "up_time": 1499762848
    +    }
    +}
    + + +
    + +
    +
    + +
    +

    + 描述: + 退出登录接口 +

    + +

    + 源码位置: + ./server/controllers/user.js:62 +

    + + + +
    示例:
    +
    {
    +    "errcode": 0,
    +    "errmsg": "success",
    +    "data": "ok"
    +}
    + + +
    + +
    +
    + +
    +

    + 描述: + 用户注册接口 +

    + +

    + 源码位置: + ./server/controllers/user.js:79 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    emailStringemail名称,不能为空 + + + +
    passwordString密码,不能为空 + + + +
    usernameString用户名 + +
    +
    + + +
    示例:
    +
    {
    +    "errcode": 0,
    +    "errmsg": "logout success...",
    +    "data": {
    +        "uid": 101,
    +        "email": "admin@admin.com",
    +        "add_time": 1499762848,
    +        "up_time": 1499762848
    +    }
    +}
    + + +
    + +
    +
    + +
    +

    + 描述: + 获取用户列表 +

    + +

    + 源码位置: + ./server/controllers/user.js:136 +

    + + + + +
    + +
    +
    + +
    +

    + 描述: + 获取用户列表 +

    + +

    + 源码位置: + ./server/controllers/user.js:159 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    id用户uid + + + +
    +
    + + + +
    + +
    +
    + +
    +

    + 描述: + 获取用户列表,只有admin用户才有此权限 +

    + +

    + 源码位置: + ./server/controllers/user.js:184 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    id用户uid + + + +
    +
    + + + +
    + @@ -498,7 +903,7 @@

    源码位置: - ./server/controllers/project.js:11 + ./server/controllers/project.js:12

    @@ -627,7 +1032,7 @@

    源码位置: - ./server/controllers/project.js:73 + ./server/controllers/project.js:74

    @@ -711,7 +1116,7 @@

    源码位置: - ./server/controllers/project.js:105 + ./server/controllers/project.js:106

    @@ -795,7 +1200,7 @@

    源码位置: - ./server/controllers/project.js:137 + ./server/controllers/project.js:138

    @@ -878,7 +1283,7 @@

    源码位置: - ./server/controllers/project.js:161 + ./server/controllers/project.js:162

    @@ -978,7 +1383,7 @@

    源码位置: - ./server/controllers/project.js:185 + ./server/controllers/project.js:186

    @@ -1050,7 +1455,7 @@

    源码位置: - ./server/controllers/project.js:212 + ./server/controllers/project.js:219

    @@ -1482,18 +1887,15 @@ - - -
    -

    @@ -1501,6 +1903,12 @@ 添加项目分组

    +

    + 源码位置: + ./server/controllers/interface.js:77 +

    + +

    参数:

    @@ -1523,21 +1931,9 @@ - username - String - 用户名称,不能为空 - - - - - - - - - - password - String - 密码,不能为空 + id + Number + 接口id,不能为空 @@ -1550,14 +1946,366 @@
    -
    返回示例:
    +
    示例:
    +
    ./api/interface/get.json
    + + + + +
    +
    + +
    +

    + 描述: + 添加项目分组 +

    + +

    + 源码位置: + ./server/controllers/interface.js:100 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    project_idNumber项目id,不能为空 + + + +
    +
    + + +
    示例:
    +
    ./api/interface/list.json
    + + +
    + +
    +
    + +
    +

    + 描述: + 添加项目分组 +

    + +

    + 源码位置: + ./server/controllers/interface.js:124 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    idNumber接口id,不能为空 + + + +
    pathString接口请求路径 + +
    methodString请求方式 + +
    req_headersArray请求的header信息 + +
    req_headers[].nameString请求的header信息名 + +
    req_headers[].valueString请求的header信息值 + +
    req_headers[].requiredBoolean是否是必须,默认为否 + +
    req_headers[].descStringheader描述 + +
    req_params_typeString请求参数方式,有["form", "json", "text", "xml"]四种 + +
    req_paramsMixed请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串 + +
    req_params[].nameString请求参数名 + +
    req_params[].valueString请求参数值,可填写生成规则(mock)。如@email,随机生成一条email + +
    req_params[].typeString请求参数类型,有["text", "file"]两种 + +
    res_body_typeString相应信息的数据格式,有["json", "text", "xml"]三种 + +
    res_bodyString响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能 + +
    descString接口描述 + +
    +
    + + +
    示例:
    {
         "errcode": 0,
         "errmsg": "success",
         "data": {
    -        "_id": 4,
    -        "username": "testuser",
    -        "password": "testpassword"
    +        "n": 1,
    +        "nModified": 1,
    +        "ok": 1
    +    }
    +}
    + + +
    + +
    +
    + +
    +

    + 描述: + 删除接口 +

    + +

    + 源码位置: + ./server/controllers/interface.js:189 +

    + + +

    + 参数: +

    +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
    参数名类型描述必选支持版本
    idNumber接口id,不能为空 + + + +
    +
    + + +
    示例:
    +
    {
    +    "errcode": 0,
    +    "errmsg": "success",
    +    "data": {
    +        "n": 1,
    +        "ok": 1
         }
     }
    diff --git a/doc/build/static/server/controllers/base.js.html b/doc/build/static/server/controllers/base.js.html index 03c27a1c..29e2e63b 100644 --- a/doc/build/static/server/controllers/base.js.html +++ b/doc/build/static/server/controllers/base.js.html @@ -27,27 +27,65 @@
                     import yapi from '../yapi.js'
     import  projectModel from '../models/project.js'
    +import userModel from '../models/user.js'
    +const jwt = require('jsonwebtoken');
    +
    +
     class baseController{
         constructor(ctx){
    -        console.log('baseControler init...')
    +
    +        //网站上线后,role对象key是不能修改的,value可以修改
    +        this.roles = {
    +            admin: 'Admin',
    +            member: '网站会员'
    +        }
         }
     
    -    getUid(){
    -        return 0
    +    async init(ctx){
    +        this.$user = null;
    +        if(ctx.path === '/user/login' || ctx.path === '/user/reg' || ctx.path === '/user/status' || ctx.path === '/user/logout'){
    +            this.$auth = true;
    +        }else{
    +            await this.checkLogin(ctx)
    +        }
    +        
         }
     
    -    getLoginStatus(){
    -        // let token = getCookie('_yapi_token');
    -        // let uid   = getCookie('_yapi_uid');
    -        // let usermodel
    +    getUid(ctx){
    +        return this.$uid;
    +    }
    +
    +    async checkLogin(ctx){
    +        let token = ctx.cookies.get('_yapi_token');
    +        let uid   = ctx.cookies.get('_yapi_uid');
    +        try{
    +            if(!token || !uid) return false;
    +            let userInst = yapi.getInst(userModel); //创建user实体
    +            let result = await userInst.findById(uid);
    +            let decoded = jwt.verify(token, result.passsalt)
    +            if(decoded.uid == uid){
    +                this.$uid = uid;
    +                this.$auth = true;
    +                this.$user = result;             
    +                return true;
    +            }
    +            return false;
    +        }catch(e){
    +            return false;
    +        }
    +
    +    }
    +
    +    async getLoginStatus(ctx){
    +        if(await this.checkLogin(ctx) === true){
    +            return ctx.body = yapi.commons.resReturn(yapi.commons.fieldSelect(this.$user,['_id','username','email', 'up_time', 'add_time']));
    +        }
    +        return ctx.body = yapi.commons.resReturn(null, 300 , 'Please login.');
     
    -        // usermode.token === token
    -        // return true
    -        return true
         }
     
         getRole(){
    -        return 'admin'
    +        return this.$user.role;
         }
     
         async jungeProjectAuth(id){
    diff --git a/doc/build/static/server/controllers/group.js.html b/doc/build/static/server/controllers/group.js.html
    index 87f5bc1b..59b81679 100644
    --- a/doc/build/static/server/controllers/group.js.html
    +++ b/doc/build/static/server/controllers/group.js.html
    @@ -28,6 +28,7 @@
                     import  groupModel from '../models/group.js'
     import yapi from '../yapi.js'
     import baseController from './base.js'
    +import  projectModel from '../models/project.js'
     
     // 
     class groupController extends baseController{
    @@ -110,7 +111,16 @@ class groupController extends baseController{
         async del(ctx){   
             try{
                 var groupInst = yapi.getInst(groupModel);
    -            let id = ctx.request.body.id;
    +            var projectInst = yapi.getInst(projectModel);
    +            let id = ctx.request.body.id;            
    +            if(!id){
    +                return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
    +            }
    +            let count = projectInst.countByGroupId(id);
    +            if(count > 0){
    +                return ctx.body = yapi.commons.resReturn(null, 403, '请先删除该分组下的项目');
    +            }
    +
                 let result = await groupInst.del(id);
                 ctx.body = yapi.commons.resReturn(result)
             }catch(err){
    diff --git a/doc/build/static/server/controllers/interface.js.html b/doc/build/static/server/controllers/interface.js.html
    index 4ed9d353..5f546f23 100644
    --- a/doc/build/static/server/controllers/interface.js.html
    +++ b/doc/build/static/server/controllers/interface.js.html
    @@ -102,6 +102,16 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/get
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/get.json
    +     */
         async get(ctx){
             let params = ctx.request.query;
             if(!params.id){
    @@ -115,6 +125,17 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/list
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   project_id 项目id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/list.json
    +     */
    +
         async list(ctx){
             let project_id = ctx.request.query.project_id;
             if(!project_id){
    @@ -128,6 +149,32 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/up
    +     * @method POST
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @param {String}   [path] 接口请求路径
    +     * @param {String}   [method] 请求方式
    +     * @param {Array}  [req_headers] 请求的header信息
    +     * @param {String}  [req_headers[].name] 请求的header信息名
    +     * @param {String}  [req_headers[].value] 请求的header信息值
    +     * @param {Boolean}  [req_headers[].required] 是否是必须,默认为否
    +     * @param {String}  [req_headers[].desc] header描述
    +     * @param {String}  [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
    +     * @param {Mixed}  [req_params] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
    +     * @param {String} [req_params[].name] 请求参数名
    +     * @param {String} [req_params[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
    +     * @param {String} [req_params[].type] 请求参数类型,有["text", "file"]两种
    +     * @param {String}  [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
    +     * @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
    +     * @param  {String} [desc] 接口描述 
    +     * @returns {Object} 
    +     * @example ./api/interface/up.json
    +     */
    +
         async up(ctx){
             let params = ctx.request.body;
             params.method = params.method || 'GET';
    @@ -167,15 +214,34 @@ class interfaceController extends baseController{
     
         }
     
    +    /**
    +     * 删除接口
    +     * @interface /interface/del
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/del.json
    +     */
    +
         async del(ctx){
             try{
    -            let id = ctx.request.body.id;
    +            let id = ctx.request.body.id;            
    +            
                 if(!id){
                     return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
                 }
    -            if(await this.jungeMemberAuth(id) !== true){
    -                return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
    +
    +            let data = await this.Model.get(params.id);
    +
    +            if(data.uid != this.getUid()){
    +                if(await this.jungeProjectAuth(data.project_id) !== true){
    +                    return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
    +                }
                 }
    +
    +            
                 let result = await this.Model.del(id);
                 ctx.body = yapi.commons.resReturn(result)
             }catch(err){
    diff --git a/doc/build/static/server/controllers/project.js.html b/doc/build/static/server/controllers/project.js.html
    index b34121c5..7a698951 100644
    --- a/doc/build/static/server/controllers/project.js.html
    +++ b/doc/build/static/server/controllers/project.js.html
    @@ -28,6 +28,7 @@
                     import  projectModel from '../models/project.js'
     import yapi from '../yapi.js'
     import baseController from './base.js'
    +import interfaceModel from '../models/interface.js'
     
     class projectController extends baseController {
     
    @@ -227,11 +228,17 @@ class projectController extends baseController {
                 if(!id){
                     return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
                 }
    +            let interfaceInst = yapi.getInst(interfaceModel);
    +            let count = await interfaceInst.countByProjectId(id);
    +            if(count > 0){
    +                return ctx.body = yapi.commons.resReturn(null, 400, '请先删除该项目下所有接口');
    +            }
    +
                 if(await this.jungeProjectAuth(id) !== true){
                     return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
                 }
                 let result = await this.Model.del(id);
    -            ctx.body = yapi.commons.resReturn(result)
    +            ctx.body = yapi.commons.resReturn(result);
             }catch(err){
                  ctx.body = yapi.commons.resReturn(null, 402, e.message)
             }
    diff --git a/doc/build/static/server/controllers/user.js.html b/doc/build/static/server/controllers/user.js.html
    index b81d4fbe..9d19e2a8 100644
    --- a/doc/build/static/server/controllers/user.js.html
    +++ b/doc/build/static/server/controllers/user.js.html
    @@ -30,101 +30,151 @@ import yapi from '../yapi.js'
     import baseController from './base.js'
     import mongoose from 'mongoose'
     
    -const sha1 = require('sha1');
    +const jwt = require('jsonwebtoken');
     
     class userController extends baseController{
         constructor(ctx){
             super(ctx)
    -        console.log('constructor...')
         }
         /**
    -     * 添加项目分组
    +     * 用户登录接口
          * @interface /user/login
          * @method POST
          * @category user
          * @foldnumber 10
    -     * @param {String} username 用户名称,不能为空
    +     * @param {String} email email名称,不能为空
          * @param  {String} password 密码,不能为空
          * @returns {Object} 
          * @example ./api/user/login.json
          */
         async login(ctx){   //登录
    -        var userInst = yapi.getInst(userModel); //创建user实体
    -        let username = ctx.request.body.username;
    +        let userInst = yapi.getInst(userModel); //创建user实体
    +        let email = ctx.request.body.email;
             let password = ctx.request.body.password;
    -        let result = await userInst.findByName(username);
    -        console.log(password)
    -
             
    -
    -        userInst.save(function(error){
    -            console.log(111)
    -            var error = userInst.validateSync();
    -            assert.equal(error.errors['password'].message, 'password required');
    -        });
    -        
    -        if(!username){
    -            return ctx.body = yapi.commons.resReturn(null,400,'用户名不能为空');
    +        if(!email){
    +            return ctx.body = yapi.commons.resReturn(null,400,'email不能为空');
             }
    -        //  if(!password){
    -        //     return ctx.body = yapi.commons.resReturn(null,400,'密码不能为空');
    -        // }
    -        //输入一个不存在的用户名
    -        var checkRepeat = await userInst.checkRepeat(username);//然后检查是否已经存在该用户
    -        if(checkRepeat==0){
    -            return ctx.body = yapi.commons.resReturn(null,404,'该用户不存在');  //返回的错误码对吗????
    -        }else if(sha1(result.password)===password){    //用户名存在,判断密码是否正确,正确则可以登录
    -            console.log('密码一致');   //是不是还需要把用户名密码一些东西写到session
    -            // setCookie('token', sha1(username+password));
    -            // userInst.update({_id, result._id}, {token: sha1(username+password)})
    -            // return ctx.body = {username: ''}
    -            return ctx.body = yapi.commons.resReturn(null,200,'ok'); 
    +         if(!password){
    +            return ctx.body = yapi.commons.resReturn(null,400,'密码不能为空');
    +        }
    +
    +        let result = await userInst.findByEmail(email);
    +        
    +        
    +        if(!result){
    +            return ctx.body = yapi.commons.resReturn(null,404,'该用户不存在');  
    +        }else if(yapi.commons.generatePassword(password, result.passsalt) === result.password){ 
    +            let token = jwt.sign({uid: result._id},result.passsalt,{expiresIn: '7 days'});            
    +            ctx.cookies.set('_yapi_token', token, {
    +                expires: yapi.commons.expireDate(7),
    +                httpOnly: true
    +            })
    +            ctx.cookies.set('_yapi_uid', result._id, {
    +                expires: yapi.commons.expireDate(7),
    +                httpOnly: true
    +            })
    +            
    +            return ctx.body = yapi.commons.resReturn({
    +                uid: result._id,
    +                email: result.email,
    +                add_time: result.add_time,
    +                up_time: result.up_time
    +
    +            }, 0, 'logout success...'); 
             }else{
    -             return ctx.body = yapi.commons.resReturn(null,400,'密码错误'); 
    +            return ctx.body = yapi.commons.resReturn(null, 405, '密码错误');
             }
         }
     
    +    /**
    +     * 退出登录接口
    +     * @interface /user/logout
    +     * @method GET
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example ./api/user/logout.json
    +     */
    +
    +    async logout(ctx){
    +        ctx.cookies.set('_yapi_token', null);
    +        ctx.cookies.set('_yapi_uid', null);
    +        ctx.body = yapi.commons.resReturn('ok');
    +    }
     
     
    +    /**
    +     * 用户注册接口
    +     * @interface /user/reg
    +     * @method POST
    +     * @category user
    +     * @foldnumber 10
    +     * @param {String} email email名称,不能为空
    +     * @param  {String} password 密码,不能为空
    +     * @param {String} [username] 用户名
    +     * @returns {Object} 
    +     * @example ./api/user/login.json
    +     */
         async reg(ctx){  //注册
             var userInst = yapi.getInst(userModel); 
             let params = ctx.request.body; //获取请求的参数,检查是否存在用户名和密码
    -        // if(!params.username){
    -        //     return ctx.body = yapi.commons.resReturn(null,400,'用户名不能为空');
    -        // }
    -        // if(!params.password){
    -        //     return ctx.body = yapi.commons.resReturn(null,400,'密码不能为空'); 
    -        // }
    -        // if(!params.email){
    -        //     return ctx.body = yapi.commons.resReturn(null,400,'邮箱不能为空'); 
    -        // }
    -        
    -        // var checkRepeat = await userInst.checkRepeat(params.username);//然后检查是否已经存在该用户
    -        // if(checkRepeat>0){
    -        //     return ctx.body = yapi.commons.resReturn(null,401,'该用户名已经注册');
    -        // }
    -        // var checkRepeat = await userInst.checkRepeat(params.email);//然后检查是否已经存在该用户
    -        // if(checkRepeat>0){
    -        //     return ctx.body = yapi.commons.resReturn(null,401,'该邮箱已经注册');
    -        // }
    -        
    +        if(!params.email){
    +            return ctx.body = yapi.commons.resReturn(null,400,'邮箱不能为空'); 
    +        }
    +        if(!params.password){
    +            return ctx.body = yapi.commons.resReturn(null,400,'密码不能为空'); 
    +        }
    +                
    +        var checkRepeat = await userInst.checkRepeat(params.email);//然后检查是否已经存在该用户
    +        if(checkRepeat>0){
    +            return ctx.body = yapi.commons.resReturn(null,401,'该email已经注册');
    +        }
    +
    +        let passsalt = yapi.commons.randStr();
             let data = {
                 username: params.username,
    -            password: sha1(params.password),//加密
    +            password: yapi.commons.generatePassword(params.password, passsalt),//加密
                 email: params.email,
    -            role: params.role,
    +            passsalt: passsalt,
    +            role: 'member',
                 add_time: yapi.commons.time(),
                 up_time: yapi.commons.time()
             }
             try{
                 let user = await userInst.save(data);
    -            user = yapi.commons.fieldSelect(user,['id','username','password','email','role'])
    -            ctx.body = yapi.commons.resReturn(user);
    +            
    +            ctx.body = yapi.commons.resReturn({
    +                uid: user._id,
    +                email: user.email,
    +                add_time: user.add_time,
    +                up_time: user.up_time,
    +                role: 'member',
    +            });
    +            yapi.commons.sendMail({
    +                to: params.email,
    +                contents: `欢迎注册,您的账号 ${params.email} 已经注册成功`
    +            })
             }catch(e){
                 ctx.body = yapi.commons.resReturn(null, 401, e.message);
             }
         }
    -    async list(ctx){  //获取用户列表并分页 
    +
    +
    +    /**
    +     * 获取用户列表
    +     * @interface /user/list
    +     * @method GET
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
    +
    +    async list(ctx){
    +        if(this.getRole() !== 'admin'){
    +                return ctx.body = yapi.commons.resReturn(null, 402, 'Without permission.');
    +            }
             var userInst = yapi.getInst(userModel);
             try{
                 let user = await  userInst.list();
    @@ -133,18 +183,47 @@ class userController extends baseController{
                 return ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    /**
    +     * 获取用户列表
    +     * @interface /user/list
    +     * @method GET
    +     * @param id 用户uid
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
    +
         async findById(ctx){    //根据id获取用户信息
    -         try{
    +         try{             
                 var userInst = yapi.getInst(userModel);
                 let id = ctx.request.body.id;
    +            if(this.getUid() != id){
    +                return ctx.body = yapi.commons.resReturn(null, 402, 'Without permission.');
    +            }
                 let result = await userInst.findById(id);
                 return ctx.body = yapi.commons.resReturn(result);
             }catch(e){
                 return ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    /**
    +     * 获取用户列表,只有admin用户才有此权限
    +     * @interface /user/del
    +     * @method POST
    +     * @param id 用户uid
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
         async del(ctx){   //根据id删除一个用户
             try{
    +            if(this.getRole() !== 'admin'){
    +                return ctx.body = yapi.commons.resReturn(null, 402, 'Without permission.');
    +            }
                 var userInst = yapi.getInst(userModel);
                 let id = ctx.request.body.id;
                 let result = await userInst.del(id);
    @@ -153,18 +232,15 @@ class userController extends baseController{
                 ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    
         async update(ctx){    //更新用户信息
             try{
                 var userInst = yapi.getInst(userModel);
    -            let id = ctx.request.body.id;
    +            let id = this.getUid();
                 let data ={};
                 ctx.request.body.username && (data.username = ctx.request.body.username)
    -            ctx.request.body.password && (data.password = ctx.request.body.password)
                 ctx.request.body.email && (data.email = ctx.request.body.email)
    -            ctx.request.body.role && (data.role = ctx.request.body.role)
    -            if (Object.keys(data).length===0){
    -                 ctx.body = yapi.commons.resReturn(null,404,'用户名、密码、Email、role都为空');
    -            }
                 let result = await userInst.update(id,data);
                 ctx.body = yapi.commons.resReturn(result);
             }catch(e){
    diff --git a/exampleCode/api/user/login.json b/exampleCode/api/user/login.json
    index 85772898..ca4f5f26 100644
    --- a/exampleCode/api/user/login.json
    +++ b/exampleCode/api/user/login.json
    @@ -1,9 +1,10 @@
     {
         "errcode": 0,
    -    "errmsg": "success",
    +    "errmsg": "logout success...",
         "data": {
    -        "_id": 4,
    -        "username": "testuser",
    -        "password": "testpassword"
    +        "uid": 101,
    +        "email": "admin@admin.com",
    +        "add_time": 1499762848,
    +        "up_time": 1499762848
         }
     }
    \ No newline at end of file
    diff --git a/package.json b/package.json
    index c9e89d5f..5bbc3f77 100644
    --- a/package.json
    +++ b/package.json
    @@ -4,6 +4,8 @@
       "description": "YAPI",
       "main": "index.js",
       "scripts": {
    +    "build-server": "babel  server -d server_dist",
    +    "dev-server": "nodemon server_dist/app.js dev",
         "start": "webpack-dev-server"
       },
       "repository": {
    diff --git a/server/controllers/interface.js b/server/controllers/interface.js
    index 91e6ed36..d870f512 100644
    --- a/server/controllers/interface.js
    +++ b/server/controllers/interface.js
    @@ -75,6 +75,16 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/get
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/get.json
    +     */
         async get(ctx){
             let params = ctx.request.query;
             if(!params.id){
    @@ -88,6 +98,17 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/list
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   project_id 项目id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/list.json
    +     */
    +
         async list(ctx){
             let project_id = ctx.request.query.project_id;
             if(!project_id){
    @@ -101,6 +122,32 @@ class interfaceController extends baseController{
             }
         }
     
    +    /**
    +     * 添加项目分组
    +     * @interface /interface/up
    +     * @method POST
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @param {String}   [path] 接口请求路径
    +     * @param {String}   [method] 请求方式
    +     * @param {Array}  [req_headers] 请求的header信息
    +     * @param {String}  [req_headers[].name] 请求的header信息名
    +     * @param {String}  [req_headers[].value] 请求的header信息值
    +     * @param {Boolean}  [req_headers[].required] 是否是必须,默认为否
    +     * @param {String}  [req_headers[].desc] header描述
    +     * @param {String}  [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
    +     * @param {Mixed}  [req_params] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
    +     * @param {String} [req_params[].name] 请求参数名
    +     * @param {String} [req_params[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
    +     * @param {String} [req_params[].type] 请求参数类型,有["text", "file"]两种
    +     * @param {String}  [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
    +     * @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
    +     * @param  {String} [desc] 接口描述 
    +     * @returns {Object} 
    +     * @example ./api/interface/up.json
    +     */
    +
         async up(ctx){
             let params = ctx.request.body;
             params.method = params.method || 'GET';
    @@ -140,15 +187,34 @@ class interfaceController extends baseController{
     
         }
     
    +    /**
    +     * 删除接口
    +     * @interface /interface/del
    +     * @method GET
    +     * @category interface
    +     * @foldnumber 10
    +     * @param {Number}   id 接口id,不能为空
    +     * @returns {Object} 
    +     * @example ./api/interface/del.json
    +     */
    +
         async del(ctx){
             try{
    -            let id = ctx.request.body.id;
    +            let id = ctx.request.body.id;            
    +            
                 if(!id){
                     return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
                 }
    -            if(await this.jungeMemberAuth(id) !== true){
    -                return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
    +
    +            let data = await this.Model.get(params.id);
    +
    +            if(data.uid != this.getUid()){
    +                if(await this.jungeProjectAuth(data.project_id) !== true){
    +                    return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
    +                }
                 }
    +
    +            
                 let result = await this.Model.del(id);
                 ctx.body = yapi.commons.resReturn(result)
             }catch(err){
    diff --git a/server/controllers/user.js b/server/controllers/user.js
    index 753581ef..165b295f 100644
    --- a/server/controllers/user.js
    +++ b/server/controllers/user.js
    @@ -10,12 +10,12 @@ class userController extends baseController{
             super(ctx)
         }
         /**
    -     * 添加项目分组
    +     * 用户登录接口
          * @interface /user/login
          * @method POST
          * @category user
          * @foldnumber 10
    -     * @param {String} username 用户名称,不能为空
    +     * @param {String} email email名称,不能为空
          * @param  {String} password 密码,不能为空
          * @returns {Object} 
          * @example ./api/user/login.json
    @@ -47,12 +47,29 @@ class userController extends baseController{
                     expires: yapi.commons.expireDate(7),
                     httpOnly: true
                 })
    -            return ctx.body = yapi.commons.resReturn(null, 0, 'logout success...'); 
    +            
    +            return ctx.body = yapi.commons.resReturn({
    +                uid: result._id,
    +                email: result.email,
    +                add_time: result.add_time,
    +                up_time: result.up_time
    +
    +            }, 0, 'logout success...'); 
             }else{
                 return ctx.body = yapi.commons.resReturn(null, 405, '密码错误');
             }
         }
     
    +    /**
    +     * 退出登录接口
    +     * @interface /user/logout
    +     * @method GET
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example ./api/user/logout.json
    +     */
    +
         async logout(ctx){
             ctx.cookies.set('_yapi_token', null);
             ctx.cookies.set('_yapi_uid', null);
    @@ -60,7 +77,18 @@ class userController extends baseController{
         }
     
     
    -
    +    /**
    +     * 用户注册接口
    +     * @interface /user/reg
    +     * @method POST
    +     * @category user
    +     * @foldnumber 10
    +     * @param {String} email email名称,不能为空
    +     * @param  {String} password 密码,不能为空
    +     * @param {String} [username] 用户名
    +     * @returns {Object} 
    +     * @example ./api/user/login.json
    +     */
         async reg(ctx){  //注册
             var userInst = yapi.getInst(userModel); 
             let params = ctx.request.body; //获取请求的参数,检查是否存在用户名和密码
    @@ -88,8 +116,14 @@ class userController extends baseController{
             }
             try{
                 let user = await userInst.save(data);
    -            user = yapi.commons.fieldSelect(user,['id','username','email'])
    -            ctx.body = yapi.commons.resReturn(user);
    +            
    +            ctx.body = yapi.commons.resReturn({
    +                uid: user._id,
    +                email: user.email,
    +                add_time: user.add_time,
    +                up_time: user.up_time,
    +                role: 'member',
    +            });
                 yapi.commons.sendMail({
                     to: params.email,
                     contents: `欢迎注册,您的账号 ${params.email} 已经注册成功`
    @@ -98,7 +132,22 @@ class userController extends baseController{
                 ctx.body = yapi.commons.resReturn(null, 401, e.message);
             }
         }
    -    async list(ctx){  
    +
    +
    +    /**
    +     * 获取用户列表
    +     * @interface /user/list
    +     * @method GET
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
    +
    +    async list(ctx){
    +        if(this.getRole() !== 'admin'){
    +                return ctx.body = yapi.commons.resReturn(null, 402, 'Without permission.');
    +            }
             var userInst = yapi.getInst(userModel);
             try{
                 let user = await  userInst.list();
    @@ -107,6 +156,18 @@ class userController extends baseController{
                 return ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    /**
    +     * 获取用户列表
    +     * @interface /user/list
    +     * @method GET
    +     * @param id 用户uid
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
    +
         async findById(ctx){    //根据id获取用户信息
              try{             
                 var userInst = yapi.getInst(userModel);
    @@ -120,6 +181,17 @@ class userController extends baseController{
                 return ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    /**
    +     * 获取用户列表,只有admin用户才有此权限
    +     * @interface /user/del
    +     * @method POST
    +     * @param id 用户uid
    +     * @category user
    +     * @foldnumber 10
    +     * @returns {Object} 
    +     * @example 
    +     */
         async del(ctx){   //根据id删除一个用户
             try{
                 if(this.getRole() !== 'admin'){
    @@ -133,6 +205,8 @@ class userController extends baseController{
                 ctx.body = yapi.commons.resReturn(null,402,e.message);
             }
         }
    +
    +    
         async update(ctx){    //更新用户信息
             try{
                 var userInst = yapi.getInst(userModel);
    diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js
    index 058cb5a0..f1abd53f 100644
    --- a/server_dist/controllers/interface.js
    +++ b/server_dist/controllers/interface.js
    @@ -173,6 +173,18 @@ var interfaceController = function (_baseController) {
     
                 return add;
             }()
    +
    +        /**
    +         * 添加项目分组
    +         * @interface /interface/get
    +         * @method GET
    +         * @category interface
    +         * @foldnumber 10
    +         * @param {Number}   id 接口id,不能为空
    +         * @returns {Object} 
    +         * @example ./api/interface/get.json
    +         */
    +
         }, {
             key: 'get',
             value: function () {
    @@ -223,6 +235,18 @@ var interfaceController = function (_baseController) {
     
                 return get;
             }()
    +
    +        /**
    +         * 添加项目分组
    +         * @interface /interface/list
    +         * @method GET
    +         * @category interface
    +         * @foldnumber 10
    +         * @param {Number}   project_id 项目id,不能为空
    +         * @returns {Object} 
    +         * @example ./api/interface/list.json
    +         */
    +
         }, {
             key: 'list',
             value: function () {
    @@ -273,6 +297,33 @@ var interfaceController = function (_baseController) {
     
                 return list;
             }()
    +
    +        /**
    +         * 添加项目分组
    +         * @interface /interface/up
    +         * @method POST
    +         * @category interface
    +         * @foldnumber 10
    +         * @param {Number}   id 接口id,不能为空
    +         * @param {String}   [path] 接口请求路径
    +         * @param {String}   [method] 请求方式
    +         * @param {Array}  [req_headers] 请求的header信息
    +         * @param {String}  [req_headers[].name] 请求的header信息名
    +         * @param {String}  [req_headers[].value] 请求的header信息值
    +         * @param {Boolean}  [req_headers[].required] 是否是必须,默认为否
    +         * @param {String}  [req_headers[].desc] header描述
    +         * @param {String}  [req_params_type] 请求参数方式,有["form", "json", "text", "xml"]四种
    +         * @param {Mixed}  [req_params] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
    +         * @param {String} [req_params[].name] 请求参数名
    +         * @param {String} [req_params[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
    +         * @param {String} [req_params[].type] 请求参数类型,有["text", "file"]两种
    +         * @param {String}  [res_body_type] 相应信息的数据格式,有["json", "text", "xml"]三种
    +         * @param {String} [res_body] 响应信息,可填写任意字符串,如果res_body_type是json,则会调用mock功能
    +         * @param  {String} [desc] 接口描述 
    +         * @returns {Object} 
    +         * @example ./api/interface/up.json
    +         */
    +
         }, {
             key: 'up',
             value: function () {
    @@ -361,11 +412,23 @@ var interfaceController = function (_baseController) {
     
                 return up;
             }()
    +
    +        /**
    +         * 删除接口
    +         * @interface /interface/del
    +         * @method GET
    +         * @category interface
    +         * @foldnumber 10
    +         * @param {Number}   id 接口id,不能为空
    +         * @returns {Object} 
    +         * @example ./api/interface/del.json
    +         */
    +
         }, {
             key: 'del',
             value: function () {
                 var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
    -                var id, result;
    +                var id, data, result;
                     return _regenerator2.default.wrap(function _callee5$(_context5) {
                         while (1) {
                             switch (_context5.prev = _context5.next) {
    @@ -382,41 +445,52 @@ var interfaceController = function (_baseController) {
     
                                 case 4:
                                     _context5.next = 6;
    -                                return this.jungeMemberAuth(id);
    +                                return this.Model.get(params.id);
     
                                 case 6:
    +                                data = _context5.sent;
    +
    +                                if (!(data.uid != this.getUid())) {
    +                                    _context5.next = 13;
    +                                    break;
    +                                }
    +
    +                                _context5.next = 10;
    +                                return this.jungeProjectAuth(data.project_id);
    +
    +                            case 10:
                                     _context5.t0 = _context5.sent;
     
                                     if (!(_context5.t0 !== true)) {
    -                                    _context5.next = 9;
    +                                    _context5.next = 13;
                                         break;
                                     }
     
                                     return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
     
    -                            case 9:
    -                                _context5.next = 11;
    +                            case 13:
    +                                _context5.next = 15;
                                     return this.Model.del(id);
     
    -                            case 11:
    +                            case 15:
                                     result = _context5.sent;
     
                                     ctx.body = _yapi2.default.commons.resReturn(result);
    -                                _context5.next = 18;
    +                                _context5.next = 22;
                                     break;
     
    -                            case 15:
    -                                _context5.prev = 15;
    +                            case 19:
    +                                _context5.prev = 19;
                                     _context5.t1 = _context5['catch'](0);
     
                                     ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
     
    -                            case 18:
    +                            case 22:
                                 case 'end':
                                     return _context5.stop();
                             }
                         }
    -                }, _callee5, this, [[0, 15]]);
    +                }, _callee5, this, [[0, 19]]);
                 }));
     
                 function del(_x5) {
    diff --git a/server_dist/controllers/user.js b/server_dist/controllers/user.js
    index 5844fe46..fb519d27 100644
    --- a/server_dist/controllers/user.js
    +++ b/server_dist/controllers/user.js
    @@ -56,12 +56,12 @@ var userController = function (_baseController) {
             return (0, _possibleConstructorReturn3.default)(this, (userController.__proto__ || (0, _getPrototypeOf2.default)(userController)).call(this, ctx));
         }
         /**
    -     * 添加项目分组
    +     * 用户登录接口
          * @interface /user/login
          * @method POST
          * @category user
          * @foldnumber 10
    -     * @param {String} username 用户名称,不能为空
    +     * @param {String} email email名称,不能为空
          * @param  {String} password 密码,不能为空
          * @returns {Object} 
          * @example ./api/user/login.json
    @@ -128,7 +128,14 @@ var userController = function (_baseController) {
                                         expires: _yapi2.default.commons.expireDate(7),
                                         httpOnly: true
                                     });
    -                                return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 0, 'logout success...'));
    +
    +                                return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn({
    +                                    uid: result._id,
    +                                    email: result.email,
    +                                    add_time: result.add_time,
    +                                    up_time: result.up_time
    +
    +                                }, 0, 'logout success...'));
     
                                 case 21:
                                     return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '密码错误'));
    @@ -147,6 +154,17 @@ var userController = function (_baseController) {
     
                 return login;
             }()
    +
    +        /**
    +         * 退出登录接口
    +         * @interface /user/logout
    +         * @method GET
    +         * @category user
    +         * @foldnumber 10
    +         * @returns {Object} 
    +         * @example ./api/user/logout.json
    +         */
    +
         }, {
             key: 'logout',
             value: function () {
    @@ -173,6 +191,20 @@ var userController = function (_baseController) {
     
                 return logout;
             }()
    +
    +        /**
    +         * 用户注册接口
    +         * @interface /user/reg
    +         * @method POST
    +         * @category user
    +         * @foldnumber 10
    +         * @param {String} email email名称,不能为空
    +         * @param  {String} password 密码,不能为空
    +         * @param {String} [username] 用户名
    +         * @returns {Object} 
    +         * @example ./api/user/login.json
    +         */
    +
         }, {
             key: 'reg',
             value: function () {
    @@ -233,27 +265,33 @@ var userController = function (_baseController) {
                                 case 16:
                                     user = _context3.sent;
     
    -                                user = _yapi2.default.commons.fieldSelect(user, ['id', 'username', 'email']);
    -                                ctx.body = _yapi2.default.commons.resReturn(user);
    +
    +                                ctx.body = _yapi2.default.commons.resReturn({
    +                                    uid: user._id,
    +                                    email: user.email,
    +                                    add_time: user.add_time,
    +                                    up_time: user.up_time,
    +                                    role: 'member'
    +                                });
                                     _yapi2.default.commons.sendMail({
                                         to: params.email,
                                         contents: '\u6B22\u8FCE\u6CE8\u518C\uFF0C\u60A8\u7684\u8D26\u53F7 ' + params.email + ' \u5DF2\u7ECF\u6CE8\u518C\u6210\u529F'
                                     });
    -                                _context3.next = 25;
    +                                _context3.next = 24;
                                     break;
     
    -                            case 22:
    -                                _context3.prev = 22;
    +                            case 21:
    +                                _context3.prev = 21;
                                     _context3.t0 = _context3['catch'](13);
     
                                     ctx.body = _yapi2.default.commons.resReturn(null, 401, _context3.t0.message);
     
    -                            case 25:
    +                            case 24:
                                 case 'end':
                                     return _context3.stop();
                             }
                         }
    -                }, _callee3, this, [[13, 22]]);
    +                }, _callee3, this, [[13, 21]]);
                 }));
     
                 function reg(_x3) {
    @@ -262,6 +300,17 @@ var userController = function (_baseController) {
     
                 return reg;
             }()
    +
    +        /**
    +         * 获取用户列表
    +         * @interface /user/list
    +         * @method GET
    +         * @category user
    +         * @foldnumber 10
    +         * @returns {Object} 
    +         * @example 
    +         */
    +
         }, {
             key: 'list',
             value: function () {
    @@ -271,26 +320,34 @@ var userController = function (_baseController) {
                         while (1) {
                             switch (_context4.prev = _context4.next) {
                                 case 0:
    +                                if (!(this.getRole() !== 'admin')) {
    +                                    _context4.next = 2;
    +                                    break;
    +                                }
    +
    +                                return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, 'Without permission.'));
    +
    +                            case 2:
                                     userInst = _yapi2.default.getInst(_user2.default);
    -                                _context4.prev = 1;
    -                                _context4.next = 4;
    +                                _context4.prev = 3;
    +                                _context4.next = 6;
                                     return userInst.list();
     
    -                            case 4:
    +                            case 6:
                                     user = _context4.sent;
                                     return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(user));
     
    -                            case 8:
    -                                _context4.prev = 8;
    -                                _context4.t0 = _context4['catch'](1);
    +                            case 10:
    +                                _context4.prev = 10;
    +                                _context4.t0 = _context4['catch'](3);
                                     return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message));
     
    -                            case 11:
    +                            case 13:
                                 case 'end':
                                     return _context4.stop();
                             }
                         }
    -                }, _callee4, this, [[1, 8]]);
    +                }, _callee4, this, [[3, 10]]);
                 }));
     
                 function list(_x4) {
    @@ -299,6 +356,18 @@ var userController = function (_baseController) {
     
                 return list;
             }()
    +
    +        /**
    +         * 获取用户列表
    +         * @interface /user/list
    +         * @method GET
    +         * @param id 用户uid
    +         * @category user
    +         * @foldnumber 10
    +         * @returns {Object} 
    +         * @example 
    +         */
    +
         }, {
             key: 'findById',
             value: function () {
    @@ -346,6 +415,18 @@ var userController = function (_baseController) {
     
                 return findById;
             }()
    +
    +        /**
    +         * 获取用户列表,只有admin用户才有此权限
    +         * @interface /user/del
    +         * @method POST
    +         * @param id 用户uid
    +         * @category user
    +         * @foldnumber 10
    +         * @returns {Object} 
    +         * @example 
    +         */
    +
         }, {
             key: 'del',
             value: function () {
    
    From 2eeac22a48e10358ffa89c7ebd066390e6eb638e Mon Sep 17 00:00:00 2001
    From: "waliang.wang" 
    Date: Tue, 11 Jul 2017 19:12:13 +0800
    Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8E=A5=E5=8F=A3?=
     =?UTF-8?q?=E9=9D=99=E6=80=81=E9=A1=B5=E9=9D=A2?=
    MIME-Version: 1.0
    Content-Type: text/plain; charset=UTF-8
    Content-Transfer-Encoding: 8bit
    
    ---
     client/ReduxContainer.js                      |  4 +-
     client/actionTypes.js                         |  6 ++
     client/actions/interface.js                   | 33 +++++++++++
     client/containers/Interface/Interface.js      | 45 +++++++++++++++
     client/containers/Interface/Interface.scss    | 38 +++++++++++++
     .../Interface/InterfaceList/InterfaceList.js  | 18 ++++++
     .../InterfaceTable/InterfaceTable.js          | 55 +++++++++++++++++++
     client/containers/Login/Login_container.js    | 24 --------
     client/containers/index.js                    |  2 +
     client/reducer/interface/interface.js         | 16 ++++++
     client/routes.js                              |  3 +-
     client/styles/common.scss                     |  3 +-
     12 files changed, 220 insertions(+), 27 deletions(-)
     create mode 100644 client/actionTypes.js
     create mode 100644 client/actions/interface.js
     create mode 100644 client/containers/Interface/Interface.js
     create mode 100644 client/containers/Interface/Interface.scss
     create mode 100644 client/containers/Interface/InterfaceList/InterfaceList.js
     create mode 100644 client/containers/Interface/InterfaceTable/InterfaceTable.js
     delete mode 100644 client/containers/Login/Login_container.js
     create mode 100644 client/reducer/interface/interface.js
    
    diff --git a/client/ReduxContainer.js b/client/ReduxContainer.js
    index dd3a41eb..6b1347ef 100644
    --- a/client/ReduxContainer.js
    +++ b/client/ReduxContainer.js
    @@ -1,7 +1,9 @@
     import LoginRedux from './reducer/Login/Login_redux.js'
     import group from './reducer/group/group.js'
    +import Interface from './reducer/interface/interface.js'
     
     export default {
    +  group,
       LoginRedux,
    -  group
    +  Interface,
     }
    diff --git a/client/actionTypes.js b/client/actionTypes.js
    new file mode 100644
    index 00000000..fb51f5b1
    --- /dev/null
    +++ b/client/actionTypes.js
    @@ -0,0 +1,6 @@
    +// Interface
    +export const FETCH_INTERFACE_DATA = 'FETCH_INTERFACE_DATA';
    +
    +// Home
    +export const FETCH_HOME_DATA = 'FETCH_INTERFACE_DATA';
    +
    diff --git a/client/actions/interface.js b/client/actions/interface.js
    new file mode 100644
    index 00000000..91feefd3
    --- /dev/null
    +++ b/client/actions/interface.js
    @@ -0,0 +1,33 @@
    +import {
    +  FETCH_INTERFACE_DATA,
    +} from '../actionTypes.js';
    +
    +export function fetchAuditIcons () {
    +  const data = [{
    +    key: '1',
    +    name: 'John Brown',
    +    age: 32,
    +    address: 'New York No. 1 Lake Park',
    +    date: '2015-11-11 13:00:15',
    +    features: '3',
    +  }, {
    +    key: '2',
    +    name: 'Jim Green',
    +    age: 42,
    +    address: 'London No. 1 Lake Park',
    +    date: '2015-11-11 13:00:15',
    +    features: '3',
    +  }, {
    +    key: '3',
    +    name: 'Joe Black',
    +    age: 32,
    +    address: 'Sidney No. 1 Lake Park',
    +    date: '2015-11-11 13:00:15',
    +    features: '3',
    +  }]
    +
    +  return {
    +    type: FETCH_INTERFACE_DATA,
    +    payload: data,
    +  };
    +}
    \ No newline at end of file
    diff --git a/client/containers/Interface/Interface.js b/client/containers/Interface/Interface.js
    new file mode 100644
    index 00000000..e7ac78d6
    --- /dev/null
    +++ b/client/containers/Interface/Interface.js
    @@ -0,0 +1,45 @@
    +import './Interface.scss'
    +import React, { Component } from 'react'
    +import { connect } from 'react-redux'
    +import PropTypes from 'prop-types'
    +import InterfaceList from './InterfaceList/InterfaceList.js'
    +import InterfaceTable from './InterfaceTable/InterfaceTable.js'
    +import { fetchAuditIcons } from '../../actions/interface.js'
    +
    +@connect(
    +  state => {
    +    return {
    +      interfaceData: state.data,
    +    }
    +  },
    +  {
    +    fetchAuditIcons,
    +  }
    +)
    +
    +class Interface extends Component {
    +  static propTypes = {
    +    fetchAuditIcons: PropTypes.func,
    +  }
    +
    +  constructor(props) {
    +    super(props)
    +  }
    +
    +  componentWillMount () {
    +    this.props.fetchAuditIcons()
    +  }
    +
    +  render () {
    +    const data = this.props.fetchAuditIcons().payload
    +
    +    return (
    +      
    + + +
    + ) + } +} + +export default Interface \ No newline at end of file diff --git a/client/containers/Interface/Interface.scss b/client/containers/Interface/Interface.scss new file mode 100644 index 00000000..9df8129c --- /dev/null +++ b/client/containers/Interface/Interface.scss @@ -0,0 +1,38 @@ +/* .interface-box.css */ +.interface-box { + max-width: 11rem; + display: -webkit-box; + -webkit-box-flex: 1; + margin: 15px auto 0 auto; + font-size: 0.14rem; + + .interface-list { + width: 216px; + line-height: 45px; + background: #f9fafe; + + li { + padding: 0 0 0 30px; + color: #344562; + cursor: pointer; + + &:hover, &.active { + background: #657289; + color: #FFF; + } + } + } + + .interface-table { + -webkit-box-flex: 1; + margin: 0 0 0 20px; + + .ant-table-wrapper table { + font-size: .14rem; + + button { + margin: 0 10px 0 0; + } + } + } +} \ No newline at end of file diff --git a/client/containers/Interface/InterfaceList/InterfaceList.js b/client/containers/Interface/InterfaceList/InterfaceList.js new file mode 100644 index 00000000..1db38a0b --- /dev/null +++ b/client/containers/Interface/InterfaceList/InterfaceList.js @@ -0,0 +1,18 @@ +import React, { Component } from 'react' + +class InterfaceList extends Component { + constructor(props) { + super(props) + } + + render () { + return ( +
      +
    • 添加接口
    • +
    • 管理项目成员
    • +
    + ) + } +} + +export default InterfaceList \ No newline at end of file diff --git a/client/containers/Interface/InterfaceTable/InterfaceTable.js b/client/containers/Interface/InterfaceTable/InterfaceTable.js new file mode 100644 index 00000000..887b8f58 --- /dev/null +++ b/client/containers/Interface/InterfaceTable/InterfaceTable.js @@ -0,0 +1,55 @@ +import React, { Component } from 'react' +import { Table, Button } from 'antd' +import PropTypes from 'prop-types' + +class InterfaceTable extends Component { + static propTypes = { + data: PropTypes.array, + } + + constructor(props) { + super(props) + } + + render () { + const columns = [{ + title: '接口名称', + dataIndex: 'name', + key: 'name', + }, { + title: '接口URL', + dataIndex: 'age', + key: 'age', + }, { + title: '操作者', + dataIndex: 'address', + key: 'address', + }, { + title: '更新日期', + dataIndex: 'date', + key: 'date', + }, { + title: '功能', + 'key': 'action', + render: () => { + return ( + + + + + ) + } + }] + + const data = this.props.data; + console.log(this.props.data) + + return ( +
    + + + ) + } +} + +export default InterfaceTable \ No newline at end of file diff --git a/client/containers/Login/Login_container.js b/client/containers/Login/Login_container.js deleted file mode 100644 index 92ad6d68..00000000 --- a/client/containers/Login/Login_container.js +++ /dev/null @@ -1,24 +0,0 @@ -import { connect } from 'react-redux' -import Login from './Login.js' - -// Action -const increaseAction = { type: 'increase' } - -function mapStateToProps() { - return { - per: '测试数据' - } -} - -function mapDispatchToProps(dispatch) { - return { - onIncreaseClick: () => dispatch(increaseAction) - } -} - -const App = connect( - mapStateToProps, - mapDispatchToProps -)(Login) - -export default App diff --git a/client/containers/index.js b/client/containers/index.js index a7398c4f..f02ebae6 100644 --- a/client/containers/index.js +++ b/client/containers/index.js @@ -1,9 +1,11 @@ import Home from './Home/Home.js' import Login from './Login/Login.js' import ProjectGroups from './ProjectGroups/ProjectGroups.js' +import Interface from './Interface/Interface.js' export { Home, Login, ProjectGroups, + Interface, } diff --git a/client/reducer/interface/interface.js b/client/reducer/interface/interface.js new file mode 100644 index 00000000..699736ca --- /dev/null +++ b/client/reducer/interface/interface.js @@ -0,0 +1,16 @@ +import { + FETCH_INTERFACE_DATA, +} from '../../actionTypes.js' + +export default (state = 3333, action) => { + switch (action.type) { + case FETCH_INTERFACE_DATA: { + return { + ...state, + icons: action.payload.data, + }; + } + default: + return state; + } +} diff --git a/client/routes.js b/client/routes.js index cfebbd3f..507133bc 100644 --- a/client/routes.js +++ b/client/routes.js @@ -1,6 +1,6 @@ import React from 'react' import { Route, HashRouter } from 'react-router-dom' -import { Home, Login, ProjectGroups } from './containers/index' +import { Home, Login, ProjectGroups, Interface } from './containers/index' export default () => { return ( @@ -9,6 +9,7 @@ export default () => { + ) diff --git a/client/styles/common.scss b/client/styles/common.scss index da060373..9813499b 100644 --- a/client/styles/common.scss +++ b/client/styles/common.scss @@ -2,7 +2,8 @@ @import '~antd/dist/antd.css'; html { - font-size:625% + font-size:625%; + background: #f1f3f6; } html, body { font-family: tahoma, 'Microsoft Yahei';