nsgm-cli 2.0.6 → 2.0.8

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.
Files changed (59) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +161 -161
  3. package/client/layout/index.tsx +248 -245
  4. package/client/redux/reducers.ts +4 -4
  5. package/client/redux/store.ts +50 -50
  6. package/client/redux/template/manage/actions.ts +190 -190
  7. package/client/redux/template/manage/reducers.ts +118 -118
  8. package/client/redux/template/manage/types.ts +24 -24
  9. package/client/service/template/manage.ts +96 -96
  10. package/client/styled/common.ts +60 -27
  11. package/client/styled/layout/index.ts +25 -25
  12. package/client/styled/template/manage.ts +51 -51
  13. package/client/utils/common.ts +89 -86
  14. package/client/utils/cookie.ts +51 -51
  15. package/client/utils/fetch.ts +25 -25
  16. package/client/utils/menu.tsx +27 -27
  17. package/client/utils/sso.ts +205 -0
  18. package/generation/README.md +19 -19
  19. package/generation/app.js +2 -2
  20. package/generation/client/redux/reducers.ts +4 -4
  21. package/generation/client/utils/menu.tsx +27 -27
  22. package/generation/gitignore +4 -4
  23. package/generation/mysql.config.js +12 -13
  24. package/generation/next.config.js +6 -6
  25. package/generation/package.json +21 -26
  26. package/generation/project.config.js +13 -12
  27. package/generation/server/rest.js +23 -20
  28. package/generation/tsconfig.json +30 -30
  29. package/index.js +10 -10
  30. package/lib/args.d.ts +6 -6
  31. package/lib/args.js +53 -53
  32. package/lib/generate.d.ts +3 -3
  33. package/lib/generate.js +751 -736
  34. package/lib/index.d.ts +2 -2
  35. package/lib/index.js +272 -272
  36. package/lib/server/db.d.ts +5 -5
  37. package/lib/server/db.js +110 -110
  38. package/lib/server/graphql.d.ts +7 -7
  39. package/lib/server/graphql.js +119 -119
  40. package/lib/server/plugins/date.d.ts +5 -5
  41. package/lib/server/plugins/date.js +16 -16
  42. package/lib/tsconfig.build.tsbuildinfo +1 -1
  43. package/mysql.config.js +14 -14
  44. package/next-env.d.ts +6 -6
  45. package/next.config.js +2 -2
  46. package/package.json +126 -126
  47. package/pages/_app.tsx +54 -44
  48. package/pages/login.tsx +79 -0
  49. package/pages/template/manage.tsx +278 -278
  50. package/project.config.js +16 -14
  51. package/public/slbhealthcheck.html +9 -9
  52. package/scripts/shutdown.sh +9 -9
  53. package/scripts/startup.sh +34 -34
  54. package/server/apis/sso.js +44 -0
  55. package/server/apis/template.js +17 -17
  56. package/server/modules/template/schema.js +33 -33
  57. package/server/rest.js +24 -20
  58. package/server/sql/template.sql +8 -8
  59. package/generation/.DS_Store +0 -0
@@ -1,97 +1,97 @@
1
- import { getLocalGraphql } from '../../utils/fetch'
2
- import _ from 'lodash'
3
-
4
- export const getTemplateService = (page=0, pageSize=10) => {
5
- const getTemplateQuery = `query ($page: Int, $pageSize: Int) { template(page: $page, pageSize: $pageSize) {
6
- totalCounts items {
7
- id name
8
- }
9
- }
10
- }`
11
-
12
- return getLocalGraphql(getTemplateQuery, {
13
- page,
14
- pageSize
15
- })
16
- }
17
-
18
- export const searchTemplateByIdService = (id: number) => {
19
-
20
- const searchTemplateByIdQuery = `query ($id: Int) { templateGet(id: $id){
21
- id name
22
- }
23
- }`
24
-
25
- return getLocalGraphql(searchTemplateByIdQuery, {
26
- id
27
- })
28
- }
29
-
30
- export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
31
- const { name } = data
32
-
33
- const searchTemplateQuery = `query ($page: Int, $pageSize: Int, $data: TemplateSearchInput) {
34
- templateSearch(page: $page, pageSize: $pageSize, data: $data) {
35
- totalCounts items {
36
- id name
37
- }
38
- }
39
- }`
40
-
41
- return getLocalGraphql(searchTemplateQuery, {
42
- page,
43
- pageSize,
44
- data: {
45
- name
46
- }
47
- })
48
- }
49
-
50
- export const addTemplateService = (data: any) => {
51
- const { name } = data
52
-
53
- const addTemplateQuery = `mutation ($data: TemplateAddInput) { templateAdd(data: $data) }`
54
-
55
- return getLocalGraphql(addTemplateQuery, {
56
- data: {
57
- name
58
- }
59
- })
60
- }
61
-
62
- export const updateTemplateService = (id: number, data: any) => {
63
- const { name } = data
64
-
65
- const updateTemplateQuery = `mutation ($id: Int, $data: TemplateAddInput) { templateUpdate(id: $id, data: $data) }`
66
-
67
- return getLocalGraphql(updateTemplateQuery, {
68
- id,
69
- data: {
70
- name
71
- }
72
- })
73
- }
74
-
75
- export const deleteTemplateService = (id: number) => {
76
- const deleteTemplateQuery = `mutation ($id: Int) { templateDelete(id: $id) }`
77
-
78
- return getLocalGraphql(deleteTemplateQuery, {
79
- id
80
- })
81
- }
82
-
83
- export const batchAddTemplateService = (datas: any) => {
84
- const batchAddTemplateQuery = `mutation ($datas: [TemplateAddInput]) { templateBatchAdd(datas: $datas) }`
85
-
86
- return getLocalGraphql(batchAddTemplateQuery, {
87
- datas
88
- })
89
- }
90
-
91
- export const batchDeleteTemplateService = (ids: any) => {
92
- const batchDeleteTemplateQuery = `mutation ($ids: [Int]) { templateBatchDelete(ids: $ids) }`
93
-
94
- return getLocalGraphql(batchDeleteTemplateQuery, {
95
- ids
96
- })
1
+ import { getLocalGraphql } from '../../utils/fetch'
2
+ import _ from 'lodash'
3
+
4
+ export const getTemplateService = (page=0, pageSize=10) => {
5
+ const getTemplateQuery = `query ($page: Int, $pageSize: Int) { template(page: $page, pageSize: $pageSize) {
6
+ totalCounts items {
7
+ id name
8
+ }
9
+ }
10
+ }`
11
+
12
+ return getLocalGraphql(getTemplateQuery, {
13
+ page,
14
+ pageSize
15
+ })
16
+ }
17
+
18
+ export const searchTemplateByIdService = (id: number) => {
19
+
20
+ const searchTemplateByIdQuery = `query ($id: Int) { templateGet(id: $id){
21
+ id name
22
+ }
23
+ }`
24
+
25
+ return getLocalGraphql(searchTemplateByIdQuery, {
26
+ id
27
+ })
28
+ }
29
+
30
+ export const searchTemplateService = (page = 0, pageSize = 10, data: any) => {
31
+ const { name } = data
32
+
33
+ const searchTemplateQuery = `query ($page: Int, $pageSize: Int, $data: TemplateSearchInput) {
34
+ templateSearch(page: $page, pageSize: $pageSize, data: $data) {
35
+ totalCounts items {
36
+ id name
37
+ }
38
+ }
39
+ }`
40
+
41
+ return getLocalGraphql(searchTemplateQuery, {
42
+ page,
43
+ pageSize,
44
+ data: {
45
+ name
46
+ }
47
+ })
48
+ }
49
+
50
+ export const addTemplateService = (data: any) => {
51
+ const { name } = data
52
+
53
+ const addTemplateQuery = `mutation ($data: TemplateAddInput) { templateAdd(data: $data) }`
54
+
55
+ return getLocalGraphql(addTemplateQuery, {
56
+ data: {
57
+ name
58
+ }
59
+ })
60
+ }
61
+
62
+ export const updateTemplateService = (id: number, data: any) => {
63
+ const { name } = data
64
+
65
+ const updateTemplateQuery = `mutation ($id: Int, $data: TemplateAddInput) { templateUpdate(id: $id, data: $data) }`
66
+
67
+ return getLocalGraphql(updateTemplateQuery, {
68
+ id,
69
+ data: {
70
+ name
71
+ }
72
+ })
73
+ }
74
+
75
+ export const deleteTemplateService = (id: number) => {
76
+ const deleteTemplateQuery = `mutation ($id: Int) { templateDelete(id: $id) }`
77
+
78
+ return getLocalGraphql(deleteTemplateQuery, {
79
+ id
80
+ })
81
+ }
82
+
83
+ export const batchAddTemplateService = (datas: any) => {
84
+ const batchAddTemplateQuery = `mutation ($datas: [TemplateAddInput]) { templateBatchAdd(datas: $datas) }`
85
+
86
+ return getLocalGraphql(batchAddTemplateQuery, {
87
+ datas
88
+ })
89
+ }
90
+
91
+ export const batchDeleteTemplateService = (ids: any) => {
92
+ const batchDeleteTemplateQuery = `mutation ($ids: [Int]) { templateBatchDelete(ids: $ids) }`
93
+
94
+ return getLocalGraphql(batchDeleteTemplateQuery, {
95
+ ids
96
+ })
97
97
  }
@@ -1,27 +1,60 @@
1
- import styled, { createGlobalStyle } from 'styled-components'
2
-
3
- export const GlobalStyle = createGlobalStyle`
4
- html,body,#__next {
5
- height: 100%;
6
- border: 1px solid white;
7
- }
8
-
9
- body {
10
- background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
11
- font-family: Helvetica;
12
- margin: 0;
13
- }
14
- `
15
-
16
- export const Container = styled.div`
17
- margin: 20px;
18
- `
19
-
20
- export const Loading = styled.div`
21
- display: flex;
22
- flex: 1;
23
- flex-direction: row;
24
- justify-content: center;
25
- align-items: center;
26
- margin-top: 100px;
27
- `
1
+ import styled, { createGlobalStyle } from 'styled-components'
2
+
3
+ export const GlobalStyle = createGlobalStyle`
4
+ html,body,#__next {
5
+ height: 100%;
6
+ border: 1px solid white;
7
+ }
8
+
9
+ body {
10
+ background-color: ${(props: any) => (props.whiteColor ? 'white' : 'black')};
11
+ font-family: Helvetica;
12
+ margin: 0;
13
+ }
14
+ `
15
+
16
+ export const Container = styled.div`
17
+ margin: 20px;
18
+ `
19
+
20
+ export const LoginContainer = styled.div`
21
+ margin: auto;
22
+ margin-top: 200px;
23
+ width: 250px;
24
+ display: flex;
25
+ flex-direction: column;
26
+ justify-content: center;
27
+ align-items: flex-start;
28
+ border: 1px solid gray;
29
+ border-radius: 5px;
30
+ padding: 20px;
31
+
32
+ .row {
33
+ width: 100%;
34
+ display: flex;
35
+ flex: 1;
36
+ flex-direction: row;
37
+ justify-content: flex-start;
38
+ align-items: center;
39
+
40
+ .user-input {
41
+ width: 210px;
42
+ margin-bottom: 5px;
43
+ }
44
+ }
45
+
46
+ .right {
47
+ margin-top: 10px;
48
+ justify-content: flex-end;
49
+ }
50
+ `
51
+
52
+ export const Loading = styled.div`
53
+ display: flex;
54
+ flex: 1;
55
+ flex-direction: row;
56
+ justify-content: center;
57
+ align-items: center;
58
+ margin-top: 100px;
59
+ `
60
+
@@ -1,26 +1,26 @@
1
- import styled from 'styled-components'
2
-
3
- export const Container = styled.div`
4
- .header {
5
- position: relative;
6
-
7
- .logo {
8
- float: left;
9
- width: 120px;
10
- height: 31px;
11
- // margin: 16px 24px 16px 0;
12
- }
13
-
14
- .site-layout-background {
15
- background: #fff;
16
- }
17
-
18
- .user {
19
- position: absolute;
20
- right: 10px;
21
- top: 0;
22
- color: white;
23
- }
24
- }
25
-
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ .header {
5
+ position: relative;
6
+
7
+ .logo {
8
+ float: left;
9
+ width: 120px;
10
+ height: 31px;
11
+ // margin: 16px 24px 16px 0;
12
+ }
13
+
14
+ .site-layout-background {
15
+ background: #fff;
16
+ }
17
+
18
+ .user {
19
+ position: absolute;
20
+ right: 10px;
21
+ top: 0;
22
+ color: white;
23
+ }
24
+ }
25
+
26
26
  `
@@ -1,52 +1,52 @@
1
- import styled from 'styled-components'
2
-
3
- export const Container = styled.div`
4
- margin: 20px;
5
- `
6
-
7
- export const SearchRow = styled.div`
8
- margin: 10px;
9
- display: flex;
10
- flex: 1;
11
- flex-direction: row;
12
- justify-content: space-between;
13
- align-items: center;
14
- `
15
-
16
- export const ModalContainer = styled.div`
17
- .line {
18
- display: flex;
19
- flex: 1;
20
- flex-direction: row;
21
- justify-content: flex-start;
22
- align-items: flex-start;
23
- height: 50px;
24
-
25
- label {
26
- display: flex;
27
- flex-direction: column;
28
- justify-content: center;
29
- align-items: flex-start;
30
- width: 80px;
31
- height: 32px;
32
- margin-right: 5px;
33
- }
34
-
35
- input {
36
- flex: 1;
37
- }
38
-
39
- .row {
40
- display: flex;
41
- flex-direction: row;
42
- justify-content: center;
43
- align-items: center;
44
-
45
- .item {
46
- flex-direction: row;
47
- justify-content: flex-start;
48
- align-items: center;
49
- }
50
- }
51
- }
1
+ import styled from 'styled-components'
2
+
3
+ export const Container = styled.div`
4
+ margin: 20px;
5
+ `
6
+
7
+ export const SearchRow = styled.div`
8
+ margin: 10px;
9
+ display: flex;
10
+ flex: 1;
11
+ flex-direction: row;
12
+ justify-content: space-between;
13
+ align-items: center;
14
+ `
15
+
16
+ export const ModalContainer = styled.div`
17
+ .line {
18
+ display: flex;
19
+ flex: 1;
20
+ flex-direction: row;
21
+ justify-content: flex-start;
22
+ align-items: flex-start;
23
+ height: 50px;
24
+
25
+ label {
26
+ display: flex;
27
+ flex-direction: column;
28
+ justify-content: center;
29
+ align-items: flex-start;
30
+ width: 80px;
31
+ height: 32px;
32
+ margin-right: 5px;
33
+ }
34
+
35
+ input {
36
+ flex: 1;
37
+ }
38
+
39
+ .row {
40
+ display: flex;
41
+ flex-direction: row;
42
+ justify-content: center;
43
+ align-items: center;
44
+
45
+ .item {
46
+ flex-direction: row;
47
+ justify-content: flex-start;
48
+ align-items: center;
49
+ }
50
+ }
51
+ }
52
52
  `
@@ -1,86 +1,89 @@
1
- import getConfig from 'next/config'
2
- import _ from 'lodash'
3
-
4
- export const getLocalEnv = () => {
5
- const nextConfig = getConfig()
6
- const { publicRuntimeConfig } = nextConfig
7
- let { env = 'uat' } = publicRuntimeConfig
8
- env = env.toLowerCase()
9
- return env
10
- }
11
-
12
- export const getLocalApiPrefix = () => {
13
- const nextConfig = getConfig()
14
- const { publicRuntimeConfig } = nextConfig
15
- let { protocol, host, port, prefix, isExport } = publicRuntimeConfig
16
-
17
- if(!isExport){
18
- if (typeof window !== 'undefined') {
19
- const location = window.location
20
- // console.log('location', location)
21
- protocol = location.protocol
22
- if (protocol.indexOf(':') != -1) {
23
- protocol = protocol.split(':')[0]
24
- }
25
- host = location.hostname
26
- port = location.port
27
- }
28
- }
29
-
30
- const localApiPrefix = protocol + '://' + host + ':' + port + prefix
31
- // console.log('localApiPrefix', localApiPrefix)
32
- return localApiPrefix
33
- }
34
-
35
- export const handleXSS = (content: string) => {
36
- content = content || ''
37
- return content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/\'/g, '&#x27;')
38
- }
39
-
40
- export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
41
- let result: any = null
42
- _.each(modalObj, (value: any, key: string) => {
43
- // console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
44
- if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
45
- if (_.trim(value) === '') {
46
- result = {
47
- key,
48
- reason: '不能为空'
49
- }
50
- return false
51
- }
52
- }
53
- })
54
- return result
55
- }
56
-
57
- export const getUrlParamByKey = (key: string) => {
58
- let result = ''
59
- if (typeof window !== 'undefined') {
60
- const locationHref = window.location.href
61
- if (locationHref.indexOf('?') !== -1) {
62
- const locationHrefArr = locationHref.split('?')
63
- if (locationHrefArr.length > 1) {
64
- const paramsStr = locationHrefArr[1]
65
-
66
- let params:any = []
67
- if (paramsStr.indexOf('&') !== -1) {
68
- params = paramsStr.split('&')
69
- } else {
70
- params.push(paramsStr)
71
- }
72
-
73
- _.each(params, (item, index) => {
74
- if (item.indexOf('=') !== -1) {
75
- const itemArr = item.split('=')
76
- if (itemArr[0] === key) {
77
- result = itemArr[1]
78
- return false
79
- }
80
- }
81
- })
82
- }
83
- }
84
- }
85
- return result
86
- }
1
+ import getConfig from 'next/config'
2
+ import _ from 'lodash'
3
+
4
+ export const getLocalEnv = () => {
5
+ const nextConfig = getConfig()
6
+ const { publicRuntimeConfig } = nextConfig
7
+ let { env = 'uat' } = publicRuntimeConfig
8
+ env = env.toLowerCase()
9
+ return env
10
+ }
11
+
12
+ export const getLocalApiPrefix = () => {
13
+ const nextConfig = getConfig()
14
+ const { publicRuntimeConfig } = nextConfig
15
+ let { protocol, host, port, prefix, isExport } = publicRuntimeConfig
16
+
17
+ let localApiPrefix = ''
18
+
19
+ if(!isExport){
20
+ if (typeof window !== 'undefined') {
21
+ const location = window.location
22
+ // console.log('location', location)
23
+
24
+ protocol = location.protocol
25
+ if (protocol.indexOf(':') != -1) {
26
+ protocol = protocol.split(':')[0]
27
+ }
28
+ host = location.hostname
29
+ port = location.port || (protocol.indexOf('https') !== -1 ? "443" : "80")
30
+ }
31
+ }
32
+
33
+ localApiPrefix = protocol + '://' + host + ':' + port + prefix
34
+ // console.log('localApiPrefix', localApiPrefix)
35
+ return localApiPrefix
36
+ }
37
+
38
+ export const handleXSS = (content: string) => {
39
+ content = content || ''
40
+ return content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/\'/g, '&#x27;')
41
+ }
42
+
43
+ export const checkModalObj = (modalObj: {}, ignoreKeys: any = []) => {
44
+ let result: any = null
45
+ _.each(modalObj, (value: any, key: string) => {
46
+ // console.log('checkModalObj', ignoreKeys, key, ignoreKeys.join('.').indexOf(key))
47
+ if (ignoreKeys.length === 0 || (ignoreKeys.length !== 0 && ignoreKeys.join('.').indexOf(key) === -1)) {
48
+ if (_.trim(value) === '') {
49
+ result = {
50
+ key,
51
+ reason: '不能为空'
52
+ }
53
+ return false
54
+ }
55
+ }
56
+ })
57
+ return result
58
+ }
59
+
60
+ export const getUrlParamByKey = (key: string) => {
61
+ let result = ''
62
+ if (typeof window !== 'undefined') {
63
+ const locationHref = window.location.href
64
+ if (locationHref.indexOf('?') !== -1) {
65
+ const locationHrefArr = locationHref.split('?')
66
+ if (locationHrefArr.length > 1) {
67
+ const paramsStr = locationHrefArr[1]
68
+
69
+ let params:any = []
70
+ if (paramsStr.indexOf('&') !== -1) {
71
+ params = paramsStr.split('&')
72
+ } else {
73
+ params.push(paramsStr)
74
+ }
75
+
76
+ _.each(params, (item, index) => {
77
+ if (item.indexOf('=') !== -1) {
78
+ const itemArr = item.split('=')
79
+ if (itemArr[0] === key) {
80
+ result = itemArr[1]
81
+ return false
82
+ }
83
+ }
84
+ })
85
+ }
86
+ }
87
+ }
88
+ return result
89
+ }