优化数据库迁移
This commit is contained in:
parent
fceba10a35
commit
bd38fd6681
11
DockerBuildTest.bat
Normal file
11
DockerBuildTest.bat
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
go env -w GOOS=linux
|
||||||
|
cd ./build
|
||||||
|
del artistinfo-dev
|
||||||
|
cd ..
|
||||||
|
go build -ldflags "-s -w" -o ./build/artistinfo-dev ./cmd/app.go
|
||||||
|
docker rmi artistinfo-dev
|
||||||
|
docker rmi 121.229.45.214:9006/artistinfo-dev
|
||||||
|
docker build . -f .\DockerfileWindowsTest -t artistinfo-dev
|
||||||
|
docker tag artistinfo-dev 121.229.45.214:9006/artistinfo-dev
|
||||||
|
docker push 121.229.45.214:9006/artistinfo-dev
|
||||||
|
pause
|
@ -3,31 +3,33 @@ FROM golang:alpine AS builder
|
|||||||
LABEL stage=gobuilder
|
LABEL stage=gobuilder
|
||||||
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
|
#ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
|
||||||
#ENV MODE_ENV test
|
#ENV MODE_ENV test
|
||||||
|
ENV TZ Asia/Shanghai
|
||||||
ENV CGO_ENABLED 0
|
ENV CGO_ENABLED 0
|
||||||
ENV GOPROXY https://goproxy.cn,direct
|
ENV GOPROXY https://goproxy.cn,direct
|
||||||
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
#RUN apk update --no-cache && apk add --no-cache tzdata
|
#RUN apk update --no-cache && apk add --no-cache tzdata
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY ./utils ../utils
|
#COPY ./utils ../utils
|
||||||
ADD ./fonchain-backup/go.mod .
|
#ADD ./fonchain-artist/go.mod .
|
||||||
ADD ./fonchain-backup/go.sum .
|
#ADD ./fonchain-artist/go.sum .
|
||||||
RUN go mod download
|
#RUN go mod download
|
||||||
COPY ./fonchain-backup .
|
#COPY ./fonchain-artist .
|
||||||
|
#
|
||||||
|
#RUN go build -ldflags "-s -w" -o /app/artistServer ./cmd/app.go
|
||||||
|
|
||||||
RUN go build -ldflags "-s -w" -o /app/backup ./cmd/app.go
|
COPY ./build/artistinfo-dev /app/artistinfo-dev
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||||
RUN apk update --no-cache
|
RUN apk update --no-cache
|
||||||
RUN apk add --no-cache ca-certificates
|
RUN apk add --no-cache ca-certificates
|
||||||
RUN apk add --no-cache tzdata
|
RUN apk add --no-cache tzdata
|
||||||
COPY ./fonchain-backup/conf /app/conf
|
COPY ./conf /app/conf
|
||||||
COPY ./fonchain-backup/conf /conf
|
COPY ./conf /conf
|
||||||
|
|
||||||
ENV TZ Asia/Shanghai
|
ENV TZ Asia/Shanghai
|
||||||
ENV DUBBO_GO_CONFIG_PATH ./conf/dubbogo.yaml
|
ENV MODE_ENV test
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY --from=builder /app/backup .
|
COPY --from=builder /app/artistinfo-dev .
|
||||||
EXPOSE 9021
|
EXPOSE 20050
|
||||||
CMD ["/app/backup"]
|
CMD ["/app/artistinfo-dev"]
|
||||||
|
BIN
build/artistinfo-dev
Normal file
BIN
build/artistinfo-dev
Normal file
Binary file not shown.
@ -187,7 +187,11 @@ func GetUser(req *artistInfoUser.GetUserRequest) (rep *artistInfoUser.GetUserRes
|
|||||||
var user model.User
|
var user model.User
|
||||||
if err = db.DB.Where("tel_num = ?", req.TelNum).First(&user).Error; err != nil {
|
if err = db.DB.Where("tel_num = ?", req.TelNum).First(&user).Error; err != nil {
|
||||||
zap.L().Error("get user info err", zap.Error(err))
|
zap.L().Error("get user info err", zap.Error(err))
|
||||||
|
if err == gorm.ErrRecordNotFound {
|
||||||
|
err = errors.New("没有找到数据")
|
||||||
|
} else {
|
||||||
err = errors.New(m.ERROR_SELECT)
|
err = errors.New(m.ERROR_SELECT)
|
||||||
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
// rep.
|
// rep.
|
||||||
|
@ -3,18 +3,17 @@ mode = dev #正式prod #测试dev
|
|||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
Db = mysql
|
Db = mysql
|
||||||
DbHost = 127.0.0.1
|
DbHost = 172.16.100.99 #214
|
||||||
DbPort = 3306
|
DbPort = 9007
|
||||||
DbUser = root
|
DbUser = artuser
|
||||||
DbPassWord = 123456
|
DbPassWord = "C250PflXIWv2SQm8"
|
||||||
DbName = artistmgmtDev
|
DbArtist = artistmgmtDev
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
|
RedisDB = 3
|
||||||
RedisDB = 2
|
RedisAddr = 172.16.100.99:9008
|
||||||
RedisAddr = 127.0.0.1:6379
|
RedisPW = "nDCTrfTtBu3Pw"
|
||||||
#RedisPW = "nDCTrfTtBu3Pw"
|
RedisDBNAme =
|
||||||
#RedisDBNAme =
|
|
||||||
|
|
||||||
[chain]
|
[chain]
|
||||||
IP=127.0.0.1:37101
|
IP=127.0.0.1:37101
|
||||||
|
@ -8,10 +8,10 @@ dubbo:
|
|||||||
demoZK:
|
demoZK:
|
||||||
protocol: zookeeper
|
protocol: zookeeper
|
||||||
timeout: 120s
|
timeout: 120s
|
||||||
address: 127.0.0.1:2181
|
# address: 127.0.0.1:2181
|
||||||
# address: 121.229.45.214:9004
|
# address: 121.229.45.214:9004
|
||||||
# address: 114.218.158.24:2181
|
# address: 114.218.158.24:2181
|
||||||
# address: zookeeper:2181
|
address: 172.16.100.93:2181
|
||||||
protocols:
|
protocols:
|
||||||
triple: #triple
|
triple: #triple
|
||||||
name: tri
|
name: tri
|
||||||
|
@ -3,15 +3,14 @@ mode = dev #正式prod #测试dev
|
|||||||
|
|
||||||
[mysql]
|
[mysql]
|
||||||
Db = mysql
|
Db = mysql
|
||||||
DbHost = mysql
|
DbHost = 172.16.100.99 #214
|
||||||
DbPort = 3306
|
DbPort = 9007
|
||||||
DbUser = root
|
DbUser = artuser
|
||||||
DbPassWord = 123456
|
DbPassWord = "C250PflXIWv2SQm8"
|
||||||
DbName = artistmgmttest
|
DbArtist = artistmgmtDev
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
|
RedisDB = 3
|
||||||
RedisDB = 2
|
|
||||||
RedisAddr = 172.16.100.99:9008
|
RedisAddr = 172.16.100.99:9008
|
||||||
RedisPW = "nDCTrfTtBu3Pw"
|
RedisPW = "nDCTrfTtBu3Pw"
|
||||||
RedisDBNAme =
|
RedisDBNAme =
|
||||||
|
@ -8,10 +8,10 @@ dubbo:
|
|||||||
demoZK:
|
demoZK:
|
||||||
protocol: zookeeper
|
protocol: zookeeper
|
||||||
timeout: 120s
|
timeout: 120s
|
||||||
# address: 127.0.0.1:2181
|
# address: 127.0.0.1:2181
|
||||||
# address: 121.229.45.214:9004
|
# address: 121.229.45.214:9004
|
||||||
# address: 114.218.158.24:2181
|
# address: 114.218.158.24:2181
|
||||||
address: zookeeper:2181
|
address: 172.16.100.93:2181
|
||||||
protocols:
|
protocols:
|
||||||
triple: #triple
|
triple: #triple
|
||||||
name: tri
|
name: tri
|
||||||
|
@ -10,7 +10,6 @@ DbPassWord = 123456
|
|||||||
DbName = artistmgmttest
|
DbName = artistmgmttest
|
||||||
|
|
||||||
[redis]
|
[redis]
|
||||||
|
|
||||||
RedisDB = 2
|
RedisDB = 2
|
||||||
RedisAddr = 127.0.0.1:6379
|
RedisAddr = 127.0.0.1:6379
|
||||||
#RedisPW = "nDCTrfTtBu3Pw"
|
#RedisPW = "nDCTrfTtBu3Pw"
|
||||||
|
@ -19,18 +19,57 @@ dubbo:
|
|||||||
port: 20050
|
port: 20050
|
||||||
provider:
|
provider:
|
||||||
services:
|
services:
|
||||||
ArtistInfoProvider:
|
ArtistInfoUserProvider:
|
||||||
|
interface: com.fontree.microservices.common.ArtistInfoUser
|
||||||
|
retries: 100
|
||||||
|
ArtistInfoArtworkProvider:
|
||||||
|
interface: com.fontree.microservices.common.ArtistInfoArtwork
|
||||||
|
retries: 100
|
||||||
|
ArtistInfoArtshowProvider:
|
||||||
|
interface: com.fontree.microservices.common.ArtistInfoArtshow
|
||||||
|
retries: 100
|
||||||
|
#ContractProvider:
|
||||||
|
# interface: com.fontree.microservices.common.Contract
|
||||||
|
# retries: 0
|
||||||
|
#ArtWorkProvider:
|
||||||
|
# interface: com.fontree.microservices.common.ArtWork
|
||||||
|
# retries: 0
|
||||||
|
#SupplyProvider:
|
||||||
|
# interface: com.fontree.microservices.common.Supply
|
||||||
|
# retries: 0
|
||||||
|
consumer:
|
||||||
|
request-timeout: 120s
|
||||||
|
references:
|
||||||
|
AccountClientImpl:
|
||||||
|
protocol: tri
|
||||||
|
interface: com.fontree.microservices.common.Account
|
||||||
|
filter: cshutdown,sign,fonDomainFilter,fonValidateFilter
|
||||||
|
params:
|
||||||
|
.accessKeyId: "Accountksl"
|
||||||
|
.secretAccessKey: "BSDY-FDF1-Fontree_account"
|
||||||
|
ArtistClientImpl:
|
||||||
|
protocol: tri
|
||||||
|
interface: com.fontree.microservices.common.Artist
|
||||||
|
ArtistInfoClientImpl:
|
||||||
|
protocol: tri
|
||||||
interface: com.fontree.microservices.common.ArtistInfo
|
interface: com.fontree.microservices.common.ArtistInfo
|
||||||
# retries: 100
|
ContractClientImpl:
|
||||||
ContractProvider:
|
timeout: 15s
|
||||||
interface: com.fontree.microservices.common.Contract
|
protocol: tri
|
||||||
# retries: 0
|
interface: com.fontree.microservices.common.contract
|
||||||
ArtWorkProvider:
|
filter: cshutdown,sign
|
||||||
interface: com.fontree.microservices.common.ArtWork
|
params:
|
||||||
# retries: 0
|
.accessKeyId: "SYD8-Chain-04"
|
||||||
SupplyProvider:
|
.secretAccessKey: "Al-Chain-FDF112"
|
||||||
|
ArtworkClientImpl:
|
||||||
|
protocol: tri
|
||||||
|
interface: com.fontree.microservices.common.Artwork
|
||||||
|
ArtworkQueryClientImpl:
|
||||||
|
protocol: tri
|
||||||
|
interface: com.fontree.microservices.common.ArtworkQuery
|
||||||
|
SupplyClientImpl:
|
||||||
|
protocol: tri
|
||||||
interface: com.fontree.microservices.common.Supply
|
interface: com.fontree.microservices.common.Supply
|
||||||
# retries: 0
|
|
||||||
logger:
|
logger:
|
||||||
zap-config:
|
zap-config:
|
||||||
level: info # 日志级别
|
level: info # 日志级别
|
||||||
|
Binary file not shown.
Binary file not shown.
37
makefile
Normal file
37
makefile
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
.PHONY: all build run gotool help
|
||||||
|
|
||||||
|
BINARY="artisrService"
|
||||||
|
|
||||||
|
all: gotool build
|
||||||
|
|
||||||
|
build:
|
||||||
|
go env -w GOOS=linux
|
||||||
|
go build -ldflags "-s -w" -o ./build/${BINARY} ./cmd/app.go
|
||||||
|
|
||||||
|
pushTest:
|
||||||
|
DockerBuildTest.bat
|
||||||
|
pushProd:
|
||||||
|
DockerBuildProd.bat
|
||||||
|
|
||||||
|
run:
|
||||||
|
@go run ./cmd/app.go
|
||||||
|
|
||||||
|
gotool:
|
||||||
|
go fmt ./
|
||||||
|
go vet ./
|
||||||
|
|
||||||
|
#protoc:
|
||||||
|
#protoc --go_out=./pb/artist --go-triple_out=./pb/artist --validate_out="lang=go:./pb/artist" ./pb/artist/artist.proto
|
||||||
|
#protoc --go_out=./pb/artist --go-grpc_out=./pb/artist --go-triple_out=./pb/artist --validate_out="lang=go:./pb/artist" ./pb/artist/artist.proto
|
||||||
|
protoc:
|
||||||
|
protoc --proto_path=. --go_out=./pb --go-triple_out=./pb --govalidators_out="lang=go:./pb" ./pb/artist.proto
|
||||||
|
protoc --proto_path=. --go_out=./pb --go-triple_out=./pb --govalidators_out="lang=go:./pb" ./pb/artist_third_party.proto
|
||||||
|
all_protoc:
|
||||||
|
protoc --go_out=./pb/artist --go-grpc_out=./pb/artist --go-triple_out=./pb/artist --govalidators_out=./pb/artist ./pb/artist/artist.proto
|
||||||
|
|
||||||
|
help:
|
||||||
|
@echo "make - 格式化 Go 代码, 并编译生成二进制文件"
|
||||||
|
@echo "make build - 编译 Go 代码, 生成二进制文件"
|
||||||
|
@echo "make run - 直接运行 Go 代码"
|
||||||
|
@echo "make gotool - 运行 Go 工具 'fmt' and 'vet'"
|
||||||
|
@echo "make protoc - 解析proto文件"
|
@ -95,7 +95,7 @@ func Database(conn string) {
|
|||||||
func migration() {
|
func migration() {
|
||||||
//自迁移模式
|
//自迁移模式
|
||||||
err := DB.AutoMigrate(
|
err := DB.AutoMigrate(
|
||||||
&old.Bank{},
|
//&old.Bank{},
|
||||||
&model.RealName{},
|
&model.RealName{},
|
||||||
&model.User{},
|
&model.User{},
|
||||||
&model.Invite{},
|
&model.Invite{},
|
||||||
|
Loading…
Reference in New Issue
Block a user