Showing
26 changed files
with
409 additions
and
510 deletions
app/components/doc-act-list.vue
deleted
100644 → 0
1 | -<template> | ||
2 | - <Collapse accordion v-model="openAct" @on-change="actChange"> | ||
3 | - <Panel :name="act.name" v-for="act in list" :key="act.name"> | ||
4 | - {{act.name}}({{act.desc}}) | ||
5 | - <div slot="content" class="act-content" v-if="act.__rendered"> | ||
6 | - <h2>接口路径</h2> | ||
7 | - <div class="path">{{getPath(act)}}</div> | ||
8 | - <div v-if="showUrlParams(act)"> | ||
9 | - <h2>提交参数</h2> | ||
10 | - <Table :columns="reqColumns" :data="paramsColumns(act)"></Table> | ||
11 | - </div> | ||
12 | - <div v-if="act.reqMethod === 'JSON'"> | ||
13 | - <h2>提交示例</h2> | ||
14 | - <json-view :value="paramsJsonColumns(act)" icon-prefix="ivu-icon" @copied="copied"></json-view> | ||
15 | - </div> | ||
16 | - <div v-if="act.responseInfo.data"> | ||
17 | - <h2>返回示例</h2> | ||
18 | - <json-view :value="act.responseInfo.data" icon-prefix="ivu-icon" @copied="copied"></json-view> | ||
19 | - </div> | ||
20 | - <div v-if="act.responseInfo.codeDesc.length"> | ||
21 | - <h2>状态码</h2> | ||
22 | - <Table :width="500" :columns="codeColumns" :data="act.responseInfo.codeDesc"></Table> | ||
23 | - </div> | ||
24 | - </div> | ||
25 | - </Panel> | ||
26 | - </Collapse> | ||
27 | -</template> | ||
28 | - | ||
29 | -<script> | ||
30 | -import _ from 'lodash'; | ||
31 | -import config from 'config'; | ||
32 | -import JsonView from 'vue-json-viewer'; | ||
33 | - | ||
34 | -export default { | ||
35 | - name: 'DocActList', | ||
36 | - props: { | ||
37 | - list: Array | ||
38 | - }, | ||
39 | - data() { | ||
40 | - return { | ||
41 | - test2: '', | ||
42 | - openAct: [], | ||
43 | - reqColumns: [{ | ||
44 | - title: '名称', | ||
45 | - key: 'name' | ||
46 | - }, { | ||
47 | - title: '类型', | ||
48 | - key: 'paramType' | ||
49 | - }, { | ||
50 | - title: '必填', | ||
51 | - key: 'required' | ||
52 | - }, { | ||
53 | - title: '默认值', | ||
54 | - key: 'defaultValue' | ||
55 | - }, { | ||
56 | - title: '描述', | ||
57 | - key: 'desc' | ||
58 | - }], | ||
59 | - resColumns: [{ | ||
60 | - title: '类型', | ||
61 | - key: 'clazz' | ||
62 | - }, { | ||
63 | - title: '描述', | ||
64 | - key: 'desc' | ||
65 | - }], | ||
66 | - codeColumns: [{ | ||
67 | - title: '状态码', | ||
68 | - key: 'code' | ||
69 | - }, { | ||
70 | - title: '说明', | ||
71 | - key: 'desc' | ||
72 | - }], | ||
73 | - reqData: [], | ||
74 | - resData: [] | ||
75 | - }; | ||
76 | - }, | ||
77 | - methods: { | ||
78 | - actChange(open) { | ||
79 | - let act = this.list.find(a => a.name === open[0]); | ||
80 | - | ||
81 | - if (act) { | ||
82 | - act.__rendered = true; | ||
83 | - } | ||
84 | - }, | ||
85 | - getPath(act) { | ||
86 | - if (act.reqMethod === 'JSON') { | ||
87 | - return config.axiosBaseUrl + act.path; | ||
88 | - } | ||
89 | - const params = act.paramInfo.map(param => { | ||
90 | - return `${param.name}=${param.defaultValue}`; | ||
91 | - }).join('&'); | ||
92 | - | ||
93 | - if (act.path.indexOf('method') >= 0) { | ||
94 | - return `${config.axiosBaseUrl}/?${act.path}&${params}`; | ||
95 | - } | ||
96 | - return `${config.axiosBaseUrl}/?${params}`; | ||
97 | - }, | ||
98 | - paramsColumns(act) { | ||
99 | - return act.paramInfo[0].data ? this.transformParams(act.paramInfo[0].data) : act.paramInfo; | ||
100 | - }, | ||
101 | - paramsJsonColumns(act) { | ||
102 | - if (act.paramInfo.length && act.paramInfo[0].data !== 'object') { | ||
103 | - let data = {}; | ||
104 | - | ||
105 | - act.paramInfo.forEach(param => { | ||
106 | - data[param.name] = param.defaultValue; | ||
107 | - }); | ||
108 | - return data; | ||
109 | - } | ||
110 | - return act.paramInfo[0].data; | ||
111 | - }, | ||
112 | - showUrlParams(act) { | ||
113 | - return (act.reqMethod === 'URL' && act.paramInfo.length) || | ||
114 | - (act.reqMethod === 'JSON' && act.paramInfo.length && typeof act.paramInfo[0].data !== 'object'); | ||
115 | - }, | ||
116 | - transformParams(data) { | ||
117 | - return _.map(data, (v, k) => { | ||
118 | - return { | ||
119 | - name: k, | ||
120 | - paramType: typeof v | ||
121 | - }; | ||
122 | - }); | ||
123 | - }, | ||
124 | - copied() { | ||
125 | - this.$Message.success('复制成功'); | ||
126 | - } | ||
127 | - }, | ||
128 | - components: { | ||
129 | - JsonView | ||
130 | - } | ||
131 | -}; | ||
132 | -</script> | ||
133 | - | ||
134 | -<style lang="scss"> | ||
135 | -.act-content { | ||
136 | - padding: 0 16px; | ||
137 | - | ||
138 | - .path { | ||
139 | - font-size: 15px; | ||
140 | - } | ||
141 | -} | ||
142 | -</style> |
app/components/doc-menu.vue
deleted
100644 → 0
1 | -<template> | ||
2 | - <i-menu width="auto" class="doc-menu" :active-name="store.groupName" @on-select="selectGroup"> | ||
3 | - <i-menu-group title="分组"> | ||
4 | - <i-menu-item | ||
5 | - :name="group.name" | ||
6 | - v-for="group in store.groups" | ||
7 | - :key="group.name"> | ||
8 | - {{group.desc}} | ||
9 | - <i-spin class="group-spin" | ||
10 | - size="small" | ||
11 | - v-if="store.groupName === group.name && store.featchApising"> | ||
12 | - <Icon type="load-c" size="14" class="spin-icon-load"></Icon> | ||
13 | - </i-spin> | ||
14 | - </i-menu-item> | ||
15 | - </i-menu-group> | ||
16 | - </i-menu> | ||
17 | -</template> | ||
18 | - | ||
19 | -<script> | ||
20 | -import { | ||
21 | - FETCH_GROUP_REQUEST, | ||
22 | - FETCH_API_REQUEST | ||
23 | -} from 'store/types'; | ||
24 | -import {mapState} from 'vuex'; | ||
25 | -export default { | ||
26 | - name: 'DocMenu', | ||
27 | - computed: { | ||
28 | - ...mapState(['store']) | ||
29 | - }, | ||
30 | - created() { | ||
31 | - this.$store.dispatch(FETCH_GROUP_REQUEST); | ||
32 | - }, | ||
33 | - methods: { | ||
34 | - selectGroup(groupName) { | ||
35 | - this.$store.dispatch(FETCH_API_REQUEST, { | ||
36 | - groupName, | ||
37 | - keyword: '', | ||
38 | - searchType: '' | ||
39 | - }).then(() => { | ||
40 | - window.scrollTo(0, 0); | ||
41 | - }); | ||
42 | - } | ||
43 | - } | ||
44 | -}; | ||
45 | -</script> | ||
46 | - | ||
47 | -<style lang="scss"> | ||
48 | -.doc-menu { | ||
49 | - .ivu-menu-item { | ||
50 | - word-wrap: break-word; | ||
51 | - } | ||
52 | - | ||
53 | - .group-spin { | ||
54 | - display: inline-block; | ||
55 | - float: right; | ||
56 | - } | ||
57 | - | ||
58 | - .spin-icon-load { | ||
59 | - animation: ani-spin 1s linear infinite; | ||
60 | - } | ||
61 | - @keyframes ani-spin { | ||
62 | - from { transform: rotate(0deg);} | ||
63 | - 50% { transform: rotate(180deg);} | ||
64 | - to { transform: rotate(360deg);} | ||
65 | - } | ||
66 | -} | ||
67 | -</style> |
app/components/doc-search.vue
deleted
100644 → 0
1 | -<template> | ||
2 | - <div class="search-box"> | ||
3 | - <i-form ref="formInline" inline> | ||
4 | - <i-form-item> | ||
5 | - <Input v-model="keyword" style="width: 300px;"> | ||
6 | - <Select v-model="searchType" slot="prepend" style="width: 100px"> | ||
7 | - <Option value="controller">controller</Option> | ||
8 | - <Option value="keyword">关键词</Option> | ||
9 | - </Select> | ||
10 | - </Input> | ||
11 | - </i-form-item> | ||
12 | - <i-form-item> | ||
13 | - <i-button type="primary" @click="searchAll" >搜全部</i-button> | ||
14 | - <i-button type="primary" @click="searchGroup" v-show="store.groupName">搜当前分组</i-button> | ||
15 | - <i-button type="warning" @click="reset">清空</i-button> | ||
16 | - </i-form-item> | ||
17 | - </i-form> | ||
18 | - </div> | ||
19 | -</template> | ||
20 | - | ||
21 | -<script> | ||
22 | -import { | ||
23 | - FETCH_API_REQUEST | ||
24 | -} from 'store/types'; | ||
25 | -import {mapState} from 'vuex'; | ||
26 | -export default { | ||
27 | - name: 'DocSearch', | ||
28 | - computed: { | ||
29 | - ...mapState(['store']) | ||
30 | - }, | ||
31 | - data() { | ||
32 | - return { | ||
33 | - searchType: 'controller', | ||
34 | - keyword: '' | ||
35 | - }; | ||
36 | - }, | ||
37 | - methods: { | ||
38 | - searchGroup() { | ||
39 | - if (!this.keyword) { | ||
40 | - this.$Message.warning('请输入关键词'); | ||
41 | - return; | ||
42 | - } | ||
43 | - this.$store.dispatch(FETCH_API_REQUEST, { | ||
44 | - groupName: this.store.groupName, | ||
45 | - keyword: this.keyword, | ||
46 | - searchType: this.searchType | ||
47 | - }).then(() => { | ||
48 | - window.scrollTo(0, 0); | ||
49 | - }); | ||
50 | - }, | ||
51 | - searchAll() { | ||
52 | - if (!this.keyword) { | ||
53 | - this.$Message.warning('请输入关键词'); | ||
54 | - return; | ||
55 | - } | ||
56 | - this.$store.dispatch(FETCH_API_REQUEST, { | ||
57 | - groupName: '', | ||
58 | - keyword: this.keyword, | ||
59 | - searchType: this.searchType | ||
60 | - }).then(() => { | ||
61 | - window.scrollTo(0, 0); | ||
62 | - }); | ||
63 | - }, | ||
64 | - reset() { | ||
65 | - if (this.store.apiSearchType) { | ||
66 | - this.keyword = ''; | ||
67 | - this.$store.dispatch(FETCH_API_REQUEST, { | ||
68 | - groupName: this.store.groupName, | ||
69 | - keyword: '', | ||
70 | - searchType: '' | ||
71 | - }).then(() => { | ||
72 | - window.scrollTo(0, 0); | ||
73 | - }); | ||
74 | - } | ||
75 | - } | ||
76 | - } | ||
77 | -}; | ||
78 | -</script> | ||
79 | - | ||
80 | -<style lang="scss"> | ||
81 | -.search-box { | ||
82 | - padding: 20px; | ||
83 | - border-bottom: solid 1px #dddee1; | ||
84 | - | ||
85 | - .ivu-form-item { | ||
86 | - margin-bottom: 0; | ||
87 | - } | ||
88 | -} | ||
89 | -</style> |
1 | -import DocMenu from './doc-menu'; | ||
2 | -import DocSearch from './doc-search'; | ||
3 | -import DocCtrlList from './doc-ctrl-list'; | ||
4 | -import DocActList from './doc-act-list'; | ||
5 | -import DocHeader from './doc-header'; | 1 | +import LayoutSearch from './layout-search'; |
2 | +import LayoutHeader from './layout-header'; | ||
3 | +import LayoutList from './layout-list'; | ||
6 | 4 | ||
7 | export default { | 5 | export default { |
8 | - DocMenu, | ||
9 | - DocSearch, | ||
10 | - DocCtrlList, | ||
11 | - DocActList, | ||
12 | - DocHeader | 6 | + LayoutSearch, |
7 | + LayoutHeader, | ||
8 | + LayoutList | ||
13 | }; | 9 | }; |
app/components/layout-list.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="result-list"> | ||
3 | + <h3>查询结果:</h3> | ||
4 | + <i-table :columns="columns" :data="fulltext.fulltexts"></i-table> | ||
5 | + <i-page | ||
6 | + :current="fulltext.searchParams.page" | ||
7 | + :page-size="fulltext.searchParams.rows" | ||
8 | + :show-total="true" | ||
9 | + :show-sizer="true" | ||
10 | + :total="fulltext.count" | ||
11 | + @on-change="pageChange" | ||
12 | + @on-page-size-change="pageSizeChange"></i-page> | ||
13 | + </div> | ||
14 | +</template> | ||
15 | + | ||
16 | +<script> | ||
17 | +import ListExtend from './list-extend'; | ||
18 | +import {FETCH_FULLTEXT_REQUEST} from 'store/types'; | ||
19 | +import {mapState} from 'vuex'; | ||
20 | +export default { | ||
21 | + name: 'LayoutList', | ||
22 | + data() { | ||
23 | + return { | ||
24 | + columns: [{ | ||
25 | + type: 'expand', | ||
26 | + width: 50, | ||
27 | + render: (h, params) => { | ||
28 | + return h(ListExtend, { | ||
29 | + props: { | ||
30 | + value: params.row | ||
31 | + } | ||
32 | + }); | ||
33 | + } | ||
34 | + }, { | ||
35 | + title: 'uid', | ||
36 | + key: 'uid' | ||
37 | + }, { | ||
38 | + title: 'os', | ||
39 | + key: 'os' | ||
40 | + }, { | ||
41 | + title: 'pt', | ||
42 | + key: 'pt' | ||
43 | + }, { | ||
44 | + title: 'pn', | ||
45 | + key: 'pn' | ||
46 | + }, { | ||
47 | + title: 'av', | ||
48 | + key: 'av' | ||
49 | + }] | ||
50 | + }; | ||
51 | + }, | ||
52 | + computed: { | ||
53 | + ...mapState(['fulltext']) | ||
54 | + }, | ||
55 | + methods: { | ||
56 | + pageChange(page) { | ||
57 | + this.$store.dispatch(FETCH_FULLTEXT_REQUEST, {page: page}); | ||
58 | + }, | ||
59 | + pageSizeChange(rows) { | ||
60 | + this.$store.dispatch(FETCH_FULLTEXT_REQUEST, {rows: rows, page: 1}); | ||
61 | + } | ||
62 | + } | ||
63 | +}; | ||
64 | +</script> | ||
65 | + | ||
66 | +<style lang="scss"> | ||
67 | +.result-list { | ||
68 | + .ivu-page { | ||
69 | + margin-top: 20px; | ||
70 | + } | ||
71 | + h3 { | ||
72 | + margin-bottom: 10px; | ||
73 | + } | ||
74 | +} | ||
75 | +</style> |
app/components/layout-search.vue
0 → 100644
1 | +<template> | ||
2 | + <div class="search-box"> | ||
3 | + <h3>查询条件:</h3> | ||
4 | + <i-form :label-width="60"> | ||
5 | + <i-form-item label="uid:"> | ||
6 | + <i-input v-model="forms.uid" placeholder="请输入uid"></i-input> | ||
7 | + </i-form-item> | ||
8 | + <i-form-item label="os:"> | ||
9 | + <i-input v-model="forms.os" placeholder="请输入(android or iOS)"></i-input> | ||
10 | + </i-form-item> | ||
11 | + <i-form-item label="pt:"> | ||
12 | + <i-input v-model="forms.pt" placeholder="请输入pt"></i-input> | ||
13 | + </i-form-item> | ||
14 | + <i-form-item label="pn:"> | ||
15 | + <i-input v-model="forms.pn" placeholder="请输入pn"></i-input> | ||
16 | + </i-form-item> | ||
17 | + <i-form-item label="av:"> | ||
18 | + <i-input v-model="forms.av" placeholder="请输入av"></i-input> | ||
19 | + </i-form-item> | ||
20 | + <i-form-item label="times:"> | ||
21 | + <Date-picker | ||
22 | + type="datetimerange" | ||
23 | + v-model="dateRange" | ||
24 | + placement="bottom-start" | ||
25 | + format="yyyy-MM-dd HH:mm:ss" | ||
26 | + class="dt-limit" | ||
27 | + :options="dtLimitOpt" | ||
28 | + placeholder="选择开始结束日期"></Date-picker> | ||
29 | + </i-form-item> | ||
30 | + <i-form-item> | ||
31 | + <i-button type="primary" @click="search">查询</i-button> | ||
32 | + <i-button type="warning" @click="reset">清空</i-button> | ||
33 | + </i-form-item> | ||
34 | + </i-form> | ||
35 | + </div> | ||
36 | +</template> | ||
37 | + | ||
38 | +<script> | ||
39 | +import moment from 'moment'; | ||
40 | +import {FETCH_FULLTEXT_REQUEST} from 'store/types'; | ||
41 | +export default { | ||
42 | + name: 'LayoutSearch', | ||
43 | + data() { | ||
44 | + return { | ||
45 | + forms: { | ||
46 | + uid: '', | ||
47 | + os: '', | ||
48 | + pt: '', | ||
49 | + pn: '', | ||
50 | + av: '', | ||
51 | + ts_start: '', | ||
52 | + ts_end: '' | ||
53 | + }, | ||
54 | + dateRange: [moment().add(-7, 'days').format('YYYY-MM-DD HH:mm:ss'), moment().format('YYYY-MM-DD HH:mm:ss')], | ||
55 | + dtLimitOpt: { | ||
56 | + shortcuts: [ | ||
57 | + { | ||
58 | + text: '最近一周', | ||
59 | + value() { | ||
60 | + const end = new Date(); | ||
61 | + const start = new Date(); | ||
62 | + | ||
63 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); | ||
64 | + return [start, end]; | ||
65 | + } | ||
66 | + }, | ||
67 | + { | ||
68 | + text: '最近一个月', | ||
69 | + value() { | ||
70 | + const end = new Date(); | ||
71 | + const start = new Date(); | ||
72 | + | ||
73 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); | ||
74 | + return [start, end]; | ||
75 | + } | ||
76 | + }, | ||
77 | + { | ||
78 | + text: '最近三个月', | ||
79 | + value() { | ||
80 | + const end = new Date(); | ||
81 | + const start = new Date(); | ||
82 | + | ||
83 | + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); | ||
84 | + return [start, end]; | ||
85 | + } | ||
86 | + } | ||
87 | + ] | ||
88 | + } | ||
89 | + }; | ||
90 | + }, | ||
91 | + methods: { | ||
92 | + search() { | ||
93 | + this.forms.ts_start = this.dateRange[0] ? moment(this.dateRange[0]).unix() : ''; | ||
94 | + this.forms.ts_end = this.dateRange[1] ? moment(this.dateRange[1]).unix() : ''; | ||
95 | + | ||
96 | + this.$store.dispatch(FETCH_FULLTEXT_REQUEST, Object.assign(this.forms, { | ||
97 | + page: 1 | ||
98 | + })); | ||
99 | + }, | ||
100 | + reset() { | ||
101 | + this.forms = { | ||
102 | + uid: '', | ||
103 | + os: '', | ||
104 | + pt: '', | ||
105 | + pn: '', | ||
106 | + av: '', | ||
107 | + ts_start: '', | ||
108 | + ts_end: '' | ||
109 | + }; | ||
110 | + this.dateRange = []; | ||
111 | + this.$store.dispatch(FETCH_FULLTEXT_REQUEST, Object.assign(this.forms, { | ||
112 | + page: 1 | ||
113 | + })); | ||
114 | + } | ||
115 | + } | ||
116 | +}; | ||
117 | +</script> | ||
118 | + | ||
119 | +<style lang="scss"> | ||
120 | +.search-box { | ||
121 | + | ||
122 | + .ivu-form-item { | ||
123 | + margin-bottom: 10px; | ||
124 | + } | ||
125 | + h3 { | ||
126 | + margin-bottom: 10px; | ||
127 | + } | ||
128 | + .dt-limit { | ||
129 | + width: 280px; | ||
130 | + } | ||
131 | +} | ||
132 | +</style> |
app/components/list-extend.vue
0 → 100644
1 | +<template> | ||
2 | + <json-viewer :value="value" icon-prefix="ivu-icon" class="list-extend" @copied="copied"></json-viewer> | ||
3 | +</template> | ||
4 | + | ||
5 | +<script> | ||
6 | +import JsonViewer from 'vue-json-viewer'; | ||
7 | +export default { | ||
8 | + name: 'ListExtend', | ||
9 | + props: { | ||
10 | + value: [Object, Array] | ||
11 | + }, | ||
12 | + components: { | ||
13 | + JsonViewer | ||
14 | + }, | ||
15 | + methods: { | ||
16 | + copied() { | ||
17 | + this.$Message.success('复制成功'); | ||
18 | + } | ||
19 | + } | ||
20 | +}; | ||
21 | +</script> | ||
22 | + | ||
23 | +<style lang="scss"> | ||
24 | +.list-extend { | ||
25 | + background: #fff; | ||
26 | +} | ||
27 | +</style> |
1 | const config = { | 1 | const config = { |
2 | dev: { | 2 | dev: { |
3 | - axiosBaseUrl: 'http://172.16.6.201:8080', | 3 | + axiosBaseUrl: '/api', |
4 | axiosResponseType: 'json', | 4 | axiosResponseType: 'json', |
5 | }, | 5 | }, |
6 | production: { | 6 | production: { |
7 | - axiosBaseUrl: 'http://172.16.6.201:8080', | 7 | + axiosBaseUrl: '/api', |
8 | axiosResponseType: 'json', | 8 | axiosResponseType: 'json', |
9 | } | 9 | } |
10 | }; | 10 | }; |
1 | <template> | 1 | <template> |
2 | <div class="layout"> | 2 | <div class="layout"> |
3 | - <doc-header></doc-header> | 3 | + <layout-header></layout-header> |
4 | <div class="layout-content"> | 4 | <div class="layout-content"> |
5 | <div class="layout-left"> | 5 | <div class="layout-left"> |
6 | - <doc-menu></doc-menu> | 6 | + <layout-search></layout-search> |
7 | </div> | 7 | </div> |
8 | <div class="layout-right"> | 8 | <div class="layout-right"> |
9 | - <article> | ||
10 | - <doc-search></doc-search> | ||
11 | - <doc-ctrl-list></doc-ctrl-list> | ||
12 | - </article> | 9 | + <layout-list></layout-list> |
13 | </div> | 10 | </div> |
14 | </div> | 11 | </div> |
15 | <BackTop></BackTop> | 12 | <BackTop></BackTop> |
@@ -39,12 +36,15 @@ export default { | @@ -39,12 +36,15 @@ export default { | ||
39 | flex: auto; | 36 | flex: auto; |
40 | } | 37 | } |
41 | .layout-left { | 38 | .layout-left { |
42 | - width: 200px; | ||
43 | - padding-top: 5px; | ||
44 | - padding-bottom: 5px; | 39 | + width: 380px; |
40 | + padding: 20px; | ||
41 | + padding-top: 10px; | ||
42 | + border-right: solid 1px #dddee1; | ||
45 | } | 43 | } |
46 | .layout-right { | 44 | .layout-right { |
47 | - flex: auto; | 45 | + flex: 1; |
46 | + padding: 20px; | ||
47 | + padding-top: 10px; | ||
48 | position: relative; | 48 | position: relative; |
49 | 49 | ||
50 | & article:after { | 50 | & article:after { |
app/store/fulltext.js
0 → 100644
1 | +import { | ||
2 | + FETCH_FULLTEXT_FAILURE, | ||
3 | + FETCH_FULLTEXT_REQUEST, | ||
4 | + FETCH_FULLTEXT_SUCCESS | ||
5 | +} from './types'; | ||
6 | +import api from 'common/api'; | ||
7 | + | ||
8 | +export default { | ||
9 | + state: { | ||
10 | + fetching: false, | ||
11 | + fulltexts: [], | ||
12 | + searchParams: { | ||
13 | + page: 1, | ||
14 | + count: 10 | ||
15 | + }, | ||
16 | + count: 0 | ||
17 | + }, | ||
18 | + mutations: { | ||
19 | + [FETCH_FULLTEXT_REQUEST](state, params) { | ||
20 | + state.featchApising = true; | ||
21 | + state.searchParams = Object.assign(state.searchParams, params); | ||
22 | + }, | ||
23 | + [FETCH_FULLTEXT_FAILURE](state) { | ||
24 | + state.featchApising = false; | ||
25 | + }, | ||
26 | + [FETCH_FULLTEXT_SUCCESS](state, params) { | ||
27 | + state.featchApising = false; | ||
28 | + state.fulltexts = params.data; | ||
29 | + state.count = params.count; | ||
30 | + } | ||
31 | + }, | ||
32 | + actions: { | ||
33 | + [FETCH_FULLTEXT_REQUEST]({commit, state}, params) { | ||
34 | + commit(FETCH_FULLTEXT_REQUEST, params); | ||
35 | + return api.get('/list', state.searchParams).then(res => { | ||
36 | + if (res.code === 200) { | ||
37 | + commit(FETCH_FULLTEXT_SUCCESS, {data: res.data, count: res.count}); | ||
38 | + } else { | ||
39 | + commit(FETCH_FULLTEXT_FAILURE); | ||
40 | + } | ||
41 | + }, () => { | ||
42 | + commit(FETCH_FULLTEXT_FAILURE); | ||
43 | + }); | ||
44 | + } | ||
45 | + } | ||
46 | +}; |
1 | import Vue from 'vue'; | 1 | import Vue from 'vue'; |
2 | import Vuex from 'vuex'; | 2 | import Vuex from 'vuex'; |
3 | 3 | ||
4 | -import store from './store'; | 4 | +import fulltext from './fulltext'; |
5 | 5 | ||
6 | 6 | ||
7 | Vue.use(Vuex); | 7 | Vue.use(Vuex); |
@@ -9,7 +9,7 @@ Vue.use(Vuex); | @@ -9,7 +9,7 @@ Vue.use(Vuex); | ||
9 | export function createStore() { | 9 | export function createStore() { |
10 | return new Vuex.Store({ | 10 | return new Vuex.Store({ |
11 | modules: { | 11 | modules: { |
12 | - store | 12 | + fulltext |
13 | }, | 13 | }, |
14 | strict: process.env.NODE_ENV !== 'production' | 14 | strict: process.env.NODE_ENV !== 'production' |
15 | }); | 15 | }); |
app/store/store.js
deleted
100644 → 0
1 | -import { | ||
2 | - FETCH_API_FAILURE, | ||
3 | - FETCH_API_REQUEST, | ||
4 | - FETCH_API_SUCCESS, | ||
5 | - FETCH_GROUP_FAILURE, | ||
6 | - FETCH_GROUP_REQUEST, | ||
7 | - FETCH_GROUP_SUCCESS | ||
8 | -} from './types'; | ||
9 | -import api from 'common/api'; | ||
10 | - | ||
11 | -export default { | ||
12 | - state: { | ||
13 | - cacheApis: {}, | ||
14 | - groups: [], | ||
15 | - fetchGroupsing: false, | ||
16 | - apis: [], | ||
17 | - featchApising: false, | ||
18 | - groupName: '', | ||
19 | - apiPage: 1, | ||
20 | - apiRows: 10, | ||
21 | - apiCount: 0, | ||
22 | - apiKeyword: '', | ||
23 | - apiSearchType: '' | ||
24 | - }, | ||
25 | - mutations: { | ||
26 | - [FETCH_GROUP_REQUEST](state) { | ||
27 | - state.fetchGroupsing = true; | ||
28 | - }, | ||
29 | - [FETCH_GROUP_FAILURE](state) { | ||
30 | - state.fetchGroupsing = false; | ||
31 | - }, | ||
32 | - [FETCH_GROUP_SUCCESS](state, params) { | ||
33 | - state.fetchGroupsing = false; | ||
34 | - state.groups = params.list; | ||
35 | - | ||
36 | - params.list.forEach(group => { | ||
37 | - state.cacheApis[group.name] = { | ||
38 | - rows: [], | ||
39 | - total: 0 | ||
40 | - }; | ||
41 | - }); | ||
42 | - }, | ||
43 | - [FETCH_API_REQUEST](state, params) { | ||
44 | - if (params.groupName === '') { | ||
45 | - state.groupName = ''; | ||
46 | - } else if (params.groupName) { | ||
47 | - state.groupName = params.groupName; | ||
48 | - } | ||
49 | - if (params.keyword === '') { | ||
50 | - state.apiKeyword = ''; | ||
51 | - } else if (params.keyword) { | ||
52 | - state.apiKeyword = params.keyword; | ||
53 | - } | ||
54 | - if (params.searchType === '') { | ||
55 | - state.apiSearchType = ''; | ||
56 | - } else if (params.searchType) { | ||
57 | - state.apiSearchType = params.searchType; | ||
58 | - } | ||
59 | - state.apiPage = params.page || 1; | ||
60 | - state.apiRows = params.rows || state.apiRows; | ||
61 | - state.featchApising = true; | ||
62 | - }, | ||
63 | - [FETCH_API_FAILURE](state) { | ||
64 | - state.featchApising = false; | ||
65 | - }, | ||
66 | - [FETCH_API_SUCCESS](state, params) { | ||
67 | - state.featchApising = false; | ||
68 | - state.apiCount = params.data.total; | ||
69 | - state.apis = params.data.rows; | ||
70 | - | ||
71 | - if (!state.apiSearchType && state.groupName && !params.cache) { | ||
72 | - const groupCache = state.cacheApis[state.groupName]; | ||
73 | - const start = (state.apiPage - 1) * state.apiRows; | ||
74 | - | ||
75 | - if (groupCache.rows.length >= start) { | ||
76 | - groupCache.rows.splice(start, state.apiRows, ...params.data.rows); | ||
77 | - groupCache.total = params.data.total; | ||
78 | - } | ||
79 | - groupCache.__cached = true; | ||
80 | - } | ||
81 | - } | ||
82 | - }, | ||
83 | - actions: { | ||
84 | - [FETCH_GROUP_REQUEST]({commit}) { | ||
85 | - commit(FETCH_GROUP_REQUEST); | ||
86 | - return api.get('/gateway/api/findGroup').then(res => { | ||
87 | - commit(FETCH_GROUP_SUCCESS, {list: res}); | ||
88 | - }, () => { | ||
89 | - commit(FETCH_GROUP_FAILURE); | ||
90 | - }); | ||
91 | - }, | ||
92 | - [FETCH_API_REQUEST]({commit, state}, params) { | ||
93 | - let apiPromise; | ||
94 | - | ||
95 | - commit(FETCH_API_REQUEST, params); | ||
96 | - if (state.apiSearchType === 'controller') { | ||
97 | - apiPromise = api.get('/gateway/api/findByName', { | ||
98 | - groupName: state.groupName || void 0, | ||
99 | - key: state.apiKeyword, | ||
100 | - page: state.apiPage, | ||
101 | - rows: state.apiRows | ||
102 | - }); | ||
103 | - } else if (state.apiSearchType === 'keyword') { | ||
104 | - apiPromise = api.get('/gateway/api/find', { | ||
105 | - groupName: state.groupName || void 0, | ||
106 | - key: state.apiKeyword, | ||
107 | - page: state.apiPage, | ||
108 | - rows: state.apiRows | ||
109 | - }); | ||
110 | - } else { | ||
111 | - const cacheGroup = state.cacheApis[state.groupName]; | ||
112 | - | ||
113 | - if (cacheGroup && cacheGroup.__cached) { | ||
114 | - const start = (state.apiPage - 1) * state.apiRows; | ||
115 | - const end = state.apiPage * state.apiRows > cacheGroup.total ? cacheGroup.total : state.apiPage * state.apiRows; | ||
116 | - | ||
117 | - if (cacheGroup.rows.length >= end) { | ||
118 | - commit(FETCH_API_SUCCESS, { | ||
119 | - data: { | ||
120 | - total: cacheGroup.total, | ||
121 | - rows: cacheGroup.rows.slice(start, end) | ||
122 | - }, | ||
123 | - cache: true | ||
124 | - }); | ||
125 | - return Promise.resolve(); | ||
126 | - } | ||
127 | - } | ||
128 | - apiPromise = api.get('/gateway/api/findByGroup', { | ||
129 | - key: state.groupName, | ||
130 | - page: state.apiPage, | ||
131 | - rows: state.apiRows | ||
132 | - }); | ||
133 | - } | ||
134 | - return apiPromise.then(res => { | ||
135 | - if (res.code === 200) { | ||
136 | - commit(FETCH_API_SUCCESS, {data: res.data}); | ||
137 | - } else { | ||
138 | - commit(FETCH_API_FAILURE); | ||
139 | - } | ||
140 | - }, () => { | ||
141 | - commit(FETCH_API_FAILURE); | ||
142 | - }); | ||
143 | - } | ||
144 | - } | ||
145 | -}; |
1 | -export const FETCH_GROUP_REQUEST = 'FETCH_GROUP_REQUEST'; | ||
2 | -export const FETCH_GROUP_SUCCESS = 'FETCH_GROUP_SUCCESS'; | ||
3 | -export const FETCH_GROUP_FAILURE = 'FETCH_GROUP_FAILURE'; | ||
4 | - | ||
5 | -export const FETCH_API_REQUEST = 'FETCH_API_REQUEST'; | ||
6 | -export const FETCH_API_SUCCESS = 'FETCH_API_SUCCESS'; | ||
7 | -export const FETCH_API_FAILURE = 'FETCH_API_FAILURE'; | 1 | +export const FETCH_FULLTEXT_FAILURE = 'FETCH_FULLTEXT_FAILURE'; |
2 | +export const FETCH_FULLTEXT_REQUEST = 'FETCH_FULLTEXT_REQUEST'; | ||
3 | +export const FETCH_FULLTEXT_SUCCESS = 'FETCH_FULLTEXT_SUCCESS'; | ||
8 | 4 |
@@ -14,11 +14,13 @@ module.exports = { | @@ -14,11 +14,13 @@ module.exports = { | ||
14 | env: { | 14 | env: { |
15 | NODE_ENV: '"dev"' | 15 | NODE_ENV: '"dev"' |
16 | }, | 16 | }, |
17 | - port: 6010, | 17 | + port: 7002, |
18 | autoOpenBrowser: true, | 18 | autoOpenBrowser: true, |
19 | assetsSubDirectory: 'static', | 19 | assetsSubDirectory: 'static', |
20 | assetsPublicPath: '/', | 20 | assetsPublicPath: '/', |
21 | - proxyTable: {}, | 21 | + proxyTable: { |
22 | + '/api': 'http://localhost:7001' | ||
23 | + }, | ||
22 | cssSourceMap: false, | 24 | cssSourceMap: false, |
23 | } | 25 | } |
24 | }; | 26 | }; |
@@ -70,10 +70,6 @@ app.use(devMiddleware); | @@ -70,10 +70,6 @@ app.use(devMiddleware); | ||
70 | // compilation error display | 70 | // compilation error display |
71 | app.use(hotMiddleware); | 71 | app.use(hotMiddleware); |
72 | 72 | ||
73 | -// serve pure static assets | ||
74 | -let staticPath = path.posix.join(config.dev.assetsPublicPath, config.dev.assetsSubDirectory); | ||
75 | - | ||
76 | -app.use(staticPath, express.static('./static')); | ||
77 | 73 | ||
78 | let uri = 'http://localhost:' + port; | 74 | let uri = 'http://localhost:' + port; |
79 | 75 |
1 | 'use strict'; | 1 | 'use strict'; |
2 | const path = require('path'); | 2 | const path = require('path'); |
3 | +const webpack = require('webpack'); | ||
3 | 4 | ||
4 | let vueLoaderConfig = require('./vue-loader.conf'); | 5 | let vueLoaderConfig = require('./vue-loader.conf'); |
5 | let config = require('./config'); | 6 | let config = require('./config'); |
@@ -7,11 +8,11 @@ let utils = require('./utils'); | @@ -7,11 +8,11 @@ let utils = require('./utils'); | ||
7 | 8 | ||
8 | 9 | ||
9 | function resolve(dir) { | 10 | function resolve(dir) { |
10 | - return path.join(__dirname, '../src', dir); | 11 | + return path.join(__dirname, '../app', dir); |
11 | } | 12 | } |
12 | module.exports = { | 13 | module.exports = { |
13 | entry: { | 14 | entry: { |
14 | - app: './src/app.js' | 15 | + app: './app/app.js' |
15 | }, | 16 | }, |
16 | devtool: 'cheap-module-source-map', | 17 | devtool: 'cheap-module-source-map', |
17 | output: { | 18 | output: { |
@@ -37,7 +38,7 @@ module.exports = { | @@ -37,7 +38,7 @@ module.exports = { | ||
37 | { | 38 | { |
38 | test: /\.js$/, | 39 | test: /\.js$/, |
39 | loader: 'babel-loader', | 40 | loader: 'babel-loader', |
40 | - include: [/vue-json-viewer.*?js$/, path.join(__dirname, '../src')], | 41 | + include: [/vue-json-viewer.*?js$/, path.join(__dirname, '../api')], |
41 | exclude: /node_modules/ | 42 | exclude: /node_modules/ |
42 | }, | 43 | }, |
43 | { | 44 | { |
@@ -73,5 +74,8 @@ module.exports = { | @@ -73,5 +74,8 @@ module.exports = { | ||
73 | }] | 74 | }] |
74 | } | 75 | } |
75 | ] | 76 | ] |
76 | - } | 77 | + }, |
78 | + plugins: [ | ||
79 | + new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | ||
80 | + ] | ||
77 | }; | 81 | }; |
@@ -25,7 +25,7 @@ module.exports = merge(baseConfig, { | @@ -25,7 +25,7 @@ module.exports = merge(baseConfig, { | ||
25 | new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), | 25 | new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), |
26 | new HtmlWebpackPlugin({ | 26 | new HtmlWebpackPlugin({ |
27 | filename: 'index.html', | 27 | filename: 'index.html', |
28 | - template: './src/index.html', | 28 | + template: './app/index.html', |
29 | inject: true | 29 | inject: true |
30 | }), | 30 | }), |
31 | new FriendlyErrorsPlugin(), | 31 | new FriendlyErrorsPlugin(), |
@@ -38,7 +38,7 @@ let webpackConfig = merge(baseConfig, { | @@ -38,7 +38,7 @@ let webpackConfig = merge(baseConfig, { | ||
38 | }), | 38 | }), |
39 | new HtmlWebpackPlugin({ | 39 | new HtmlWebpackPlugin({ |
40 | filename: 'index.html', | 40 | filename: 'index.html', |
41 | - template: './src/index.html', | 41 | + template: './app/index.html', |
42 | inject: true, | 42 | inject: true, |
43 | minify: { | 43 | minify: { |
44 | removeComments: true, | 44 | removeComments: true, |
@@ -4,7 +4,9 @@ | @@ -4,7 +4,9 @@ | ||
4 | "description": "", | 4 | "description": "", |
5 | "main": "app.js", | 5 | "main": "app.js", |
6 | "scripts": { | 6 | "scripts": { |
7 | - "dev": "nodemon --watch server server.js" | 7 | + "dev": "nodemon --watch server server.js", |
8 | + "static": "node ./build/dev-server.js", | ||
9 | + "build": "node ./build/build.js" | ||
8 | }, | 10 | }, |
9 | "repository": { | 11 | "repository": { |
10 | "type": "git", | 12 | "type": "git", |
@@ -13,16 +15,70 @@ | @@ -13,16 +15,70 @@ | ||
13 | "author": "", | 15 | "author": "", |
14 | "license": "ISC", | 16 | "license": "ISC", |
15 | "dependencies": { | 17 | "dependencies": { |
18 | + "axios": "^0.16.2", | ||
16 | "body-parser": "^1.18.2", | 19 | "body-parser": "^1.18.2", |
20 | + "clipboard": "^1.7.1", | ||
17 | "compression": "^1.7.1", | 21 | "compression": "^1.7.1", |
18 | "cookie-parser": "^1.4.3", | 22 | "cookie-parser": "^1.4.3", |
19 | "express": "^4.16.2", | 23 | "express": "^4.16.2", |
24 | + "iview": "^2.4.0", | ||
25 | + "iview-loader": "^1.0.0-beta.4", | ||
20 | "lodash": "^4.17.4", | 26 | "lodash": "^4.17.4", |
27 | + "moment": "^2.19.1", | ||
21 | "mongoose": "^4.12.3", | 28 | "mongoose": "^4.12.3", |
22 | "serve-favicon": "^2.4.5", | 29 | "serve-favicon": "^2.4.5", |
23 | - "yoho-node-lib": "^0.5.7" | 30 | + "vue": "^2.5.2", |
31 | + "vue-json-viewer": "^1.0.2", | ||
32 | + "vue-loader": "^13.3.0", | ||
33 | + "vue-markdown": "^2.2.4", | ||
34 | + "vue-router": "^3.0.1", | ||
35 | + "vue-template-compiler": "^2.5.2", | ||
36 | + "vuex": "^2.4.1", | ||
37 | + "yoho-cookie": "^1.2.0", | ||
38 | + "yoho-node-lib": "^0.5.7", | ||
39 | + "yoho-store": "^1.3.20" | ||
24 | }, | 40 | }, |
25 | "devDependencies": { | 41 | "devDependencies": { |
26 | - "nodemon": "^1.12.1" | 42 | + "autoprefixer": "^7.0.1", |
43 | + "autoprefixer-loader": "^3.2.0", | ||
44 | + "babel-core": "^6.24.1", | ||
45 | + "babel-eslint": "^7.2.3", | ||
46 | + "babel-loader": "^7.0.0", | ||
47 | + "babel-plugin-syntax-dynamic-import": "^6.18.0", | ||
48 | + "babel-plugin-syntax-jsx": "^6.18.0", | ||
49 | + "babel-plugin-transform-object-rest-spread": "^6.23.0", | ||
50 | + "babel-plugin-transform-runtime": "^6.22.0", | ||
51 | + "babel-plugin-transform-vue-jsx": "^3.4.3", | ||
52 | + "babel-preset-env": "^1.4.0", | ||
53 | + "babel-preset-es2015": "^6.14.0", | ||
54 | + "babel-runtime": "^6.11.6", | ||
55 | + "css-loader": "^0.28.1", | ||
56 | + "eslint": "^3.3.1", | ||
57 | + "eslint-config-yoho": "^1.0.1", | ||
58 | + "eslint-plugin-html": "^1.5.2", | ||
59 | + "extract-text-webpack-plugin": "^2.1.0", | ||
60 | + "file-loader": "^1.1.5", | ||
61 | + "friendly-errors-webpack-plugin": "^1.6.1", | ||
62 | + "html-webpack-plugin": "^2.28.0", | ||
63 | + "node-sass": "^4.5.3", | ||
64 | + "nodemon": "^1.12.1", | ||
65 | + "optimize-css-assets-webpack-plugin": "^3.2.0", | ||
66 | + "postcss-loader": "^2.0.5", | ||
67 | + "postcss-pxtorem": "^3.3.1", | ||
68 | + "postcss-scss": "^1.0.0", | ||
69 | + "precss": "^1.4.0", | ||
70 | + "sass-loader": "^6.0.6", | ||
71 | + "style-loader": "^0.17.0", | ||
72 | + "stylelint": "^7.1.0", | ||
73 | + "stylelint-config-yoho": "^1.2.7", | ||
74 | + "stylelint-processor-html": "^1.0.0", | ||
75 | + "url-loader": "^0.6.2", | ||
76 | + "vue-style-loader": "^3.0.1", | ||
77 | + "webpack": "3.3", | ||
78 | + "webpack-dev-middleware": "^1.10.2", | ||
79 | + "webpack-dev-server": "^2.6.1", | ||
80 | + "webpack-hot-middleware": "^2.18.0", | ||
81 | + "webpack-merge": "^4.1.0", | ||
82 | + "yoho-lint": "^1.0.1" | ||
27 | } | 83 | } |
28 | } | 84 | } |
@@ -12,7 +12,6 @@ const Express = require('express'); | @@ -12,7 +12,6 @@ const Express = require('express'); | ||
12 | const mongoose = require('mongoose'); | 12 | const mongoose = require('mongoose'); |
13 | const pkg = require('./package.json'); | 13 | const pkg = require('./package.json'); |
14 | 14 | ||
15 | -const favicon = require('serve-favicon'); | ||
16 | const path = require('path'); | 15 | const path = require('path'); |
17 | 16 | ||
18 | global.env = { | 17 | global.env = { |
@@ -30,7 +29,7 @@ const helpers = require('yoho-node-lib/lib/helpers'); | @@ -30,7 +29,7 @@ const helpers = require('yoho-node-lib/lib/helpers'); | ||
30 | 29 | ||
31 | global.yoho = { | 30 | global.yoho = { |
32 | logger, | 31 | logger, |
33 | - helpers, | 32 | + helpers, |
34 | config | 33 | config |
35 | }; | 34 | }; |
36 | 35 | ||
@@ -44,13 +43,21 @@ app.use(cookieParser()); | @@ -44,13 +43,21 @@ app.use(cookieParser()); | ||
44 | 43 | ||
45 | const middleware = require('./server/middleware'); | 44 | const middleware = require('./server/middleware'); |
46 | const controllers = require('./server/controllers'); | 45 | const controllers = require('./server/controllers'); |
46 | + | ||
47 | require('./server/db'); // register db | 47 | require('./server/db'); // register db |
48 | -mongoose.connect('mongodb://172.16.6.108:27017/app_collect_fulltext'); | 48 | +mongoose.connect('mongodb://172.16.6.108:27017/app_collect_fulltext', { |
49 | + useMongoClient: true, | ||
50 | +}); | ||
51 | +mongoose.Promise = global.Promise; | ||
49 | 52 | ||
50 | try { | 53 | try { |
54 | + app.use((req, res, next) => { | ||
55 | + next(); | ||
56 | + }); | ||
51 | 57 | ||
52 | // controller | 58 | // controller |
53 | - app.use(controllers); | 59 | + app.use('/api', controllers); |
60 | + | ||
54 | // 异常捕获中间件 | 61 | // 异常捕获中间件 |
55 | app.use(middleware.error); | 62 | app.use(middleware.error); |
56 | } catch (err) { | 63 | } catch (err) { |
1 | -const mongoose = require("mongoose"); | 1 | +const mongoose = require('mongoose'); |
2 | 2 | ||
3 | const list = (req, res, next) => { | 3 | const list = (req, res, next) => { |
4 | const col_fulltext = mongoose.model('col_fulltext'); | 4 | const col_fulltext = mongoose.model('col_fulltext'); |
5 | - const {start_time, end_time, uid, os, pt, pn, av, page = 1, rows = 10} = req.query; | ||
6 | - | 5 | + const {ts_start, ts_end, uid, os, pt, pn, av, page = 1, rows = 10} = req.query; |
7 | let params = { | 6 | let params = { |
8 | uid, | 7 | uid, |
9 | os, | 8 | os, |
@@ -12,23 +11,28 @@ const list = (req, res, next) => { | @@ -12,23 +11,28 @@ const list = (req, res, next) => { | ||
12 | av, | 11 | av, |
13 | ts: {} | 12 | ts: {} |
14 | }; | 13 | }; |
15 | - if (start_time) { | ||
16 | - params.ts.$gte = Date.parse(start_time) / 1000; | 14 | + |
15 | + if (ts_start) { | ||
16 | + params.ts.$gte = ts_start; | ||
17 | } | 17 | } |
18 | - if (end_time) { | ||
19 | - params.ts.$lte = Date.parse(end_time) / 1000; | 18 | + if (ts_end) { |
19 | + params.ts.$lte = ts_end; | ||
20 | } | 20 | } |
21 | Object.keys(params).forEach(k => { | 21 | Object.keys(params).forEach(k => { |
22 | if (!params[k] || (typeof params[k] === 'object' && !Object.keys(params[k]).length)) { | 22 | if (!params[k] || (typeof params[k] === 'object' && !Object.keys(params[k]).length)) { |
23 | delete params[k]; | 23 | delete params[k]; |
24 | } | 24 | } |
25 | - }) | ||
26 | - return col_fulltext.find(params).skip((page-1) * rows).limit(rows).then(result => { | ||
27 | - return res.json(result); | ||
28 | }); | 25 | }); |
29 | - | ||
30 | - | ||
31 | - | 26 | + console.log(params) |
27 | + return Promise.all([ | ||
28 | + col_fulltext.find(params).count(), | ||
29 | + col_fulltext.find(params).skip((page - 1) * rows).limit(parseInt(rows, 0))]).then(resultAll => { | ||
30 | + return res.json({ | ||
31 | + code: 200, | ||
32 | + data: resultAll[1], | ||
33 | + count: resultAll[0] | ||
34 | + }); | ||
35 | + }).catch(next); | ||
32 | }; | 36 | }; |
33 | 37 | ||
34 | module.exports = { | 38 | module.exports = { |
@@ -8,8 +8,9 @@ | @@ -8,8 +8,9 @@ | ||
8 | const express = require('express'); | 8 | const express = require('express'); |
9 | const fulltextController = require('./fulltext-controller'); | 9 | const fulltextController = require('./fulltext-controller'); |
10 | 10 | ||
11 | -let router = express.Router(); | 11 | +let router = express.Router(); // eslint-disable-line |
12 | 12 | ||
13 | +router.post('/list', fulltextController.list); | ||
13 | router.get('/list', fulltextController.list); | 14 | router.get('/list', fulltextController.list); |
14 | 15 | ||
15 | module.exports = router; | 16 | module.exports = router; |
This diff could not be displayed because it is too large.
-
Please register or login to post a comment