nsgm-cli 1.0.19 → 1.0.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generation/client/layout/index.tsx +20 -22
- package/generation/client/redux/reducers.ts +2 -2
- package/generation/client/redux/store.ts +2 -2
- package/generation/client/redux/template/manage/actions.ts +9 -9
- package/generation/client/redux/template/manage/reducers.ts +15 -15
- package/generation/client/utils/common.ts +1 -1
- package/generation/client/utils/menu.tsx +2 -2
- package/generation/pages/template/manage.tsx +25 -23
- package/generation/server/apis/template.js +2 -1
- package/generation/server/modules/template/resolver.js +30 -30
- package/generation/server/rest.js +1 -1
- package/lib/generate.js +2 -0
- package/next.config.js +3 -2
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ const { SubMenu } = Menu
|
|
|
9
9
|
const { Header, Content, Sider } = Layout
|
|
10
10
|
|
|
11
11
|
const getLocationKey = () => {
|
|
12
|
-
|
|
12
|
+
const result = {
|
|
13
13
|
topMenu: '1',
|
|
14
14
|
slideMenu: '0'
|
|
15
15
|
}
|
|
@@ -28,11 +28,11 @@ const getLocationKey = () => {
|
|
|
28
28
|
|
|
29
29
|
console.log('locationStr', locationStr)
|
|
30
30
|
|
|
31
|
-
_.each(menuConfig, (item, index) => {
|
|
31
|
+
_.each(menuConfig, (item:any, index:any) => {
|
|
32
32
|
const { key, url, subMenus } = item
|
|
33
33
|
|
|
34
34
|
if (subMenus) {
|
|
35
|
-
_.each(subMenus, (subItem, subIndex) => {
|
|
35
|
+
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
36
36
|
const { key: subKey, url: subUrl } = subItem
|
|
37
37
|
|
|
38
38
|
if (locationStr === subUrl.split('?')[0]) {
|
|
@@ -40,7 +40,6 @@ const getLocationKey = () => {
|
|
|
40
40
|
const subKeyArrLen = subKeyArr.length
|
|
41
41
|
|
|
42
42
|
if (subKeyArrLen > 0) result.topMenu = subKeyArr[0]
|
|
43
|
-
|
|
44
43
|
if (subKeyArrLen > 1) result.slideMenu = subKeyArr[1]
|
|
45
44
|
|
|
46
45
|
return false
|
|
@@ -89,7 +88,7 @@ const LayoutComponent = ({ children }) => {
|
|
|
89
88
|
<Image width={100} src="../images/zhizuotu_1.png" preview={false} />
|
|
90
89
|
</div>
|
|
91
90
|
<Menu theme="dark" mode="horizontal" defaultSelectedKeys={['1']} selectedKeys={[topMenuKey]}>
|
|
92
|
-
{_.map(menuConfig, (item, index) => {
|
|
91
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
93
92
|
const { key, text, url, subMenus } = item
|
|
94
93
|
if (key) {
|
|
95
94
|
return (
|
|
@@ -123,7 +122,7 @@ const LayoutComponent = ({ children }) => {
|
|
|
123
122
|
openKeys={['slider_' + topMenuKey]}
|
|
124
123
|
style={{ height: '100%', borderRight: 0 }}
|
|
125
124
|
>
|
|
126
|
-
{_.map(menuConfig, (item, index) => {
|
|
125
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
127
126
|
const { key, text, url, icon, subMenus } = item
|
|
128
127
|
|
|
129
128
|
if (subMenus) {
|
|
@@ -137,7 +136,7 @@ const LayoutComponent = ({ children }) => {
|
|
|
137
136
|
setSliderMenuKey('1')
|
|
138
137
|
}}
|
|
139
138
|
>
|
|
140
|
-
{_.map(subMenus, (subItem, subIndex) => {
|
|
139
|
+
{_.map(subMenus, (subItem:any, subIndex:any) => {
|
|
141
140
|
const { key: subKey, text: subText, url: subUrl } = subItem
|
|
142
141
|
return (
|
|
143
142
|
<Menu.Item
|
|
@@ -183,23 +182,22 @@ const LayoutComponent = ({ children }) => {
|
|
|
183
182
|
</Sider>
|
|
184
183
|
<Layout style={{ padding: '0 24px 24px' }}>
|
|
185
184
|
<Breadcrumb style={{ margin: '16px 0' }}>
|
|
186
|
-
{_.map(menuConfig, (item, index) => {
|
|
185
|
+
{_.map(menuConfig, (item:any, index:any) => {
|
|
187
186
|
const { key, text, subMenus } = item
|
|
188
187
|
|
|
189
|
-
if (
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
if (key && key === topMenuKey) {
|
|
188
|
+
if (key && key === topMenuKey) {
|
|
189
|
+
if (subMenus) {
|
|
190
|
+
const subContent = []
|
|
191
|
+
_.each(subMenus, (subItem:any, subIndex:any) => {
|
|
192
|
+
const { key: subKey, text: subText } = subItem
|
|
193
|
+
if (subKey === key + '_' + sliderMenuKey) {
|
|
194
|
+
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{text}</Breadcrumb.Item>)
|
|
195
|
+
subContent.push(<Breadcrumb.Item key={'breadcrumb' + subIndex}>{subText}</Breadcrumb.Item>)
|
|
196
|
+
return false
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
return subContent
|
|
200
|
+
} else {
|
|
203
201
|
return <Breadcrumb.Item key={'breadcrumb' + index}>{text}</Breadcrumb.Item>
|
|
204
202
|
}
|
|
205
203
|
}
|
|
@@ -39,6 +39,6 @@ export const initializeStore = (preloadedState:any) => {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function useStore(initialState:any) {
|
|
42
|
-
const
|
|
43
|
-
return
|
|
42
|
+
const memoStore = useMemo(() => initializeStore(initialState), [initialState])
|
|
43
|
+
return memoStore
|
|
44
44
|
}
|
|
@@ -13,7 +13,7 @@ export const getTemplate = (page=0, pageSize=10) => (
|
|
|
13
13
|
|
|
14
14
|
getTemplateService(page, pageSize)
|
|
15
15
|
.then((res: any) => {
|
|
16
|
-
//console.log('action_res', res)
|
|
16
|
+
// console.log('action_res', res)
|
|
17
17
|
const { data } = res
|
|
18
18
|
dispatch({
|
|
19
19
|
type: types.GET_TEMPLATE_SUCCEEDED,
|
|
@@ -41,12 +41,12 @@ export const searchTemplate = (page=0, pageSize=10, data: any) => (
|
|
|
41
41
|
|
|
42
42
|
searchTemplateService(page, pageSize, data)
|
|
43
43
|
.then((res: any) => {
|
|
44
|
-
//console.log('action_res', res)
|
|
45
|
-
const { data } = res
|
|
44
|
+
// console.log('action_res', res)
|
|
45
|
+
const { data:resData } = res
|
|
46
46
|
dispatch({
|
|
47
47
|
type: types.SEARCH_TEMPLATE_SUCCEEDED,
|
|
48
48
|
payload: {
|
|
49
|
-
template:
|
|
49
|
+
template: resData.templateSearch
|
|
50
50
|
}
|
|
51
51
|
})
|
|
52
52
|
})
|
|
@@ -66,7 +66,7 @@ export const updateSSRTemplate = (template: any) => (
|
|
|
66
66
|
dispatch({
|
|
67
67
|
type: types.UPDATE_SSR_TEMPLATE,
|
|
68
68
|
payload: {
|
|
69
|
-
template
|
|
69
|
+
template
|
|
70
70
|
}
|
|
71
71
|
})
|
|
72
72
|
}
|
|
@@ -83,7 +83,7 @@ export const addTemplate = (obj:any) => (
|
|
|
83
83
|
|
|
84
84
|
addTemplateService(obj)
|
|
85
85
|
.then((res: any) => {
|
|
86
|
-
//console.log('action_res', res)
|
|
86
|
+
// console.log('action_res', res)
|
|
87
87
|
const { data } = res
|
|
88
88
|
const template = {
|
|
89
89
|
id: data.templateAdd,
|
|
@@ -115,7 +115,7 @@ export const modTemplate = (id: number, obj: any) => (
|
|
|
115
115
|
|
|
116
116
|
updateTemplateService(id, obj)
|
|
117
117
|
.then((res: any) => {
|
|
118
|
-
console.log('action_res', res)
|
|
118
|
+
// console.log('action_res', res)
|
|
119
119
|
const template = {
|
|
120
120
|
id,
|
|
121
121
|
...obj
|
|
@@ -146,7 +146,7 @@ export const delTemplate = (id: number) => (
|
|
|
146
146
|
|
|
147
147
|
deleteTemplateService(id)
|
|
148
148
|
.then((res: any) => {
|
|
149
|
-
console.log('action_res', res)
|
|
149
|
+
// console.log('action_res', res)
|
|
150
150
|
|
|
151
151
|
dispatch({
|
|
152
152
|
type: types.DEL_TEMPLATE_SUCCEEDED,
|
|
@@ -174,7 +174,7 @@ export const batchDelTemplate = (ids:any) => (
|
|
|
174
174
|
|
|
175
175
|
batchDeleteTemplateService(ids)
|
|
176
176
|
.then((res: any) => {
|
|
177
|
-
console.log('action_res', res)
|
|
177
|
+
// console.log('action_res', res)
|
|
178
178
|
|
|
179
179
|
dispatch({
|
|
180
180
|
type: types.BATCH_DEL_TEMPLATE_SUCCEEDED,
|
|
@@ -16,32 +16,32 @@ export const templateManageReducer = (state = initialState, { type, payload }) =
|
|
|
16
16
|
|
|
17
17
|
switch (type) {
|
|
18
18
|
case types.UPDATE_SSR_TEMPLATE:
|
|
19
|
-
//console.log('reducer_payload_ssr', payload)
|
|
19
|
+
// console.log('reducer_payload_ssr', payload)
|
|
20
20
|
return {
|
|
21
21
|
...state,
|
|
22
22
|
firstLoadFlag: true,
|
|
23
23
|
template: payload.template
|
|
24
24
|
}
|
|
25
25
|
case types.GET_TEMPLATE_SUCCEEDED:
|
|
26
|
-
//console.log('reducer_payload_get', payload)
|
|
26
|
+
// console.log('reducer_payload_get', payload)
|
|
27
27
|
return {
|
|
28
28
|
...state,
|
|
29
29
|
firstLoadFlag: false,
|
|
30
30
|
template: payload.template
|
|
31
31
|
}
|
|
32
32
|
case types.SEARCH_TEMPLATE_SUCCEEDED:
|
|
33
|
-
console.log('reducer_payload_search', payload)
|
|
33
|
+
// console.log('reducer_payload_search', payload)
|
|
34
34
|
return {
|
|
35
35
|
...state,
|
|
36
36
|
firstLoadFlag: false,
|
|
37
37
|
template: payload.template
|
|
38
38
|
}
|
|
39
39
|
case types.ADD_TEMPLATE_SUCCEEDED:
|
|
40
|
-
//console.log('reducer_payload_add', payload)
|
|
40
|
+
// console.log('reducer_payload_add', payload)
|
|
41
41
|
newItems = [...items]
|
|
42
42
|
newItems.push(payload.template)
|
|
43
43
|
|
|
44
|
-
//console.log('newItems-add', newItems)
|
|
44
|
+
// console.log('newItems-add', newItems)
|
|
45
45
|
return {
|
|
46
46
|
...state,
|
|
47
47
|
firstLoadFlag: false,
|
|
@@ -51,37 +51,37 @@ export const templateManageReducer = (state = initialState, { type, payload }) =
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
case types.MOD_TEMPLATE_SUCCEEDED:
|
|
54
|
-
//console.log('reducer_payload_mod', payload)
|
|
54
|
+
// console.log('reducer_payload_mod', payload)
|
|
55
55
|
const modItem = payload.template
|
|
56
56
|
|
|
57
57
|
_.each(items, (item, index) => {
|
|
58
|
-
if (item.id
|
|
58
|
+
if (item.id === modItem.id) {
|
|
59
59
|
newItems.push(modItem)
|
|
60
60
|
} else {
|
|
61
61
|
newItems.push(item)
|
|
62
62
|
}
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
//console.log('newItems-mod', newItems)
|
|
65
|
+
// console.log('newItems-mod', newItems)
|
|
66
66
|
return {
|
|
67
67
|
...state,
|
|
68
68
|
firstLoadFlag: false,
|
|
69
69
|
template: {
|
|
70
|
-
totalCounts
|
|
70
|
+
totalCounts,
|
|
71
71
|
items: newItems
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
case types.DEL_TEMPLATE_SUCCEEDED:
|
|
75
|
-
//console.log('reducer_payload_del', payload)
|
|
75
|
+
// console.log('reducer_payload_del', payload)
|
|
76
76
|
const delItemId = payload.id
|
|
77
77
|
|
|
78
|
-
_.each(items, (item, index) => {
|
|
79
|
-
if (item.id
|
|
78
|
+
_.each(items, (item:any, index:any) => {
|
|
79
|
+
if (item.id !== delItemId) {
|
|
80
80
|
newItems.push(item)
|
|
81
81
|
}
|
|
82
82
|
})
|
|
83
83
|
|
|
84
|
-
//console.log('newItems-del', newItems)
|
|
84
|
+
// console.log('newItems-del', newItems)
|
|
85
85
|
return {
|
|
86
86
|
...state,
|
|
87
87
|
firstLoadFlag: false,
|
|
@@ -95,7 +95,7 @@ export const templateManageReducer = (state = initialState, { type, payload }) =
|
|
|
95
95
|
const allIds = _.map(_.map(items, (item) => _.pick(item, ['id'])), 'id')
|
|
96
96
|
const diffIds = _.xor(allIds, delItemIds)
|
|
97
97
|
|
|
98
|
-
console.log('delItemIds', delItemIds, allIds, diffIds)
|
|
98
|
+
// console.log('delItemIds', delItemIds, allIds, diffIds)
|
|
99
99
|
|
|
100
100
|
newItems = _.filter(items, (item) => _.includes(diffIds, item.id))
|
|
101
101
|
|
|
@@ -103,7 +103,7 @@ export const templateManageReducer = (state = initialState, { type, payload }) =
|
|
|
103
103
|
if (newTotalCounts < 0)
|
|
104
104
|
newTotalCounts = 0
|
|
105
105
|
|
|
106
|
-
console.log('newItems-batch-del', newItems, newTotalCounts)
|
|
106
|
+
// console.log('newItems-batch-del', newItems, newTotalCounts)
|
|
107
107
|
return {
|
|
108
108
|
...state,
|
|
109
109
|
firstLoadFlag: false,
|
|
@@ -10,7 +10,7 @@ export const getLocalApiPrefix = () => {
|
|
|
10
10
|
const location = window.location
|
|
11
11
|
// console.log('location', location)
|
|
12
12
|
protocol = location.protocol
|
|
13
|
-
if (protocol.indexOf(':')
|
|
13
|
+
if (protocol.indexOf(':') !== -1) {
|
|
14
14
|
protocol = protocol.split(':')[0]
|
|
15
15
|
}
|
|
16
16
|
host = location.hostname
|
|
@@ -15,7 +15,7 @@ import { UploadOutlined } from '@ant-design/icons'
|
|
|
15
15
|
const pageSize = 100
|
|
16
16
|
const dateFormat = 'YYYY-MM-DD'
|
|
17
17
|
const currentDate = moment().format(dateFormat)
|
|
18
|
-
console.log('currentDate', currentDate)
|
|
18
|
+
// console.log('currentDate', currentDate)
|
|
19
19
|
|
|
20
20
|
const keyTitles = {
|
|
21
21
|
name: '名称'
|
|
@@ -33,18 +33,18 @@ const Page = ({ template }) => {
|
|
|
33
33
|
dispatch(updateSSRTemplate(template))
|
|
34
34
|
}, [dispatch])
|
|
35
35
|
|
|
36
|
-
const state = useSelector((
|
|
37
|
-
const { templateManage } = state
|
|
38
|
-
console.log('templateManage', templateManage)
|
|
36
|
+
const state = useSelector((rootState: RootState) => rootState)
|
|
37
|
+
const { templateManage }:any = state
|
|
38
|
+
// console.log('templateManage', templateManage)
|
|
39
39
|
|
|
40
40
|
if (!templateManage.firstLoadFlag) {
|
|
41
41
|
template = templateManage.template
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const { totalCounts, items:templateItems } = template
|
|
45
|
-
console.log('template', template)
|
|
45
|
+
// console.log('template', template)
|
|
46
46
|
|
|
47
|
-
_.each(templateItems, (item, index) => {
|
|
47
|
+
_.each(templateItems, (item:any, index:any) => {
|
|
48
48
|
const { id } = item
|
|
49
49
|
item.key = id
|
|
50
50
|
})
|
|
@@ -70,15 +70,15 @@ const Page = ({ template }) => {
|
|
|
70
70
|
{
|
|
71
71
|
title: '操作',
|
|
72
72
|
dataIndex: '',
|
|
73
|
-
render: (
|
|
73
|
+
render: (__:any, record:any) => {
|
|
74
74
|
return (
|
|
75
75
|
<Space>
|
|
76
76
|
<Button onClick={() => {
|
|
77
|
-
console.log('record', record)
|
|
77
|
+
// console.log('record', record)
|
|
78
78
|
updateTemplate(record)
|
|
79
79
|
}}>修改</Button>
|
|
80
80
|
<Button onClick={() => {
|
|
81
|
-
console.log('record', record)
|
|
81
|
+
// console.log('record', record)
|
|
82
82
|
const { id } = record
|
|
83
83
|
deleteTemplate(id)
|
|
84
84
|
}}>删除</Button>
|
|
@@ -90,7 +90,7 @@ const Page = ({ template }) => {
|
|
|
90
90
|
|
|
91
91
|
const rowSelection = {
|
|
92
92
|
onChange: (selectedRowKeys: React.Key[], selectedRows: any) => {
|
|
93
|
-
console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
|
|
93
|
+
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows)
|
|
94
94
|
setBatchDelIds(selectedRowKeys)
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -102,7 +102,7 @@ const Page = ({ template }) => {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
const updateTemplate = (record:any) => {
|
|
105
|
-
|
|
105
|
+
const { id, name } = record
|
|
106
106
|
|
|
107
107
|
setModalId(id)
|
|
108
108
|
setModalName(name)
|
|
@@ -128,7 +128,7 @@ const Page = ({ template }) => {
|
|
|
128
128
|
|
|
129
129
|
const getMessageTitle = (key: string) => {
|
|
130
130
|
let result = keyTitles[key]
|
|
131
|
-
if (result
|
|
131
|
+
if (result === undefined)
|
|
132
132
|
result = key
|
|
133
133
|
return result
|
|
134
134
|
}
|
|
@@ -137,12 +137,12 @@ const Page = ({ template }) => {
|
|
|
137
137
|
const modalObj = {
|
|
138
138
|
name: handleXSS(modalName)
|
|
139
139
|
}
|
|
140
|
-
console.log('handleOk', modalObj)
|
|
140
|
+
// console.log('handleOk', modalObj)
|
|
141
141
|
|
|
142
142
|
const checkResult = checkModalObj(modalObj)
|
|
143
143
|
|
|
144
144
|
if (!checkResult) {
|
|
145
|
-
if (modalId
|
|
145
|
+
if (modalId === 0) { // 新增
|
|
146
146
|
dispatch(addTemplate(modalObj))
|
|
147
147
|
} else {
|
|
148
148
|
dispatch(modTemplate(modalId, modalObj))
|
|
@@ -166,7 +166,7 @@ const Page = ({ template }) => {
|
|
|
166
166
|
if (templateItems.length > 0) {
|
|
167
167
|
const wb = XLSX.utils.book_new()
|
|
168
168
|
const jsonData = _.map(templateItems, (item) => _.omit(item, ['key']))
|
|
169
|
-
//console.log('jsonData', jsonData)
|
|
169
|
+
// console.log('jsonData', jsonData)
|
|
170
170
|
const ws = XLSX.utils.json_to_sheet(jsonData)
|
|
171
171
|
|
|
172
172
|
/* add worksheet to workbook */
|
|
@@ -182,10 +182,12 @@ const Page = ({ template }) => {
|
|
|
182
182
|
const uploadProps = {
|
|
183
183
|
name: 'file',
|
|
184
184
|
action: '/rest/template/import',
|
|
185
|
-
onChange(info:any) {
|
|
185
|
+
onChange(info: any) {
|
|
186
|
+
/*
|
|
186
187
|
if (info.file.status !== 'uploading') {
|
|
187
188
|
console.log(info.file, info.fileList)
|
|
188
189
|
}
|
|
190
|
+
*/
|
|
189
191
|
|
|
190
192
|
if (info.file.status === 'done') {
|
|
191
193
|
message.success(`${info.file.name} 文件上传成功`)
|
|
@@ -241,13 +243,13 @@ const Page = ({ template }) => {
|
|
|
241
243
|
...rowSelection,
|
|
242
244
|
}} dataSource={dataSource} columns={columns} pagination={{
|
|
243
245
|
total: totalCounts,
|
|
244
|
-
pageSize
|
|
245
|
-
onChange: (page,
|
|
246
|
-
console.log('onChange', page,
|
|
247
|
-
dispatch(
|
|
246
|
+
pageSize,
|
|
247
|
+
onChange: (page:any, newPageSize:any) => {
|
|
248
|
+
// console.log('onChange', page, newPageSize)
|
|
249
|
+
dispatch(searchTemplate(page - 1, pageSize, { name: handleXSS(searchName) }))
|
|
248
250
|
}
|
|
249
251
|
}} />
|
|
250
|
-
<Modal title={(modalId
|
|
252
|
+
<Modal title={(modalId === 0 ? "新增" : "修改") + " template"} visible={isModalVisiable} onOk={handleOk} onCancel={handleCancel} okText="确认" cancelText="取消">
|
|
251
253
|
<ModalContainer>
|
|
252
254
|
<div className="line">
|
|
253
255
|
<label>{keyTitles.name}</label>
|
|
@@ -264,12 +266,12 @@ Page.getInitialProps = async () => {
|
|
|
264
266
|
let template = null
|
|
265
267
|
|
|
266
268
|
await getTemplateService(0, pageSize).then((res: any) => {
|
|
267
|
-
console.log('res', res)
|
|
269
|
+
// console.log('res', res)
|
|
268
270
|
const { data } = res
|
|
269
271
|
template = data.template
|
|
270
272
|
})
|
|
271
273
|
|
|
272
|
-
console.log('template-getInitialProps', template)
|
|
274
|
+
// console.log('template-getInitialProps', template)
|
|
273
275
|
|
|
274
276
|
return {
|
|
275
277
|
template
|
|
@@ -8,7 +8,8 @@ router.post('/import', (req, res) => {
|
|
|
8
8
|
const workbook = XLSX.read(req.files.file.data, { type: "buffer" })
|
|
9
9
|
//console.log('Sheets', workbook.Sheets)
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const entry = 'Template'
|
|
12
|
+
const datas = XLSX.utils.sheet_to_json(workbook.Sheets[entry])
|
|
12
13
|
//console.log('datas', datas)
|
|
13
14
|
|
|
14
15
|
templateBatchAdd(datas)
|
|
@@ -11,16 +11,16 @@ module.exports = {
|
|
|
11
11
|
const countSql = 'SELECT count(*) as counts from template'
|
|
12
12
|
const values = [pageSize, page * pageSize]
|
|
13
13
|
|
|
14
|
-
console.log('sql', sql, values, countSql)
|
|
14
|
+
// console.log('sql', sql, values, countSql)
|
|
15
15
|
|
|
16
16
|
connection.query(sql, values, (error, results, fields) => {
|
|
17
17
|
if (error) throw error
|
|
18
|
-
console.log('results', results)
|
|
18
|
+
// console.log('results', results)
|
|
19
19
|
|
|
20
20
|
connection.query(countSql, (countError, countResults, countFields) => {
|
|
21
21
|
if (countError) throw countError
|
|
22
22
|
const totalCounts = countResults[0].counts
|
|
23
|
-
console.log('totalCounts', totalCounts)
|
|
23
|
+
// console.log('totalCounts', totalCounts)
|
|
24
24
|
|
|
25
25
|
resolve({
|
|
26
26
|
totalCounts,
|
|
@@ -33,21 +33,21 @@ module.exports = {
|
|
|
33
33
|
})
|
|
34
34
|
},
|
|
35
35
|
templateGet: ({ id }) => {
|
|
36
|
-
console.log('templateGet', id)
|
|
36
|
+
// console.log('templateGet', id)
|
|
37
37
|
return new Promise((resolve, reject)=>{
|
|
38
38
|
getConnection().then((connection)=>{
|
|
39
39
|
let sql = 'SELECT id, name from template WHERE 1=1'
|
|
40
40
|
let values = []
|
|
41
41
|
|
|
42
|
-
if(id
|
|
42
|
+
if(id !== undefined){
|
|
43
43
|
sql += ' AND id=? '
|
|
44
44
|
values.push(id)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
console.log('sql', sql, values)
|
|
47
|
+
// console.log('sql', sql, values)
|
|
48
48
|
connection.query(sql, values, (error, results, fields) => {
|
|
49
49
|
if (error) throw error
|
|
50
|
-
console.log('results', results)
|
|
50
|
+
// console.log('results', results)
|
|
51
51
|
|
|
52
52
|
if(results.length > 0)
|
|
53
53
|
resolve(results[0])
|
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
|
59
59
|
})
|
|
60
60
|
},
|
|
61
61
|
templateSearch: ({ page = 0, pageSize = 10, data }) => {
|
|
62
|
-
console.log('templateSearch', page, pageSize, data)
|
|
62
|
+
// console.log('templateSearch', page, pageSize, data)
|
|
63
63
|
const { name } = data
|
|
64
64
|
return new Promise((resolve, reject)=>{
|
|
65
65
|
getConnection().then((connection)=>{
|
|
@@ -67,7 +67,7 @@ module.exports = {
|
|
|
67
67
|
const countsValues = []
|
|
68
68
|
|
|
69
69
|
let whereSql = ''
|
|
70
|
-
if(name
|
|
70
|
+
if(name !== undefined && name !== ''){
|
|
71
71
|
whereSql += ' AND name like ? '
|
|
72
72
|
values.push('%' + name + '%')
|
|
73
73
|
countsValues.push('%' + name + '%')
|
|
@@ -79,16 +79,16 @@ module.exports = {
|
|
|
79
79
|
values.push(pageSize)
|
|
80
80
|
values.push(page * pageSize)
|
|
81
81
|
|
|
82
|
-
console.log('sql', sql, values, countSql)
|
|
82
|
+
// console.log('sql', sql, values, countSql)
|
|
83
83
|
|
|
84
84
|
connection.query(sql, values, (error, results, fields) => {
|
|
85
85
|
if (error) throw error
|
|
86
|
-
console.log('results', results)
|
|
86
|
+
// console.log('results', results)
|
|
87
87
|
|
|
88
88
|
connection.query(countSql, countsValues, (countError, countResults, countFields) => {
|
|
89
89
|
if (countError) throw countError
|
|
90
90
|
const totalCounts = countResults[0].counts
|
|
91
|
-
console.log('totalCounts', totalCounts)
|
|
91
|
+
// console.log('totalCounts', totalCounts)
|
|
92
92
|
|
|
93
93
|
resolve({
|
|
94
94
|
totalCounts,
|
|
@@ -101,7 +101,7 @@ module.exports = {
|
|
|
101
101
|
})
|
|
102
102
|
},
|
|
103
103
|
templateAdd: ({ data }) => {
|
|
104
|
-
console.log('templateAdd', data)
|
|
104
|
+
// console.log('templateAdd', data)
|
|
105
105
|
const { name } = data
|
|
106
106
|
return new Promise((resolve, reject)=>{
|
|
107
107
|
getConnection().then((connection)=>{
|
|
@@ -109,10 +109,10 @@ module.exports = {
|
|
|
109
109
|
let sql = 'INSERT INTO template (name) values (?)'
|
|
110
110
|
let values = [name]
|
|
111
111
|
|
|
112
|
-
console.log('sql', sql, values)
|
|
112
|
+
// console.log('sql', sql, values)
|
|
113
113
|
connection.query(sql, values, (error, results, fields) => {
|
|
114
114
|
if (error) throw error
|
|
115
|
-
console.log('results', results)
|
|
115
|
+
// console.log('results', results)
|
|
116
116
|
|
|
117
117
|
resolve(results.insertId)
|
|
118
118
|
connection.end()
|
|
@@ -120,8 +120,8 @@ module.exports = {
|
|
|
120
120
|
})
|
|
121
121
|
})
|
|
122
122
|
},
|
|
123
|
-
templateBatchAdd: (datas) => {
|
|
124
|
-
console.log('templateBatchAdd', datas)
|
|
123
|
+
templateBatchAdd: ({ datas }) => {
|
|
124
|
+
// console.log('templateBatchAdd', datas)
|
|
125
125
|
return new Promise((resolve, reject)=>{
|
|
126
126
|
getConnection().then((connection)=>{
|
|
127
127
|
|
|
@@ -136,10 +136,10 @@ module.exports = {
|
|
|
136
136
|
|
|
137
137
|
sql = sql.substring(0, sql.length - 1)
|
|
138
138
|
|
|
139
|
-
console.log('sql', sql, values)
|
|
139
|
+
// console.log('sql', sql, values)
|
|
140
140
|
connection.query(sql, values, (error, results, fields) => {
|
|
141
141
|
if (error) throw error
|
|
142
|
-
console.log('results', results)
|
|
142
|
+
// console.log('results', results)
|
|
143
143
|
|
|
144
144
|
resolve(results.insertId)
|
|
145
145
|
connection.end()
|
|
@@ -148,19 +148,19 @@ module.exports = {
|
|
|
148
148
|
})
|
|
149
149
|
},
|
|
150
150
|
templateUpdate: ({ id, data }) => {
|
|
151
|
-
console.log('templateUpdate', id, data)
|
|
151
|
+
// console.log('templateUpdate', id, data)
|
|
152
152
|
const { name } = data
|
|
153
153
|
return new Promise((resolve, reject)=>{
|
|
154
154
|
getConnection().then((connection)=>{
|
|
155
155
|
let sql = 'UPDATE template SET'
|
|
156
156
|
let values = []
|
|
157
157
|
|
|
158
|
-
if(name
|
|
158
|
+
if(name !== undefined){
|
|
159
159
|
sql += ' name=? '
|
|
160
160
|
values.push(name)
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
if(sql.indexOf('?')
|
|
163
|
+
if(sql.indexOf('?') === -1){
|
|
164
164
|
sql += ' id=? '
|
|
165
165
|
values.push(id)
|
|
166
166
|
}
|
|
@@ -168,10 +168,10 @@ module.exports = {
|
|
|
168
168
|
sql += ' WHERE id=? '
|
|
169
169
|
values.push(id)
|
|
170
170
|
|
|
171
|
-
console.log('sql', sql, values)
|
|
171
|
+
// console.log('sql', sql, values)
|
|
172
172
|
connection.query(sql, values, (error, results, fields) => {
|
|
173
173
|
if (error) throw error
|
|
174
|
-
console.log('results', results)
|
|
174
|
+
// console.log('results', results)
|
|
175
175
|
|
|
176
176
|
resolve(true)
|
|
177
177
|
connection.end()
|
|
@@ -180,16 +180,16 @@ module.exports = {
|
|
|
180
180
|
})
|
|
181
181
|
},
|
|
182
182
|
templateDelete: ({ id }) => {
|
|
183
|
-
console.log('templateDelete', id)
|
|
183
|
+
// console.log('templateDelete', id)
|
|
184
184
|
return new Promise((resolve, reject)=>{
|
|
185
185
|
getConnection().then((connection)=>{
|
|
186
186
|
const sql = 'DELETE FROM template WHERE id=?'
|
|
187
187
|
const values = [id]
|
|
188
|
-
console.log('sql', sql, values)
|
|
188
|
+
// console.log('sql', sql, values)
|
|
189
189
|
|
|
190
190
|
connection.query(sql, values, (error, results, fields) => {
|
|
191
191
|
if (error) throw error
|
|
192
|
-
console.log('results', results)
|
|
192
|
+
// console.log('results', results)
|
|
193
193
|
|
|
194
194
|
resolve(true)
|
|
195
195
|
connection.end()
|
|
@@ -198,7 +198,7 @@ module.exports = {
|
|
|
198
198
|
})
|
|
199
199
|
},
|
|
200
200
|
templateBatchDelete: ({ ids }) => {
|
|
201
|
-
console.log('templateBatchDelete', ids)
|
|
201
|
+
// console.log('templateBatchDelete', ids)
|
|
202
202
|
return new Promise((resolve, reject)=>{
|
|
203
203
|
getConnection().then((connection)=>{
|
|
204
204
|
let sql = 'DELETE FROM template WHERE id in ('
|
|
@@ -214,11 +214,11 @@ module.exports = {
|
|
|
214
214
|
sql += ')'
|
|
215
215
|
|
|
216
216
|
const values = ids
|
|
217
|
-
console.log('sql', sql, values)
|
|
217
|
+
// console.log('sql', sql, values)
|
|
218
218
|
|
|
219
219
|
connection.query(sql, values, (error, results, fields) => {
|
|
220
220
|
if (error) throw error
|
|
221
|
-
console.log('results', results)
|
|
221
|
+
// console.log('results', results)
|
|
222
222
|
|
|
223
223
|
resolve(true)
|
|
224
224
|
connection.end()
|
|
@@ -6,7 +6,7 @@ const router = express.Router()
|
|
|
6
6
|
|
|
7
7
|
router.use((req, res, next) => {
|
|
8
8
|
const fullUrl = req.protocol + '://' + req.get('host') + req.originalUrl
|
|
9
|
-
console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
|
|
9
|
+
// console.log(moment().format('YYYY-MM-DD HH:mm:ss') + ' ' + fullUrl)
|
|
10
10
|
next()
|
|
11
11
|
})
|
|
12
12
|
|
package/lib/generate.js
CHANGED
|
@@ -284,12 +284,14 @@ var initFiles = function (dictionary, upgradeFlag) {
|
|
|
284
284
|
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save nsgm-cli');
|
|
285
285
|
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/node');
|
|
286
286
|
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/react');
|
|
287
|
+
shelljs_1.default.exec('cd ' + dictionary + ' && npm install --save-dev @types/lodash');
|
|
287
288
|
}
|
|
288
289
|
else {
|
|
289
290
|
shelljs_1.default.sed('-i', eval('/nsgm-cli-project/'), path_1.default.basename(destFolder) + '-project', destPackagePath);
|
|
290
291
|
shelljs_1.default.exec('npm install --save nsgm-cli');
|
|
291
292
|
shelljs_1.default.exec('npm install --save-dev @types/node');
|
|
292
293
|
shelljs_1.default.exec('npm install --save-dev @types/react');
|
|
294
|
+
shelljs_1.default.exec('npm install --save-dev @types/lodash');
|
|
293
295
|
}
|
|
294
296
|
}
|
|
295
297
|
console.log('initFiles finished');
|
package/next.config.js
CHANGED
|
@@ -52,10 +52,11 @@ module.exports = (phase, defaultConfig, options) => {
|
|
|
52
52
|
prefix,
|
|
53
53
|
protocol,
|
|
54
54
|
host,
|
|
55
|
-
port
|
|
55
|
+
port,
|
|
56
|
+
phase
|
|
56
57
|
},
|
|
57
58
|
generateBuildId: async () => {
|
|
58
|
-
return '
|
|
59
|
+
return 'nsgm-cli-' + version
|
|
59
60
|
},
|
|
60
61
|
exportPathMap: async function (defaultPathMap,
|
|
61
62
|
{ dev, dir, outDir }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nsgm-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "A CLI tool to run Next/Style-components and Graphql/Mysql fullstack project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"markdown-it": "^12.0.4",
|
|
68
68
|
"moment": "^2.29.1",
|
|
69
69
|
"mysql": "^2.18.1",
|
|
70
|
-
"next": "^
|
|
70
|
+
"next": "^11.0.1",
|
|
71
71
|
"react": "^17.0.1",
|
|
72
72
|
"react-dom": "^17.0.1",
|
|
73
73
|
"react-redux": "^7.2.2",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"terser-webpack-plugin": "^4.2.3",
|
|
82
82
|
"typescript": "^4.1.3",
|
|
83
83
|
"uglify-es": "^3.3.9",
|
|
84
|
-
"webpack": "^
|
|
84
|
+
"webpack": "^5.44.0",
|
|
85
85
|
"webpack-simple-progress-plugin": "0.0.4",
|
|
86
86
|
"xlsx": "^0.16.9"
|
|
87
87
|
},
|