mirror of
https://github.com/YMFE/yapi.git
synced 2025-01-06 12:45:22 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
4544ecb23b
@ -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>
|
||||
)
|
||||
|
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) {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
|
||||
@ -22,6 +23,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}
|
||||
@ -60,6 +62,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,
|
||||
@ -160,18 +163,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 +203,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
|
||||
*/
|
||||
@ -228,9 +220,22 @@ class projectController extends baseController {
|
||||
try{
|
||||
let result = await this.Model.listWithPaging(group_id, page, limit);
|
||||
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: Math.ceil(count / limit),
|
||||
list: result
|
||||
list: result,
|
||||
userinfo: _users
|
||||
})
|
||||
}catch(err){
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message)
|
||||
@ -292,10 +297,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);
|
||||
@ -322,6 +339,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
|
||||
*/
|
||||
|
@ -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();
|
||||
|
@ -18,7 +18,8 @@ class projectModel extends baseModel{
|
||||
}},
|
||||
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}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
@ -606,26 +546,44 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 9:
|
||||
count = _context6.sent;
|
||||
uids = [];
|
||||
|
||||
result.forEach(function (item) {
|
||||
if (uids.indexOf(item.uid) !== -1) {
|
||||
uids.push(item.uid);
|
||||
}
|
||||
});
|
||||
|
||||
_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
|
||||
list: result,
|
||||
userinfo: _users
|
||||
});
|
||||
_context6.next = 16;
|
||||
_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
|
||||
*/
|
||||
|
@ -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,
|
||||
|
@ -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