From e781bd3071842b5372f42b8af06aa315fe671c39 Mon Sep 17 00:00:00 2001
From: qitmac000249 <xilli.yu@Qunar.com>
Date: Thu, 27 Jul 2017 15:50:04 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9user=E9=A1=B5=E9=9D=A2?=
 =?UTF-8?q?=E7=BB=86=E8=8A=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 client/containers/User/LeftMenu.js   |  2 +-
 client/containers/User/Profile.js    | 16 ++++-----
 client/containers/User/index.scss    | 12 +++----
 server_dist/controllers/interface.js | 49 +++++++++++++++++++++-------
 server_dist/utils/commons.js         | 18 ++++++----
 server_dist/utils/db.js              |  5 +--
 6 files changed, 66 insertions(+), 36 deletions(-)

diff --git a/client/containers/User/LeftMenu.js b/client/containers/User/LeftMenu.js
index 5a3acec9..7b919d6d 100644
--- a/client/containers/User/LeftMenu.js
+++ b/client/containers/User/LeftMenu.js
@@ -83,7 +83,7 @@ class LeftMenu extends Component {
     const { dataSource } = this.state;
     return (<div className="user-list">
       <div className='cur-user'>
-        <div className='user-name'><span>用户名 : </span>{`${this.props.curUserName}`}</div>
+        <div className='user-name'><span>用户名 :</span>{`${this.props.curUserName}`}</div>
       </div>
       <Row type="flex" justify="start" className="search">
         <Col span="24">
diff --git a/client/containers/User/Profile.js b/client/containers/User/Profile.js
index 7030d60f..ef276f50 100644
--- a/client/containers/User/Profile.js
+++ b/client/containers/User/Profile.js
@@ -132,7 +132,7 @@ class Profile extends Component {
       userNameEditHtml = <div >
         <span className="text">{userinfo.username}</span>&nbsp;&nbsp;
         {/*<span className="text-button"  onClick={() => { this.handleEdit('usernameEdit', true) }}><Icon type="edit" />修改</span>*/}
-        <Button size={'small'} icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>
+        <Button  icon="edit" onClick={() => { this.handleEdit('usernameEdit', true) }}>修改</Button>
       </div>
     } else {
       userNameEditHtml = <div>
@@ -148,14 +148,14 @@ class Profile extends Component {
       emailEditHtml = <div >
         <span className="text">{userinfo.email}</span>&nbsp;&nbsp;
         {/*<span className="text-button" onClick={() => { this.handleEdit('emailEdit', true) }} ><Icon type="edit" />修改</span>*/}
-        <Button size={'small'} icon="edit" onClick={() => { this.handleEdit('emailEdit', true) }}>修改</Button>
+        <Button  icon="edit" onClick={() => { this.handleEdit('emailEdit', true) }}>修改</Button>
       </div>
     } else {
       emailEditHtml = <div>
         <Input placeholder="Email" value={_userinfo.email} name="email" onChange={this.changeUserinfo} />
         <ButtonGroup className="edit-buttons" >
-          <Button size={'small'} className="edit-button" onClick={() => { this.handleEdit('emailEdit', false) }} >Cancel</Button>
-          <Button size={'small'} className="edit-button" type="primary" onClick={ () => { this.updateUserinfo('email')} }>OK</Button>
+          <Button  className="edit-button" onClick={() => { this.handleEdit('emailEdit', false) }} >Cancel</Button>
+          <Button  className="edit-button" type="primary" onClick={ () => { this.updateUserinfo('email')} }>OK</Button>
         </ButtonGroup>
       </div>
     }
@@ -164,7 +164,7 @@ class Profile extends Component {
       roleEditHtml = <div>
         <span className="text">{roles[userinfo.role]}</span>&nbsp;&nbsp;
         {/*<span className="text-button" onClick={() => { this.handleEdit('roleEdit', true) }} ><Icon type="edit" />修改</span>*/}
-        <Button size={'small'} icon="edit" onClick={() => { this.handleEdit('roleEdit', true) }}>修改</Button>
+        <Button  icon="edit" onClick={() => { this.handleEdit('roleEdit', true) }}>修改</Button>
       </div>
     } else {
       roleEditHtml = <Select defaultValue={_userinfo.role} onChange={ this.changeRole} style={{ width: 150 }} >
@@ -175,15 +175,15 @@ class Profile extends Component {
     }
 
     if (this.state.secureEdit === false) {
-      secureEditHtml = <Button size={'small'} icon="edit" onClick={() => { this.handleEdit('secureEdit', true) }}>修改</Button>
+      secureEditHtml = <Button  icon="edit" onClick={() => { this.handleEdit('secureEdit', true) }}>修改</Button>
     } else {
       secureEditHtml = <div>
         <Input style={{display: this.state.userinfo.role === 'admin' ? 'none': ''}} placeholder="旧的密码" type="password" name="old_password" id="old_password" />
         <Input placeholder="新的密码" type="password" name="password" id="password" />
         <Input placeholder="确认密码" type="password" name="verify_pass" id="verify_pass" />
         <ButtonGroup className="edit-buttons" >
-          <Button size={'small'} className="edit-button" onClick={() => { this.handleEdit('secureEdit', false) }}>Cancel</Button>
-          <Button size={'small'} className="edit-button" onClick={this.updatePassword} type="primary">OK</Button>
+          <Button  className="edit-button" onClick={() => { this.handleEdit('secureEdit', false) }}>Cancel</Button>
+          <Button  className="edit-button" onClick={this.updatePassword} type="primary">OK</Button>
         </ButtonGroup>
       </div>
     }
diff --git a/client/containers/User/index.scss b/client/containers/User/index.scss
index 5bbb3b9b..b5124269 100644
--- a/client/containers/User/index.scss
+++ b/client/containers/User/index.scss
@@ -30,15 +30,15 @@
     }
   }
   .user-name{
-    padding: 24px 0px;
-    text-align: center;
+    padding: 24px 10px;
+    // text-align: center;
     background-color: #34495e;
     color: white;
     font-size: 16px;
     border-top-left-radius:5px;
     border-top-right-radius: 5px; 
     span{
-      margin-right: 10px;
+      margin-right: 5px;
     }
   }
   .router-content{
@@ -70,9 +70,6 @@
     box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
     background: #FFF;
     border-radius:5px;
-    .ant-btn-group{
-      margin-top: 12px;
-    }
     .user-item {
       min-height:35px;
       line-height:35px;
@@ -90,10 +87,11 @@
       .ant-col-12{
         .ant-input{
           width: 70%;
+          margin-right: 24px;
         }
       }
       .ant-col-4{
-        color: black;
+        color: rgba(0,0,0,0.85);
         padding: 0px 10px;
         text-indent: .7em;
         // background-color: #f1f3f6;
diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js
index 039bd5ad..1a6941c4 100644
--- a/server_dist/controllers/interface.js
+++ b/server_dist/controllers/interface.js
@@ -94,6 +94,7 @@ var interfaceController = function (_baseController) {
                             case 0:
                                 params = ctx.request.body;
 
+
                                 params = _yapi2.default.commons.handleParams(params, {
                                     project_id: 'number',
                                     title: 'string',
@@ -160,8 +161,12 @@ var interfaceController = function (_baseController) {
                                 };
 
 
-                                if (params.req_params_form) data.req_params_form = params.req_params_form;
-                                if (params.req_params_other) data.req_params_other = params.req_params_other;
+                                if (params.req_params_form) {
+                                    data.req_params_form = params.req_params_form;
+                                }
+                                if (params.req_params_other) {
+                                    data.req_params_other = params.req_params_other;
+                                }
 
                                 _context.next = 22;
                                 return this.Model.save(data);
@@ -301,7 +306,7 @@ var interfaceController = function (_baseController) {
                                 _context3.prev = 10;
                                 _context3.t0 = _context3['catch'](3);
 
-                                ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
+                                ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
 
                             case 13:
                             case 'end':
@@ -356,6 +361,7 @@ var interfaceController = function (_baseController) {
                             case 0:
                                 params = ctx.request.body;
 
+
                                 params = _yapi2.default.commons.handleParams(params, {
                                     title: 'string',
                                     path: 'string',
@@ -364,6 +370,7 @@ var interfaceController = function (_baseController) {
                                 });
                                 params.method = params.method || 'GET';
                                 params.method = params.method.toUpperCase();
+
                                 id = ctx.request.body.id;
 
                                 if (id) {
@@ -412,18 +419,36 @@ var interfaceController = function (_baseController) {
                                 };
 
 
-                                if (params.path) data.path = params.path;
-                                if (params.title) data.title = params.title;
-                                if (params.desc) data.desc = params.desc;
-                                if (params.method) data.method = params.method;
+                                if (params.path) {
+                                    data.path = params.path;
+                                }
+                                if (params.title) {
+                                    data.title = params.title;
+                                }
+                                if (params.desc) {
+                                    data.desc = params.desc;
+                                }
+                                if (params.method) {
+                                    data.method = params.method;
+                                }
 
-                                if (params.req_headers) data.req_headers = params.req_headers;
+                                if (params.req_headers) {
+                                    data.req_headers = params.req_headers;
+                                }
 
-                                if (params.req_params_form) data.req_params_form = params.req_params_form;
-                                if (params.req_params_other) data.req_params_other = params.req_params_other;
+                                if (params.req_params_form) {
+                                    data.req_params_form = params.req_params_form;
+                                }
+                                if (params.req_params_other) {
+                                    data.req_params_other = params.req_params_other;
+                                }
 
-                                if (params.res_body_type) data.res_body_type = params.res_body_type;
-                                if (params.res_body) data.res_body = params.res_body;
+                                if (params.res_body_type) {
+                                    data.res_body_type = params.res_body_type;
+                                }
+                                if (params.res_body) {
+                                    data.res_body = params.res_body;
+                                }
 
                                 _context4.prev = 28;
                                 _context4.next = 31;
diff --git a/server_dist/utils/commons.js b/server_dist/utils/commons.js
index c43f49ee..792f05ab 100644
--- a/server_dist/utils/commons.js
+++ b/server_dist/utils/commons.js
@@ -47,13 +47,17 @@ exports.log = function (msg, type) {
 
     switch (type) {
         case 'log':
-            f = console.log;break;
+            f = console.log;
+            break;
         case 'warn':
-            f = console.warn;break;
+            f = console.warn;
+            break;
         case 'error':
-            f = console.error;break;
+            f = console.error;
+            break;
         default:
-            f = console.log;break;
+            f = console.log;
+            break;
     }
 
     f(type + ':', msg);
@@ -231,9 +235,11 @@ exports.handleParams = function (params, keys) {
         if (params[key]) {
             switch (filter) {
                 case 'string':
-                    params[key] = trim(params[key] + '');break;
+                    params[key] = trim(params[key] + '');
+                    break;
                 case 'number':
-                    params[key] = parseInt(params[key], 10);break;
+                    params[key] = parseInt(params[key], 10);
+                    break;
                 default:
                     params[key] = trim(params + '');
             }
diff --git a/server_dist/utils/db.js b/server_dist/utils/db.js
index cb66a49a..21aae9bd 100644
--- a/server_dist/utils/db.js
+++ b/server_dist/utils/db.js
@@ -31,12 +31,13 @@ function connect() {
     var options = {};
 
     if (config.user) {
-        options.user = config.db.user, options.pass = config.db.pass;
+        options.user = config.db.user;
+        options.pass = config.db.pass;
     }
 
     var db = _mongoose2.default.connect('mongodb://' + config.db.servername + ':' + config.db.port + '/' + config.db.DATABASE, options);
 
-    db.then(function (res) {
+    db.then(function () {
         _yapi2.default.commons.log('mongodb load success...');
     }, function (err) {
         _yapi2.default.commons.log(err, 'Mongo connect error');