作者 yangfu

merge branch gql

apiVersion: v1
kind: Service
metadata:
name: mmmgodevp
namespace: mmm-suplus-dev
labels:
k8s-app: mmmgodevp
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: mmmgodevp
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mmmgodevp
namespace: mmm-suplus-dev
labels:
k8s-app: mmmgodevp
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: mmmgodevp
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: mmmgodevp
image: 192.168.0.243:5000/mmm/godevp:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
- name: POSTGRESQL_DB_NAME
value: "godevp_dev"
- name: POSTGRESQL_USER
value: "postgres"
- name: POSTGRESQL_PASSWORD
value: "eagle1010"
- name: POSTGRESQL_HOST
value: "114.55.200.59"
- name: POSTGRESQL_PORT
value: "31543"
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: DEFAULT_GUEST_COMPANY
value: "10011"
- name: ABILITY_SERVICE_HOST
value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
- name: MMM_OPEN_API_SERVICE_HOST
value: "http://mmm-open-api-dev.fjmaimaimai.com"
- name: UCENTER_SERVICE_HOST
value: "https://suplus-ucenter-dev.fjmaimaimai.com"
- name: BUSINESS_ADMIN_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: service.businessadmin
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: partner
name: mmmgodevp
namespace: mmm-suplus-prd
labels:
k8s-app: partner
k8s-app: mmmgodevp
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: partner
k8s-app: mmmgodevp
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: partner
name: mmmgodevp
namespace: mmm-suplus-prd
labels:
k8s-app: partner
k8s-app: mmmgodevp
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: partner
k8s-app: mmmgodevp
spec:
affinity:
nodeAffinity:
... ... @@ -43,8 +43,8 @@ spec:
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: partner
image: 192.168.0.243:5000/mmm/partner:master
- name: mmmgodevp
image: 192.168.0.243:5000/mmm/mmmgodevp:master
imagePullPolicy: Always
ports:
- containerPort: 8082
... ... @@ -55,7 +55,7 @@ spec:
- name: HTTP_PORT
value: "8082"
- name: POSTGRESQL_DB_NAME
value: "partner"
value: "godevp"
- name: POSTGRESQL_USER
value: "postgres"
- name: POSTGRESQL_PASSWORD
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp
if [ "$?" == "1" ];then
kubectl create -f /tmp/prd/partner/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl create -f /tmp/prd/godevp/godevp.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp
if [ "$?" == "0" ];then
echo "partner service install success!"
echo "godevp service install success!"
else
echo "partner service install fail!"
echo "godevp service install fail!"
fi
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp
if [ "$?" == "0" ];then
echo "partner deployment install success!"
echo "godevp deployment install success!"
else
echo "partner deployment install fail!"
echo "godevp deployment install fail!"
fi
else
kubectl delete -f /tmp/prd/partner/partner.yaml
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl delete -f /tmp/prd/godevp/godevp.yaml
kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp
done
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp
done
kubectl create -f /tmp/prd/partner/partner.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q partner
kubectl create -f /tmp/prd/godevp/godevp.yaml --record
kubectl -n mmm-suplus-prd get svc | grep -q mmmgodevp
if [ "$?" == "0" ];then
echo "partner service update success!"
echo "godevp service update success!"
else
echo "partner service update fail!"
echo "godevp service update fail!"
fi
kubectl -n mmm-suplus-prd get pods | grep -q partner
kubectl -n mmm-suplus-prd get pods | grep -q mmmgodevp
if [ "$?" == "0" ];then
echo "partner deployment update success!"
echo "godevp deployment update success!"
else
echo "partner deployment update fail!"
echo "godevp deployment update fail!"
fi
fi
\ No newline at end of file
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n mmm-suplus-test get pods | grep -q mmmpartner
if [ "$?" == "1" ];then
kubectl create -f /tmp/test/partner/partner.yaml --record
kubectl -n mmm-suplus-test get svc | grep -q mmmpartner
if [ "$?" == "0" ];then
echo "mmmpartner service install success!"
else
echo "mmmpartner service install fail!"
fi
kubectl -n mmm-suplus-test get pods | grep -q mmmpartner
if [ "$?" == "0" ];then
echo "mmmpartner deployment install success!"
else
echo "mmmpartner deployment install fail!"
fi
else
kubectl delete -f /tmp/test/partner/partner.yaml
kubectl -n mmm-suplus-test get svc | grep -q mmmpartner
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-test get svc | grep -q mmmpartner
done
kubectl -n mmm-suplus-test get pods | grep -q mmmpartner
while [ "$?" == "0" ]
do
kubectl -n mmm-suplus-test get pods | grep -q mmmpartner
done
kubectl create -f /tmp/test/partner/partner.yaml --record
kubectl -n mmm-suplus-test get svc | grep -q mmmpartner
if [ "$?" == "0" ];then
echo "mmmpartner service update success!"
else
echo "mmmpartner service update fail!"
fi
kubectl -n mmm-suplus-test get pods | grep -q mmmpartner
if [ "$?" == "0" ];then
echo "mmmpartner deployment update success!"
else
echo "mmmpartner deployment update fail!"
fi
fi
\ No newline at end of file
apiVersion: v1
kind: Service
metadata:
name: mmmpartner
namespace: mmm-suplus-test
labels:
k8s-app: mmmpartner
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: mmmpartner
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: mmmpartner
namespace: mmm-suplus-test
labels:
k8s-app: mmmpartner
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: mmmpartner
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: mmmpartner
image: 192.168.0.243:5000/mmm/partner:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: HTTP_PORT
value: "8082"
- name: POSTGRESQL_DB_NAME
value: "partner_test"
- name: POSTGRESQL_USER
value: "postgres"
- name: POSTGRESQL_PASSWORD
value: "eagle1010"
- name: POSTGRESQL_HOST
value: "114.55.200.59"
- name: POSTGRESQL_PORT
value: "31543"
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: DEFAULT_GUEST_COMPANY
value: "358"
- name: ABILITY_SERVICE_HOST
value: "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
- name: MMM_OPEN_API_SERVICE_HOST
value: "http://mmm-open-api-dev.fjmaimaimai.com"
- name: UCENTER_SERVICE_HOST
value: "https://suplus-ucenter-test.fjmaimaimai.com"
- name: BUSINESS_ADMIN_SERVICE_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: service.businessadmin
- name: REDIS_HOST
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.ip
- name: REDIS_PORT
valueFrom:
configMapKeyRef:
name: suplus-config
key: redis.port
- name: REDIS_AUTH
value: ""
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
package utils
import (
"io/ioutil"
"mime/multipart"
"sort"
)
const LimitFileHeaderSize = 1024 * 1024
type ImportFile struct {
FileName string
FileContent []byte
}
func ReadMultipartFormFile(mapFile map[string][]*multipart.FileHeader, sizeLimit int) []ImportFile {
var rsp []ImportFile
for _, k := range getSortFileKeys(mapFile) {
v := mapFile[k]
rsp = append(rsp, readFormFile(v, sizeLimit)...)
}
return rsp
}
func readFormFile(files []*multipart.FileHeader, sizeLimit int) []ImportFile {
var rsp []ImportFile
if sizeLimit == 0 {
sizeLimit = LimitFileHeaderSize
}
for i := range files {
if files[i].Size > int64(sizeLimit) {
continue
}
f, _ := files[i].Open()
data, _ := ioutil.ReadAll(f)
f.Close()
rsp = append(rsp, ImportFile{
FileName: files[i].Filename,
FileContent: data,
})
}
return rsp
}
//获取排序键值
func getSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) {
for k, _ := range files {
keys = append(keys, k)
}
sort.Strings(keys)
return
}
... ...
... ... @@ -3,11 +3,9 @@ package controllers
import (
"github.com/tiptok/gocomm/pkg/log"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/project_module_files"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol"
protocolx "gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/protocol/project_module_files"
"io/ioutil"
"mime/multipart"
"sort"
)
type ProjectModuleFilesController struct {
... ... @@ -142,21 +140,11 @@ func (controller *ProjectModuleFilesController) Import() {
request.ProjectModuleId, _ = controller.GetInt64("projectModuleId")
request.ProjectModuleVersionId, _ = controller.GetInt64("projectModuleVersionId")
request.ParentId, _ = controller.GetInt64("parentId")
for _, k := range getSortFileKeys(controller.Ctx.Request.MultipartForm.File) {
v := controller.Ctx.Request.MultipartForm.File[k]
log.Info(k, v[0].Filename, v[0].Size)
for i := range v {
if v[i].Size > 50*1024 {
continue
}
f, _ := v[i].Open()
data, _ := ioutil.ReadAll(f)
f.Close()
request.ImportFiles = append(request.ImportFiles, protocolx.ImportFile{
FileName: v[i].Filename,
FileContent: data,
})
}
for _, v := range utils.ReadMultipartFormFile(controller.Ctx.Request.MultipartForm.File, 5*1024) {
request.ImportFiles = append(request.ImportFiles, protocolx.ImportFile{
FileName: v.FileName,
FileContent: v.FileContent,
})
}
data, err := svr.Import(header, request)
if err != nil {
... ... @@ -189,12 +177,3 @@ func (controller *ProjectModuleFilesController) ReviseTag() {
}
msg = protocol.NewResponseMessageData(data, err)
}
//获取排序键值
func getSortFileKeys(files map[string][]*multipart.FileHeader) (keys []string) {
for k, _ := range files {
keys = append(keys, k)
}
sort.Strings(keys)
return
}
... ...
... ... @@ -32,7 +32,7 @@ func CheckAuthorization(ctx *context.Context) {
}()
authorization := ctx.Input.Header("Authorization")
if len(authorization) == 0 {
msg = protocol.NewResponseMessage(-1, errAuthorization.Error())
msg = protocol.NewResponseMessage(2, errAuthorization.Error())
return
}
var token string
... ... @@ -44,7 +44,7 @@ func CheckAuthorization(ctx *context.Context) {
}
claim, err := common.ParseJWTToken(token)
if err != nil {
msg = protocol.NewResponseMessage(-1, errAuthorizationExpire.Error())
msg = protocol.NewResponseMessage(2, errAuthorizationExpire.Error())
return
}
userId, _ := strconv.Atoi(claim.Username)
... ...
... ... @@ -3,6 +3,7 @@ package project_module_files
import (
"fmt"
"github.com/astaxie/beego/validation"
"strings"
)
type CreateProjectModuleFilesRequest struct {
... ... @@ -27,6 +28,13 @@ type CreateProjectModuleFilesRequest struct {
func (CreateProjectModuleFilesRequest *CreateProjectModuleFilesRequest) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(CreateProjectModuleFilesRequest)
// 符号:/ \\ 在目录中有使用,需要替换为 -
//if CreateProjectModuleFilesRequest.FileType==2{
// CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName,"/","\\",-1)
//}else if CreateProjectModuleFilesRequest.FileType==1{
CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName, "/", "-", -1)
CreateProjectModuleFilesRequest.FileName = strings.Replace(CreateProjectModuleFilesRequest.FileName, "\\", "-", -1)
//}
if err != nil {
return err
}
... ...