mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-13 14:26:50 +08:00
fix: merge
This commit is contained in:
commit
935512fc4c
1
.gitignore
vendored
1
.gitignore
vendored
@ -39,3 +39,4 @@ prd/
|
||||
dev/
|
||||
.tags
|
||||
.tags1
|
||||
tsconfig.json
|
||||
|
@ -120,7 +120,7 @@ export default class InterfaceCaseContent extends Component {
|
||||
const { currCase, currProject } = this.props;
|
||||
const data = Object.assign({}, currCase, currProject, {_id: currCase._id});
|
||||
return (
|
||||
<div>
|
||||
<div style={{padding: '6px 0'}}>
|
||||
<h1 style={{marginLeft: 8}}>{currCase.casename}</h1>
|
||||
<div>
|
||||
<Postman data={data} type="case" saveTip="更新保存修改" save={this.updateCase} ref={this.savePostmanRef} />
|
||||
|
@ -293,7 +293,7 @@ class InterfaceMenu extends Component {
|
||||
return <div>
|
||||
<div className="interface-filter">
|
||||
<Input onChange={this.onFilter} value={this.state.filter} placeholder="Filter by name" style={{ width: "70%" }} />
|
||||
<Tag color="#108ee9" style={{ marginLeft: "15px" }} ><Icon type="plus" onClick={() => this.changeModal('add_cat_modal_visible', true)} /></Tag>
|
||||
<Tag color="#108ee9" onClick={() => this.changeModal('add_cat_modal_visible', true)} style={{ marginLeft: "15px" }} ><Icon type="plus" /></Tag>
|
||||
<Modal
|
||||
title="添加接口"
|
||||
visible={this.state.visible}
|
||||
|
@ -43,7 +43,6 @@ class interfaceController extends baseController {
|
||||
*/
|
||||
async add(ctx) {
|
||||
let params = ctx.request.body;
|
||||
|
||||
params = yapi.commons.handleParams(params, {
|
||||
project_id: 'number',
|
||||
title: 'string',
|
||||
@ -52,6 +51,11 @@ class interfaceController extends baseController {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
params.res_body_type = params.res_body_type ? params.res_body_type.toLowerCase() : 'json';
|
||||
@ -196,14 +200,14 @@ class interfaceController extends baseController {
|
||||
}
|
||||
try {
|
||||
let result = await this.catModel.list(project_id), newResult = [];
|
||||
for(let i=0, item, list;i< result.length; i++){
|
||||
for (let i = 0, item, list; i < result.length; i++) {
|
||||
item = result[i].toObject()
|
||||
list = await this.Model.listByCatid(item._id, '_id title method path')
|
||||
for(let j=0; j< list.length; j++){
|
||||
for (let j = 0; j < list.length; j++) {
|
||||
list[j] = list[j].toObject()
|
||||
}
|
||||
}
|
||||
item.list = list;
|
||||
newResult[i] = item
|
||||
newResult[i] = item
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(newResult);
|
||||
} catch (err) {
|
||||
@ -249,6 +253,7 @@ class interfaceController extends baseController {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
|
||||
@ -257,7 +262,12 @@ class interfaceController extends baseController {
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口id不能为空');
|
||||
}
|
||||
|
||||
let interfaceData = await this.Model.get(id);
|
||||
let auth = await this.checkAuth(interfaceData.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
if (params.path && !yapi.commons.verifyPath(params.path)) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/');
|
||||
@ -287,7 +297,7 @@ class interfaceController extends baseController {
|
||||
data.method = params.method;
|
||||
}
|
||||
|
||||
if(params.catid){
|
||||
if (params.catid) {
|
||||
data.catid = params.catid;
|
||||
}
|
||||
|
||||
@ -323,7 +333,7 @@ class interfaceController extends baseController {
|
||||
data.res_body = params.res_body;
|
||||
}
|
||||
|
||||
if(params.status){
|
||||
if (params.status) {
|
||||
data.status = params.status;
|
||||
}
|
||||
|
||||
@ -331,13 +341,13 @@ class interfaceController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
let username = this.getUsername();
|
||||
let cate;
|
||||
if(params.catid){
|
||||
if (params.catid) {
|
||||
cate = await this.catModel.get(+params.catid);
|
||||
}else{
|
||||
} else {
|
||||
let inter = await this.Model.get(id);
|
||||
cate = await this.catModel.get(inter.catid);
|
||||
cate = interfaceData.catid;
|
||||
}
|
||||
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
|
||||
type: 'project',
|
||||
@ -374,8 +384,9 @@ class interfaceController extends baseController {
|
||||
let data = await this.Model.get(ctx.request.body.id);
|
||||
|
||||
if (data.uid != this.getUid()) {
|
||||
if (await this.jungeProjectAuth(data.project_id) !== true) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
let auth = await this.checkAuth(data.project_id, 'project', 'danger')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
}
|
||||
|
||||
@ -438,10 +449,16 @@ class interfaceController extends baseController {
|
||||
if (!params.project_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
if (!params.name) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '名称不能为空');
|
||||
}
|
||||
|
||||
|
||||
let result = await this.catModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -474,10 +491,15 @@ class interfaceController extends baseController {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
up_time: yapi.commons.time()
|
||||
});
|
||||
});
|
||||
|
||||
let username = this.getUsername();
|
||||
let cate = await this.catModel.get(params.catid);
|
||||
|
||||
let auth = await this.checkAuth(cate.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}"`,
|
||||
type: 'project',
|
||||
@ -511,7 +533,7 @@ class interfaceController extends baseController {
|
||||
let result = await this.catModel.del(id);
|
||||
let r = await this.Model.delByCatid(id);
|
||||
let username = this.getUsername();
|
||||
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分类 "${cate.name}" 及该分类下的接口`,
|
||||
type: 'project',
|
||||
|
@ -21,7 +21,7 @@ class interfaceColController extends baseController{
|
||||
* @example
|
||||
*/
|
||||
async list(ctx){
|
||||
try {
|
||||
try {
|
||||
let id = ctx.query.project_id;
|
||||
let result = await this.colModel.list(id);
|
||||
|
||||
@ -64,6 +64,11 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '名称不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
let result = await this.colModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -133,9 +138,16 @@ class interfaceColController extends baseController{
|
||||
method: 'string'
|
||||
});
|
||||
|
||||
|
||||
if (!params.project_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(params.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
if (!params.col_id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '接口集id不能为空');
|
||||
}
|
||||
@ -192,11 +204,16 @@ class interfaceColController extends baseController{
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '用例id不能为空');
|
||||
}
|
||||
|
||||
|
||||
if(!params.casename){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '用例名称不能为空');
|
||||
}
|
||||
|
||||
let caseData = await this.caseModel.get(id);
|
||||
let auth = await this.checkAuth(caseData.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
params.uid = this.getUid();
|
||||
|
||||
let result = await this.caseModel.up(params.id, params);
|
||||
@ -244,6 +261,13 @@ class interfaceColController extends baseController{
|
||||
async upCol(ctx){
|
||||
try{
|
||||
let params = ctx.request.body;
|
||||
let id = params.col_id;
|
||||
let colData = await this.colModel.get(id);
|
||||
let auth = await this.checkAuth(colData.project_id, 'project', 'edit')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
|
||||
let result = await this.colModel.up(params.col_id, {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
|
@ -589,6 +589,11 @@ class projectController extends baseController {
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
|
||||
let auth = await this.checkAuth(id, 'project', 'danger')
|
||||
if (!auth) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '没有权限');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.up(id, data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
|
@ -72,7 +72,7 @@ app.use(compress({
|
||||
}));
|
||||
|
||||
app.use(function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
|
@ -59,7 +59,7 @@ var baseController = function () {
|
||||
(0, _createClass3.default)(baseController, [{
|
||||
key: 'init',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var ignoreRouter;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -103,7 +103,7 @@ var baseController = function () {
|
||||
}, {
|
||||
key: 'checkLogin',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var token, uid, userInst, result, decoded;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -170,7 +170,7 @@ var baseController = function () {
|
||||
}, {
|
||||
key: 'getLoginStatus',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var result;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -222,7 +222,7 @@ var baseController = function () {
|
||||
}, {
|
||||
key: 'getProjectRole',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(id, type) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(id, type) {
|
||||
var _this = this;
|
||||
|
||||
var result, interfaceInst, interfaceData, projectInst, projectData, memberData, groupInst, groupData, groupMemberData;
|
||||
@ -379,7 +379,7 @@ var baseController = function () {
|
||||
}, {
|
||||
key: 'checkAuth',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(id, type, action) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(id, type, action) {
|
||||
var role;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
|
@ -88,7 +88,7 @@ var groupController = function (_baseController) {
|
||||
(0, _createClass3.default)(groupController, [{
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, groupInst, result;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -160,7 +160,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, groupUserdata, groupInst, checkRepeat, data, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -272,7 +272,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getUserdata',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(uid, role) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
|
||||
var userInst, userData;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -333,7 +333,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, groupInst, check, groupUserdata, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -446,7 +446,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'changeMemberRole',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, groupInst, check, result;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -547,7 +547,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getMemberList',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, groupInst, group;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
@ -611,7 +611,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var params, groupInst, check, result;
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
@ -709,7 +709,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var groupInst, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
||||
while (1) {
|
||||
@ -762,7 +762,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _this2 = this;
|
||||
|
||||
var groupInst, projectInst, interfaceInst, interfaceColInst, interfaceCaseInst, _id, projectList, result;
|
||||
@ -802,7 +802,7 @@ var groupController = function (_baseController) {
|
||||
projectList = _context10.sent;
|
||||
|
||||
projectList.forEach(function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(p) {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -881,7 +881,7 @@ var groupController = function (_baseController) {
|
||||
}, {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var groupInst, _id2, data, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
|
@ -106,14 +106,13 @@ var interfaceController = function (_baseController) {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, username, cate;
|
||||
var params, auth, checkRepeat, data, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
params = ctx.request.body;
|
||||
|
||||
|
||||
params = _yapi2.default.commons.handleParams(params, {
|
||||
project_id: 'number',
|
||||
title: 'string',
|
||||
@ -122,49 +121,64 @@ var interfaceController = function (_baseController) {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
_context.next = 4;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 4:
|
||||
auth = _context.sent;
|
||||
|
||||
if (auth) {
|
||||
_context.next = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 7:
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
params.res_body_type = params.res_body_type ? params.res_body_type.toLowerCase() : 'json';
|
||||
|
||||
if (params.project_id) {
|
||||
_context.next = 7;
|
||||
_context.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 7:
|
||||
case 12:
|
||||
if (params.path) {
|
||||
_context.next = 9;
|
||||
_context.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口请求路径不能为空'));
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
if (_yapi2.default.commons.verifyPath(params.path)) {
|
||||
_context.next = 11;
|
||||
_context.next = 16;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 11:
|
||||
_context.next = 13;
|
||||
case 16:
|
||||
_context.next = 18;
|
||||
return this.Model.checkRepeat(params.project_id, params.path, params.method);
|
||||
|
||||
case 13:
|
||||
case 18:
|
||||
checkRepeat = _context.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context.next = 16;
|
||||
_context.next = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 16:
|
||||
_context.prev = 16;
|
||||
case 21:
|
||||
_context.prev = 21;
|
||||
data = {
|
||||
project_id: params.project_id,
|
||||
catid: params.catid,
|
||||
@ -199,18 +213,18 @@ var interfaceController = function (_baseController) {
|
||||
data.req_body_other = params.req_body_other;
|
||||
}
|
||||
|
||||
_context.next = 24;
|
||||
_context.next = 29;
|
||||
return this.Model.save(data);
|
||||
|
||||
case 24:
|
||||
case 29:
|
||||
result = _context.sent;
|
||||
username = this.getUsername();
|
||||
// let project = await this.projectModel.get(params.project_id);
|
||||
|
||||
_context.next = 28;
|
||||
_context.next = 33;
|
||||
return this.catModel.get(params.catid);
|
||||
|
||||
case 28:
|
||||
case 33:
|
||||
cate = _context.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
@ -221,21 +235,21 @@ var interfaceController = function (_baseController) {
|
||||
typeid: params.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 36;
|
||||
_context.next = 41;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
_context.prev = 33;
|
||||
_context.t0 = _context['catch'](16);
|
||||
case 38:
|
||||
_context.prev = 38;
|
||||
_context.t0 = _context['catch'](21);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 36:
|
||||
case 41:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[16, 33]]);
|
||||
}, _callee, this, [[21, 38]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -527,7 +541,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, id, interfaceData, checkRepeat, data, result, username, cate, inter;
|
||||
var params, id, interfaceData, auth, checkRepeat, data, result, username, cate, inter;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
@ -542,6 +556,7 @@ var interfaceController = function (_baseController) {
|
||||
desc: 'string',
|
||||
catid: 'number'
|
||||
});
|
||||
|
||||
params.method = params.method || 'GET';
|
||||
params.method = params.method.toUpperCase();
|
||||
|
||||
@ -560,34 +575,47 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 9:
|
||||
interfaceData = _context6.sent;
|
||||
_context6.next = 12;
|
||||
return this.checkAuth(interfaceData.project_id, 'project', 'edit');
|
||||
|
||||
case 12:
|
||||
auth = _context6.sent;
|
||||
|
||||
if (auth) {
|
||||
_context6.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 15:
|
||||
if (!(params.path && !_yapi2.default.commons.verifyPath(params.path))) {
|
||||
_context6.next = 12;
|
||||
_context6.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口path第一位必须是/,最后一位不能为/'));
|
||||
|
||||
case 12:
|
||||
case 17:
|
||||
if (!(params.path && params.path !== interfaceData.path && params.method !== interfaceData.method)) {
|
||||
_context6.next = 18;
|
||||
_context6.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
_context6.next = 15;
|
||||
_context6.next = 20;
|
||||
return this.Model.checkRepeat(interfaceData.project_id, params.path, params.method);
|
||||
|
||||
case 15:
|
||||
case 20:
|
||||
checkRepeat = _context6.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context6.next = 18;
|
||||
_context6.next = 23;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context6.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的接口:' + params.path + '[' + params.method + ']'));
|
||||
|
||||
case 18:
|
||||
case 23:
|
||||
data = {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
@ -646,41 +674,38 @@ var interfaceController = function (_baseController) {
|
||||
data.status = params.status;
|
||||
}
|
||||
|
||||
_context6.prev = 33;
|
||||
_context6.next = 36;
|
||||
_context6.prev = 38;
|
||||
_context6.next = 41;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 36:
|
||||
case 41:
|
||||
result = _context6.sent;
|
||||
username = this.getUsername();
|
||||
cate = void 0;
|
||||
|
||||
if (!params.catid) {
|
||||
_context6.next = 45;
|
||||
_context6.next = 50;
|
||||
break;
|
||||
}
|
||||
|
||||
_context6.next = 42;
|
||||
_context6.next = 47;
|
||||
return this.catModel.get(+params.catid);
|
||||
|
||||
case 42:
|
||||
case 47:
|
||||
cate = _context6.sent;
|
||||
_context6.next = 51;
|
||||
_context6.next = 54;
|
||||
break;
|
||||
|
||||
case 45:
|
||||
_context6.next = 47;
|
||||
case 50:
|
||||
_context6.next = 52;
|
||||
return this.Model.get(id);
|
||||
|
||||
case 47:
|
||||
case 52:
|
||||
inter = _context6.sent;
|
||||
_context6.next = 50;
|
||||
return this.catModel.get(inter.catid);
|
||||
|
||||
case 50:
|
||||
cate = _context6.sent;
|
||||
cate = interfaceData.catid;
|
||||
|
||||
case 51:
|
||||
case 54:
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
|
||||
@ -690,21 +715,21 @@ var interfaceController = function (_baseController) {
|
||||
typeid: cate.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 58;
|
||||
_context6.next = 61;
|
||||
break;
|
||||
|
||||
case 55:
|
||||
_context6.prev = 55;
|
||||
_context6.t0 = _context6['catch'](33);
|
||||
case 58:
|
||||
_context6.prev = 58;
|
||||
_context6.t0 = _context6['catch'](38);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
||||
|
||||
case 58:
|
||||
case 61:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[33, 55]]);
|
||||
}, _callee6, this, [[38, 58]]);
|
||||
}));
|
||||
|
||||
function up(_x6) {
|
||||
@ -729,7 +754,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var id, data, inter, result, username, cate;
|
||||
var id, data, auth, inter, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
switch (_context7.prev = _context7.next) {
|
||||
@ -757,17 +782,17 @@ var interfaceController = function (_baseController) {
|
||||
}
|
||||
|
||||
_context7.next = 10;
|
||||
return this.jungeProjectAuth(data.project_id);
|
||||
return this.checkAuth(data.project_id, 'project', 'danger');
|
||||
|
||||
case 10:
|
||||
_context7.t0 = _context7.sent;
|
||||
auth = _context7.sent;
|
||||
|
||||
if (!(_context7.t0 !== true)) {
|
||||
if (auth) {
|
||||
_context7.next = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 13:
|
||||
_context7.next = 15;
|
||||
@ -801,9 +826,9 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 27:
|
||||
_context7.prev = 27;
|
||||
_context7.t1 = _context7['catch'](0);
|
||||
_context7.t0 = _context7['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t1.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t0.message);
|
||||
|
||||
case 30:
|
||||
case 'end':
|
||||
@ -906,7 +931,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'addCat',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, result, username;
|
||||
var params, auth, result, username;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -928,15 +953,29 @@ var interfaceController = function (_baseController) {
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 5:
|
||||
_context9.next = 7;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 7:
|
||||
auth = _context9.sent;
|
||||
|
||||
if (auth) {
|
||||
_context9.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 10:
|
||||
if (params.name) {
|
||||
_context9.next = 7;
|
||||
_context9.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '名称不能为空'));
|
||||
|
||||
case 7:
|
||||
_context9.next = 9;
|
||||
case 12:
|
||||
_context9.next = 14;
|
||||
return this.catModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -946,7 +985,7 @@ var interfaceController = function (_baseController) {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context9.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
@ -960,21 +999,21 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context9.next = 18;
|
||||
_context9.next = 23;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
_context9.prev = 15;
|
||||
case 20:
|
||||
_context9.prev = 20;
|
||||
_context9.t0 = _context9['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t0.message);
|
||||
|
||||
case 18:
|
||||
case 23:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[0, 15]]);
|
||||
}, _callee9, this, [[0, 20]]);
|
||||
}));
|
||||
|
||||
function addCat(_x9) {
|
||||
@ -987,7 +1026,7 @@ var interfaceController = function (_baseController) {
|
||||
key: 'upCat',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, result, username, cate;
|
||||
var params, result, username, cate, auth;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
switch (_context10.prev = _context10.next) {
|
||||
@ -1009,7 +1048,20 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 8:
|
||||
cate = _context10.sent;
|
||||
_context10.next = 11;
|
||||
return this.checkAuth(cate.project_id, 'project', 'edit');
|
||||
|
||||
case 11:
|
||||
auth = _context10.sent;
|
||||
|
||||
if (auth) {
|
||||
_context10.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 14:
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '"',
|
||||
type: 'project',
|
||||
@ -1019,21 +1071,21 @@ var interfaceController = function (_baseController) {
|
||||
});
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 16;
|
||||
_context10.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context10.prev = 13;
|
||||
case 18:
|
||||
_context10.prev = 18;
|
||||
_context10.t0 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context10.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 13]]);
|
||||
}, _callee10, this, [[0, 18]]);
|
||||
}));
|
||||
|
||||
function upCat(_x10) {
|
||||
|
@ -75,15 +75,16 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var id, result, i;
|
||||
var _id, result, i;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_context.prev = 0;
|
||||
id = ctx.query.project_id;
|
||||
_id = ctx.query.project_id;
|
||||
_context.next = 4;
|
||||
return this.colModel.list(id);
|
||||
return this.colModel.list(_id);
|
||||
|
||||
case 4:
|
||||
result = _context.sent;
|
||||
@ -150,7 +151,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'addCol',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, result;
|
||||
var params, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -181,6 +182,20 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 7:
|
||||
_context2.next = 9;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 9:
|
||||
auth = _context2.sent;
|
||||
|
||||
if (auth) {
|
||||
_context2.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context2.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 12:
|
||||
_context2.next = 14;
|
||||
return this.colModel.save({
|
||||
name: params.name,
|
||||
project_id: params.project_id,
|
||||
@ -190,26 +205,26 @@ var interfaceColController = function (_baseController) {
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context2.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context2.next = 16;
|
||||
_context2.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context2.prev = 13;
|
||||
case 18:
|
||||
_context2.prev = 18;
|
||||
_context2.t0 = _context2['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[0, 13]]);
|
||||
}, _callee2, this, [[0, 18]]);
|
||||
}));
|
||||
|
||||
function addCol(_x2) {
|
||||
@ -234,16 +249,17 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'getCaseList',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var id, inst, result;
|
||||
var _id2, inst, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
_context3.prev = 0;
|
||||
id = ctx.query.col_id;
|
||||
_id2 = ctx.query.col_id;
|
||||
inst = _yapi2.default.getInst(_interfaceCase2.default);
|
||||
_context3.next = 5;
|
||||
return inst.list(id, 'all');
|
||||
return inst.list(_id2, 'all');
|
||||
|
||||
case 5:
|
||||
result = _context3.sent;
|
||||
@ -298,7 +314,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'addCase',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, result;
|
||||
var params, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
switch (_context4.prev = _context4.next) {
|
||||
@ -322,51 +338,65 @@ var interfaceColController = function (_baseController) {
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目id不能为空'));
|
||||
|
||||
case 5:
|
||||
_context4.next = 7;
|
||||
return this.checkAuth(params.project_id, 'project', 'edit');
|
||||
|
||||
case 7:
|
||||
auth = _context4.sent;
|
||||
|
||||
if (auth) {
|
||||
_context4.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 10:
|
||||
if (params.col_id) {
|
||||
_context4.next = 7;
|
||||
_context4.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '接口集id不能为空'));
|
||||
|
||||
case 7:
|
||||
case 12:
|
||||
if (params.casename) {
|
||||
_context4.next = 9;
|
||||
_context4.next = 14;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
|
||||
params.uid = this.getUid();
|
||||
params.index = 0;
|
||||
params.add_time = _yapi2.default.commons.time();
|
||||
params.up_time = _yapi2.default.commons.time();
|
||||
_context4.next = 15;
|
||||
_context4.next = 20;
|
||||
return this.caseModel.save(params);
|
||||
|
||||
case 15:
|
||||
case 20:
|
||||
result = _context4.sent;
|
||||
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context4.next = 22;
|
||||
_context4.next = 27;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
_context4.prev = 19;
|
||||
case 24:
|
||||
_context4.prev = 24;
|
||||
_context4.t0 = _context4['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
||||
|
||||
case 22:
|
||||
case 27:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[0, 19]]);
|
||||
}, _callee4, this, [[0, 24]]);
|
||||
}));
|
||||
|
||||
function addCase(_x4) {
|
||||
@ -400,7 +430,7 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'upCase',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, result;
|
||||
var params, caseData, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
switch (_context5.prev = _context5.next) {
|
||||
@ -431,33 +461,52 @@ var interfaceColController = function (_baseController) {
|
||||
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '用例名称不能为空'));
|
||||
|
||||
case 7:
|
||||
_context5.next = 9;
|
||||
return this.caseModel.get(id);
|
||||
|
||||
case 9:
|
||||
caseData = _context5.sent;
|
||||
_context5.next = 12;
|
||||
return this.checkAuth(caseData.project_id, 'project', 'edit');
|
||||
|
||||
case 12:
|
||||
auth = _context5.sent;
|
||||
|
||||
if (auth) {
|
||||
_context5.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context5.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 15:
|
||||
|
||||
params.uid = this.getUid();
|
||||
|
||||
_context5.next = 10;
|
||||
_context5.next = 18;
|
||||
return this.caseModel.up(params.id, params);
|
||||
|
||||
case 10:
|
||||
case 18:
|
||||
result = _context5.sent;
|
||||
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context5.next = 17;
|
||||
_context5.next = 25;
|
||||
break;
|
||||
|
||||
case 14:
|
||||
_context5.prev = 14;
|
||||
case 22:
|
||||
_context5.prev = 22;
|
||||
_context5.t0 = _context5['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context5.t0.message);
|
||||
|
||||
case 17:
|
||||
case 25:
|
||||
case 'end':
|
||||
return _context5.stop();
|
||||
}
|
||||
}
|
||||
}, _callee5, this, [[0, 14]]);
|
||||
}, _callee5, this, [[0, 22]]);
|
||||
}));
|
||||
|
||||
function upCase(_x5) {
|
||||
@ -482,15 +531,16 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'getCase',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var id, result;
|
||||
var _id3, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
case 0:
|
||||
_context6.prev = 0;
|
||||
id = ctx.query.caseid;
|
||||
_id3 = ctx.query.caseid;
|
||||
_context6.next = 4;
|
||||
return this.caseModel.get(id);
|
||||
return this.caseModel.get(_id3);
|
||||
|
||||
case 4:
|
||||
result = _context6.sent;
|
||||
@ -536,39 +586,60 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'upCol',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var params, result;
|
||||
var params, _id4, colData, auth, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
switch (_context7.prev = _context7.next) {
|
||||
case 0:
|
||||
_context7.prev = 0;
|
||||
params = ctx.request.body;
|
||||
_context7.next = 4;
|
||||
_id4 = params.col_id;
|
||||
_context7.next = 5;
|
||||
return this.colModel.get(_id4);
|
||||
|
||||
case 5:
|
||||
colData = _context7.sent;
|
||||
_context7.next = 8;
|
||||
return this.checkAuth(colData.project_id, 'project', 'edit');
|
||||
|
||||
case 8:
|
||||
auth = _context7.sent;
|
||||
|
||||
if (auth) {
|
||||
_context7.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context7.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 11:
|
||||
_context7.next = 13;
|
||||
return this.colModel.up(params.col_id, {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 4:
|
||||
case 13:
|
||||
result = _context7.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context7.next = 11;
|
||||
_context7.next = 20;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_context7.prev = 8;
|
||||
case 17:
|
||||
_context7.prev = 17;
|
||||
_context7.t0 = _context7['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context7.t0.message);
|
||||
|
||||
case 11:
|
||||
case 20:
|
||||
case 'end':
|
||||
return _context7.stop();
|
||||
}
|
||||
}
|
||||
}, _callee7, this, [[0, 8]]);
|
||||
}, _callee7, this, [[0, 17]]);
|
||||
}));
|
||||
|
||||
function upCol(_x7) {
|
||||
@ -652,15 +723,16 @@ var interfaceColController = function (_baseController) {
|
||||
key: 'delCol',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var id, colData, auth, result;
|
||||
var _id5, colData, auth, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
case 0:
|
||||
_context9.prev = 0;
|
||||
id = ctx.query.col_id;
|
||||
_id5 = ctx.query.col_id;
|
||||
_context9.next = 4;
|
||||
return this.colModel.get(id);
|
||||
return this.colModel.get(_id5);
|
||||
|
||||
case 4:
|
||||
colData = _context9.sent;
|
||||
@ -689,12 +761,12 @@ var interfaceColController = function (_baseController) {
|
||||
|
||||
case 12:
|
||||
_context9.next = 14;
|
||||
return this.colModel.del(id);
|
||||
return this.colModel.del(_id5);
|
||||
|
||||
case 14:
|
||||
result = _context9.sent;
|
||||
_context9.next = 17;
|
||||
return this.caseModel.delByCol(id);
|
||||
return this.caseModel.delByCol(_id5);
|
||||
|
||||
case 17:
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(result));
|
||||
|
@ -75,7 +75,7 @@ var logController = function (_baseController) {
|
||||
(0, _createClass3.default)(logController, [{
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var typeid, page, limit, type, result, count;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
@ -1295,7 +1295,7 @@ var projectController = function (_baseController) {
|
||||
key: 'upSet',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var id, data, result;
|
||||
var id, data, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
while (1) {
|
||||
switch (_context12.prev = _context12.next) {
|
||||
@ -1314,36 +1314,50 @@ var projectController = function (_baseController) {
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 6:
|
||||
_context12.prev = 6;
|
||||
_context12.next = 9;
|
||||
_context12.next = 8;
|
||||
return this.checkAuth(id, 'project', 'danger');
|
||||
|
||||
case 8:
|
||||
auth = _context12.sent;
|
||||
|
||||
if (auth) {
|
||||
_context12.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '没有权限'));
|
||||
|
||||
case 11:
|
||||
_context12.prev = 11;
|
||||
_context12.next = 14;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 9:
|
||||
case 14:
|
||||
result = _context12.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context12.next = 16;
|
||||
_context12.next = 21;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context12.prev = 13;
|
||||
_context12.t0 = _context12['catch'](6);
|
||||
case 18:
|
||||
_context12.prev = 18;
|
||||
_context12.t0 = _context12['catch'](11);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context12.t0.message);
|
||||
|
||||
case 16:
|
||||
case 21:
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then();
|
||||
} catch (e) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
|
||||
case 17:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context12.stop();
|
||||
}
|
||||
}
|
||||
}, _callee12, this, [[6, 13]]);
|
||||
}, _callee12, this, [[11, 18]]);
|
||||
}));
|
||||
|
||||
function upSet(_x13) {
|
||||
|
@ -47,7 +47,7 @@ function matchApi(apiPath, apiRule) {
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var hostname, config, path, paths, projectId, projectInst, project, interfaceData, newData, newpath, interfaceInst, _newData, findInterface, res;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
|
@ -26,7 +26,7 @@ function websocket(app) {
|
||||
return next(ctx);
|
||||
});
|
||||
router.get('/api/interface/solve_conflict', function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var inst;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user