正在显示
9 个修改的文件
包含
95 行增加
和
299 行删除
deploy/k8s/dev/partner.yaml
已删除
100644 → 0
1 | -apiVersion: v1 | ||
2 | -kind: Service | ||
3 | -metadata: | ||
4 | - name: mmmgodevp | ||
5 | - namespace: mmm-suplus-dev | ||
6 | - labels: | ||
7 | - k8s-app: mmmgodevp | ||
8 | -spec: | ||
9 | - ports: | ||
10 | - - name: "http" | ||
11 | - port: 80 | ||
12 | - targetPort: 8082 | ||
13 | - selector: | ||
14 | - k8s-app: mmmgodevp | ||
15 | ---- | ||
16 | -apiVersion: extensions/v1beta1 | ||
17 | -kind: Deployment | ||
18 | -metadata: | ||
19 | - name: mmmgodevp | ||
20 | - namespace: mmm-suplus-dev | ||
21 | - labels: | ||
22 | - k8s-app: mmmgodevp | ||
23 | -spec: | ||
24 | - replicas: 1 | ||
25 | - template: | ||
26 | - metadata: | ||
27 | - labels: | ||
28 | - k8s-app: mmmgodevp | ||
29 | - spec: | ||
30 | - affinity: | ||
31 | - nodeAffinity: | ||
32 | - preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | - - preference: {} | ||
34 | - weight: 100 | ||
35 | - requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | - nodeSelectorTerms: | ||
37 | - - matchExpressions: | ||
38 | - - key: kubernetes.io/hostname | ||
39 | - operator: In | ||
40 | - values: | ||
41 | - - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | - - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | - - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | - - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | - containers: | ||
46 | - - name: mmmgodevp | ||
47 | - image: 192.168.0.243:5000/mmm/godevp:dev | ||
48 | - imagePullPolicy: Always | ||
49 | - ports: | ||
50 | - - containerPort: 8082 | ||
51 | - volumeMounts: | ||
52 | - - mountPath: /opt/logs | ||
53 | - name: accesslogs | ||
54 | - env: | ||
55 | - - name: HTTP_PORT | ||
56 | - value: "8082" | ||
57 | - - name: POSTGRESQL_DB_NAME | ||
58 | - value: "godevp_dev" | ||
59 | - - name: POSTGRESQL_USER | ||
60 | - value: "postgres" | ||
61 | - - name: POSTGRESQL_PASSWORD | ||
62 | - value: "eagle1010" | ||
63 | - - name: POSTGRESQL_HOST | ||
64 | - value: "114.55.200.59" | ||
65 | - - name: POSTGRESQL_PORT | ||
66 | - value: "31543" | ||
67 | - - name: LOG_LEVEL | ||
68 | - value: "debug" | ||
69 | - - name: ERROR_BASE_CODE | ||
70 | - value: "1" | ||
71 | - - name: ERROR_BASE_CODE_MULTIPLE | ||
72 | - value: "1000" | ||
73 | - - name: DEFAULT_GUEST_COMPANY | ||
74 | - value: "10011" | ||
75 | - - name: ABILITY_SERVICE_HOST | ||
76 | - value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | ||
77 | - - name: MMM_OPEN_API_SERVICE_HOST | ||
78 | - value: "http://mmm-open-api-dev.fjmaimaimai.com" | ||
79 | - - name: UCENTER_SERVICE_HOST | ||
80 | - value: "https://suplus-ucenter-dev.fjmaimaimai.com" | ||
81 | - - name: BUSINESS_ADMIN_SERVICE_HOST | ||
82 | - valueFrom: | ||
83 | - configMapKeyRef: | ||
84 | - name: suplus-config | ||
85 | - key: service.businessadmin | ||
86 | - - name: REDIS_HOST | ||
87 | - valueFrom: | ||
88 | - configMapKeyRef: | ||
89 | - name: suplus-config | ||
90 | - key: redis.ip | ||
91 | - - name: REDIS_PORT | ||
92 | - valueFrom: | ||
93 | - configMapKeyRef: | ||
94 | - name: suplus-config | ||
95 | - key: redis.port | ||
96 | - - name: REDIS_AUTH | ||
97 | - value: "" | ||
98 | - volumes: | ||
99 | - - name: accesslogs | ||
100 | - emptyDir: {} |
1 | apiVersion: v1 | 1 | apiVersion: v1 |
2 | kind: Service | 2 | kind: Service |
3 | metadata: | 3 | metadata: |
4 | - name: partner | 4 | + name: mmmgodevp |
5 | namespace: mmm-suplus-prd | 5 | namespace: mmm-suplus-prd |
6 | labels: | 6 | labels: |
7 | - k8s-app: partner | 7 | + k8s-app: mmmgodevp |
8 | spec: | 8 | spec: |
9 | ports: | 9 | ports: |
10 | - name: "http" | 10 | - name: "http" |
11 | port: 80 | 11 | port: 80 |
12 | targetPort: 8082 | 12 | targetPort: 8082 |
13 | selector: | 13 | selector: |
14 | - k8s-app: partner | 14 | + k8s-app: mmmgodevp |
15 | --- | 15 | --- |
16 | apiVersion: extensions/v1beta1 | 16 | apiVersion: extensions/v1beta1 |
17 | kind: Deployment | 17 | kind: Deployment |
18 | metadata: | 18 | metadata: |
19 | - name: partner | 19 | + name: mmmgodevp |
20 | namespace: mmm-suplus-prd | 20 | namespace: mmm-suplus-prd |
21 | labels: | 21 | labels: |
22 | - k8s-app: partner | 22 | + k8s-app: mmmgodevp |
23 | spec: | 23 | spec: |
24 | replicas: 1 | 24 | replicas: 1 |
25 | template: | 25 | template: |
26 | metadata: | 26 | metadata: |
27 | labels: | 27 | labels: |
28 | - k8s-app: partner | 28 | + k8s-app: mmmgodevp |
29 | spec: | 29 | spec: |
30 | affinity: | 30 | affinity: |
31 | nodeAffinity: | 31 | nodeAffinity: |
@@ -43,8 +43,8 @@ spec: | @@ -43,8 +43,8 @@ spec: | ||
43 | - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | 43 | - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb |
44 | - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | 44 | - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy |
45 | containers: | 45 | containers: |
46 | - - name: partner | ||
47 | - image: 192.168.0.243:5000/mmm/partner:master | 46 | + - name: mmmgodevp |
47 | + image: 192.168.0.243:5000/mmm/mmmgodevp:master | ||
48 | imagePullPolicy: Always | 48 | imagePullPolicy: Always |
49 | ports: | 49 | ports: |
50 | - containerPort: 8082 | 50 | - containerPort: 8082 |
@@ -55,7 +55,7 @@ spec: | @@ -55,7 +55,7 @@ spec: | ||
55 | - name: HTTP_PORT | 55 | - name: HTTP_PORT |
56 | value: "8082" | 56 | value: "8082" |
57 | - name: POSTGRESQL_DB_NAME | 57 | - name: POSTGRESQL_DB_NAME |
58 | - value: "partner" | 58 | + value: "godevp" |
59 | - name: POSTGRESQL_USER | 59 | - name: POSTGRESQL_USER |
60 | value: "postgres" | 60 | value: "postgres" |
61 | - name: POSTGRESQL_PASSWORD | 61 | - name: POSTGRESQL_PASSWORD |
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | export PATH=/root/local/bin:$PATH | 2 | export PATH=/root/local/bin:$PATH |
3 | -kubectl -n mmm-suplus-prd get pods | grep -q partner | 3 | +kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp |
4 | if [ "$?" == "1" ];then | 4 | if [ "$?" == "1" ];then |
5 | - kubectl create -f /tmp/prd/partner/partner.yaml --record | ||
6 | - kubectl -n mmm-suplus-prd get svc | grep -q partner | 5 | + kubectl create -f /tmp/prd/godevp/godevp.yaml --record |
6 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp | ||
7 | if [ "$?" == "0" ];then | 7 | if [ "$?" == "0" ];then |
8 | - echo "partner service install success!" | 8 | + echo "godevp service install success!" |
9 | else | 9 | else |
10 | - echo "partner service install fail!" | 10 | + echo "godevp service install fail!" |
11 | fi | 11 | fi |
12 | - kubectl -n mmm-suplus-prd get pods | grep -q partner | 12 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp |
13 | if [ "$?" == "0" ];then | 13 | if [ "$?" == "0" ];then |
14 | - echo "partner deployment install success!" | 14 | + echo "godevp deployment install success!" |
15 | else | 15 | else |
16 | - echo "partner deployment install fail!" | 16 | + echo "godevp deployment install fail!" |
17 | fi | 17 | fi |
18 | else | 18 | else |
19 | - kubectl delete -f /tmp/prd/partner/partner.yaml | ||
20 | - kubectl -n mmm-suplus-prd get svc | grep -q partner | 19 | + kubectl delete -f /tmp/prd/godevp/godevp.yaml |
20 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp | ||
21 | while [ "$?" == "0" ] | 21 | while [ "$?" == "0" ] |
22 | do | 22 | do |
23 | - kubectl -n mmm-suplus-prd get svc | grep -q partner | 23 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp |
24 | done | 24 | done |
25 | - kubectl -n mmm-suplus-prd get pods | grep -q partner | 25 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp |
26 | while [ "$?" == "0" ] | 26 | while [ "$?" == "0" ] |
27 | do | 27 | do |
28 | - kubectl -n mmm-suplus-prd get pods | grep -q partner | 28 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp |
29 | done | 29 | done |
30 | - kubectl create -f /tmp/prd/partner/partner.yaml --record | ||
31 | - kubectl -n mmm-suplus-prd get svc | grep -q partner | 30 | + kubectl create -f /tmp/prd/godevp/godevp.yaml --record |
31 | + kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp | ||
32 | if [ "$?" == "0" ];then | 32 | if [ "$?" == "0" ];then |
33 | - echo "partner service update success!" | 33 | + echo "godevp service update success!" |
34 | else | 34 | else |
35 | - echo "partner service update fail!" | 35 | + echo "godevp service update fail!" |
36 | fi | 36 | fi |
37 | - kubectl -n mmm-suplus-prd get pods | grep -q partner | 37 | + kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp |
38 | if [ "$?" == "0" ];then | 38 | if [ "$?" == "0" ];then |
39 | - echo "partner deployment update success!" | 39 | + echo "godevp deployment update success!" |
40 | else | 40 | else |
41 | - echo "partner deployment update fail!" | 41 | + echo "godevp deployment update fail!" |
42 | fi | 42 | fi |
43 | fi | 43 | fi |
deploy/k8s/test/install.sh
已删除
100644 → 0
1 | -#!/bin/bash | ||
2 | -export PATH=/root/local/bin:$PATH | ||
3 | -kubectl -n mmm-suplus-test get pods | grep -q mmmpartner | ||
4 | -if [ "$?" == "1" ];then | ||
5 | - kubectl create -f /tmp/test/partner/partner.yaml --record | ||
6 | - kubectl -n mmm-suplus-test get svc | grep -q mmmpartner | ||
7 | - if [ "$?" == "0" ];then | ||
8 | - echo "mmmpartner service install success!" | ||
9 | - else | ||
10 | - echo "mmmpartner service install fail!" | ||
11 | - fi | ||
12 | - kubectl -n mmm-suplus-test get pods | grep -q mmmpartner | ||
13 | - if [ "$?" == "0" ];then | ||
14 | - echo "mmmpartner deployment install success!" | ||
15 | - else | ||
16 | - echo "mmmpartner deployment install fail!" | ||
17 | - fi | ||
18 | -else | ||
19 | - kubectl delete -f /tmp/test/partner/partner.yaml | ||
20 | - kubectl -n mmm-suplus-test get svc | grep -q mmmpartner | ||
21 | - while [ "$?" == "0" ] | ||
22 | - do | ||
23 | - kubectl -n mmm-suplus-test get svc | grep -q mmmpartner | ||
24 | - done | ||
25 | - kubectl -n mmm-suplus-test get pods | grep -q mmmpartner | ||
26 | - while [ "$?" == "0" ] | ||
27 | - do | ||
28 | - kubectl -n mmm-suplus-test get pods | grep -q mmmpartner | ||
29 | - done | ||
30 | - kubectl create -f /tmp/test/partner/partner.yaml --record | ||
31 | - kubectl -n mmm-suplus-test get svc | grep -q mmmpartner | ||
32 | - if [ "$?" == "0" ];then | ||
33 | - echo "mmmpartner service update success!" | ||
34 | - else | ||
35 | - echo "mmmpartner service update fail!" | ||
36 | - fi | ||
37 | - kubectl -n mmm-suplus-test get pods | grep -q mmmpartner | ||
38 | - if [ "$?" == "0" ];then | ||
39 | - echo "mmmpartner deployment update success!" | ||
40 | - else | ||
41 | - echo "mmmpartner deployment update fail!" | ||
42 | - fi | ||
43 | -fi |
deploy/k8s/test/partner.yaml
已删除
100644 → 0
1 | -apiVersion: v1 | ||
2 | -kind: Service | ||
3 | -metadata: | ||
4 | - name: mmmpartner | ||
5 | - namespace: mmm-suplus-test | ||
6 | - labels: | ||
7 | - k8s-app: mmmpartner | ||
8 | -spec: | ||
9 | - ports: | ||
10 | - - name: "http" | ||
11 | - port: 80 | ||
12 | - targetPort: 8082 | ||
13 | - selector: | ||
14 | - k8s-app: mmmpartner | ||
15 | ---- | ||
16 | -apiVersion: extensions/v1beta1 | ||
17 | -kind: Deployment | ||
18 | -metadata: | ||
19 | - name: mmmpartner | ||
20 | - namespace: mmm-suplus-test | ||
21 | - labels: | ||
22 | - k8s-app: mmmpartner | ||
23 | -spec: | ||
24 | - replicas: 1 | ||
25 | - template: | ||
26 | - metadata: | ||
27 | - labels: | ||
28 | - k8s-app: mmmpartner | ||
29 | - spec: | ||
30 | - affinity: | ||
31 | - nodeAffinity: | ||
32 | - preferredDuringSchedulingIgnoredDuringExecution: | ||
33 | - - preference: {} | ||
34 | - weight: 100 | ||
35 | - requiredDuringSchedulingIgnoredDuringExecution: | ||
36 | - nodeSelectorTerms: | ||
37 | - - matchExpressions: | ||
38 | - - key: kubernetes.io/hostname | ||
39 | - operator: In | ||
40 | - values: | ||
41 | - - cn-hangzhou.i-bp1djh1xn7taumbue1ze | ||
42 | - - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | - - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | - - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | - containers: | ||
46 | - - name: mmmpartner | ||
47 | - image: 192.168.0.243:5000/mmm/partner:dev | ||
48 | - imagePullPolicy: Always | ||
49 | - ports: | ||
50 | - - containerPort: 8082 | ||
51 | - volumeMounts: | ||
52 | - - mountPath: /opt/logs | ||
53 | - name: accesslogs | ||
54 | - env: | ||
55 | - - name: HTTP_PORT | ||
56 | - value: "8082" | ||
57 | - - name: POSTGRESQL_DB_NAME | ||
58 | - value: "partner_test" | ||
59 | - - name: POSTGRESQL_USER | ||
60 | - value: "postgres" | ||
61 | - - name: POSTGRESQL_PASSWORD | ||
62 | - value: "eagle1010" | ||
63 | - - name: POSTGRESQL_HOST | ||
64 | - value: "114.55.200.59" | ||
65 | - - name: POSTGRESQL_PORT | ||
66 | - value: "31543" | ||
67 | - - name: LOG_LEVEL | ||
68 | - value: "debug" | ||
69 | - - name: ERROR_BASE_CODE | ||
70 | - value: "1" | ||
71 | - - name: ERROR_BASE_CODE_MULTIPLE | ||
72 | - value: "1000" | ||
73 | - - name: DEFAULT_GUEST_COMPANY | ||
74 | - value: "358" | ||
75 | - - name: ABILITY_SERVICE_HOST | ||
76 | - value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | ||
77 | - - name: MMM_OPEN_API_SERVICE_HOST | ||
78 | - value: "http://mmm-open-api-dev.fjmaimaimai.com" | ||
79 | - - name: UCENTER_SERVICE_HOST | ||
80 | - value: "https://suplus-ucenter-test.fjmaimaimai.com" | ||
81 | - - name: BUSINESS_ADMIN_SERVICE_HOST | ||
82 | - valueFrom: | ||
83 | - configMapKeyRef: | ||
84 | - name: suplus-config | ||
85 | - key: service.businessadmin | ||
86 | - - name: REDIS_HOST | ||
87 | - valueFrom: | ||
88 | - configMapKeyRef: | ||
89 | - name: suplus-config | ||
90 | - key: redis.ip | ||
91 | - - name: REDIS_PORT | ||
92 | - valueFrom: | ||
93 | - configMapKeyRef: | ||
94 | - name: suplus-config | ||
95 | - key: redis.port | ||
96 | - - name: REDIS_AUTH | ||
97 | - value: "" | ||
98 | - volumes: | ||
99 | - - name: accesslogs | ||
100 | - emptyDir: {} |
pkg/infrastructure/utils/file.go
0 → 100644
1 | +package utils | ||
2 | + | ||
3 | +import ( | ||
4 | + "io/ioutil" | ||
5 | + "mime/multipart" | ||
6 | + "sort" | ||
7 | +) | ||
8 | + | ||
9 | +const LimitFileHeaderSize = 1024 * 1024 | ||
10 | + | ||
11 | +type ImportFile struct { | ||
12 | + FileName string | ||
13 | + FileContent []byte | ||
14 | +} | ||
15 | + | ||
16 | +func ReadMultipartFormFile(mapFile map[string][]*multipart.FileHeader, sizeLimit int) []ImportFile { | ||
17 | + var rsp []ImportFile | ||
18 | + for _, k := range getSortFileKeys(mapFile) { | ||
19 | + v := mapFile[k] | ||
20 | + rsp = append(rsp, readFormFile(v, sizeLimit)...) | ||
21 | + } | ||
22 | + return rsp | ||
23 | +} | ||
24 | + | ||
25 | +func readFormFile(files []*multipart.FileHeader, sizeLimit int) []ImportFile { | ||
26 | + var rsp []ImportFile | ||
27 | + if sizeLimit == 0 { | ||
28 | + sizeLimit = LimitFileHeaderSize | ||
29 | + } | ||
30 | + for i := range files { | ||
31 | + if files[i].Size > int64(sizeLimit) { | ||
32 | + continue | ||
33 | + } | ||
34 | + f, _ := files[i].Open() | ||
35 | + data, _ := ioutil.ReadAll(f) | ||
36 | + f.Close() | ||
37 | + rsp = append(rsp, ImportFile{ | ||
38 | + FileName: files[i].Filename, | ||
39 | + FileContent: data, | ||
40 | + }) | ||
41 | + } | ||
42 | + return rsp | ||
43 | +} | ||
44 | + | ||
45 | +//获取排序键值 | ||
46 | +func getSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) { | ||
47 | + for k, _ := range files { | ||
48 | + keys = append(keys, k) | ||
49 | + } | ||
50 | + sort.Strings(keys) | ||
51 | + return | ||
52 | +} |
@@ -3,11 +3,9 @@ package controllers | @@ -3,11 +3,9 @@ package controllers | ||
3 | import ( | 3 | import ( |
4 | "github.com/tiptok/gocomm/pkg/log" | 4 | "github.com/tiptok/gocomm/pkg/log" |
5 | "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/project_module_files" | 5 | "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/project_module_files" |
6 | + "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol" | 7 | "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol" |
7 | protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_files" | 8 | protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_files" |
8 | - "io/ioutil" | ||
9 | - "mime/multipart" | ||
10 | - "sort" | ||
11 | ) | 9 | ) |
12 | 10 | ||
13 | type ProjectModuleFilesController struct { | 11 | type ProjectModuleFilesController struct { |
@@ -142,22 +140,12 @@ func (controller *ProjectModuleFilesController) Import() { | @@ -142,22 +140,12 @@ func (controller *ProjectModuleFilesController) Import() { | ||
142 | request.ProjectModuleId, _ = controller.GetInt64("projectModuleId") | 140 | request.ProjectModuleId, _ = controller.GetInt64("projectModuleId") |
143 | request.ProjectModuleVersionId, _ = controller.GetInt64("projectModuleVersionId") | 141 | request.ProjectModuleVersionId, _ = controller.GetInt64("projectModuleVersionId") |
144 | request.ParentId, _ = controller.GetInt64("parentId") | 142 | request.ParentId, _ = controller.GetInt64("parentId") |
145 | - for _, k := range getSortFileKeys(controller.Ctx.Request.MultipartForm.File) { | ||
146 | - v := controller.Ctx.Request.MultipartForm.File[k] | ||
147 | - log.Info(k, v[0].Filename, v[0].Size) | ||
148 | - for i := range v { | ||
149 | - if v[i].Size > 50*1024 { | ||
150 | - continue | ||
151 | - } | ||
152 | - f, _ := v[i].Open() | ||
153 | - data, _ := ioutil.ReadAll(f) | ||
154 | - f.Close() | 143 | + for _, v := range utils.ReadMultipartFormFile(controller.Ctx.Request.MultipartForm.File, 5*1024) { |
155 | request.ImportFiles = append(request.ImportFiles, protocolx.ImportFile{ | 144 | request.ImportFiles = append(request.ImportFiles, protocolx.ImportFile{ |
156 | - FileName: v[i].Filename, | ||
157 | - FileContent: data, | 145 | + FileName: v.FileName, |
146 | + FileContent: v.FileContent, | ||
158 | }) | 147 | }) |
159 | } | 148 | } |
160 | - } | ||
161 | data, err := svr.Import(header, request) | 149 | data, err := svr.Import(header, request) |
162 | if err != nil { | 150 | if err != nil { |
163 | log.Error(err) | 151 | log.Error(err) |
@@ -189,12 +177,3 @@ func (controller *ProjectModuleFilesController) ReviseTag() { | @@ -189,12 +177,3 @@ func (controller *ProjectModuleFilesController) ReviseTag() { | ||
189 | } | 177 | } |
190 | msg = protocol.NewResponseMessageData(data, err) | 178 | msg = protocol.NewResponseMessageData(data, err) |
191 | } | 179 | } |
192 | - | ||
193 | -//获取排序键值 | ||
194 | -func getSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) { | ||
195 | - for k, _ := range files { | ||
196 | - keys = append(keys, k) | ||
197 | - } | ||
198 | - sort.Strings(keys) | ||
199 | - return | ||
200 | -} |
@@ -32,7 +32,7 @@ func CheckAuthorization(ctx *context.Context) { | @@ -32,7 +32,7 @@ func CheckAuthorization(ctx *context.Context) { | ||
32 | }() | 32 | }() |
33 | authorization := ctx.Input.Header("Authorization") | 33 | authorization := ctx.Input.Header("Authorization") |
34 | if len(authorization) == 0 { | 34 | if len(authorization) == 0 { |
35 | - msg = protocol.NewResponseMessage(-1, errAuthorization.Error()) | 35 | + msg = protocol.NewResponseMessage(2, errAuthorization.Error()) |
36 | return | 36 | return |
37 | } | 37 | } |
38 | var token string | 38 | var token string |
@@ -44,7 +44,7 @@ func CheckAuthorization(ctx *context.Context) { | @@ -44,7 +44,7 @@ func CheckAuthorization(ctx *context.Context) { | ||
44 | } | 44 | } |
45 | claim, err := common.ParseJWTToken(token) | 45 | claim, err := common.ParseJWTToken(token) |
46 | if err != nil { | 46 | if err != nil { |
47 | - msg = protocol.NewResponseMessage(-1, errAuthorizationExpire.Error()) | 47 | + msg = protocol.NewResponseMessage(2, errAuthorizationExpire.Error()) |
48 | return | 48 | return |
49 | } | 49 | } |
50 | userId, _ := strconv.Atoi(claim.Username) | 50 | userId, _ := strconv.Atoi(claim.Username) |
@@ -3,6 +3,7 @@ package project_module_files | @@ -3,6 +3,7 @@ package project_module_files | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | "github.com/astaxie/beego/validation" | 5 | "github.com/astaxie/beego/validation" |
6 | + "strings" | ||
6 | ) | 7 | ) |
7 | 8 | ||
8 | type CreateProjectModuleFilesRequest struct { | 9 | type CreateProjectModuleFilesRequest struct { |
@@ -27,6 +28,13 @@ type CreateProjectModuleFilesRequest struct { | @@ -27,6 +28,13 @@ type CreateProjectModuleFilesRequest struct { | ||
27 | func (CreateProjectModuleFilesRequest *CreateProjectModuleFilesRequest) ValidateCommand() error { | 28 | func (CreateProjectModuleFilesRequest *CreateProjectModuleFilesRequest) ValidateCommand() error { |
28 | valid := validation.Validation{} | 29 | valid := validation.Validation{} |
29 | b, err := valid.Valid(CreateProjectModuleFilesRequest) | 30 | b, err := valid.Valid(CreateProjectModuleFilesRequest) |
31 | + // 符号:/ \\ 在目录中有使用,需要替换为 - | ||
32 | + //if CreateProjectModuleFilesRequest.FileType==2{ | ||
33 | + // CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName,"/","\\",-1) | ||
34 | + //}else if CreateProjectModuleFilesRequest.FileType==1{ | ||
35 | + CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName, "/", "-", -1) | ||
36 | + CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName, "\\", "-", -1) | ||
37 | + //} | ||
30 | if err != nil { | 38 | if err != nil { |
31 | return err | 39 | return err |
32 | } | 40 | } |
-
请 注册 或 登录 后发表评论