mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-07 14:16:52 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
43f7cc87a4
@ -21,22 +21,11 @@ const Panel = Collapse.Panel;
|
||||
const RadioButton = Radio.Button;
|
||||
const RadioGroup = Radio.Group;
|
||||
|
||||
// @connect(
|
||||
// state => ({
|
||||
// currInterface: state.inter.curdata,
|
||||
// currProject: state.project.currProject
|
||||
// })
|
||||
// )
|
||||
// @withRouter
|
||||
export default class Run extends Component {
|
||||
|
||||
static propTypes = {
|
||||
data: PropTypes.object
|
||||
// match: PropTypes.object,
|
||||
// currProject: PropTypes.object,
|
||||
// currInterface: PropTypes.object,
|
||||
// reqBody: PropTypes.string,
|
||||
// interfaceName: PropTypes.string
|
||||
data: PropTypes.object,
|
||||
save:PropTypes.func
|
||||
}
|
||||
|
||||
state = {
|
||||
@ -50,7 +39,6 @@ export default class Run extends Component {
|
||||
currDomain: '',
|
||||
bodyType: '',
|
||||
bodyOther: ''
|
||||
// addColModalVisible: false
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -78,18 +66,12 @@ export default class Run extends Component {
|
||||
req_params = [],
|
||||
req_body_other = '',
|
||||
req_body_form = [],
|
||||
prd_host = '',
|
||||
basepath = '',
|
||||
protocol = '',
|
||||
env = []
|
||||
env = [],
|
||||
domain = ''
|
||||
} = data;
|
||||
const pathname = (basepath + url).replace(/\/+/g, '/');
|
||||
|
||||
const domains = {prd: protocol + '://' + prd_host};
|
||||
env.forEach(item => {
|
||||
domains[item.name] = item.domain;
|
||||
})
|
||||
|
||||
let hasContentType = false;
|
||||
req_headers.forEach(headerItem => {
|
||||
// TODO 'Content-Type' 排除大小写不同格式影响
|
||||
@ -101,6 +83,10 @@ export default class Run extends Component {
|
||||
if (!hasContentType) {
|
||||
req_headers.push({name: 'Content-Type', value: 'application/x-www-form-urlencoded'});
|
||||
}
|
||||
const domains = env.concat();
|
||||
if (domain && !env.find(item => item.domain === domain)) {
|
||||
domains.push([{name: 'default', domain}])
|
||||
}
|
||||
|
||||
this.setState({
|
||||
method,
|
||||
@ -111,7 +97,7 @@ export default class Run extends Component {
|
||||
bodyForm: req_body_form.concat(),
|
||||
headers: req_headers.concat(),
|
||||
bodyOther: req_body_other,
|
||||
currDomain: domains.prd,
|
||||
currDomain: domain || env[0].domain,
|
||||
bodyType: req_body_type || 'form',
|
||||
loading: false
|
||||
});
|
||||
@ -359,42 +345,6 @@ export default class Run extends Component {
|
||||
console.log(index)
|
||||
}
|
||||
|
||||
// saveToCol = async (colId, caseName) => {
|
||||
// const project_id = this.props.match.params.id;
|
||||
// const {
|
||||
// currDomain: domain,
|
||||
// pathname: path,
|
||||
// method,
|
||||
// pathParam: req_params,
|
||||
// query: req_query,
|
||||
// headers: req_headers,
|
||||
// bodyType: req_body_type,
|
||||
// bodyForm: req_body_form,
|
||||
// bodyOther: req_body_other
|
||||
// } = this.state;
|
||||
// const res = await axios.post('/api/col/add_case', {
|
||||
// casename: caseName,
|
||||
// col_id: colId,
|
||||
// project_id,
|
||||
// env: '',
|
||||
// domain,
|
||||
// path,
|
||||
// method,
|
||||
// req_params,
|
||||
// req_query,
|
||||
// req_headers,
|
||||
// req_body_type,
|
||||
// req_body_form,
|
||||
// req_body_other
|
||||
// });
|
||||
// if (res.data.errcode) {
|
||||
// message.error(res.data.errmsg)
|
||||
// } else {
|
||||
// message.success('添加成功')
|
||||
// this.setState({addColModalVisible: false})
|
||||
// }
|
||||
// }
|
||||
|
||||
render () {
|
||||
|
||||
const { method, domains, pathParam, pathname, query, headers, bodyForm, bodyOther, currDomain, bodyType } = this.state;
|
||||
@ -434,7 +384,7 @@ export default class Run extends Component {
|
||||
</Select>
|
||||
<Select value={currDomain} mode="combobox" filterOption={() => true} style={{flexBasis: 180, flexGrow: 1}} onChange={this.changeDomain} onSelect={this.selectDomain}>
|
||||
{
|
||||
Object.keys(domains).map((key, index) => (<Option value={domains[key]} key={index}>{key + ':' + domains[key]}</Option>))
|
||||
domains.map((item, index) => (<Option value={item.domain} key={index}>{item.name + ':' + item.domain}</Option>))
|
||||
}
|
||||
</Select>
|
||||
<Input value={path + search} onChange={this.changePath} spellCheck="false" style={{flexBasis: 180, flexGrow: 1}} />
|
||||
@ -449,7 +399,7 @@ export default class Run extends Component {
|
||||
</Tooltip>
|
||||
<Tooltip placement="bottom" title="保存到集合">
|
||||
<Button
|
||||
onClick={() => this.setState({addColModalVisible: true})}
|
||||
onClick={this.props.save}
|
||||
type="primary"
|
||||
style={{marginLeft: 10}}
|
||||
>保存</Button>
|
||||
@ -585,11 +535,6 @@ export default class Run extends Component {
|
||||
</div>
|
||||
</Spin>
|
||||
</Card>
|
||||
{/*<AddColModal
|
||||
visible={this.state.addColModalVisible}
|
||||
onCancel={() => this.setState({addColModalVisible: false})}
|
||||
onOk={this.saveToCol}
|
||||
></AddColModal>*/}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -48,14 +48,61 @@
|
||||
.logbidden{
|
||||
color: #c0c1c1;
|
||||
cursor: default;
|
||||
line-height: 30px;
|
||||
padding-left: 30px;
|
||||
padding: 8px !important;
|
||||
}
|
||||
.loggetMore{
|
||||
line-height: 30px;
|
||||
padding-left: 30px;
|
||||
color: #4eaef3;
|
||||
}
|
||||
|
||||
.ant-timeline-item{
|
||||
&:after{
|
||||
content: "";
|
||||
width: 0px;
|
||||
height: 0px;
|
||||
display: block;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.ant-timeline-item-content{
|
||||
background-color: #ececec;
|
||||
float: left;
|
||||
width: auto;
|
||||
margin-left: 40px;
|
||||
padding: 0px;
|
||||
padding-bottom: 16px;
|
||||
min-width: 300px;
|
||||
border-radius: 8px;
|
||||
|
||||
.logMesHeade{
|
||||
color: white;
|
||||
padding: 16px 8px 8px 8px;
|
||||
background-color: gray;
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
}
|
||||
.logoTimeago{
|
||||
left: -120px;
|
||||
}
|
||||
.logcontent{
|
||||
text-indent: 2em;
|
||||
line-height: 1.5em;
|
||||
margin-top: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.ant-timeline-item-pending{
|
||||
padding: 0px;
|
||||
.ant-timeline-item-content{
|
||||
padding: 0px;
|
||||
min-width: auto;
|
||||
.loggetMore{
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.logHead{
|
||||
height: 80px;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Timeline, Spin, Avatar } from 'antd'
|
||||
import { Timeline, Spin, Avatar,Icon } from 'antd'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { formatTime } from '../../../../common.js';
|
||||
@ -57,7 +57,6 @@ function timeago(timestamp) {
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
console.log(state);
|
||||
return {
|
||||
newsData: state.news.newsData,
|
||||
curpage: state.news.curpage,
|
||||
@ -112,14 +111,24 @@ class TimeTree extends Component {
|
||||
|
||||
render() {
|
||||
let data = this.props.newsData ? this.props.newsData.list : [];
|
||||
let logType = {
|
||||
project: "项目",
|
||||
group: "分组",
|
||||
interface: "接口",
|
||||
interface_col: "接口集",
|
||||
user: "用户",
|
||||
other: "其他"
|
||||
};
|
||||
if (data && data.length) {
|
||||
|
||||
data = data.map(function (item, i) {
|
||||
return (<Timeline.Item dot={<Avatar src={`/api/user/avatar?uid=${item.uid}`} />} key={i}>
|
||||
<span className="logoTimeago">{timeago(item.add_time)}</span>
|
||||
<span className="logusername"><Link to={`/user/profile/${item.uid}`}>{item.username}</Link></span>
|
||||
<span className="logtype">{item.type}</span>
|
||||
<span className="logtime">{formatTime(item.add_time)}</span>
|
||||
<div className="logMesHeade">
|
||||
<span className="logoTimeago">{timeago(item.add_time)}</span>
|
||||
<span className="logusername"><Link to={`/user/profile/${item.uid}`}><Icon type="user" />{item.username}</Link></span>
|
||||
<span className="logtype">{logType[item.type]}动态</span>
|
||||
<span className="logtime">{formatTime(item.add_time)}</span>
|
||||
</div>
|
||||
<span className="logcontent">{item.content}</span>
|
||||
</Timeline.Item>);
|
||||
});
|
||||
|
@ -78,8 +78,8 @@ export default class InterfaceCaseContent extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { currCase } = this.props;
|
||||
const data = currCase;
|
||||
const { currCase, currProject } = this.props;
|
||||
const data = Object.assign({}, currCase, currProject);
|
||||
return (
|
||||
<div>
|
||||
<h1 style={{marginLeft: 8}}>{currCase.casename}</h1>
|
||||
|
@ -75,7 +75,7 @@ export default class AddColModal extends Component {
|
||||
onOk={() => this.props.onOk(id, this.state.caseName)}
|
||||
onCancel={this.props.onCancel}
|
||||
>
|
||||
<Row gutter={6}>
|
||||
<Row gutter={6} className="modal-input">
|
||||
<Col span="5"><div className="label">接口用例名:</div></Col>
|
||||
<Col span="15">
|
||||
<Input
|
||||
|
@ -5,6 +5,7 @@ import { withRouter } from 'react-router';
|
||||
import axios from 'axios';
|
||||
import { message } from 'antd';
|
||||
import { Postman } from '../../../../../components'
|
||||
import AddColModal from './AddColModal'
|
||||
|
||||
// import {
|
||||
// } from '../../../reducer/modules/group.js'
|
||||
@ -40,8 +41,11 @@ export default class Run extends Component {
|
||||
componentWillReceiveProps() {
|
||||
}
|
||||
|
||||
savePostmanRef = (postman) => {
|
||||
this.postman = postman;
|
||||
}
|
||||
|
||||
saveToCol = async (colId, caseName) => {
|
||||
saveCase = async (colId, caseName) => {
|
||||
const project_id = this.props.match.params.id;
|
||||
const {
|
||||
currDomain: domain,
|
||||
@ -53,12 +57,11 @@ export default class Run extends Component {
|
||||
bodyType: req_body_type,
|
||||
bodyForm: req_body_form,
|
||||
bodyOther: req_body_other
|
||||
} = this.state;
|
||||
} = this.postman.state;
|
||||
const res = await axios.post('/api/col/add_case', {
|
||||
casename: caseName,
|
||||
col_id: colId,
|
||||
project_id,
|
||||
env: '',
|
||||
domain,
|
||||
path,
|
||||
method,
|
||||
@ -73,7 +76,7 @@ export default class Run extends Component {
|
||||
message.error(res.data.errmsg)
|
||||
} else {
|
||||
message.success('添加成功')
|
||||
this.setState({addColModalVisible: false})
|
||||
this.setState({saveCaseModalVisible: false})
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,7 +86,12 @@ export default class Run extends Component {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Postman data={data} />
|
||||
<Postman data={data} save={() => this.setState({saveCaseModalVisible: true})} ref={this.savePostmanRef} />
|
||||
<AddColModal
|
||||
visible={this.state.saveCaseModalVisible}
|
||||
onCancel={() => this.setState({saveCaseModalVisible: false})}
|
||||
onOk={this.saveCase}
|
||||
></AddColModal>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ class View extends Component {
|
||||
if(req_body_type === 'json'){
|
||||
return <div style={{display:this.props.curData.req_body_other?"block":"none"}} className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div id="vreq_body_json" style={{ minHeight: "300px" }}></div>
|
||||
<div id="vreq_body_json" style={{ minHeight: "200px" }}></div>
|
||||
</div>
|
||||
|
||||
}else if(req_body_type === 'form'){
|
||||
@ -89,7 +89,7 @@ class View extends Component {
|
||||
if(res_body_type === 'json'){
|
||||
return <div style={{display:this.props.curData.res_body?"":"none"}} className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div id="vres_body_json" style={{ minHeight: "300px" }}></div>
|
||||
<div id="vres_body_json" style={{ minHeight: "200px" }}></div>
|
||||
</div>
|
||||
}else if(res_body_type === 'raw'){
|
||||
return <div style={{display:this.props.curData.res_body?"":"none"}} className="colBody">
|
||||
@ -238,7 +238,7 @@ class View extends Component {
|
||||
</div>
|
||||
<div className="colMockUrl">
|
||||
<span className="colKey">Mock地址:</span>
|
||||
<span className="colValue">{location.protocol + '//' + location.hostname + (location.port !== "" ? ":" + location.port : "") + `/mock/${this.props.currProject._id}${this.props.currProject.basepath}/yourPath`}</span>
|
||||
<span className="colValue">{location.protocol + '//' + location.hostname + (location.port !== "" ? ":" + location.port : "") + `/mock/${this.props.currProject._id}${this.props.currProject.basepath}/${this.props.curData.path}`}</span>
|
||||
</div>
|
||||
{this.props.curData.desc?<div className="colDesc">
|
||||
<span className="colKey">接口描述:</span>
|
||||
|
@ -35,6 +35,10 @@
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
}
|
||||
.colDesc{
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
.ant-table-thead {
|
||||
th{
|
||||
color: #6d6c6c;
|
||||
@ -75,6 +79,7 @@
|
||||
.colMockUrl{
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: 0px;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
.colDesc{
|
||||
line-height: 1.5em;
|
||||
|
@ -3,12 +3,14 @@ import interfaceCatModel from '../models/interfaceCat.js';
|
||||
import baseController from './base.js';
|
||||
import yapi from '../yapi.js';
|
||||
import userModel from '../models/user.js';
|
||||
import projectModel from '../models/project.js';
|
||||
|
||||
class interfaceController extends baseController {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(interfaceModel);
|
||||
this.catModel = yapi.getInst(interfaceCatModel)
|
||||
this.catModel = yapi.getInst(interfaceCatModel);
|
||||
this.projectModel = yapi.getInst(projectModel);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -107,6 +109,16 @@ class interfaceController extends baseController {
|
||||
}
|
||||
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
// let project = await this.projectModel.get(params.project_id);
|
||||
let cate = await this.catModel.get(params.catid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 为分类 "${cate.name}" 添加了接口 "${data.title}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.project_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -317,6 +329,22 @@ class interfaceController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.up(id, data);
|
||||
let username = this.getUsername();
|
||||
let cate;
|
||||
if(params.catid){
|
||||
cate = await this.catModel.get(+params.catid);
|
||||
}else{
|
||||
let inter = await this.Model.get(id);
|
||||
cate = await this.catModel.get(inter.catid);
|
||||
}
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}" 下的接口 "${data.title}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -351,8 +379,19 @@ class interfaceController extends baseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
let inter = await this.Model.get(id);
|
||||
let result = await this.Model.del(id);
|
||||
|
||||
let username = this.getUsername();
|
||||
let cate = await this.catModel.get(inter.catid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分类 "${cate.name}" 下的接口 "${inter.title}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (err) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
@ -411,6 +450,16 @@ class interfaceController extends baseController {
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
})
|
||||
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 添加了分类 "${params.name}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.project_id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
|
||||
} catch (e) {
|
||||
@ -425,7 +474,18 @@ 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);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 更新了分类 "${cate.name}"`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result)
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 400, e.message)
|
||||
@ -447,8 +507,19 @@ class interfaceController extends baseController {
|
||||
}
|
||||
}
|
||||
|
||||
let cate = await this.catModel.get(id);
|
||||
let result = await this.catModel.del(id);
|
||||
let r = await this.Model.delByCatid(id)
|
||||
let r = await this.Model.delByCatid(id);
|
||||
let username = this.getUsername();
|
||||
|
||||
yapi.commons.saveLog({
|
||||
content: `用户 "${username}" 删除了分类 "${cate.name}" 及该分类下的接口`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
return ctx.body = yapi.commons.resReturn(r);
|
||||
|
||||
|
||||
|
@ -110,7 +110,6 @@ class interfaceColController extends baseController{
|
||||
* @param {String} casename
|
||||
* @param {Number} col_id
|
||||
* @param {Number} project_id
|
||||
* @param {String} env
|
||||
* @param {String} domain
|
||||
* @param {String} path
|
||||
* @param {String} method
|
||||
@ -130,7 +129,6 @@ class interfaceColController extends baseController{
|
||||
casename: 'string',
|
||||
project_id: 'number',
|
||||
col_id: 'number',
|
||||
env: 'string',
|
||||
domain: 'string',
|
||||
method: 'string'
|
||||
});
|
||||
|
@ -106,11 +106,32 @@ class projectController extends baseController {
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
up_time: yapi.commons.time(),
|
||||
env: [{ name: 'local', domain: 'http://127.0.0.1' }]
|
||||
};
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let colInst = yapi.getInst(interfaceColModel);
|
||||
let catInst = yapi.getInst(interfaceCatModel);
|
||||
if (result._id) {
|
||||
await colInst.save({
|
||||
name: '公共测试集',
|
||||
project_id: result._id,
|
||||
desc: '公共测试集',
|
||||
uid: this.getUid(),
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
})
|
||||
await catInst.save({
|
||||
name: '公共分类',
|
||||
project_id: result._id,
|
||||
desc: '公共分类',
|
||||
uid: this.getUid(),
|
||||
add_time: yapi.commons.time(),
|
||||
up_time: yapi.commons.time()
|
||||
})
|
||||
}
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
@ -160,7 +181,7 @@ class projectController extends baseController {
|
||||
params.role = params.role === 'owner' ? 'owner' : 'dev';
|
||||
|
||||
let userdata = await this.getUserdata(params.member_uid, params.role);
|
||||
if(userdata === null){
|
||||
if (userdata === null) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '成员uid不存在')
|
||||
}
|
||||
|
||||
@ -217,7 +238,7 @@ class projectController extends baseController {
|
||||
let result = await this.Model.delMember(params.id, params.member_uid);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${member.username}`,
|
||||
type: 'project',
|
||||
@ -234,11 +255,11 @@ class projectController extends baseController {
|
||||
}
|
||||
|
||||
|
||||
async getUserdata(uid, role){
|
||||
async getUserdata(uid, role) {
|
||||
role = role || 'dev';
|
||||
let userInst = yapi.getInst(userModel);
|
||||
let userData = await userInst.findById(uid);
|
||||
if(!userData){
|
||||
if (!userData) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
@ -292,7 +313,7 @@ class projectController extends baseController {
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.getBaseInfo(params.id);
|
||||
if(!result){
|
||||
if (!result) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '不存在的项目');
|
||||
}
|
||||
result = result.toObject();
|
||||
@ -324,19 +345,19 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组id不能为空');
|
||||
}
|
||||
|
||||
let auth =await this.checkAuth(group_id, 'group', 'edit')
|
||||
let auth = await this.checkAuth(group_id, 'group', 'edit')
|
||||
try {
|
||||
let result = await this.Model.list(group_id, auth);
|
||||
let follow = await this.followModel.list(this.getUid());
|
||||
let uids = [];
|
||||
result.forEach((item, index) => {
|
||||
result[index] = item.toObject();
|
||||
let f = _.find(follow, (fol)=>{
|
||||
let f = _.find(follow, (fol) => {
|
||||
return fol.projectid === item._id
|
||||
})
|
||||
if(f){
|
||||
if (f) {
|
||||
result[index].follow = true;
|
||||
}else{
|
||||
} else {
|
||||
result[index].follow = false;
|
||||
}
|
||||
if (uids.indexOf(item.uid) === -1) {
|
||||
@ -404,7 +425,7 @@ class projectController extends baseController {
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
async changeMemberRole(ctx){
|
||||
async changeMemberRole(ctx) {
|
||||
let params = ctx.request.body;
|
||||
let projectInst = yapi.getInst(projectModel);
|
||||
if (!params.member_uid) {
|
||||
@ -428,15 +449,13 @@ class projectController extends baseController {
|
||||
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
let member = await yapi.getInst(userModel).findByUids(params.member_uid);
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}修改了项目${project.name}中成员${member.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -444,6 +463,39 @@ class projectController extends baseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 项目设置
|
||||
* @interface /project/upset
|
||||
* @method POST
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {String} icon 项目icon
|
||||
* @param {Array} color 项目color
|
||||
* @returns {Object}
|
||||
* @example ./api/project/upset
|
||||
*/
|
||||
async upSet(ctx) {
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.up(id, data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
}
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then();
|
||||
} catch (e) {
|
||||
yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑项目
|
||||
* @interface /project/up
|
||||
@ -504,38 +556,20 @@ class projectController extends baseController {
|
||||
|
||||
if (params.name) data.name = params.name;
|
||||
if (params.desc) data.desc = params.desc;
|
||||
if (params.basepath ) {
|
||||
if (params.basepath) {
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.env) data.env = params.env;
|
||||
if(params.color) data.color = params.color;
|
||||
if(params.icon) data.icon = params.icon;
|
||||
if (params.color) data.color = params.color;
|
||||
if (params.icon) data.icon = params.icon;
|
||||
let result = await this.Model.up(id, data);
|
||||
// try{
|
||||
// let data = {};
|
||||
// if(params.name){
|
||||
// data.projectname = params.name;
|
||||
// }
|
||||
// if(params.icon){
|
||||
// data.icon = params.icon;
|
||||
// }
|
||||
// if(params.color){
|
||||
// data.color = params.color;
|
||||
// }
|
||||
// this.followModel.updateById(this.getUid(),id,data);
|
||||
// }catch(e){
|
||||
// yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
// }
|
||||
|
||||
let username = this.getUsername();
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}更新了项目${projectData.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
typeid: id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
@ -543,37 +577,37 @@ class projectController extends baseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改项目头像
|
||||
* @interface /project/upset
|
||||
* @method POST
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id
|
||||
* @param {String} color
|
||||
* @param {String} icon
|
||||
* @return {Object}
|
||||
*/
|
||||
async upSet(ctx){
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
if(!id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
try{
|
||||
let result = await this.Model.up(id, data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
}catch(e){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
}
|
||||
try{
|
||||
this.followModel.updateById(this.getUid(),id,data).then();
|
||||
}catch(e){
|
||||
yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 修改项目头像
|
||||
* @interface /project/upset
|
||||
* @method POST
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id
|
||||
* @param {String} color
|
||||
* @param {String} icon
|
||||
* @return {Object}
|
||||
*/
|
||||
async upSet(ctx) {
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
if (!id) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.up(id, data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
}
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then();
|
||||
} catch (e) {
|
||||
yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊搜索项目名称或者组名称
|
||||
@ -650,7 +684,7 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '项目id不存在');
|
||||
}
|
||||
|
||||
const arr = JSON.stringify(count.map(function(item) {
|
||||
const arr = JSON.stringify(count.map(function (item) {
|
||||
// 返回的json模板数据: item.res_body
|
||||
const mockData = Mock.mock(
|
||||
yapi.commons.json_parse(item.res_body)
|
||||
@ -691,7 +725,7 @@ class projectController extends baseController {
|
||||
});
|
||||
}
|
||||
module.exports = run;`
|
||||
.trim();
|
||||
.trim();
|
||||
return ctx.body = res;
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,6 @@ class interfaceCase extends baseModel {
|
||||
project_id: { type: Number, required: true },
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
env: [{
|
||||
name: String, domain: String
|
||||
}],
|
||||
domain: { type: String },
|
||||
path: { type: String },
|
||||
method: { type: String },
|
||||
|
@ -62,7 +62,7 @@ class logModel extends baseModel {
|
||||
return this.model.find({
|
||||
type: type,
|
||||
typeid: typeid
|
||||
}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}).sort({add_time:-1}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}
|
||||
|
||||
listCount(typeid,type) {
|
||||
|
@ -65,7 +65,7 @@ app.use(_router2.default.allowedMethods());
|
||||
(0, _websocket2.default)(app);
|
||||
|
||||
app.use(function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(id, type) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(id, type, action) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(id, type, action) {
|
||||
var role;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
|
@ -69,7 +69,7 @@ var followController = function (_baseController) {
|
||||
(0, _createClass3.default)(followController, [{
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var uid, page, limit, result;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -134,7 +134,7 @@ var followController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, uid, checkRepeat, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -212,7 +212,7 @@ var followController = function (_baseController) {
|
||||
}, {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var params, uid, checkRepeat, data, result;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
|
@ -88,7 +88,7 @@ var groupController = function (_baseController) {
|
||||
(0, _createClass3.default)(groupController, [{
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(uid, role) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(p) {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_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)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var groupInst, _id2, data, result;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
|
@ -52,6 +52,10 @@ var _user = require('../models/user.js');
|
||||
|
||||
var _user2 = _interopRequireDefault(_user);
|
||||
|
||||
var _project = require('../models/project.js');
|
||||
|
||||
var _project2 = _interopRequireDefault(_project);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var interfaceController = function (_baseController) {
|
||||
@ -64,6 +68,7 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
_this.Model = _yapi2.default.getInst(_interface2.default);
|
||||
_this.catModel = _yapi2.default.getInst(_interfaceCat2.default);
|
||||
_this.projectModel = _yapi2.default.getInst(_project2.default);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@ -100,8 +105,8 @@ var interfaceController = function (_baseController) {
|
||||
(0, _createClass3.default)(interfaceController, [{
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result;
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@ -199,23 +204,38 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 24:
|
||||
result = _context.sent;
|
||||
username = this.getUsername();
|
||||
// let project = await this.projectModel.get(params.project_id);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 31;
|
||||
break;
|
||||
_context.next = 28;
|
||||
return this.catModel.get(params.catid);
|
||||
|
||||
case 28:
|
||||
_context.prev = 28;
|
||||
cate = _context.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u4E3A\u5206\u7C7B "' + cate.name + '" \u6DFB\u52A0\u4E86\u63A5\u53E3 "' + data.title + '"',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 36;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
_context.prev = 33;
|
||||
_context.t0 = _context['catch'](16);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 31:
|
||||
case 36:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[16, 28]]);
|
||||
}, _callee, this, [[16, 33]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -239,7 +259,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -301,7 +321,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var project_id, result;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -351,7 +371,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'listByCat',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var catid, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -401,7 +421,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'listByMenu',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var project_id, result, newResult, i, item, list, j;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -506,8 +526,8 @@ 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;
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, id, interfaceData, checkRepeat, data, result, username, cate, inter;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
@ -632,23 +652,59 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 36:
|
||||
result = _context6.sent;
|
||||
username = this.getUsername();
|
||||
cate = void 0;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 43;
|
||||
if (!params.catid) {
|
||||
_context6.next = 45;
|
||||
break;
|
||||
}
|
||||
|
||||
_context6.next = 42;
|
||||
return this.catModel.get(+params.catid);
|
||||
|
||||
case 42:
|
||||
cate = _context6.sent;
|
||||
_context6.next = 51;
|
||||
break;
|
||||
|
||||
case 40:
|
||||
_context6.prev = 40;
|
||||
case 45:
|
||||
_context6.next = 47;
|
||||
return this.Model.get(id);
|
||||
|
||||
case 47:
|
||||
inter = _context6.sent;
|
||||
_context6.next = 50;
|
||||
return this.catModel.get(inter.catid);
|
||||
|
||||
case 50:
|
||||
cate = _context6.sent;
|
||||
|
||||
case 51:
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + data.title + '"',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context6.next = 58;
|
||||
break;
|
||||
|
||||
case 55:
|
||||
_context6.prev = 55;
|
||||
_context6.t0 = _context6['catch'](33);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context6.t0.message);
|
||||
|
||||
case 43:
|
||||
case 58:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[33, 40]]);
|
||||
}, _callee6, this, [[33, 55]]);
|
||||
}));
|
||||
|
||||
function up(_x6) {
|
||||
@ -672,8 +728,8 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var id, data, result;
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var id, data, inter, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
switch (_context7.prev = _context7.next) {
|
||||
@ -715,27 +771,46 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 13:
|
||||
_context7.next = 15;
|
||||
return this.Model.del(id);
|
||||
return this.Model.get(id);
|
||||
|
||||
case 15:
|
||||
inter = _context7.sent;
|
||||
_context7.next = 18;
|
||||
return this.Model.del(id);
|
||||
|
||||
case 18:
|
||||
result = _context7.sent;
|
||||
username = this.getUsername();
|
||||
_context7.next = 22;
|
||||
return this.catModel.get(inter.catid);
|
||||
|
||||
case 22:
|
||||
cate = _context7.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + cate.name + '" \u4E0B\u7684\u63A5\u53E3 "' + inter.title + '"',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context7.next = 22;
|
||||
_context7.next = 30;
|
||||
break;
|
||||
|
||||
case 19:
|
||||
_context7.prev = 19;
|
||||
case 27:
|
||||
_context7.prev = 27;
|
||||
_context7.t1 = _context7['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context7.t1.message);
|
||||
|
||||
case 22:
|
||||
case 30:
|
||||
case 'end':
|
||||
return _context7.stop();
|
||||
}
|
||||
}
|
||||
}, _callee7, this, [[0, 19]]);
|
||||
}, _callee7, this, [[0, 27]]);
|
||||
}));
|
||||
|
||||
function del(_x7) {
|
||||
@ -747,7 +822,7 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'solveConflict',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _this2 = this;
|
||||
|
||||
var id, result, userInst, userinfo, data;
|
||||
@ -830,8 +905,8 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCat',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, result;
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, result, username;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -873,24 +948,33 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 9:
|
||||
result = _context9.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u6DFB\u52A0\u4E86\u5206\u7C7B "' + params.name + '"',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.project_id
|
||||
});
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
|
||||
_context9.next = 16;
|
||||
_context9.next = 18;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context9.prev = 13;
|
||||
case 15:
|
||||
_context9.prev = 15;
|
||||
_context9.t0 = _context9['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t0.message);
|
||||
|
||||
case 16:
|
||||
case 18:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[0, 13]]);
|
||||
}, _callee9, this, [[0, 15]]);
|
||||
}));
|
||||
|
||||
function addCat(_x9) {
|
||||
@ -902,8 +986,8 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCat',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, result;
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, result, username, cate;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
switch (_context10.prev = _context10.next) {
|
||||
@ -919,23 +1003,37 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 4:
|
||||
result = _context10.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 11;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context10.next = 8;
|
||||
return this.catModel.get(params.catid);
|
||||
|
||||
case 8:
|
||||
_context10.prev = 8;
|
||||
cate = _context10.sent;
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u66F4\u65B0\u4E86\u5206\u7C7B "' + cate.name + '"',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 16;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context10.prev = 13;
|
||||
_context10.t0 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 400, _context10.t0.message);
|
||||
|
||||
case 11:
|
||||
case 16:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 8]]);
|
||||
}, _callee10, this, [[0, 13]]);
|
||||
}));
|
||||
|
||||
function upCat(_x10) {
|
||||
@ -947,8 +1045,8 @@ var interfaceController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCat',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var id, catData, auth, result, r;
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var id, catData, auth, cate, result, r, username;
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
while (1) {
|
||||
switch (_context11.prev = _context11.next) {
|
||||
@ -985,29 +1083,45 @@ var interfaceController = function (_baseController) {
|
||||
|
||||
case 12:
|
||||
_context11.next = 14;
|
||||
return this.catModel.del(id);
|
||||
return this.catModel.get(id);
|
||||
|
||||
case 14:
|
||||
result = _context11.sent;
|
||||
cate = _context11.sent;
|
||||
_context11.next = 17;
|
||||
return this.Model.delByCatid(id);
|
||||
return this.catModel.del(id);
|
||||
|
||||
case 17:
|
||||
result = _context11.sent;
|
||||
_context11.next = 20;
|
||||
return this.Model.delByCatid(id);
|
||||
|
||||
case 20:
|
||||
r = _context11.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237 "' + username + '" \u5220\u9664\u4E86\u5206\u7C7B "' + cate.name + '" \u53CA\u8BE5\u5206\u7C7B\u4E0B\u7684\u63A5\u53E3',
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: cate.project_id
|
||||
});
|
||||
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(r));
|
||||
|
||||
case 21:
|
||||
_context11.prev = 21;
|
||||
case 26:
|
||||
_context11.prev = 26;
|
||||
_context11.t0 = _context11['catch'](0);
|
||||
|
||||
_yapi2.default.commons.resReturn(null, 400, _context11.t0.message);
|
||||
|
||||
case 24:
|
||||
case 29:
|
||||
case 'end':
|
||||
return _context11.stop();
|
||||
}
|
||||
}
|
||||
}, _callee11, this, [[0, 21]]);
|
||||
}, _callee11, this, [[0, 26]]);
|
||||
}));
|
||||
|
||||
function delCat(_x11) {
|
||||
|
@ -74,7 +74,7 @@ var interfaceColController = function (_baseController) {
|
||||
(0, _createClass3.default)(interfaceColController, [{
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var id, result, i;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -149,7 +149,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCol',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, result;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -233,7 +233,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getCaseList',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var id, inst, result;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -282,7 +282,6 @@ var interfaceColController = function (_baseController) {
|
||||
* @param {String} casename
|
||||
* @param {Number} col_id
|
||||
* @param {Number} project_id
|
||||
* @param {String} env
|
||||
* @param {String} domain
|
||||
* @param {String} path
|
||||
* @param {String} method
|
||||
@ -298,7 +297,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addCase',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -311,7 +310,6 @@ var interfaceColController = function (_baseController) {
|
||||
casename: 'string',
|
||||
project_id: 'number',
|
||||
col_id: 'number',
|
||||
env: 'string',
|
||||
domain: 'string',
|
||||
method: 'string'
|
||||
});
|
||||
@ -392,7 +390,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getCase',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var id, result;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -446,7 +444,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCol',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, result;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
@ -503,7 +501,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upCaseIndex',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _this2 = this;
|
||||
|
||||
var params;
|
||||
@ -562,7 +560,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCol',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var id, colData, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
||||
while (1) {
|
||||
@ -639,7 +637,7 @@ var interfaceColController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delCase',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var caseid, caseData, auth, result;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
|
@ -75,7 +75,7 @@ var logController = function (_baseController) {
|
||||
(0, _createClass3.default)(logController, [{
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var typeid, page, limit, type, result, count;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
@ -148,8 +148,8 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, username;
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, data, result, colInst, catInst, username;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@ -233,7 +233,8 @@ var projectController = function (_baseController) {
|
||||
icon: params.icon,
|
||||
color: params.color,
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
up_time: _yapi2.default.commons.time(),
|
||||
env: [{ name: 'local', domain: 'http://127.0.0.1' }]
|
||||
};
|
||||
_context.prev = 20;
|
||||
_context.next = 23;
|
||||
@ -241,6 +242,36 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 23:
|
||||
result = _context.sent;
|
||||
colInst = _yapi2.default.getInst(_interfaceCol2.default);
|
||||
catInst = _yapi2.default.getInst(_interfaceCat2.default);
|
||||
|
||||
if (!result._id) {
|
||||
_context.next = 31;
|
||||
break;
|
||||
}
|
||||
|
||||
_context.next = 29;
|
||||
return colInst.save({
|
||||
name: '公共测试集',
|
||||
project_id: result._id,
|
||||
desc: '公共测试集',
|
||||
uid: this.getUid(),
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 29:
|
||||
_context.next = 31;
|
||||
return catInst.save({
|
||||
name: '公共分类',
|
||||
project_id: result._id,
|
||||
desc: '公共分类',
|
||||
uid: this.getUid(),
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
});
|
||||
|
||||
case 31:
|
||||
username = this.getUsername();
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
@ -254,21 +285,21 @@ var projectController = function (_baseController) {
|
||||
icon: params.icon
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 32;
|
||||
_context.next = 39;
|
||||
break;
|
||||
|
||||
case 29:
|
||||
_context.prev = 29;
|
||||
case 36:
|
||||
_context.prev = 36;
|
||||
_context.t1 = _context['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t1.message);
|
||||
|
||||
case 32:
|
||||
case 39:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[20, 29]]);
|
||||
}, _callee, this, [[20, 36]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -292,7 +323,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, check, userdata, result, username, project;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
@ -422,7 +453,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var params, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -528,7 +559,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getUserdata',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(uid, role) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(uid, role) {
|
||||
var userInst, userData;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -586,7 +617,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'getMemberList',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, project;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -648,7 +679,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'get',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var params, result, catInst, cat;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
@ -733,7 +764,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var group_id, auth, result, follow, uids, _users, users;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
@ -833,7 +864,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var id, interfaceInst, interfaceColInst, interfaceCaseInst, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
||||
while (1) {
|
||||
@ -926,7 +957,7 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'changeMemberRole',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, projectInst, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
@ -995,7 +1026,7 @@ var projectController = function (_baseController) {
|
||||
case 24:
|
||||
project = _context9.sent;
|
||||
_context9.next = 27;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(params.member_uid);
|
||||
return _yapi2.default.getInst(_user2.default).findById(params.member_uid);
|
||||
|
||||
case 27:
|
||||
member = _context9.sent;
|
||||
@ -1005,9 +1036,7 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id,
|
||||
color: project.color,
|
||||
icon: project.icon
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 35;
|
||||
@ -1034,6 +1063,81 @@ var projectController = function (_baseController) {
|
||||
return changeMemberRole;
|
||||
}()
|
||||
|
||||
/**
|
||||
* 项目设置
|
||||
* @interface /project/upset
|
||||
* @method POST
|
||||
* @category project
|
||||
* @foldnumber 10
|
||||
* @param {Number} id 项目id,不能为空
|
||||
* @param {String} icon 项目icon
|
||||
* @param {Array} color 项目color
|
||||
* @returns {Object}
|
||||
* @example ./api/project/upset
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: 'upSet',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var id, data, result;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
switch (_context10.prev = _context10.next) {
|
||||
case 0:
|
||||
id = ctx.request.body.id;
|
||||
data = {};
|
||||
|
||||
data.color = ctx.request.body.color;
|
||||
data.icon = ctx.request.body.icon;
|
||||
|
||||
if (id) {
|
||||
_context10.next = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 6:
|
||||
_context10.prev = 6;
|
||||
_context10.next = 9;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 9:
|
||||
result = _context10.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 16;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context10.prev = 13;
|
||||
_context10.t0 = _context10['catch'](6);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t0.message);
|
||||
|
||||
case 16:
|
||||
try {
|
||||
this.followModel.updateById(this.getUid(), id, data).then();
|
||||
} catch (e) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
|
||||
case 17:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[6, 13]]);
|
||||
}));
|
||||
|
||||
function upSet(_x11) {
|
||||
return _ref10.apply(this, arguments);
|
||||
}
|
||||
|
||||
return upSet;
|
||||
}()
|
||||
|
||||
/**
|
||||
* 编辑项目
|
||||
* @interface /project/up
|
||||
@ -1054,13 +1158,13 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var id, params, projectData, checkRepeat, data, result, username;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
while (1) {
|
||||
switch (_context10.prev = _context10.next) {
|
||||
switch (_context11.prev = _context11.next) {
|
||||
case 0:
|
||||
_context10.prev = 0;
|
||||
_context11.prev = 0;
|
||||
id = ctx.request.body.id;
|
||||
params = ctx.request.body;
|
||||
|
||||
@ -1075,39 +1179,39 @@ var projectController = function (_baseController) {
|
||||
});
|
||||
|
||||
if (id) {
|
||||
_context10.next = 7;
|
||||
_context11.next = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 7:
|
||||
_context10.next = 9;
|
||||
_context11.next = 9;
|
||||
return this.checkAuth(id, 'project', 'edit');
|
||||
|
||||
case 9:
|
||||
_context10.t0 = _context10.sent;
|
||||
_context11.t0 = _context11.sent;
|
||||
|
||||
if (!(_context10.t0 !== true)) {
|
||||
_context10.next = 12;
|
||||
if (!(_context11.t0 !== true)) {
|
||||
_context11.next = 12;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
|
||||
case 12:
|
||||
_context10.next = 14;
|
||||
_context11.next = 14;
|
||||
return this.Model.get(id);
|
||||
|
||||
case 14:
|
||||
projectData = _context10.sent;
|
||||
projectData = _context11.sent;
|
||||
|
||||
if (!((params.basepath = this.handleBasepath(params.basepath)) === false)) {
|
||||
_context10.next = 17;
|
||||
_context11.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
|
||||
|
||||
case 17:
|
||||
|
||||
@ -1116,22 +1220,22 @@ var projectController = function (_baseController) {
|
||||
}
|
||||
|
||||
if (!params.name) {
|
||||
_context10.next = 24;
|
||||
_context11.next = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
_context10.next = 21;
|
||||
_context11.next = 21;
|
||||
return this.Model.checkNameRepeat(params.name);
|
||||
|
||||
case 21:
|
||||
checkRepeat = _context10.sent;
|
||||
checkRepeat = _context11.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context10.next = 24;
|
||||
_context11.next = 24;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
|
||||
|
||||
case 24:
|
||||
data = {
|
||||
@ -1147,28 +1251,11 @@ var projectController = function (_baseController) {
|
||||
if (params.env) data.env = params.env;
|
||||
if (params.color) data.color = params.color;
|
||||
if (params.icon) data.icon = params.icon;
|
||||
_context10.next = 33;
|
||||
_context11.next = 33;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 33:
|
||||
result = _context10.sent;
|
||||
|
||||
// try{
|
||||
// let data = {};
|
||||
// if(params.name){
|
||||
// data.projectname = params.name;
|
||||
// }
|
||||
// if(params.icon){
|
||||
// data.icon = params.icon;
|
||||
// }
|
||||
// if(params.color){
|
||||
// data.color = params.color;
|
||||
// }
|
||||
// this.followModel.updateById(this.getUid(),id,data);
|
||||
// }catch(e){
|
||||
// yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
// }
|
||||
|
||||
result = _context11.sent;
|
||||
username = this.getUsername();
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
@ -1176,30 +1263,28 @@ var projectController = function (_baseController) {
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id,
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
typeid: id
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 42;
|
||||
_context11.next = 42;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
_context10.prev = 39;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
_context11.prev = 39;
|
||||
_context11.t1 = _context11['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t1.message);
|
||||
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
return _context11.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 39]]);
|
||||
}, _callee11, this, [[0, 39]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
return _ref10.apply(this, arguments);
|
||||
function up(_x12) {
|
||||
return _ref11.apply(this, arguments);
|
||||
}
|
||||
|
||||
return up;
|
||||
@ -1220,11 +1305,11 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'upSet',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var id, data, result;
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
while (1) {
|
||||
switch (_context11.prev = _context11.next) {
|
||||
switch (_context12.prev = _context12.next) {
|
||||
case 0:
|
||||
id = ctx.request.body.id;
|
||||
data = {};
|
||||
@ -1233,29 +1318,29 @@ var projectController = function (_baseController) {
|
||||
data.icon = ctx.request.body.icon;
|
||||
|
||||
if (id) {
|
||||
_context11.next = 6;
|
||||
_context12.next = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 6:
|
||||
_context11.prev = 6;
|
||||
_context11.next = 9;
|
||||
_context12.prev = 6;
|
||||
_context12.next = 9;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 9:
|
||||
result = _context11.sent;
|
||||
result = _context12.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context11.next = 16;
|
||||
_context12.next = 16;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context11.prev = 13;
|
||||
_context11.t0 = _context11['catch'](6);
|
||||
_context12.prev = 13;
|
||||
_context12.t0 = _context12['catch'](6);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t0.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context12.t0.message);
|
||||
|
||||
case 16:
|
||||
try {
|
||||
@ -1266,14 +1351,14 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 17:
|
||||
case 'end':
|
||||
return _context11.stop();
|
||||
return _context12.stop();
|
||||
}
|
||||
}
|
||||
}, _callee11, this, [[6, 13]]);
|
||||
}, _callee12, this, [[6, 13]]);
|
||||
}));
|
||||
|
||||
function upSet(_x12) {
|
||||
return _ref11.apply(this, arguments);
|
||||
function upSet(_x13) {
|
||||
return _ref12.apply(this, arguments);
|
||||
}
|
||||
|
||||
return upSet;
|
||||
@ -1293,40 +1378,40 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'search',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var q, projectList, groupList, projectRules, groupRules, queryList;
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
||||
while (1) {
|
||||
switch (_context12.prev = _context12.next) {
|
||||
switch (_context13.prev = _context13.next) {
|
||||
case 0:
|
||||
q = ctx.request.query.q;
|
||||
|
||||
if (q) {
|
||||
_context12.next = 3;
|
||||
_context13.next = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'No keyword.'));
|
||||
return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'No keyword.'));
|
||||
|
||||
case 3:
|
||||
if (_yapi2.default.commons.validateSearchKeyword(q)) {
|
||||
_context12.next = 5;
|
||||
_context13.next = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'Bad query.'));
|
||||
return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(void 0, 400, 'Bad query.'));
|
||||
|
||||
case 5:
|
||||
_context12.next = 7;
|
||||
_context13.next = 7;
|
||||
return this.Model.search(q);
|
||||
|
||||
case 7:
|
||||
projectList = _context12.sent;
|
||||
_context12.next = 10;
|
||||
projectList = _context13.sent;
|
||||
_context13.next = 10;
|
||||
return this.groupModel.search(q);
|
||||
|
||||
case 10:
|
||||
groupList = _context12.sent;
|
||||
groupList = _context13.sent;
|
||||
projectRules = ['_id', 'name', 'basepath', 'uid', 'env', 'members', { key: 'group_id', alias: 'groupId' }, { key: 'up_time', alias: 'upTime' }, { key: 'add_time', alias: 'addTime' }];
|
||||
groupRules = ['_id', 'uid', { key: 'group_name', alias: 'groupName' }, { key: 'group_desc', alias: 'groupDesc' }, { key: 'add_time', alias: 'addTime' }, { key: 'up_time', alias: 'upTime' }];
|
||||
|
||||
@ -1338,18 +1423,18 @@ var projectController = function (_baseController) {
|
||||
project: projectList,
|
||||
group: groupList
|
||||
};
|
||||
return _context12.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(queryList, 0, 'ok'));
|
||||
return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(queryList, 0, 'ok'));
|
||||
|
||||
case 17:
|
||||
case 'end':
|
||||
return _context12.stop();
|
||||
return _context13.stop();
|
||||
}
|
||||
}
|
||||
}, _callee12, this);
|
||||
}, _callee13, this);
|
||||
}));
|
||||
|
||||
function search(_x13) {
|
||||
return _ref12.apply(this, arguments);
|
||||
function search(_x14) {
|
||||
return _ref13.apply(this, arguments);
|
||||
}
|
||||
|
||||
return search;
|
||||
@ -1368,36 +1453,36 @@ var projectController = function (_baseController) {
|
||||
}, {
|
||||
key: 'download',
|
||||
value: function () {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var _ref14 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee14(ctx) {
|
||||
var project_id, interfaceInst, count, arr, fileName, res;
|
||||
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
||||
return _regenerator2.default.wrap(function _callee14$(_context14) {
|
||||
while (1) {
|
||||
switch (_context13.prev = _context13.next) {
|
||||
switch (_context14.prev = _context14.next) {
|
||||
case 0:
|
||||
project_id = ctx.request.query.project_id;
|
||||
interfaceInst = _yapi2.default.getInst(_interface2.default);
|
||||
// 根据 project_id 获取接口数据
|
||||
|
||||
_context13.next = 4;
|
||||
_context14.next = 4;
|
||||
return interfaceInst.list(project_id);
|
||||
|
||||
case 4:
|
||||
count = _context13.sent;
|
||||
count = _context14.sent;
|
||||
|
||||
if (project_id) {
|
||||
_context13.next = 9;
|
||||
_context14.next = 9;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
return _context14.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 9:
|
||||
if (count) {
|
||||
_context13.next = 11;
|
||||
_context14.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context13.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目id不存在'));
|
||||
return _context14.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目id不存在'));
|
||||
|
||||
case 11:
|
||||
arr = (0, _stringify2.default)(count.map(function (item) {
|
||||
@ -1411,23 +1496,23 @@ var projectController = function (_baseController) {
|
||||
fileName = 'mock.js';
|
||||
|
||||
ctx.attachment(fileName);
|
||||
_context13.next = 16;
|
||||
_context14.next = 16;
|
||||
return send(ctx, fileName, { root: __dirname + '/public' });
|
||||
|
||||
case 16:
|
||||
res = ('\n var Mock = require(\'mockjs\');\n var xhook = require(\'xhook\');\n var data = ' + arr + ';\n function run() {\n xhook.before(function(request, callback) {\n setTimeout(function() {\n var res;\n data.forEach((item) => {\n // \u8BF7\u6C42\u7684\u63A5\u53E3\u5728 data \u4E2D\u5B58\u5728\n if(request.url === item.path) {\n res = {\n status: 200,\n text: Mock.mock(item.mock)\n }\n }\n });\n if (res) {\n callback(res);\n }else {\n callback({ status: 405, text: \'\u63A5\u53E3\u4E0D\u5B58\u5728\' });\n }\n }, 500);\n });\n }\n module.exports = run;').trim();
|
||||
return _context13.abrupt('return', ctx.body = res);
|
||||
return _context14.abrupt('return', ctx.body = res);
|
||||
|
||||
case 18:
|
||||
case 'end':
|
||||
return _context13.stop();
|
||||
return _context14.stop();
|
||||
}
|
||||
}
|
||||
}, _callee13, this);
|
||||
}, _callee14, this);
|
||||
}));
|
||||
|
||||
function download(_x14) {
|
||||
return _ref13.apply(this, arguments);
|
||||
function download(_x15) {
|
||||
return _ref14.apply(this, arguments);
|
||||
}
|
||||
|
||||
return download;
|
||||
|
@ -99,7 +99,7 @@ var userController = function (_baseController) {
|
||||
(0, _createClass3.default)(userController, [{
|
||||
key: 'login',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var userInst, email, password, result;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
@ -190,7 +190,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'logout',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -248,7 +248,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'loginByToken',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var config, token, ret, login;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
@ -300,7 +300,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'handleThirdLogin',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee4(email, username) {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(email, username) {
|
||||
var user, data, passsalt, userInst;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
@ -384,7 +384,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'changePassword',
|
||||
value: function () {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var _ref5 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee5(ctx) {
|
||||
var params, userInst, user, passsalt, data, result;
|
||||
return _regenerator2.default.wrap(function _callee5$(_context5) {
|
||||
while (1) {
|
||||
@ -512,7 +512,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'reg',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var userInst, params, checkRepeat, passsalt, data, user;
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
@ -636,7 +636,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var _ref7 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee7(ctx) {
|
||||
var page, limit, userInst, user, count;
|
||||
return _regenerator2.default.wrap(function _callee7$(_context7) {
|
||||
while (1) {
|
||||
@ -694,7 +694,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'findById',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var userInst, id, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
||||
while (1) {
|
||||
@ -770,7 +770,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'del',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var userInst, id, result;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
@ -846,7 +846,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'update',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var params, userInst, id, data, checkRepeat, result;
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
@ -952,7 +952,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'uploadAvatar',
|
||||
value: function () {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var _ref11 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee11(ctx) {
|
||||
var basecode, pngPrefix, jpegPrefix, type, strLength, avatarInst, result;
|
||||
return _regenerator2.default.wrap(function _callee11$(_context11) {
|
||||
while (1) {
|
||||
@ -1054,7 +1054,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'avatar',
|
||||
value: function () {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var _ref12 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee12(ctx) {
|
||||
var uid, avatarInst, data, dataBuffer, type;
|
||||
return _regenerator2.default.wrap(function _callee12$(_context12) {
|
||||
while (1) {
|
||||
@ -1118,7 +1118,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'search',
|
||||
value: function () {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var _ref13 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee13(ctx) {
|
||||
var q, queryList, rules, filteredRes;
|
||||
return _regenerator2.default.wrap(function _callee13$(_context13) {
|
||||
while (1) {
|
||||
@ -1190,7 +1190,7 @@ var userController = function (_baseController) {
|
||||
}, {
|
||||
key: 'project',
|
||||
value: function () {
|
||||
var _ref14 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee14(ctx) {
|
||||
var _ref14 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee14(ctx) {
|
||||
var _ctx$request$query, id, type, result, interfaceInst, interfaceData, projectInst, projectData, ownerAuth, devAuth, groupInst, groupData, _ownerAuth, _devAuth;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee14$(_context14) {
|
||||
|
@ -47,7 +47,7 @@ function matchApi(apiPath, apiRule) {
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx, next) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_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) {
|
||||
|
@ -54,9 +54,6 @@ var interfaceCase = function (_baseModel) {
|
||||
project_id: { type: Number, required: true },
|
||||
add_time: Number,
|
||||
up_time: Number,
|
||||
env: [{
|
||||
name: String, domain: String
|
||||
}],
|
||||
domain: { type: String },
|
||||
path: { type: String },
|
||||
method: { type: String },
|
||||
|
@ -106,7 +106,7 @@ var logModel = function (_baseModel) {
|
||||
return this.model.find({
|
||||
type: type,
|
||||
typeid: typeid
|
||||
}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}).sort({ add_time: -1 }).skip((page - 1) * limit).limit(limit).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listCount',
|
||||
|
@ -351,7 +351,7 @@ function createAction(controller, action, path, method) {
|
||||
var _this = this;
|
||||
|
||||
router[method]("/api" + INTERFACE_CONFIG[controller].prefix + path, function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var inst;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
@ -26,7 +26,7 @@ function websocket(app) {
|
||||
return next(ctx);
|
||||
});
|
||||
router.get('/api/interface/solve_conflict', function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(ctx) {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var inst;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
|
Loading…
Reference in New Issue
Block a user