mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
Merge branch 'dev' of http://gitlab.corp.qunar.com/mfe/yapi into dev
This commit is contained in:
commit
692a84a880
@ -5,8 +5,6 @@ import {
|
||||
GET_LOGIN_STATE
|
||||
} from '../constants/action-types.js';
|
||||
import axios from 'axios';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
|
||||
const checkLoginState = () => {
|
||||
return {
|
||||
@ -20,7 +18,6 @@ const loginActions = (data) => {
|
||||
return (dispatch) => {
|
||||
axios.post('/user/login', data).then((res) => {
|
||||
if (res.data.errcode === 0) {
|
||||
cookies.set(data.email, data.password);
|
||||
dispatch({
|
||||
type: LOGIN,
|
||||
payload: {
|
||||
|
@ -1,14 +1,38 @@
|
||||
import {
|
||||
FETCH_PROJECT_LIST,
|
||||
PROJECT_ADD,
|
||||
PROJECT_DEL
|
||||
PROJECT_DEL,
|
||||
CHANGE_UPDATE_MODAL,
|
||||
PROJECT_UPDATE,
|
||||
CHANGE_TABLE_LOADING
|
||||
} from '../constants/action-types.js';
|
||||
import axios from 'axios';
|
||||
import variable from '../constants/variable';
|
||||
|
||||
const fetchProjectList = (id) => {
|
||||
const fetchProjectList = (id, pageNum) => {
|
||||
return {
|
||||
type: FETCH_PROJECT_LIST,
|
||||
payload: axios.get('/project/list', {params: { group_id: id }})
|
||||
payload: axios.get('/project/list', {
|
||||
params: {
|
||||
group_id: id,
|
||||
page: pageNum,
|
||||
limit: variable.PAGE_LIMIT
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
const changeUpdateModal = (data, index) => {
|
||||
return {
|
||||
type: CHANGE_UPDATE_MODAL,
|
||||
payload: { data, index }
|
||||
};
|
||||
};
|
||||
|
||||
const changeTableLoading = (data) => {
|
||||
return {
|
||||
type: CHANGE_TABLE_LOADING,
|
||||
payload: data
|
||||
};
|
||||
};
|
||||
|
||||
@ -28,6 +52,22 @@ const addProject = (data) => {
|
||||
};
|
||||
};
|
||||
|
||||
const updateProject = (data) => {
|
||||
const { name, prd_host, basepath, desc, group_id } = data;
|
||||
const param = {
|
||||
name,
|
||||
prd_host,
|
||||
basepath,
|
||||
desc,
|
||||
group_id
|
||||
};
|
||||
return {
|
||||
type: PROJECT_UPDATE,
|
||||
// payload 可以返回 Promise,异步请求使用 axios 即可
|
||||
payload: axios.post('/project/up', param)
|
||||
};
|
||||
};
|
||||
|
||||
const delProject = (id) => {
|
||||
const param = { id };
|
||||
return {
|
||||
@ -40,5 +80,8 @@ const delProject = (id) => {
|
||||
export default {
|
||||
fetchProjectList,
|
||||
addProject,
|
||||
delProject
|
||||
delProject,
|
||||
changeUpdateModal,
|
||||
updateProject,
|
||||
changeTableLoading
|
||||
};
|
||||
|
@ -8,14 +8,18 @@ export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST'
|
||||
export const SET_CURR_GROUP = 'SET_CURR_GROUP'
|
||||
|
||||
// project
|
||||
export const FETCH_PROJECT_LIST = 'FETCH_PROJECT_LIST'
|
||||
export const PROJECT_ADD = 'PROJECT_ADD'
|
||||
export const PROJECT_DEL = 'PROJECT_DEL'
|
||||
export const CHANGE_TABLE_LOADING = 'CHANGE_TABLE_LOADING' // 控制表格的Loading状态
|
||||
export const CHANGE_UPDATE_MODAL = 'CHANGE_UPDATE_MODAL' // 控制模态框 - 修改项目
|
||||
export const OPRATE_ADD_MODAL = 'OPRATE_ADD_MODAL' // 控制模态框 - 创建项目
|
||||
export const FETCH_PROJECT_LIST = 'FETCH_PROJECT_LIST' // 获取项目列表
|
||||
export const PROJECT_ADD = 'PROJECT_ADD' // 添加项目
|
||||
export const PROJECT_UPDATE = 'PROJECT_UPDATE' // 修改项目
|
||||
export const PROJECT_DEL = 'PROJECT_DEL' // 删除项目
|
||||
|
||||
// login
|
||||
export const LOGIN = 'LOGIN';
|
||||
export const GET_LOGIN_STATE = 'GET_LOGIN_STATE';
|
||||
export const REGISTER = 'REGISTER';
|
||||
export const LOGIN = 'LOGIN'; // 登录
|
||||
export const GET_LOGIN_STATE = 'GET_LOGIN_STATE'; // 获取登录信息
|
||||
export const REGISTER = 'REGISTER'; // 注册
|
||||
|
||||
//header
|
||||
export const LOGIN_TYPE = 'LOGIN_TYPE';
|
||||
|
3
client/constants/variable.js
Normal file
3
client/constants/variable.js
Normal file
@ -0,0 +1,3 @@
|
||||
export default {
|
||||
PAGE_LIMIT: 10 // 默认每页展示10条数据
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
import './Home.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Row, Col, Button } from 'antd'
|
||||
import PropTypes from "prop-types"
|
||||
import Login from '../Login/login-wrap'
|
||||
import Login from '../Login/LoginWrap'
|
||||
import Intro from '../../components/Intro/Intro'
|
||||
import Footer from "../../components/Footer/Footer";
|
||||
|
||||
@ -66,12 +67,18 @@ class Home extends Component {
|
||||
<div className="home-main">
|
||||
{login?
|
||||
(
|
||||
<div className="main-one">
|
||||
<div>
|
||||
登录以后的首页
|
||||
<div className="user-home">
|
||||
<div className="user-des">
|
||||
<p className="title">YAPI</p>
|
||||
<p className="des">一个高效,易用,功能强大的api管理系统</p>
|
||||
<div className="btn">
|
||||
<Button type="primary" size="large">
|
||||
<Link to="/ProjectGroups" onClick={this.toStart}>开始</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<Button type="primary" size="large">开始</Button>
|
||||
</div>)
|
||||
</div>
|
||||
)
|
||||
: <HomeGuest introList={this.props.introList}/>}
|
||||
<Footer/>
|
||||
</div>
|
||||
|
@ -43,6 +43,31 @@ $color-black-lighter: #404040;
|
||||
padding-left: .15rem;
|
||||
}
|
||||
}
|
||||
.user-home{
|
||||
height:calc(100% - .64rem);
|
||||
padding: .5rem .5rem 0 .5rem;
|
||||
.user-des{
|
||||
max-width: 11rem;
|
||||
margin: 0 auto .5rem;
|
||||
text-align: center;
|
||||
.title{
|
||||
font-size: .8rem;
|
||||
margin-bottom: .2rem;
|
||||
}
|
||||
.des{
|
||||
font-size: .25rem;
|
||||
margin-bottom: .3rem;
|
||||
}
|
||||
.btn{
|
||||
button{
|
||||
font-size: .2rem;
|
||||
line-height: .2rem;
|
||||
height: .5rem;
|
||||
padding: .15rem .5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.main-part{
|
||||
padding: .9rem .5rem;
|
||||
&:nth-child(odd){
|
||||
|
@ -1,10 +1,8 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Form, Button, Input, Icon, Checkbox } from 'antd';
|
||||
import { Form, Button, Input, Icon } from 'antd';
|
||||
import { loginActions } from '../../actions/login';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
const FormItem = Form.Item;
|
||||
@connect(
|
||||
state => {
|
||||
@ -37,27 +35,15 @@ class Login extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
handleChange = (value) => {
|
||||
if (cookies.get(value)) {
|
||||
this.props.form.setFieldsValue({
|
||||
password: cookies.get(value)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const that = this;
|
||||
return (
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
|
||||
{/* 用户名 (Email) */}
|
||||
<FormItem>
|
||||
{getFieldDecorator('email', {
|
||||
rules: [{ required: true, message: '请输入email!' }],
|
||||
onChange(e) {
|
||||
that.handleChange(e.target.value);
|
||||
}
|
||||
rules: [{ required: true, message: '请输入email!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
)}
|
||||
@ -78,14 +64,6 @@ class Login extends Component {
|
||||
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
</FormItem>
|
||||
|
||||
{/* 记住密码 */}
|
||||
{getFieldDecorator('remember', {
|
||||
valuePropName: 'checked',
|
||||
initialValue: true
|
||||
})(
|
||||
<Checkbox>记住密码</Checkbox>
|
||||
)}
|
||||
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import './login.scss'
|
||||
import './Login.scss'
|
||||
import React, { Component } from 'react'
|
||||
import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Tabs } from 'antd';
|
||||
import LoginForm from './login';
|
||||
import RegForm from './reg';
|
||||
import LoginForm from './Login';
|
||||
import RegForm from './Reg';
|
||||
const TabPane = Tabs.TabPane;
|
||||
|
||||
|
@ -1,94 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Form, Button, Input, Icon, Checkbox } from 'antd';
|
||||
import { loginActions } from '../../actions/login';
|
||||
import Cookies from 'universal-cookie';
|
||||
const cookies = new Cookies();
|
||||
const FormItem = Form.Item;
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
loginData: state.login
|
||||
}
|
||||
},
|
||||
{
|
||||
loginActions
|
||||
}
|
||||
)
|
||||
|
||||
class Login extends Component {
|
||||
constructor(props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
static propTypes = {
|
||||
form: PropTypes.object,
|
||||
loginActions: PropTypes.func
|
||||
}
|
||||
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
const form = this.props.form;
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
this.props.loginActions(values);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleChange = (value) => {
|
||||
if (cookies.get(value)) {
|
||||
this.props.form.setFieldsValue({
|
||||
password: cookies.get(value)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
const that = this;
|
||||
return (
|
||||
<Form onSubmit={this.handleSubmit}>
|
||||
|
||||
{/* 用户名 (Email) */}
|
||||
<FormItem>
|
||||
{getFieldDecorator('email', {
|
||||
rules: [{ required: true, message: '请输入email!' }],
|
||||
onChange(e) {
|
||||
that.handleChange(e.target.value);
|
||||
}
|
||||
})(
|
||||
<Input prefix={<Icon type="user" style={{ fontSize: 13 }} />} placeholder="Email" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{/* 密码 */}
|
||||
<FormItem>
|
||||
{getFieldDecorator('password', {
|
||||
rules: [{ required: true, message: '请输入密码!' }]
|
||||
})(
|
||||
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }} />} type="password" placeholder="Password" />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
|
||||
{/* 登录按钮 */}
|
||||
<FormItem>
|
||||
<Button type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
</FormItem>
|
||||
|
||||
{/* 记住密码 */}
|
||||
{getFieldDecorator('remember', {
|
||||
valuePropName: 'checked',
|
||||
initialValue: true
|
||||
})(
|
||||
<Checkbox>记住密码</Checkbox>
|
||||
)}
|
||||
|
||||
</Form>
|
||||
)
|
||||
}
|
||||
}
|
||||
const LoginForm = Form.create()(Login);
|
||||
export default LoginForm;
|
@ -12,8 +12,7 @@ const TYPE_EDIT = 'edit';
|
||||
import {
|
||||
fetchGroupList,
|
||||
setCurrGroup,
|
||||
addGroup,
|
||||
fetchProjectList
|
||||
setGroupList
|
||||
} from '../../../actions/group.js'
|
||||
|
||||
import './GroupList.scss'
|
||||
@ -26,8 +25,7 @@ import './GroupList.scss'
|
||||
{
|
||||
fetchGroupList,
|
||||
setCurrGroup,
|
||||
addGroup,
|
||||
fetchProjectList
|
||||
setGroupList
|
||||
}
|
||||
)
|
||||
export default class GroupList extends Component {
|
||||
@ -37,14 +35,17 @@ export default class GroupList extends Component {
|
||||
currGroup: PropTypes.object,
|
||||
fetchGroupList: PropTypes.func,
|
||||
setCurrGroup: PropTypes.func,
|
||||
fetchProjectList: PropTypes.func
|
||||
setGroupList: PropTypes.func
|
||||
}
|
||||
|
||||
state = {
|
||||
addGroupModalVisible: false,
|
||||
editGroupModalVisible: false,
|
||||
newGroupName: '',
|
||||
newGroupDesc: ''
|
||||
newGroupDesc: '',
|
||||
currGroupName: '',
|
||||
currGroupDesc: '',
|
||||
groupList: []
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -54,6 +55,7 @@ export default class GroupList extends Component {
|
||||
componentWillMount() {
|
||||
this.props.fetchGroupList().then(() => {
|
||||
const currGroup = this.props.groupList[0] || { group_name: '', group_desc: '' };
|
||||
this.setState({groupList: this.props.groupList});
|
||||
this.props.setCurrGroup(currGroup)
|
||||
});
|
||||
}
|
||||
@ -95,7 +97,9 @@ export default class GroupList extends Component {
|
||||
this.setState({
|
||||
addGroupModalVisible: false
|
||||
});
|
||||
this.props.fetchGroupList()
|
||||
this.props.fetchGroupList().then(() => {
|
||||
this.setState({groupList: this.props.groupList});
|
||||
})
|
||||
this.props.setCurrGroup(res.data.data)
|
||||
}
|
||||
});
|
||||
@ -154,6 +158,7 @@ export default class GroupList extends Component {
|
||||
message.success('删除成功');
|
||||
self.props.fetchGroupList().then(() => {
|
||||
const currGroup = self.props.groupList[0] || { group_name: '', group_desc: '' };
|
||||
self.setState({groupList: self.props.groupList});
|
||||
self.props.setCurrGroup(currGroup)
|
||||
});
|
||||
}
|
||||
@ -162,8 +167,19 @@ export default class GroupList extends Component {
|
||||
});
|
||||
}
|
||||
|
||||
@autobind
|
||||
searchGroup(e, value) {
|
||||
const v = value || e.target.value;
|
||||
const { groupList } = this.props;
|
||||
if (v === '') {
|
||||
this.setState({groupList})
|
||||
} else {
|
||||
this.setState({groupList: groupList.filter(group => new RegExp(v, 'i').test(group.group_name))})
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
const { groupList, currGroup } = this.props;
|
||||
const { currGroup } = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
@ -178,10 +194,7 @@ export default class GroupList extends Component {
|
||||
</div>
|
||||
<div className="group-operate">
|
||||
<div className="search">
|
||||
<Search
|
||||
placeholder="input search text"
|
||||
onSearch={value => console.log(value)}
|
||||
/>
|
||||
<Search onChange={this.searchGroup} onSearch={(v) => this.searchGroup(null, v)}/>
|
||||
</div>
|
||||
<Button type="primary" onClick={this.showModal}>添加分组</Button>
|
||||
</div>
|
||||
@ -192,7 +205,7 @@ export default class GroupList extends Component {
|
||||
selectedKeys={[`${currGroup._id}`]}
|
||||
>
|
||||
{
|
||||
groupList.map((group) => (
|
||||
this.state.groupList.map((group) => (
|
||||
<Menu.Item key={`${group._id}`} className="group-item">
|
||||
<Icon type="folder-open" />{group.group_name}
|
||||
</Menu.Item>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import React, { Component } from 'react';
|
||||
import GroupList from './GroupList/GroupList.js';
|
||||
import ProjectList from './ProjectList';
|
||||
import ProjectList from './ProjectList/ProjectList.js';
|
||||
import { Row, Col } from 'antd';
|
||||
|
||||
import './ProjectGroups.scss'
|
||||
|
@ -2,14 +2,17 @@ import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Table, Button, Modal, Form, Input, Icon, Tooltip, Select, Popconfirm, message } from 'antd';
|
||||
import { addProject, fetchProjectList, delProject } from '../../../actions/project';
|
||||
import { addProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../actions/project';
|
||||
import UpDateModal from './UpDateModal';
|
||||
import variable from '../../../constants/variable';
|
||||
import { autobind } from 'core-decorators';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
|
||||
import './ProjectList.scss'
|
||||
|
||||
const confirm = (id, handleDelete, currGroupId, handleFetchList) => {
|
||||
const deleteConfirm = (id, handleDelete, currGroupId, handleFetchList) => {
|
||||
const test = () => {
|
||||
handleDelete(id).then((res) => {
|
||||
console.log(res);
|
||||
@ -22,7 +25,7 @@ const confirm = (id, handleDelete, currGroupId, handleFetchList) => {
|
||||
return test;
|
||||
};
|
||||
|
||||
const getColumns = (data, handleDelete, currGroupId, handleFetchList) => {
|
||||
const getColumns = (data, handleDelete, currGroupId, handleFetchList, handleUpdateModal) => {
|
||||
return [{
|
||||
title: '项目名称',
|
||||
dataIndex: 'name',
|
||||
@ -39,13 +42,13 @@ const getColumns = (data, handleDelete, currGroupId, handleFetchList) => {
|
||||
}, {
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
render: (text, record) => {
|
||||
render: (text, record, index) => {
|
||||
const id = record._id;
|
||||
return (
|
||||
<span>
|
||||
<a href="#">修改</a>
|
||||
<a onClick={() => handleUpdateModal(true, index)}>修改</a>
|
||||
<span className="ant-divider" />
|
||||
<Popconfirm title="你确定要删除项目吗?" onConfirm={confirm(id, handleDelete, currGroupId, handleFetchList)} okText="删除" cancelText="取消">
|
||||
<Popconfirm title="你确定要删除项目吗?" onConfirm={deleteConfirm(id, handleDelete, currGroupId, handleFetchList)} okText="删除" cancelText="取消">
|
||||
<a href="#">删除</a>
|
||||
</Popconfirm>
|
||||
</span>
|
||||
@ -68,13 +71,18 @@ const formItemLayout = {
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
currGroup: state.group.currGroup
|
||||
tableLoading: state.project.tableLoading,
|
||||
currGroup: state.group.currGroup,
|
||||
total: state.project.total,
|
||||
currPage: state.project.currPage
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchProjectList,
|
||||
addProject,
|
||||
delProject
|
||||
delProject,
|
||||
changeUpdateModal,
|
||||
changeTableLoading
|
||||
}
|
||||
)
|
||||
class ProjectList extends Component {
|
||||
@ -82,7 +90,6 @@ class ProjectList extends Component {
|
||||
super(props);
|
||||
this.state = {
|
||||
visible: false,
|
||||
tabelLoading: true,
|
||||
protocol: 'http:\/\/',
|
||||
projectData: []
|
||||
}
|
||||
@ -92,50 +99,64 @@ class ProjectList extends Component {
|
||||
fetchProjectList: PropTypes.func,
|
||||
addProject: PropTypes.func,
|
||||
delProject: PropTypes.func,
|
||||
changeUpdateModal: PropTypes.func,
|
||||
changeTableLoading: PropTypes.func,
|
||||
projectList: PropTypes.array,
|
||||
currGroup: PropTypes.object
|
||||
tableLoading: PropTypes.bool,
|
||||
currGroup: PropTypes.object,
|
||||
total: PropTypes.number,
|
||||
currPage: PropTypes.number
|
||||
}
|
||||
showAddProjectModal = () => {
|
||||
|
||||
// 显示模态框 - 创建项目
|
||||
@autobind
|
||||
showAddProjectModal() {
|
||||
this.setState({
|
||||
visible: true
|
||||
});
|
||||
}
|
||||
handleOk = (e) => {
|
||||
|
||||
// 确认修改
|
||||
@autobind
|
||||
handleOk(e) {
|
||||
const { form, currGroup, changeTableLoading, addProject, fetchProjectList } = this.props;
|
||||
const that = this;
|
||||
e.preventDefault();
|
||||
this.props.form.validateFields((err, values) => {
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
values.prd_host = this.state.protocol + values.prd_host;
|
||||
|
||||
// 获取当前分组id传入values
|
||||
values.group_id = this.props.currGroup._id;
|
||||
values.group_id = currGroup._id;
|
||||
|
||||
console.log('Received values of form: ', values);
|
||||
this.setState({
|
||||
visible: false,
|
||||
tabelLoading: true
|
||||
});
|
||||
this.props.addProject(values).then((res) => {
|
||||
changeTableLoading(true);
|
||||
addProject(values).then((res) => {
|
||||
console.log(res);
|
||||
// 添加项目成功后再次请求列表
|
||||
this.props.fetchProjectList(this.props.currGroup._id).then((res) => {
|
||||
this.setState({
|
||||
tabelLoading: false
|
||||
if (res.payload.data.errcode == 0) {
|
||||
that.setState({
|
||||
visible: false
|
||||
});
|
||||
console.log(117,res);
|
||||
});
|
||||
form.resetFields();
|
||||
message.success('创建成功! ');
|
||||
fetchProjectList(currGroup._id, this.props.currPage).then((res) => {
|
||||
changeTableLoading(false);
|
||||
console.log(131,res);
|
||||
});
|
||||
} else {
|
||||
changeTableLoading(false);
|
||||
message.error(res.payload.data.errmsg);
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
this.setState({
|
||||
tabelLoading: false
|
||||
});
|
||||
changeTableLoading(false);
|
||||
});
|
||||
this.props.form.resetFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 取消修改
|
||||
handleCancel = () => {
|
||||
@autobind
|
||||
handleCancel() {
|
||||
this.props.form.resetFields();
|
||||
this.setState({
|
||||
visible: false
|
||||
@ -143,25 +164,33 @@ class ProjectList extends Component {
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
@autobind
|
||||
protocolChange(value) {
|
||||
this.setState({
|
||||
protocol: value
|
||||
})
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps){
|
||||
// 分页逻辑
|
||||
@autobind
|
||||
paginationChange(pageNum) {
|
||||
this.props.fetchProjectList(this.props.currGroup._id, pageNum).then((res) => {
|
||||
if (res.payload.data.errcode) {
|
||||
message.error(res.payload.data.errmsg);
|
||||
} else {
|
||||
this.props.changeTableLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// 切换分组
|
||||
if (this.props.currGroup !== nextProps.currGroup) {
|
||||
// const param = {
|
||||
// group_id: nextProps.currGroup._id
|
||||
// };
|
||||
this.props.fetchProjectList(nextProps.currGroup._id).then((res) => {
|
||||
this.props.fetchProjectList(nextProps.currGroup._id, this.props.currPage).then((res) => {
|
||||
if (res.payload.data.errcode) {
|
||||
message.error(res.payload.data.errmsg);
|
||||
} else {
|
||||
this.setState({
|
||||
tabelLoading: false
|
||||
});
|
||||
this.props.changeTableLoading(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -182,7 +211,7 @@ class ProjectList extends Component {
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
return (
|
||||
<div>
|
||||
<div className="m-container">
|
||||
<Modal
|
||||
title="创建项目"
|
||||
visible={this.state.visible}
|
||||
@ -230,7 +259,7 @@ class ProjectList extends Component {
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="URL"
|
||||
label="基本路径"
|
||||
>
|
||||
{getFieldDecorator('basepath', {
|
||||
rules: [{
|
||||
@ -255,11 +284,16 @@ class ProjectList extends Component {
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
<UpDateModal/>
|
||||
<Table
|
||||
loading={this.state.tabelLoading}
|
||||
columns={getColumns(this.state.projectData, this.props.delProject, this.props.currGroup._id, this.props.fetchProjectList)}
|
||||
loading={this.props.tableLoading}
|
||||
columns={getColumns(this.state.projectData, this.props.delProject, this.props.currGroup._id, this.props.fetchProjectList, this.props.changeUpdateModal)}
|
||||
dataSource={this.state.projectData}
|
||||
pagination={{
|
||||
total: this.props.total * variable.PAGE_LIMIT,
|
||||
defaultPageSize: variable.PAGE_LIMIT,
|
||||
onChange: this.paginationChange
|
||||
}}
|
||||
title={() => <Button type="primary" onClick={this.showAddProjectModal}>创建项目</Button>}
|
||||
/>
|
||||
|
@ -1,3 +1,26 @@
|
||||
.m-container{
|
||||
background-color: #fff;
|
||||
padding: 16px 24px;
|
||||
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.ant-input-group-wrapper {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.dynamic-delete-button {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
top: 4px;
|
||||
font-size: 24px;
|
||||
color: #999;
|
||||
transition: all .3s;
|
||||
}
|
||||
.dynamic-delete-button:hover {
|
||||
color: #777;
|
||||
}
|
||||
.dynamic-delete-button[disabled] {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
305
client/containers/ProjectGroups/ProjectList/UpDateModal.js
Normal file
305
client/containers/ProjectGroups/ProjectList/UpDateModal.js
Normal file
@ -0,0 +1,305 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { connect } from 'react-redux';
|
||||
import { Modal, Form, Input, Icon, Tooltip, Select, message, Button } from 'antd';
|
||||
import { updateProject, fetchProjectList, delProject, changeUpdateModal, changeTableLoading } from '../../../actions/project';
|
||||
const { TextArea } = Input;
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
|
||||
import './ProjectList.scss'
|
||||
|
||||
// layout
|
||||
const formItemLayout = {
|
||||
labelCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 6 }
|
||||
},
|
||||
wrapperCol: {
|
||||
xs: { span: 24 },
|
||||
sm: { span: 14 }
|
||||
}
|
||||
};
|
||||
const formItemLayoutWithOutLabel = {
|
||||
wrapperCol: {
|
||||
xs: { span: 24, offset: 0 },
|
||||
sm: { span: 20, offset: 4 }
|
||||
}
|
||||
};
|
||||
let uuid = 0;
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
projectList: state.project.projectList,
|
||||
isUpdateModalShow: state.project.isUpdateModalShow,
|
||||
handleUpdateIndex: state.project.handleUpdateIndex,
|
||||
tableLoading: state.project.tableLoading,
|
||||
currGroup: state.group.currGroup
|
||||
}
|
||||
},
|
||||
{
|
||||
fetchProjectList,
|
||||
updateProject,
|
||||
delProject,
|
||||
changeUpdateModal,
|
||||
changeTableLoading
|
||||
}
|
||||
)
|
||||
class UpDateModal extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
protocol: 'http:\/\/'
|
||||
}
|
||||
}
|
||||
static propTypes = {
|
||||
form: PropTypes.object,
|
||||
fetchProjectList: PropTypes.func,
|
||||
updateProject: PropTypes.func,
|
||||
delProject: PropTypes.func,
|
||||
changeUpdateModal: PropTypes.func,
|
||||
changeTableLoading: PropTypes.func,
|
||||
projectList: PropTypes.array,
|
||||
currGroup: PropTypes.object,
|
||||
isUpdateModalShow: PropTypes.bool,
|
||||
handleUpdateIndex: PropTypes.number
|
||||
}
|
||||
|
||||
// 修改线上域名的协议类型 (http/https)
|
||||
protocolChange = (value) => {
|
||||
this.setState({
|
||||
protocol: value
|
||||
})
|
||||
}
|
||||
|
||||
handleCancel = () => {
|
||||
this.props.form.resetFields();
|
||||
this.props.changeUpdateModal(false, -1);
|
||||
}
|
||||
|
||||
handleOk = (e) => {
|
||||
e.preventDefault();
|
||||
const { form, updateProject, changeUpdateModal, currGroup, projectList, handleUpdateIndex, fetchProjectList, changeTableLoading } = this.props;
|
||||
form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log(values);
|
||||
let assignValue = Object.assign(projectList[handleUpdateIndex], values);
|
||||
assignValue.prd_host = this.state.protocol + assignValue.prd_host;
|
||||
assignValue.env = assignValue.envs.map((item) => {
|
||||
console.log(assignValue);
|
||||
const arr = assignValue['envs-'+item].split(',');
|
||||
if (arr.length === 2) {
|
||||
return {
|
||||
host: arr[0],
|
||||
name: arr[1]
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log(assignValue);
|
||||
|
||||
changeTableLoading(true);
|
||||
updateProject(assignValue).then((res) => {
|
||||
if (res.payload.data.errcode == 0) {
|
||||
changeUpdateModal(false, -1);
|
||||
message.success('修改成功! ');
|
||||
fetchProjectList(currGroup._id).then((res) => {
|
||||
console.log(res);
|
||||
changeTableLoading(false);
|
||||
});
|
||||
} else {
|
||||
changeTableLoading(false);
|
||||
message.error(res.payload.data.errmsg);
|
||||
}
|
||||
}).catch((err) => {
|
||||
console.log(err);
|
||||
changeTableLoading(false);
|
||||
});
|
||||
form.resetFields();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
remove = (k) => {
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
// We need at least one passenger
|
||||
if (envs.length === 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// can use data-binding to set
|
||||
form.setFieldsValue({
|
||||
envs: envs.filter(key => key !== k)
|
||||
});
|
||||
}
|
||||
|
||||
add = () => {
|
||||
uuid++;
|
||||
const { form } = this.props;
|
||||
// can use data-binding to get
|
||||
const envs = form.getFieldValue('envs');
|
||||
const nextKeys = envs.concat(uuid);
|
||||
// can use data-binding to set
|
||||
// important! notify form to detect changes
|
||||
form.setFieldsValue({
|
||||
envs: nextKeys
|
||||
});
|
||||
}
|
||||
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log('Received values of form: ', values);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator, getFieldValue } = this.props.form;
|
||||
// const that = this;
|
||||
const { isUpdateModalShow, projectList, handleUpdateIndex } = this.props;
|
||||
let initFormValues = {};
|
||||
let envMessage = [];
|
||||
// 如果列表存在且用户点击修改按钮时,设置表单默认值
|
||||
if (projectList.length !== 0 && handleUpdateIndex !== -1 ) {
|
||||
// console.log(projectList[handleUpdateIndex]);
|
||||
const { name, basepath, desc, env } = projectList[handleUpdateIndex];
|
||||
initFormValues = { name, basepath, desc, env };
|
||||
if (env) {
|
||||
envMessage = env.map((item) => {
|
||||
return item.host + ',' + item.name;
|
||||
})
|
||||
}
|
||||
initFormValues.prd_host = projectList[handleUpdateIndex].prd_host.split('\/\/')[1];
|
||||
initFormValues.prd_protocol = projectList[handleUpdateIndex].prd_host.split('\/\/')[0] + '\/\/';
|
||||
}
|
||||
|
||||
getFieldDecorator('envs', { initialValue: envMessage });
|
||||
const envs = getFieldValue('envs');
|
||||
const formItems = envs.map((k, index) => {
|
||||
return (
|
||||
<FormItem
|
||||
{...(index === 0 ? formItemLayout : formItemLayoutWithOutLabel)}
|
||||
label={index === 0 ? (
|
||||
<span>环境配置
|
||||
<Tooltip title="依次输入环境域名(host)与环境名称,以英文逗号分隔">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>) : ''}
|
||||
required={false}
|
||||
key={k}
|
||||
>
|
||||
{getFieldDecorator(`envs-${k}`, {
|
||||
validateTrigger: ['onChange', 'onBlur'],
|
||||
initialValue: envMessage.length !== 0 ? k : '',
|
||||
rules: [{
|
||||
required: false,
|
||||
whitespace: true,
|
||||
message: "请输入环境配置,放弃配置请清空输入框"
|
||||
}]
|
||||
})(
|
||||
<Input placeholder="请输入环境配置" style={{ width: '60%', marginRight: 8 }} />
|
||||
)}
|
||||
{envs.length > 1 ? (
|
||||
<Icon
|
||||
className="dynamic-delete-button"
|
||||
type="minus-circle-o"
|
||||
disabled={envs.length === 1}
|
||||
onClick={() => this.remove(k)}
|
||||
/>
|
||||
) : null}
|
||||
</FormItem>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<Modal
|
||||
title="修改项目"
|
||||
visible={isUpdateModalShow}
|
||||
onOk={this.handleOk}
|
||||
onCancel={this.handleCancel}
|
||||
>
|
||||
<Form>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="项目名称"
|
||||
>
|
||||
{getFieldDecorator('name', {
|
||||
initialValue: initFormValues.name,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目名称!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label={(
|
||||
<span>
|
||||
线上域名
|
||||
<Tooltip title="将根据配置的线上域名访问mock数据">
|
||||
<Icon type="question-circle-o" />
|
||||
</Tooltip>
|
||||
</span>
|
||||
)}
|
||||
>
|
||||
{getFieldDecorator('prd_host', {
|
||||
initialValue: initFormValues.prd_host,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目线上域名!'
|
||||
}]
|
||||
})(
|
||||
<Input addonBefore={(
|
||||
<Select defaultValue={initFormValues.prd_protocol} onChange={this.protocolChange}>
|
||||
<Option value="http://">{'http:\/\/'}</Option>
|
||||
<Option value="https://">{'https:\/\/'}</Option>
|
||||
</Select>)} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="基本路径"
|
||||
>
|
||||
{getFieldDecorator('basepath', {
|
||||
initialValue: initFormValues.basepath,
|
||||
rules: [{
|
||||
required: true, message: '请输入项目基本路径!'
|
||||
}]
|
||||
})(
|
||||
<Input />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
<FormItem
|
||||
{...formItemLayout}
|
||||
label="描述"
|
||||
>
|
||||
{getFieldDecorator('desc', {
|
||||
initialValue: initFormValues.desc,
|
||||
rules: [{
|
||||
required: true, message: '请输入描述!'
|
||||
}]
|
||||
})(
|
||||
<TextArea rows={4} />
|
||||
)}
|
||||
</FormItem>
|
||||
|
||||
{formItems}
|
||||
<FormItem {...formItemLayoutWithOutLabel}>
|
||||
<Button type="dashed" onClick={this.add} style={{ width: '60%' }}>
|
||||
<Icon type="plus" /> 添加环境配置
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default Form.create()(UpDateModal);
|
@ -10,27 +10,39 @@ import {
|
||||
} from 'antd'
|
||||
import axios from 'axios';
|
||||
|
||||
const limit = 10;
|
||||
|
||||
class List extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
data: []
|
||||
data: [],
|
||||
total: null,
|
||||
current: 1
|
||||
}
|
||||
}
|
||||
|
||||
getUserList() {
|
||||
axios.get('/user/list').then((res) => {
|
||||
let result = res.data;
|
||||
changePage =(current)=>{
|
||||
this.setState({
|
||||
current: current
|
||||
}, this.getUserList)
|
||||
}
|
||||
|
||||
getUserList() {
|
||||
axios.get('/user/list?page=' + this.state.current).then((res) => {
|
||||
let result = res.data;
|
||||
|
||||
if (result.errcode === 0) {
|
||||
let list = result.data.list;
|
||||
let total = result.data.total * limit;
|
||||
list.map((item, index) => {
|
||||
item.key = index;
|
||||
item.up_time = formatTime(item.up_time)
|
||||
})
|
||||
this.setState({
|
||||
data: list
|
||||
data: list,
|
||||
total: total
|
||||
});
|
||||
}
|
||||
})
|
||||
@ -106,10 +118,17 @@ class List extends Component {
|
||||
return true;
|
||||
} )
|
||||
|
||||
const pageConfig = {
|
||||
total: this.state.total,
|
||||
pageSize: limit,
|
||||
current: this.state.current,
|
||||
onChange: this.changePage
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="user-table">
|
||||
|
||||
<Table columns={columns} dataSource={data} />
|
||||
<Table columns={columns} pagination={pageConfig} dataSource={data} />
|
||||
|
||||
</section>
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
import Home from './Home/Home.js'
|
||||
import Login from './Login/login-wrap.js'
|
||||
import Login from './Login/LoginWrap.js'
|
||||
import ProjectGroups from './ProjectGroups/ProjectGroups.js'
|
||||
import Interface from './Interface/Interface.js'
|
||||
import News from './News/News.js'
|
||||
|
@ -1,16 +1,35 @@
|
||||
import {
|
||||
FETCH_PROJECT_LIST,
|
||||
PROJECT_ADD,
|
||||
PROJECT_DEL
|
||||
PROJECT_DEL,
|
||||
CHANGE_UPDATE_MODAL,
|
||||
CHANGE_TABLE_LOADING
|
||||
} from '../../constants/action-types';
|
||||
|
||||
const initialState = {
|
||||
isUpdateModalShow: false,
|
||||
handleUpdateIndex: -1,
|
||||
projectList: [],
|
||||
total: null
|
||||
tableLoading: true,
|
||||
total: 0,
|
||||
currPage: 1
|
||||
};
|
||||
|
||||
export default (state = initialState, action) => {
|
||||
switch (action.type) {
|
||||
case CHANGE_UPDATE_MODAL: {
|
||||
return {
|
||||
...state,
|
||||
isUpdateModalShow: action.payload.data,
|
||||
handleUpdateIndex: action.payload.index
|
||||
};
|
||||
}
|
||||
case CHANGE_TABLE_LOADING: {
|
||||
return {
|
||||
...state,
|
||||
tableLoading: action.payload
|
||||
}
|
||||
}
|
||||
case FETCH_PROJECT_LIST: {
|
||||
return {
|
||||
...state,
|
||||
|
210
doc/build/api.html
vendored
210
doc/build/api.html
vendored
@ -321,7 +321,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#51" target="_blank">./server/controllers/group.js:51</a>
|
||||
<a href="./static/server/controllers/group.js.html#54" target="_blank">./server/controllers/group.js:54</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -383,7 +383,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#71" target="_blank">./server/controllers/group.js:71</a>
|
||||
<a href="./static/server/controllers/group.js.html#74" target="_blank">./server/controllers/group.js:74</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -455,7 +455,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/group.js.html#102" target="_blank">./server/controllers/group.js:102</a>
|
||||
<a href="./static/server/controllers/group.js.html#108" target="_blank">./server/controllers/group.js:108</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -906,7 +906,7 @@
|
||||
<tr>
|
||||
<td>limit</td>
|
||||
<td>Number</td>
|
||||
<td>分页大小</td>
|
||||
<td>分页大小,默认为10条</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
@ -1235,7 +1235,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#15" target="_blank">./server/controllers/project.js:15</a>
|
||||
<a href="./static/server/controllers/project.js.html#16" target="_blank">./server/controllers/project.js:16</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1296,6 +1296,18 @@
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>protocol</td>
|
||||
<td>String</td>
|
||||
<td>线上域名协议,不能为空</td>
|
||||
<td>
|
||||
|
||||
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
|
||||
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>group_id</td>
|
||||
<td>Number</td>
|
||||
@ -1364,7 +1376,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#77" target="_blank">./server/controllers/project.js:77</a>
|
||||
<a href="./static/server/controllers/project.js.html#80" target="_blank">./server/controllers/project.js:80</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1448,7 +1460,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#109" target="_blank">./server/controllers/project.js:109</a>
|
||||
<a href="./static/server/controllers/project.js.html#112" target="_blank">./server/controllers/project.js:112</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1532,7 +1544,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#142" target="_blank">./server/controllers/project.js:142</a>
|
||||
<a href="./static/server/controllers/project.js.html#145" target="_blank">./server/controllers/project.js:145</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1610,7 +1622,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#181" target="_blank">./server/controllers/project.js:181</a>
|
||||
<a href="./static/server/controllers/project.js.html#173" target="_blank">./server/controllers/project.js:173</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1693,7 +1705,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#205" target="_blank">./server/controllers/project.js:205</a>
|
||||
<a href="./static/server/controllers/project.js.html#197" target="_blank">./server/controllers/project.js:197</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1743,7 +1755,7 @@
|
||||
<tr>
|
||||
<td>limit</td>
|
||||
<td>Number</td>
|
||||
<td>分页大小</td>
|
||||
<td>每页数据条目,默认为10</td>
|
||||
<td>
|
||||
|
||||
</td>
|
||||
@ -1762,32 +1774,160 @@
|
||||
<span class="token string">"total"</span><span class="token punctuation">:</span> <span class="token number">2</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"list"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">133</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a1"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a2.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a1/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500004234</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500004234</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">529</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"yapi"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"aaa"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://www.yapi.com"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500465369</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500522419</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token string">"101"</span><span class="token punctuation">]</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">163</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"project_a2"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"project.a2.cc"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"/a2/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">101</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500006397</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500006397</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">558</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"12"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"21\n"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://11/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"12/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500466250</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500466250</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span><span class="token punctuation">[</span><span class="token string">"101"</span><span class="token punctuation">]</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">626</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"1233"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"123"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://1234/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"1234/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500471230</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500471230</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">665</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"222"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"222"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://222/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"222/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500471668</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500471668</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">704</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"333"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"222333"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://333/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"333/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500471674</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500471674</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">743</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"444"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"444"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"https://444/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"444/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500471695</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500471695</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">763</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"122333"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"3/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://33/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"33/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500481743</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500481743</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">778</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"555"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"555"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"https://555/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"555/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500519203</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500519203</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span><span class="token punctuation">,</span>
|
||||
<span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">823</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"name"</span><span class="token punctuation">:</span> <span class="token string">"5"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"desc"</span><span class="token punctuation">:</span> <span class="token string">"5"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"prd_host"</span><span class="token punctuation">:</span> <span class="token string">"http://5/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"basepath"</span><span class="token punctuation">:</span> <span class="token string">"5/"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"uid"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"group_id"</span><span class="token punctuation">:</span> <span class="token number">181</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500519769</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500519769</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"__v"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"env"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span><span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"members"</span><span class="token punctuation">:</span> <span class="token punctuation">[</span>
|
||||
<span class="token string">"107"</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">]</span>
|
||||
<span class="token punctuation">]</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"userinfo"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
<span class="token string">"107"</span><span class="token punctuation">:</span> <span class="token punctuation">{</span>
|
||||
<span class="token string">"_id"</span><span class="token punctuation">:</span> <span class="token number">107</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"username"</span><span class="token punctuation">:</span> <span class="token string">"admin"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"email"</span><span class="token punctuation">:</span> <span class="token string">"admin@admin.com"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"role"</span><span class="token punctuation">:</span> <span class="token string">"admin"</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"add_time"</span><span class="token punctuation">:</span> <span class="token number">1500280333</span><span class="token punctuation">,</span>
|
||||
<span class="token string">"up_time"</span><span class="token punctuation">:</span> <span class="token number">1500373530</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span>
|
||||
<span class="token punctuation">}</span></code></pre>
|
||||
|
||||
@ -1812,7 +1952,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#239" target="_blank">./server/controllers/project.js:239</a>
|
||||
<a href="./static/server/controllers/project.js.html#244" target="_blank">./server/controllers/project.js:244</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -1884,7 +2024,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#272" target="_blank">./server/controllers/project.js:272</a>
|
||||
<a href="./static/server/controllers/project.js.html#277" target="_blank">./server/controllers/project.js:277</a>
|
||||
</p>
|
||||
|
||||
|
||||
@ -2044,7 +2184,7 @@
|
||||
|
||||
<p>
|
||||
<small class="text-muted">源码位置:</small>
|
||||
<a href="./static/server/controllers/project.js.html#333" target="_blank">./server/controllers/project.js:333</a>
|
||||
<a href="./static/server/controllers/project.js.html#351" target="_blank">./server/controllers/project.js:351</a>
|
||||
</p>
|
||||
|
||||
|
||||
|
@ -50,6 +50,9 @@ class groupController extends baseController{
|
||||
*/
|
||||
async add(ctx) {
|
||||
let params = ctx.request.body;
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
if(!params.group_name){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组名不能为空');
|
||||
}
|
||||
@ -107,7 +110,10 @@ class groupController extends baseController{
|
||||
* @example ./api/group/del.json
|
||||
*/
|
||||
|
||||
async del(ctx){
|
||||
async del(ctx){
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
try{
|
||||
var groupInst = yapi.getInst(groupModel);
|
||||
var projectInst = yapi.getInst(projectModel);
|
||||
@ -115,7 +121,7 @@ class groupController extends baseController{
|
||||
if(!id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
|
||||
}
|
||||
let count = projectInst.countByGroupId(id);
|
||||
let count = await projectInst.countByGroupId(id);
|
||||
if(count > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 403, '请先删除该分组下的项目');
|
||||
}
|
||||
@ -141,13 +147,16 @@ class groupController extends baseController{
|
||||
*/
|
||||
|
||||
async up(ctx){
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
try{
|
||||
var groupInst = yapi.getInst(groupModel);
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
ctx.request.body.group_name && (data.group_name = ctx.request.body.group_name)
|
||||
ctx.request.body.group_desc && (data.group_desc = ctx.request.body.group_desc)
|
||||
if(Object.keys(data).length ===0){
|
||||
if(Object.keys(data).length === 0 ){
|
||||
ctx.body = yapi.commons.resReturn(null, 404, '分组名和分组描述不能为空');
|
||||
}
|
||||
let result = await groupInst.up(id, data);
|
||||
|
@ -31,6 +31,7 @@ import baseController from './base.js'
|
||||
import interfaceModel from '../models/interface.js'
|
||||
import groupModel from '../models/group'
|
||||
import commons from '../utils/commons.js'
|
||||
import userModel from '../models/user.js'
|
||||
|
||||
class projectController extends baseController {
|
||||
|
||||
@ -49,6 +50,7 @@ class projectController extends baseController {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} protocol 线上域名协议,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
@ -87,6 +89,7 @@ class projectController extends baseController {
|
||||
desc: params.desc,
|
||||
prd_host: params.prd_host,
|
||||
basepath: params.basepath,
|
||||
protocol: params.protocol || 'http',
|
||||
members: [this.getUid()],
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
@ -187,18 +190,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let project = await this.Model.get(params.id);
|
||||
let userInst = yapi.getInst(userModel);
|
||||
let result = [];
|
||||
|
||||
for(let i of project.members) {
|
||||
let user = await userInst.findById(i);
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
}
|
||||
let result = await userInst.findByUids(project.members);
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch(e) {
|
||||
@ -238,7 +230,7 @@ class projectController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 每页数据条目,默认为10
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
@ -254,10 +246,23 @@ class projectController extends baseController {
|
||||
|
||||
try{
|
||||
let result = await this.Model.listWithPaging(group_id, page, limit);
|
||||
let count = await this.Model.listCount();
|
||||
let count = await this.Model.listCount(group_id);
|
||||
let uids = [];
|
||||
result.forEach( (item)=> {
|
||||
if(uids.indexOf(item.uid) !== -1){
|
||||
uids.push(item.uid)
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
|
||||
users.forEach((item)=> {
|
||||
_users[item._id] = item;
|
||||
} )
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: count,
|
||||
list: result
|
||||
total: Math.ceil(count / limit),
|
||||
list: result,
|
||||
userinfo: _users
|
||||
})
|
||||
}catch(err){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
@ -319,10 +324,22 @@ class projectController extends baseController {
|
||||
try{
|
||||
let id = ctx.request.body.id;
|
||||
let params = ctx.request.body;
|
||||
if(!id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
|
||||
if(await this.jungeMemberAuth(id, this.getUid()) !== true){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
let projectData = await this.Model.get(id);
|
||||
if(projectData.name === params.name){
|
||||
delete params.name;
|
||||
}
|
||||
if(projectData.basepath === params.basepath && projectData.prd_host === params.prd_host){
|
||||
delete params.basepath
|
||||
delete params.prd_host
|
||||
}
|
||||
|
||||
if(params.name){
|
||||
let checkRepeat = await this.Model.checkNameRepeat(params.name);
|
||||
@ -349,6 +366,7 @@ class projectController extends baseController {
|
||||
data.prd_host = params.prd_host;
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if(params.protocol) data.protocol = params.protocol;
|
||||
if(params.env) data.env = params.env;
|
||||
|
||||
let result = await this.Model.up(id, data);
|
||||
|
@ -318,7 +318,7 @@ class userController extends baseController {
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 分页大小,默认为10条
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -332,7 +332,7 @@ class userController extends baseController {
|
||||
let user = await userInst.listWithPaging(page, limit);
|
||||
let count = await userInst.listCount();
|
||||
return ctx.body = yapi.commons.resReturn({
|
||||
total: count,
|
||||
total: Math.ceil(count / limit),
|
||||
list: user
|
||||
});
|
||||
} catch(e) {
|
||||
|
@ -3,6 +3,7 @@
|
||||
//header Content-Type:application/json
|
||||
|
||||
{
|
||||
"title": "testapi",
|
||||
"desc": "api",
|
||||
"method": "post",
|
||||
"path": "/testapi",
|
||||
@ -37,6 +38,7 @@
|
||||
"data": {
|
||||
"__v": 0,
|
||||
"_id": 422,
|
||||
"title": "testapi",
|
||||
"project_id": 8,
|
||||
"path": "/testapi",
|
||||
"desc": "api",
|
||||
|
@ -5,31 +5,159 @@
|
||||
"total": 2,
|
||||
"list": [
|
||||
{
|
||||
"_id": 133,
|
||||
"name": "project_a1",
|
||||
"prd_host": "project.a2.cc",
|
||||
"basepath": "/a1/",
|
||||
"uid": 101,
|
||||
"group_id": 101,
|
||||
"add_time": 1500004234,
|
||||
"up_time": 1500004234,
|
||||
"_id": 529,
|
||||
"name": "yapi",
|
||||
"desc": "aaa",
|
||||
"prd_host": "http://www.yapi.com",
|
||||
"basepath": "/a/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500465369,
|
||||
"up_time": 1500522419,
|
||||
"__v": 0,
|
||||
"env":[],
|
||||
"members":["101"]
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 163,
|
||||
"name": "project_a2",
|
||||
"prd_host": "project.a2.cc",
|
||||
"basepath": "/a2/",
|
||||
"uid": 101,
|
||||
"group_id": 101,
|
||||
"add_time": 1500006397,
|
||||
"up_time": 1500006397,
|
||||
"_id": 558,
|
||||
"name": "12",
|
||||
"desc": "21\n",
|
||||
"prd_host": "http://11/",
|
||||
"basepath": "12/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500466250,
|
||||
"up_time": 1500466250,
|
||||
"__v": 0,
|
||||
"env":[],
|
||||
"members":["101"]
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 626,
|
||||
"name": "1233",
|
||||
"desc": "123",
|
||||
"prd_host": "http://1234/",
|
||||
"basepath": "1234/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500471230,
|
||||
"up_time": 1500471230,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 665,
|
||||
"name": "222",
|
||||
"desc": "222",
|
||||
"prd_host": "http://222/",
|
||||
"basepath": "222/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500471668,
|
||||
"up_time": 1500471668,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 704,
|
||||
"name": "333",
|
||||
"desc": "222333",
|
||||
"prd_host": "http://333/",
|
||||
"basepath": "333/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500471674,
|
||||
"up_time": 1500471674,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 743,
|
||||
"name": "444",
|
||||
"desc": "444",
|
||||
"prd_host": "https://444/",
|
||||
"basepath": "444/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500471695,
|
||||
"up_time": 1500471695,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 763,
|
||||
"name": "122333",
|
||||
"desc": "3/",
|
||||
"prd_host": "http://33/",
|
||||
"basepath": "33/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500481743,
|
||||
"up_time": 1500481743,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 778,
|
||||
"name": "555",
|
||||
"desc": "555",
|
||||
"prd_host": "https://555/",
|
||||
"basepath": "555/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500519203,
|
||||
"up_time": 1500519203,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
},
|
||||
{
|
||||
"_id": 823,
|
||||
"name": "5",
|
||||
"desc": "5",
|
||||
"prd_host": "http://5/",
|
||||
"basepath": "5/",
|
||||
"uid": 107,
|
||||
"group_id": 181,
|
||||
"add_time": 1500519769,
|
||||
"up_time": 1500519769,
|
||||
"__v": 0,
|
||||
"env": [],
|
||||
"members": [
|
||||
"107"
|
||||
]
|
||||
}
|
||||
]
|
||||
],
|
||||
"userinfo": {
|
||||
"107": {
|
||||
"_id": 107,
|
||||
"username": "admin",
|
||||
"email": "admin@admin.com",
|
||||
"role": "admin",
|
||||
"add_time": 1500280333,
|
||||
"up_time": 1500373530
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -23,6 +23,9 @@ class groupController extends baseController{
|
||||
*/
|
||||
async add(ctx) {
|
||||
let params = ctx.request.body;
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
if(!params.group_name){
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目分组名不能为空');
|
||||
}
|
||||
@ -80,7 +83,10 @@ class groupController extends baseController{
|
||||
* @example ./api/group/del.json
|
||||
*/
|
||||
|
||||
async del(ctx){
|
||||
async del(ctx){
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
try{
|
||||
var groupInst = yapi.getInst(groupModel);
|
||||
var projectInst = yapi.getInst(projectModel);
|
||||
@ -88,7 +94,7 @@ class groupController extends baseController{
|
||||
if(!id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 402, 'id不能为空');
|
||||
}
|
||||
let count = projectInst.countByGroupId(id);
|
||||
let count = await projectInst.countByGroupId(id);
|
||||
if(count > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 403, '请先删除该分组下的项目');
|
||||
}
|
||||
@ -114,13 +120,16 @@ class groupController extends baseController{
|
||||
*/
|
||||
|
||||
async up(ctx){
|
||||
if(this.getRole() !== 'admin'){
|
||||
return ctx.body = yapi.commons.resReturn(null,401,'没有权限');
|
||||
}
|
||||
try{
|
||||
var groupInst = yapi.getInst(groupModel);
|
||||
let id = ctx.request.body.id;
|
||||
let data = {};
|
||||
ctx.request.body.group_name && (data.group_name = ctx.request.body.group_name)
|
||||
ctx.request.body.group_desc && (data.group_desc = ctx.request.body.group_desc)
|
||||
if(Object.keys(data).length ===0){
|
||||
if(Object.keys(data).length === 0 ){
|
||||
ctx.body = yapi.commons.resReturn(null, 404, '分组名和分组描述不能为空');
|
||||
}
|
||||
let result = await groupInst.up(id, data);
|
||||
|
@ -15,6 +15,7 @@ class interfaceController extends baseController{
|
||||
* @category interface
|
||||
* @foldnumber 10
|
||||
* @param {Number} project_id 项目id,不能为空
|
||||
* @param {String} title 接口标题,不能为空
|
||||
* @param {String} path 接口请求路径,不能为空
|
||||
* @param {String} method 请求方式
|
||||
* @param {Array} [req_headers] 请求的header信息
|
||||
@ -65,8 +66,8 @@ class interfaceController extends baseController{
|
||||
up_time: yapi.commons.time()
|
||||
}
|
||||
|
||||
if(data.req_params_type === 'form') data.req_params_form = params.req_params;
|
||||
else data.req_params_other = params.req_params;
|
||||
if(params.req_params_form) data.req_params_form = params.req_params_form;
|
||||
if(params.req_params_other) data.req_params_other = params.req_params_other;
|
||||
|
||||
let result = await this.Model.save(data);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
@ -167,13 +168,14 @@ class interfaceController extends baseController{
|
||||
}
|
||||
|
||||
if(params.path) data.path = params.path;
|
||||
if(params.title) data.title = params.title;
|
||||
if(params.desc) data.desc = params.desc;
|
||||
if(params.method) data.method = params.method;
|
||||
|
||||
if(params.req_headers) data.req_headers = params.req_headers;
|
||||
|
||||
if(params.req_params_type === 'form') data.req_params_form = params.req_params;
|
||||
else data.req_params_other = params.req_params;
|
||||
if(params.req_params_form) data.req_params_form = params.req_params_form;
|
||||
if(params.req_params_other) data.req_params_other = params.req_params_other;
|
||||
|
||||
if(params.res_body_type) data.res_body_type = params.res_body_type;
|
||||
if(params.res_body) data.res_body = params.res_body;
|
||||
|
@ -4,6 +4,7 @@ import baseController from './base.js'
|
||||
import interfaceModel from '../models/interface.js'
|
||||
import groupModel from '../models/group'
|
||||
import commons from '../utils/commons.js'
|
||||
import userModel from '../models/user.js'
|
||||
|
||||
class projectController extends baseController {
|
||||
|
||||
@ -13,6 +14,32 @@ class projectController extends baseController {
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
}
|
||||
|
||||
handleBasepath(basepath){
|
||||
if(!basepath) return false;
|
||||
if(basepath[0] !== '/') basepath = '/' + basepath;
|
||||
if(basepath[basepath.length -1] === '/') basepath = basepath.substr(0, basepath.length -1)
|
||||
if(!this.verifyPath(basepath)){
|
||||
return false;
|
||||
}
|
||||
return basepath;
|
||||
}
|
||||
|
||||
verifyPath(path){
|
||||
if(/^[a-zA-Z0-9\-\/_:]+$/.test(basepath)){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
verifyDomain(domain){
|
||||
if(!domain) return false;
|
||||
if(/^[a-zA-Z0-9\-_\.]+[a-zA-Z]{2,6}$/.test(domain)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加项目分组
|
||||
* @interface /project/add
|
||||
@ -22,6 +49,7 @@ class projectController extends baseController {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} protocol 线上域名协议,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
@ -50,16 +78,26 @@ class projectController extends baseController {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目domain不能为空');
|
||||
}
|
||||
|
||||
if(params.basepath = (this.handleBasepath(params.basepath)) === false){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, 'basepath格式有误')
|
||||
}
|
||||
|
||||
if(!this.verifyDomain(params.prd_host)){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '线上域名格式有误')
|
||||
}
|
||||
|
||||
let checkRepeatDomain = await this.Model.checkDomainRepeat(params.prd_host, params.basepath);
|
||||
if(checkRepeatDomain > 0){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '已存在domain和basepath');
|
||||
}
|
||||
|
||||
|
||||
let data = {
|
||||
name: params.name,
|
||||
desc: params.desc,
|
||||
prd_host: params.prd_host,
|
||||
basepath: params.basepath,
|
||||
protocol: params.protocol || 'http',
|
||||
members: [this.getUid()],
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
@ -160,18 +198,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let project = await this.Model.get(params.id);
|
||||
let userInst = yapi.getInst(userModel);
|
||||
let result = [];
|
||||
|
||||
for(let i of project.members) {
|
||||
let user = await userInst.findById(i);
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
}
|
||||
let result = await userInst.findByUids(project.members);
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch(e) {
|
||||
@ -211,7 +238,7 @@ class projectController extends baseController {
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 每页数据条目,默认为10
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
@ -227,10 +254,23 @@ class projectController extends baseController {
|
||||
|
||||
try{
|
||||
let result = await this.Model.listWithPaging(group_id, page, limit);
|
||||
let count = await this.Model.listCount();
|
||||
let count = await this.Model.listCount(group_id);
|
||||
let uids = [];
|
||||
result.forEach( (item)=> {
|
||||
if(uids.indexOf(item.uid) !== -1){
|
||||
uids.push(item.uid)
|
||||
}
|
||||
|
||||
} )
|
||||
|
||||
let _users = {}, users = await yapi.getInst(userModel).findByUids(uids);
|
||||
users.forEach((item)=> {
|
||||
_users[item._id] = item;
|
||||
} )
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: count,
|
||||
list: result
|
||||
total: Math.ceil(count / limit),
|
||||
list: result,
|
||||
userinfo: _users
|
||||
})
|
||||
}catch(err){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
@ -292,10 +332,31 @@ class projectController extends baseController {
|
||||
try{
|
||||
let id = ctx.request.body.id;
|
||||
let params = ctx.request.body;
|
||||
if(!id){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
|
||||
}
|
||||
|
||||
if(await this.jungeMemberAuth(id, this.getUid()) !== true){
|
||||
return ctx.body = yapi.commons.resReturn(null, 405, '没有权限');
|
||||
}
|
||||
|
||||
let projectData = await this.Model.get(id);
|
||||
|
||||
if(params.basepath = (this.handleBasepath(params.basepath)) === false){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, 'basepath格式有误')
|
||||
}
|
||||
|
||||
if(!this.verifyDomain(params.prd_host)){
|
||||
return ctx.body = yapi.commons.resReturn(null, 401, '线上域名格式有误')
|
||||
}
|
||||
|
||||
if(projectData.name === params.name){
|
||||
delete params.name;
|
||||
}
|
||||
if(projectData.basepath === params.basepath && projectData.prd_host === params.prd_host){
|
||||
delete params.basepath
|
||||
delete params.prd_host
|
||||
}
|
||||
|
||||
if(params.name){
|
||||
let checkRepeat = await this.Model.checkNameRepeat(params.name);
|
||||
@ -322,6 +383,7 @@ class projectController extends baseController {
|
||||
data.prd_host = params.prd_host;
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if(params.protocol) data.protocol = params.protocol;
|
||||
if(params.env) data.env = params.env;
|
||||
|
||||
let result = await this.Model.up(id, data);
|
||||
|
@ -291,7 +291,7 @@ class userController extends baseController {
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 分页大小,默认为10条
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -305,7 +305,7 @@ class userController extends baseController {
|
||||
let user = await userInst.listWithPaging(page, limit);
|
||||
let count = await userInst.listCount();
|
||||
return ctx.body = yapi.commons.resReturn({
|
||||
total: count,
|
||||
total: Math.ceil(count / limit),
|
||||
list: user
|
||||
});
|
||||
} catch(e) {
|
||||
|
@ -5,7 +5,7 @@ import Mock from 'mockjs'
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
yapi.commons.log('mock Server running...')
|
||||
let hostname = ctx.protocol + "://" + ctx.hostname;
|
||||
let hostname = ctx.hostname;
|
||||
let config = yapi.WEBCONFIG;
|
||||
if(ctx.hostname === config.webhost){
|
||||
if(next) await next();
|
||||
|
@ -8,13 +8,9 @@ class interfaceModel extends baseModel{
|
||||
|
||||
getSchema(){
|
||||
return {
|
||||
title: {type: String, required: true},
|
||||
uid: {type: Number, required: true},
|
||||
path: {type: String, required: true, validate: {
|
||||
validator: (v) => {
|
||||
return v && v[0] !== '/';
|
||||
},
|
||||
message: '接口路径第一位不能是/'
|
||||
}},
|
||||
path: {type: String, required: true},
|
||||
method: {type: String, required: true},
|
||||
project_id: {type: Number, required: true},
|
||||
desc: String,
|
||||
|
@ -12,13 +12,14 @@ class projectModel extends baseModel{
|
||||
name: {type: String, required: true},
|
||||
basepath: {type: String, required: true, validate: {
|
||||
validator: (v) => {
|
||||
return v && v[v.length - 1] === '/'
|
||||
return v && v[0] === '/'
|
||||
},
|
||||
message: 'basepath字符串结尾必须是/'
|
||||
message: 'basepath必须是/开头'
|
||||
}},
|
||||
desc: String,
|
||||
group_id: {type: Number, required: true},
|
||||
members: Array,
|
||||
members: Array,
|
||||
protocol: {type: String, required: true},
|
||||
prd_host: {type: String, required: true},
|
||||
env: [
|
||||
{name: String, domain: String}
|
||||
@ -74,8 +75,10 @@ class projectModel extends baseModel{
|
||||
}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}
|
||||
|
||||
listCount() {
|
||||
return this.model.count();
|
||||
listCount(group_id) {
|
||||
return this.model.count({
|
||||
group_id: group_id
|
||||
});
|
||||
}
|
||||
|
||||
countByGroupId(group_id){
|
||||
|
@ -39,6 +39,11 @@ class userModel extends baseModel{
|
||||
list(){
|
||||
return this.model.find().select("_id username email role add_time up_time").exec() //显示id name email role
|
||||
}
|
||||
findByUids(uids){
|
||||
return this.model.find({
|
||||
_id: {$in: [107]}
|
||||
}).select("_id username email role add_time up_time").exec()
|
||||
}
|
||||
listWithPaging(page, limit) {
|
||||
page = parseInt(page);
|
||||
limit = parseInt(limit);
|
||||
|
@ -83,29 +83,37 @@ var groupController = function (_baseController) {
|
||||
case 0:
|
||||
params = ctx.request.body;
|
||||
|
||||
if (params.group_name) {
|
||||
if (!(this.getRole() !== 'admin')) {
|
||||
_context.next = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '没有权限'));
|
||||
|
||||
case 3:
|
||||
if (params.group_name) {
|
||||
_context.next = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目分组名不能为空'));
|
||||
|
||||
case 3:
|
||||
case 5:
|
||||
groupInst = _yapi2.default.getInst(_group2.default);
|
||||
_context.next = 6;
|
||||
_context.next = 8;
|
||||
return groupInst.checkRepeat(params.group_name);
|
||||
|
||||
case 6:
|
||||
case 8:
|
||||
checkRepeat = _context.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context.next = 9;
|
||||
_context.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '项目分组名已存在'));
|
||||
|
||||
case 9:
|
||||
case 11:
|
||||
data = {
|
||||
group_name: params.group_name,
|
||||
group_desc: params.group_desc,
|
||||
@ -113,30 +121,30 @@ var groupController = function (_baseController) {
|
||||
add_time: _yapi2.default.commons.time(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
};
|
||||
_context.prev = 10;
|
||||
_context.next = 13;
|
||||
_context.prev = 12;
|
||||
_context.next = 15;
|
||||
return groupInst.save(data);
|
||||
|
||||
case 13:
|
||||
case 15:
|
||||
result = _context.sent;
|
||||
|
||||
result = _yapi2.default.commons.fieldSelect(result, ['_id', 'group_name', 'group_desc', 'uid']);
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 21;
|
||||
_context.next = 23;
|
||||
break;
|
||||
|
||||
case 18:
|
||||
_context.prev = 18;
|
||||
_context.t0 = _context['catch'](10);
|
||||
case 20:
|
||||
_context.prev = 20;
|
||||
_context.t0 = _context['catch'](12);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 21:
|
||||
case 23:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[10, 18]]);
|
||||
}, _callee, this, [[12, 20]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -218,51 +226,63 @@ var groupController = function (_baseController) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
_context3.prev = 0;
|
||||
if (!(this.getRole() !== 'admin')) {
|
||||
_context3.next = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '没有权限'));
|
||||
|
||||
case 2:
|
||||
_context3.prev = 2;
|
||||
groupInst = _yapi2.default.getInst(_group2.default);
|
||||
projectInst = _yapi2.default.getInst(_project2.default);
|
||||
id = ctx.request.body.id;
|
||||
|
||||
if (id) {
|
||||
_context3.next = 6;
|
||||
_context3.next = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 402, 'id不能为空'));
|
||||
|
||||
case 6:
|
||||
count = projectInst.countByGroupId(id);
|
||||
case 8:
|
||||
_context3.next = 10;
|
||||
return projectInst.countByGroupId(id);
|
||||
|
||||
case 10:
|
||||
count = _context3.sent;
|
||||
|
||||
if (!(count > 0)) {
|
||||
_context3.next = 9;
|
||||
_context3.next = 13;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 403, '请先删除该分组下的项目'));
|
||||
|
||||
case 9:
|
||||
_context3.next = 11;
|
||||
case 13:
|
||||
_context3.next = 15;
|
||||
return groupInst.del(id);
|
||||
|
||||
case 11:
|
||||
case 15:
|
||||
result = _context3.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 18;
|
||||
_context3.next = 22;
|
||||
break;
|
||||
|
||||
case 15:
|
||||
_context3.prev = 15;
|
||||
_context3.t0 = _context3['catch'](0);
|
||||
case 19:
|
||||
_context3.prev = 19;
|
||||
_context3.t0 = _context3['catch'](2);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
|
||||
case 18:
|
||||
case 22:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[0, 15]]);
|
||||
}, _callee3, this, [[2, 19]]);
|
||||
}));
|
||||
|
||||
function del(_x3) {
|
||||
@ -294,7 +314,15 @@ var groupController = function (_baseController) {
|
||||
while (1) {
|
||||
switch (_context4.prev = _context4.next) {
|
||||
case 0:
|
||||
_context4.prev = 0;
|
||||
if (!(this.getRole() !== 'admin')) {
|
||||
_context4.next = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context4.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '没有权限'));
|
||||
|
||||
case 2:
|
||||
_context4.prev = 2;
|
||||
groupInst = _yapi2.default.getInst(_group2.default);
|
||||
id = ctx.request.body.id;
|
||||
data = {};
|
||||
@ -304,28 +332,28 @@ var groupController = function (_baseController) {
|
||||
if ((0, _keys2.default)(data).length === 0) {
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 404, '分组名和分组描述不能为空');
|
||||
}
|
||||
_context4.next = 9;
|
||||
_context4.next = 11;
|
||||
return groupInst.up(id, data);
|
||||
|
||||
case 9:
|
||||
case 11:
|
||||
result = _context4.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context4.next = 16;
|
||||
_context4.next = 18;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context4.prev = 13;
|
||||
_context4.t0 = _context4['catch'](0);
|
||||
case 15:
|
||||
_context4.prev = 15;
|
||||
_context4.t0 = _context4['catch'](2);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
|
||||
case 16:
|
||||
case 18:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[0, 13]]);
|
||||
}, _callee4, this, [[2, 15]]);
|
||||
}));
|
||||
|
||||
function up(_x4) {
|
||||
|
@ -1,9 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
var _getIterator2 = require('babel-runtime/core-js/get-iterator');
|
||||
|
||||
var _getIterator3 = _interopRequireDefault(_getIterator2);
|
||||
|
||||
var _regenerator = require('babel-runtime/regenerator');
|
||||
|
||||
var _regenerator2 = _interopRequireDefault(_regenerator);
|
||||
@ -56,6 +52,10 @@ var _commons = require('../utils/commons.js');
|
||||
|
||||
var _commons2 = _interopRequireDefault(_commons);
|
||||
|
||||
var _user = require('../models/user.js');
|
||||
|
||||
var _user2 = _interopRequireDefault(_user);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var projectController = function (_baseController) {
|
||||
@ -80,6 +80,7 @@ var projectController = function (_baseController) {
|
||||
* @param {String} name 项目名称,不能为空
|
||||
* @param {String} basepath 项目基本路径,不能为空
|
||||
* @param {String} prd_host 项目线上域名,不能为空。可通过配置的域名访问到mock数据
|
||||
* @param {String} protocol 线上域名协议,不能为空
|
||||
* @param {Number} group_id 项目分组id,不能为空
|
||||
* @param {String} [desc] 项目描述
|
||||
* @returns {Object}
|
||||
@ -163,6 +164,7 @@ var projectController = function (_baseController) {
|
||||
desc: params.desc,
|
||||
prd_host: params.prd_host,
|
||||
basepath: params.basepath,
|
||||
protocol: params.protocol || 'http',
|
||||
members: [this.getUid()],
|
||||
uid: this.getUid(),
|
||||
group_id: params.group_id,
|
||||
@ -384,8 +386,7 @@ var projectController = function (_baseController) {
|
||||
key: 'getMemberList',
|
||||
value: function () {
|
||||
var _ref4 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee4(ctx) {
|
||||
var params, project, userInst, result, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, i, user;
|
||||
|
||||
var params, project, userInst, result;
|
||||
return _regenerator2.default.wrap(function _callee4$(_context4) {
|
||||
while (1) {
|
||||
switch (_context4.prev = _context4.next) {
|
||||
@ -406,92 +407,30 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 6:
|
||||
project = _context4.sent;
|
||||
userInst = _yapi2.default.getInst(userModel);
|
||||
result = [];
|
||||
_iteratorNormalCompletion = true;
|
||||
_didIteratorError = false;
|
||||
_iteratorError = undefined;
|
||||
_context4.prev = 12;
|
||||
_iterator = (0, _getIterator3.default)(project.members);
|
||||
userInst = _yapi2.default.getInst(_user2.default);
|
||||
_context4.next = 10;
|
||||
return userInst.findByUids(project.members);
|
||||
|
||||
case 14:
|
||||
if (_iteratorNormalCompletion = (_step = _iterator.next()).done) {
|
||||
_context4.next = 23;
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
result = _context4.sent;
|
||||
|
||||
i = _step.value;
|
||||
_context4.next = 18;
|
||||
return userInst.findById(i);
|
||||
|
||||
case 18:
|
||||
user = _context4.sent;
|
||||
|
||||
result.push({
|
||||
_id: user._id,
|
||||
email: user.email,
|
||||
role: user.role,
|
||||
add_time: user.add_time,
|
||||
up_time: user.up_time
|
||||
});
|
||||
|
||||
case 20:
|
||||
_iteratorNormalCompletion = true;
|
||||
_context4.next = 14;
|
||||
break;
|
||||
|
||||
case 23:
|
||||
_context4.next = 29;
|
||||
break;
|
||||
|
||||
case 25:
|
||||
_context4.prev = 25;
|
||||
_context4.t0 = _context4['catch'](12);
|
||||
_didIteratorError = true;
|
||||
_iteratorError = _context4.t0;
|
||||
|
||||
case 29:
|
||||
_context4.prev = 29;
|
||||
_context4.prev = 30;
|
||||
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
|
||||
case 32:
|
||||
_context4.prev = 32;
|
||||
|
||||
if (!_didIteratorError) {
|
||||
_context4.next = 35;
|
||||
break;
|
||||
}
|
||||
|
||||
throw _iteratorError;
|
||||
|
||||
case 35:
|
||||
return _context4.finish(32);
|
||||
|
||||
case 36:
|
||||
return _context4.finish(29);
|
||||
|
||||
case 37:
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context4.next = 43;
|
||||
_context4.next = 17;
|
||||
break;
|
||||
|
||||
case 40:
|
||||
_context4.prev = 40;
|
||||
_context4.t1 = _context4['catch'](3);
|
||||
case 14:
|
||||
_context4.prev = 14;
|
||||
_context4.t0 = _context4['catch'](3);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t1.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context4.t0.message);
|
||||
|
||||
case 43:
|
||||
case 17:
|
||||
case 'end':
|
||||
return _context4.stop();
|
||||
}
|
||||
}
|
||||
}, _callee4, this, [[3, 40], [12, 25, 29, 37], [30,, 32, 36]]);
|
||||
}, _callee4, this, [[3, 14]]);
|
||||
}));
|
||||
|
||||
function getMemberList(_x4) {
|
||||
@ -571,7 +510,7 @@ var projectController = function (_baseController) {
|
||||
* @foldnumber 10
|
||||
* @param {Number} group_id 项目group_id,不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 每页数据条目,默认为10
|
||||
* @returns {Object}
|
||||
* @example ./api/project/list.json
|
||||
*/
|
||||
@ -580,7 +519,8 @@ var projectController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref6 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee6(ctx) {
|
||||
var group_id, page, limit, result, count;
|
||||
var group_id, page, limit, result, count, uids, _users, users;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee6$(_context6) {
|
||||
while (1) {
|
||||
switch (_context6.prev = _context6.next) {
|
||||
@ -602,30 +542,48 @@ var projectController = function (_baseController) {
|
||||
case 6:
|
||||
result = _context6.sent;
|
||||
_context6.next = 9;
|
||||
return this.Model.listCount();
|
||||
return this.Model.listCount(group_id);
|
||||
|
||||
case 9:
|
||||
count = _context6.sent;
|
||||
uids = [];
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn({
|
||||
total: count,
|
||||
list: result
|
||||
result.forEach(function (item) {
|
||||
if (uids.indexOf(item.uid) !== -1) {
|
||||
uids.push(item.uid);
|
||||
}
|
||||
});
|
||||
_context6.next = 16;
|
||||
|
||||
_users = {};
|
||||
_context6.next = 15;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(uids);
|
||||
|
||||
case 15:
|
||||
users = _context6.sent;
|
||||
|
||||
users.forEach(function (item) {
|
||||
_users[item._id] = item;
|
||||
});
|
||||
ctx.body = _yapi2.default.commons.resReturn({
|
||||
total: Math.ceil(count / limit),
|
||||
list: result,
|
||||
userinfo: _users
|
||||
});
|
||||
_context6.next = 23;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context6.prev = 13;
|
||||
case 20:
|
||||
_context6.prev = 20;
|
||||
_context6.t0 = _context6['catch'](3);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, e.message);
|
||||
|
||||
case 16:
|
||||
case 23:
|
||||
case 'end':
|
||||
return _context6.stop();
|
||||
}
|
||||
}
|
||||
}, _callee6, this, [[3, 13]]);
|
||||
}, _callee6, this, [[3, 20]]);
|
||||
}));
|
||||
|
||||
function list(_x6) {
|
||||
@ -748,7 +706,7 @@ var projectController = function (_baseController) {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref8 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee8(ctx) {
|
||||
var id, params, checkRepeat, checkRepeatDomain, data, result;
|
||||
var id, params, projectData, checkRepeat, checkRepeatDomain, data, result;
|
||||
return _regenerator2.default.wrap(function _callee8$(_context8) {
|
||||
while (1) {
|
||||
switch (_context8.prev = _context8.next) {
|
||||
@ -756,58 +714,81 @@ var projectController = function (_baseController) {
|
||||
_context8.prev = 0;
|
||||
id = ctx.request.body.id;
|
||||
params = ctx.request.body;
|
||||
_context8.next = 5;
|
||||
return this.jungeMemberAuth(id, this.getUid());
|
||||
|
||||
if (id) {
|
||||
_context8.next = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
|
||||
|
||||
case 5:
|
||||
_context8.next = 7;
|
||||
return this.jungeMemberAuth(id, this.getUid());
|
||||
|
||||
case 7:
|
||||
_context8.t0 = _context8.sent;
|
||||
|
||||
if (!(_context8.t0 !== true)) {
|
||||
_context8.next = 8;
|
||||
_context8.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
|
||||
|
||||
case 8:
|
||||
case 10:
|
||||
_context8.next = 12;
|
||||
return this.Model.get(id);
|
||||
|
||||
case 12:
|
||||
projectData = _context8.sent;
|
||||
|
||||
if (projectData.name === params.name) {
|
||||
delete params.name;
|
||||
}
|
||||
if (projectData.basepath === params.basepath && projectData.prd_host === params.prd_host) {
|
||||
delete params.basepath;
|
||||
delete params.prd_host;
|
||||
}
|
||||
|
||||
if (!params.name) {
|
||||
_context8.next = 14;
|
||||
_context8.next = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
_context8.next = 11;
|
||||
_context8.next = 18;
|
||||
return this.Model.checkNameRepeat(params.name);
|
||||
|
||||
case 11:
|
||||
case 18:
|
||||
checkRepeat = _context8.sent;
|
||||
|
||||
if (!(checkRepeat > 0)) {
|
||||
_context8.next = 14;
|
||||
_context8.next = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
|
||||
|
||||
case 14:
|
||||
case 21:
|
||||
if (!(params.basepath && params.prd_host)) {
|
||||
_context8.next = 20;
|
||||
_context8.next = 27;
|
||||
break;
|
||||
}
|
||||
|
||||
_context8.next = 17;
|
||||
_context8.next = 24;
|
||||
return this.Model.checkDomainRepeat(params.prd_host, params.basepath);
|
||||
|
||||
case 17:
|
||||
case 24:
|
||||
checkRepeatDomain = _context8.sent;
|
||||
|
||||
if (!(checkRepeatDomain > 0)) {
|
||||
_context8.next = 20;
|
||||
_context8.next = 27;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context8.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在domain和basepath'));
|
||||
|
||||
case 20:
|
||||
case 27:
|
||||
data = {
|
||||
uid: this.getUid(),
|
||||
up_time: _yapi2.default.commons.time()
|
||||
@ -820,30 +801,31 @@ var projectController = function (_baseController) {
|
||||
data.prd_host = params.prd_host;
|
||||
data.basepath = params.basepath;
|
||||
}
|
||||
if (params.protocol) data.protocol = params.protocol;
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
_context8.next = 27;
|
||||
_context8.next = 35;
|
||||
return this.Model.up(id, data);
|
||||
|
||||
case 27:
|
||||
case 35:
|
||||
result = _context8.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context8.next = 34;
|
||||
_context8.next = 42;
|
||||
break;
|
||||
|
||||
case 31:
|
||||
_context8.prev = 31;
|
||||
case 39:
|
||||
_context8.prev = 39;
|
||||
_context8.t1 = _context8['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context8.t1.message);
|
||||
|
||||
case 34:
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context8.stop();
|
||||
}
|
||||
}
|
||||
}, _callee8, this, [[0, 31]]);
|
||||
}, _callee8, this, [[0, 39]]);
|
||||
}));
|
||||
|
||||
function up(_x8) {
|
||||
|
@ -638,7 +638,7 @@ var userController = function (_baseController) {
|
||||
* @category user
|
||||
* @foldnumber 10
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @param {Number} [limit] 分页大小,默认为10条
|
||||
* @returns {Object}
|
||||
* @example
|
||||
*/
|
||||
@ -666,7 +666,7 @@ var userController = function (_baseController) {
|
||||
case 8:
|
||||
count = _context9.sent;
|
||||
return _context9.abrupt('return', ctx.body = _yapi2.default.commons.resReturn({
|
||||
total: count,
|
||||
total: Math.ceil(count / limit),
|
||||
list: user
|
||||
}));
|
||||
|
||||
|
@ -35,7 +35,7 @@ module.exports = function () {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
_yapi2.default.commons.log('mock Server running...');
|
||||
hostname = ctx.protocol + "://" + ctx.hostname;
|
||||
hostname = ctx.hostname;
|
||||
config = _yapi2.default.WEBCONFIG;
|
||||
|
||||
if (!(ctx.hostname === config.webhost)) {
|
||||
|
@ -58,6 +58,7 @@ var projectModel = function (_baseModel) {
|
||||
desc: String,
|
||||
group_id: { type: Number, required: true },
|
||||
members: Array,
|
||||
protocol: { type: String, required: true },
|
||||
prd_host: { type: String, required: true },
|
||||
env: [{ name: String, domain: String }],
|
||||
add_time: Number,
|
||||
@ -117,8 +118,10 @@ var projectModel = function (_baseModel) {
|
||||
}
|
||||
}, {
|
||||
key: 'listCount',
|
||||
value: function listCount() {
|
||||
return this.model.count();
|
||||
value: function listCount(group_id) {
|
||||
return this.model.count({
|
||||
group_id: group_id
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'countByGroupId',
|
||||
|
@ -87,6 +87,13 @@ var userModel = function (_baseModel) {
|
||||
value: function list() {
|
||||
return this.model.find().select("_id username email role add_time up_time").exec(); //显示id name email role
|
||||
}
|
||||
}, {
|
||||
key: 'findByUids',
|
||||
value: function findByUids(uids) {
|
||||
return this.model.find({
|
||||
_id: { $in: [107] }
|
||||
}).select("_id username email role add_time up_time").exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
value: function listWithPaging(page, limit) {
|
||||
|
Loading…
Reference in New Issue
Block a user