+
接口名:
- {this.props.viewData.casename}
-
-
- 添加时间:
- {formatTime(this.props.viewData.add_time/1000)}
-
-
- 更新时间:
- {formatTime(this.props.viewData.up_time/1000)}
-
-
- 测试环境:
- {this.props.viewData.env}
-
-
- 域名:
- {this.props.viewData.domain}
+ {this.props.viewData.title}
- 路径:
+ 接口路径:
{this.props.viewData.path}
-
-
请求方法:
-
{this.props.viewData.method}
+
+ 状态:
+ {this.props.viewData.status}
+
+ Mock地址:
+ {this.props.viewData.mockUrl}
+
+
+ 接口描述:
+ {this.props.viewData.desc}
+
+
+
+
+
+
+
+
}
}
+let data = {
+ title: '',
+ path: '',
+ status: 'undone',
+ method: 'get',
+ req_query: [{
+ name: '',
+ desc: '',
+ required: "1"
+ }],
+ req_body_type: 'form',
+ req_headers: [{
+ name: '',
+ value: '', required: "1"
+ }],
+ req_body_form: [{
+ name: '',
+ type: '',
+ required: ''
+ }],
+ res_body_type: 'json',
+ res_body: '{a:123}',
+ desc: 'FP的好处是没有OO的复杂仪式感,是沿着数据结构+算法的思路进行抽象和结构化。如果顶层设计做好,代码复用度极高,代码量少。比如要生成一颗树我用迭归算法直接生成',
+ res_body_mock: '',
+ mockUrl: "this.props.mockUrl"
+}
+// {
+// casename:"caename",
+// uid: 107,
+// col_id: 211,
+// index: 0,
+// project_id: 112,
+// add_time: new Date().getTime(),
+// up_time: new Date().getTime(),
+// env: "测试环境",
+// domain: "域名",
+// path: "路径",
+// method: "GET",
+// req_query: [{
+// name: "String",
+// value: "String",
+// required: "1"
+// }],
+// req_headers: [{
+// name: "String",
+// value: "String",
+// required: "1"
+// }],
+// req_body_type: "json",
+// res_body_form: [{
+// name: "String",
+// value: "String",
+// required: "1"
+// }],
+// res_body_other: "String"
+// }
View.defaultProps = {
- viewData: {
- casename:"caename",
- uid: 107,
- col_id: 211,
- index: 0,
- project_id: 112,
- add_time: new Date().getTime(),
- up_time: new Date().getTime(),
- env: "测试环境",
- domain: "域名",
- path: "路径",
- method: "GET",
- req_query: [{
- name: "String",
- value: "String"
- }],
- req_headers: [{
- name: "String",
- value: "String"
- }],
- req_body_type: "json",
- res_body_form: [{
- name: "String",
- value: "String"
- }],
- res_body_other: "String"
- }
+ viewData: data
}
export default View
diff --git a/client/containers/Project/Interface/InterfaceList/View.scss b/client/containers/Project/Interface/InterfaceList/View.scss
new file mode 100644
index 00000000..c8657682
--- /dev/null
+++ b/client/containers/Project/Interface/InterfaceList/View.scss
@@ -0,0 +1,35 @@
+.caseContainer{
+ padding: 24px;
+ font-size: 12px;
+ // display: flex;
+ overflow: hidden;
+ >div{
+ margin: 8px 0px;
+ // background-color: #ececec;
+ padding: 16px;
+ width: 100%;
+ box-sizing: border-box;
+ float: left;
+ .colKey{
+ font-weight: bolder;
+ margin-right: 16px;
+ }
+ }
+ .colName,.colPath,.colstatus,.colMock{
+ width: 50%;
+ float: left;
+ padding: 8px 16px;
+ }
+ .colDesc{
+ line-height: 1.5em;
+ .colKey{
+ margin-right: 0px;
+ float: left;
+ margin-bottom: 8px;
+ }
+ .colValue{
+ float: left;
+ text-indent: 2em;
+ }
+ }
+}
\ No newline at end of file
diff --git a/client/containers/Project/Interface/interface.scss b/client/containers/Project/Interface/interface.scss
index da438153..0b1b3898 100644
--- a/client/containers/Project/Interface/interface.scss
+++ b/client/containers/Project/Interface/interface.scss
@@ -65,19 +65,7 @@
}
}
}
-.caseContainer{
- padding: 24px;
- font-size: 12px;
- >div{
- margin: 8px 0px;
- padding: 12px;
- background-color: #ececec;
- .colKey{
- font-weight: bolder;
- margin-right: 16px;
- }
- }
-}
+
diff --git a/client/containers/User/Profile.js b/client/containers/User/Profile.js
index 1c3c1189..5c59c9cd 100644
--- a/client/containers/User/Profile.js
+++ b/client/containers/User/Profile.js
@@ -152,7 +152,7 @@ class Profile extends Component {
userNameEditHtml =
{userinfo.username}
{/* { this.handleEdit('usernameEdit', true) }}>修改*/}
- {userType?:""}
+ {}
} else {
userNameEditHtml =
diff --git a/client/containers/User/User.js b/client/containers/User/User.js
index 54ffdfd8..a9bd05ba 100755
--- a/client/containers/User/User.js
+++ b/client/containers/User/User.js
@@ -9,7 +9,6 @@ import Profile from './Profile.js'
import { Row } from 'antd';
import Subnav from '../../components/Subnav/Subnav.js';
@connect(state=>{
- console.log(state);
return {
curUid: state.user.uid,
userType: state.user.type,
@@ -31,7 +30,7 @@ class User extends Component {
}
componentDidMount () {
- console.log(this.props.match)
+ // console.log(this.props.match)
}
render () {
@@ -41,7 +40,7 @@ class User extends Component {
}];
if(this.props.role === "admin"){
navData.push({
- name: '成员管理',
+ name: '用户管理',
path: '/user/list'
})
}
diff --git a/client/reducer/modules/user.js b/client/reducer/modules/user.js
index 8a438c98..5bab37fb 100644
--- a/client/reducer/modules/user.js
+++ b/client/reducer/modules/user.js
@@ -18,7 +18,8 @@ const initialState = {
uid: null,
email: '',
loginState: LOADING_STATUS,
- loginWrapActiveKey: "1"
+ loginWrapActiveKey: "1",
+ role: ""
};
export default (state = initialState, action) => {
@@ -40,7 +41,8 @@ export default (state = initialState, action) => {
isLogin: true,
loginState: MEMBER_STATUS,
uid: action.payload.data.data.uid,
- userName: action.payload.data.data.username
+ userName: action.payload.data.data.username,
+ role: action.payload.data.data.role
};
} else {
return state;
@@ -52,7 +54,8 @@ export default (state = initialState, action) => {
isLogin: false,
loginState: GUEST_STATUS,
userName: null,
- uid: null
+ uid: null,
+ role: ""
}
}
case LOGIN_TYPE: {
@@ -79,6 +82,7 @@ export default (state = initialState, action) => {
export function checkLoginState() {
return(dispatch)=> {
axios.get('/api/user/status').then((res) => {
+ console.log(res)
dispatch({
type: GET_LOGIN_STATE,
payload: res
diff --git a/exampleCode/api/project/list.json b/exampleCode/api/project/list.json
index 665950ec..37a3dc06 100644
--- a/exampleCode/api/project/list.json
+++ b/exampleCode/api/project/list.json
@@ -2,7 +2,6 @@
"errcode": 0,
"errmsg": "success",
"data": {
- "total": 2,
"list": [
{
"_id": 529,
@@ -148,16 +147,6 @@
"107"
]
}
- ],
- "userinfo": {
- "107": {
- "_id": 107,
- "username": "admin",
- "email": "admin@admin.com",
- "role": "admin",
- "add_time": 1500280333,
- "up_time": 1500373530
- }
- }
+ ]
}
}
\ No newline at end of file
diff --git a/server/controllers/group.js b/server/controllers/group.js
index b28c2f35..8f281324 100644
--- a/server/controllers/group.js
+++ b/server/controllers/group.js
@@ -82,6 +82,7 @@ class groupController extends baseController {
return null;
}
return {
+ _role: userData.role,
role: role,
uid: userData._id,
username: userData.username,
@@ -89,6 +90,19 @@ class groupController extends baseController {
}
}
+ /**
+ * 添加项目分组成员
+ * @interface /group/add_member
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @returns {Object}
+ * @example
+ */
+
+
async addMember(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@@ -107,6 +121,10 @@ class groupController extends baseController {
if(groupUserdata === null){
return ctx.body = yapi.commons.resReturn(null, 400, '组长uid不存在')
}
+ if(groupUserdata._role === 'admin'){
+ return ctx.body = yapi.commons.resReturn(null, 400, '不能邀请管理员')
+ }
+ delete groupUserdata._role;
try {
let result = await groupInst.addMember(params.id, groupUserdata);
ctx.body = yapi.commons.resReturn(result);
@@ -115,6 +133,19 @@ class groupController extends baseController {
}
}
+
+ /**
+ * 修改项目分组成员角色
+ * @interface /group/change_member_role
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @param {String} role 组长uid
+ * @returns {Object}
+ * @example
+ */
async changeMemberRole(ctx){
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@@ -128,7 +159,7 @@ class groupController extends baseController {
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
- if (await this.checkAuth(id, 'group', 'danger') !== true) {
+ if (await this.checkAuth(params.id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
@@ -141,6 +172,16 @@ class groupController extends baseController {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
}
+ /**
+ * 获取所有项目成员
+ * @interface /group/get_member_list
+ * @method GET
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @returns {Object}
+ * @example
+ */
async getMemberList(ctx) {
let params = ctx.request.query;
@@ -157,6 +198,18 @@ class groupController extends baseController {
}
}
+ /**
+ * 删除项目成员
+ * @interface /group/del_member
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @returns {Object}
+ * @example
+ */
+
async delMember(ctx) {
let params = ctx.request.body;
let groupInst = yapi.getInst(groupModel);
@@ -170,7 +223,7 @@ class groupController extends baseController {
if (check === 0) {
return ctx.body = yapi.commons.resReturn(null, 400, '分组成员不存在');
}
- if (await this.checkAuth(id, 'group', 'danger') !== true) {
+ if (await this.checkAuth(params.id, 'group', 'danger') !== true) {
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
}
diff --git a/server/controllers/interface.js b/server/controllers/interface.js
index 9873723f..a66cfcc4 100644
--- a/server/controllers/interface.js
+++ b/server/controllers/interface.js
@@ -24,6 +24,7 @@ class interfaceController extends baseController {
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
* @param {String} [req_headers[].desc] header描述
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
+ * @param {Array} [req_params] name, desc两个参数
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
* @param {String} [req_body_form[].name] 请求参数名
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
@@ -83,13 +84,16 @@ class interfaceController extends baseController {
up_time: yapi.commons.time()
};
- if(params.req_query){
+ if (params.req_query) {
data.req_query = params.req_query;
}
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
+ if (params.req_params) {
+ data.req_params = params.req_params;
+ }
if (params.req_body_other) {
data.req_body_other = params.req_body_other;
}
@@ -191,7 +195,7 @@ class interfaceController extends baseController {
params.method = params.method.toUpperCase();
let id = ctx.request.body.id;
-
+
if (!id) {
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
}
@@ -228,11 +232,14 @@ class interfaceController extends baseController {
if (params.req_headers) {
data.req_headers = params.req_headers;
}
-
+
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
- if(params.req_query){
+ if (params.req_params) {
+ data.req_params = params.req_params;
+ }
+ if (params.req_query) {
data.req_query = params.req_query;
}
if (params.req_body_other) {
diff --git a/server/controllers/project.js b/server/controllers/project.js
index 792f4c18..c9cc62a6 100644
--- a/server/controllers/project.js
+++ b/server/controllers/project.js
@@ -311,8 +311,7 @@ class projectController extends baseController {
_users[item._id] = item;
});
ctx.body = yapi.commons.resReturn({
- list: result,
- userinfo: _users
+ list: result
});
} catch (e) {
ctx.body = yapi.commons.resReturn(null, 402, e.message);
diff --git a/server/models/group.js b/server/models/group.js
index a28b30b7..1d200c2b 100644
--- a/server/models/group.js
+++ b/server/models/group.js
@@ -67,7 +67,7 @@ class groupModel extends baseModel {
_id: id,
"members.uid": uid
}, {
- "$set": { "members.$.uid": role}
+ "$set": { "members.$.role": role}
}
);
}
diff --git a/server/models/interface.js b/server/models/interface.js
index c34b2fce..669fe713 100644
--- a/server/models/interface.js
+++ b/server/models/interface.js
@@ -31,6 +31,10 @@ class interfaceModel extends baseModel {
default: "1"
}
}],
+ req_params:[{
+ name: String,
+ desc: String
+ }],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'file']
diff --git a/server/router.js b/server/router.js
index 1dfd5b2c..a08d6c9f 100644
--- a/server/router.js
+++ b/server/router.js
@@ -77,6 +77,11 @@ const routerConfig = {
"path": "add_member",
"method": "post"
},
+ {
+ "action": "changeMemberRole",
+ "path": "change_member_role",
+ "method": "post"
+ },
{
"action": "delMember",
"path": "del_member",
@@ -84,7 +89,7 @@ const routerConfig = {
},
{
"action": "getMemberList",
- "path": "members",
+ "path": "get_member_list",
"method": "get"
}
],
diff --git a/server_dist/controllers/group.js b/server_dist/controllers/group.js
index 8a31ebfb..613e9ecf 100644
--- a/server_dist/controllers/group.js
+++ b/server_dist/controllers/group.js
@@ -214,6 +214,7 @@ var groupController = function (_baseController) {
case 7:
return _context2.abrupt('return', {
+ _role: userData.role,
role: role,
uid: userData._id,
username: userData.username,
@@ -234,6 +235,19 @@ var groupController = function (_baseController) {
return getUserdata;
}()
+
+ /**
+ * 添加项目分组成员
+ * @interface /group/add_member
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @returns {Object}
+ * @example
+ */
+
}, {
key: 'addMember',
value: function () {
@@ -290,29 +304,38 @@ var groupController = function (_baseController) {
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '组长uid不存在'));
case 16:
- _context3.prev = 16;
- _context3.next = 19;
+ if (!(groupUserdata._role === 'admin')) {
+ _context3.next = 18;
+ break;
+ }
+
+ return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '不能邀请管理员'));
+
+ case 18:
+ delete groupUserdata._role;
+ _context3.prev = 19;
+ _context3.next = 22;
return groupInst.addMember(params.id, groupUserdata);
- case 19:
+ case 22:
result = _context3.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
- _context3.next = 26;
+ _context3.next = 29;
break;
- case 23:
- _context3.prev = 23;
- _context3.t0 = _context3['catch'](16);
+ case 26:
+ _context3.prev = 26;
+ _context3.t0 = _context3['catch'](19);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
- case 26:
+ case 29:
case 'end':
return _context3.stop();
}
}
- }, _callee3, this, [[16, 23]]);
+ }, _callee3, this, [[19, 26]]);
}));
function addMember(_x4) {
@@ -321,6 +344,20 @@ var groupController = function (_baseController) {
return addMember;
}()
+
+ /**
+ * 修改项目分组成员角色
+ * @interface /group/change_member_role
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @param {String} role 组长uid
+ * @returns {Object}
+ * @example
+ */
+
}, {
key: 'changeMemberRole',
value: function () {
@@ -364,7 +401,7 @@ var groupController = function (_baseController) {
case 11:
_context4.next = 13;
- return this.checkAuth(id, 'group', 'danger');
+ return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context4.t0 = _context4.sent;
@@ -411,6 +448,17 @@ var groupController = function (_baseController) {
return changeMemberRole;
}()
+ /**
+ * 获取所有项目成员
+ * @interface /group/get_member_list
+ * @method GET
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @returns {Object}
+ * @example
+ */
+
}, {
key: 'getMemberList',
value: function () {
@@ -462,6 +510,19 @@ var groupController = function (_baseController) {
return getMemberList;
}()
+
+ /**
+ * 删除项目成员
+ * @interface /group/del_member
+ * @method POST
+ * @category group
+ * @foldnumber 10
+ * @param {String} id 项目分组id
+ * @param {String} member_uid 项目分组成员uid
+ * @returns {Object}
+ * @example
+ */
+
}, {
key: 'delMember',
value: function () {
@@ -505,7 +566,7 @@ var groupController = function (_baseController) {
case 11:
_context6.next = 13;
- return this.checkAuth(id, 'group', 'danger');
+ return this.checkAuth(params.id, 'group', 'danger');
case 13:
_context6.t0 = _context6.sent;
diff --git a/server_dist/controllers/interface.js b/server_dist/controllers/interface.js
index 4f828b98..eb526711 100644
--- a/server_dist/controllers/interface.js
+++ b/server_dist/controllers/interface.js
@@ -70,6 +70,7 @@ var interfaceController = function (_baseController) {
* @param {Boolean} [req_headers[].required] 是否是必须,默认为否
* @param {String} [req_headers[].desc] header描述
* @param {String} [req_body_type] 请求参数方式,有["form", "json", "text", "xml"]四种
+ * @param {Array} [req_params] name, desc两个参数
* @param {Mixed} [req_body_form] 请求参数,如果请求方式是form,参数是Array数组,其他格式请求参数是字符串
* @param {String} [req_body_form[].name] 请求参数名
* @param {String} [req_body_form[].value] 请求参数值,可填写生成规则(mock)。如@email,随机生成一条email
@@ -168,32 +169,35 @@ var interfaceController = function (_baseController) {
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
+ if (params.req_params) {
+ data.req_params = params.req_params;
+ }
if (params.req_body_other) {
data.req_body_other = params.req_body_other;
}
- _context.next = 23;
+ _context.next = 24;
return this.Model.save(data);
- case 23:
+ case 24:
result = _context.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
- _context.next = 30;
+ _context.next = 31;
break;
- case 27:
- _context.prev = 27;
+ case 28:
+ _context.prev = 28;
_context.t0 = _context['catch'](16);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
- case 30:
+ case 31:
case 'end':
return _context.stop();
}
}
- }, _callee, this, [[16, 27]]);
+ }, _callee, this, [[16, 28]]);
}));
function add(_x) {
@@ -443,6 +447,9 @@ var interfaceController = function (_baseController) {
if (params.req_body_form) {
data.req_body_form = params.req_body_form;
}
+ if (params.req_params) {
+ data.req_params = params.req_params;
+ }
if (params.req_query) {
data.req_query = params.req_query;
}
@@ -457,29 +464,29 @@ var interfaceController = function (_baseController) {
data.res_body = params.res_body;
}
- _context4.prev = 29;
- _context4.next = 32;
+ _context4.prev = 30;
+ _context4.next = 33;
return this.Model.up(id, data);
- case 32:
+ case 33:
result = _context4.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
- _context4.next = 39;
+ _context4.next = 40;
break;
- case 36:
- _context4.prev = 36;
- _context4.t0 = _context4['catch'](29);
+ case 37:
+ _context4.prev = 37;
+ _context4.t0 = _context4['catch'](30);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
- case 39:
+ case 40:
case 'end':
return _context4.stop();
}
}
- }, _callee4, this, [[29, 36]]);
+ }, _callee4, this, [[30, 37]]);
}));
function up(_x4) {
diff --git a/server_dist/controllers/project.js b/server_dist/controllers/project.js
index 1306355d..66c8431b 100644
--- a/server_dist/controllers/project.js
+++ b/server_dist/controllers/project.js
@@ -733,8 +733,7 @@ var projectController = function (_baseController) {
_users[item._id] = item;
});
ctx.body = _yapi2.default.commons.resReturn({
- list: result,
- userinfo: _users
+ list: result
});
_context7.next = 23;
break;
diff --git a/server_dist/models/group.js b/server_dist/models/group.js
index 685e7d76..ba066487 100644
--- a/server_dist/models/group.js
+++ b/server_dist/models/group.js
@@ -105,7 +105,7 @@ var groupModel = function (_baseModel) {
_id: id,
"members.uid": uid
}, {
- "$set": { "members.$.uid": role }
+ "$set": { "members.$.role": role }
});
}
}, {
diff --git a/server_dist/models/interface.js b/server_dist/models/interface.js
index f79e30f1..5f756993 100644
--- a/server_dist/models/interface.js
+++ b/server_dist/models/interface.js
@@ -70,6 +70,10 @@ var interfaceModel = function (_baseModel) {
default: "1"
}
}],
+ req_params: [{
+ name: String,
+ desc: String
+ }],
req_body_type: {
type: String,
enum: ['form', 'json', 'text', 'file']
diff --git a/server_dist/router.js b/server_dist/router.js
index bc493ebf..181a9be5 100644
--- a/server_dist/router.js
+++ b/server_dist/router.js
@@ -108,13 +108,17 @@ var routerConfig = {
"action": "addMember",
"path": "add_member",
"method": "post"
+ }, {
+ "action": "changeMemberRole",
+ "path": "change_member_role",
+ "method": "post"
}, {
"action": "delMember",
"path": "del_member",
"method": "post"
}, {
"action": "getMemberList",
- "path": "members",
+ "path": "get_member_list",
"method": "get"
}],
"user": [{