app-cloudep-member-server/Makefile

82 lines
4.0 KiB
Makefile
Raw Permalink Normal View History

# go-zero 生成風格
GO_ZERO_STYLE=go_zero
GO ?= go
GOFMT ?= gofmt "-s"
GOFILES := $(shell find . -name "*.go")
LDFLAGS := -s -w
VERSION="v1.0.3"
DOCKER_REPO="igs170911/notification"
.PHONY: test
test: # 進行測試
go test -v --cover ./...
.PHONY: fmt
fmt: # 格式優化
$(GOFMT) -w $(GOFILES)
goimports -w ./
.PHONY: gen-rpc
gen-rpc: # 建立 rpc code
2024-08-25 14:07:24 +00:00
goctl rpc protoc ./generate/protobuf/member.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
go mod tidy
@echo "Generate core-api files successfully"
.PHONY: gen-clean
gen-clean: # 建立 rpc code
rm -rf ./client
rm -rf ./etc
rm -rf ./gen_result
rm -rf ./internal
rm -rf go.mod
rm -rf go.sum
rm -rf service.go
@echo "Generate core-api files successfully"
.PHONY: run-docker
run-docker: # 建立 rpc code
docker run --platform=linux/arm64/v8 -p 8080:8080 $(DOCKER_REPO):$(VERSION)
.PHONY: build-docker
build-docker:
cp ./build/Dockerfile Dockerfile
docker buildx build -t $(DOCKER_REPO):$(VERSION) --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/ed_25519)" .
rm -rf Dockerfile
@echo "Generate core-api files successfully"
.PHONY: gen-my-sql-model
gen-my-sql-model: # 建立 rpc 資料庫
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020012_account_uid_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020013_user_table.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
goctl model mysql ddl -c no -s ./generate/database/mysql/20230719061241_machine_node.up.sql --style $(GO_ZERO_STYLE) -d ./internal/model -i ''
@echo "Generate mysql model files successfully"
gen-mongo-model: # 建立 rpc 資料庫
# 只產生 Model 剩下的要自己撰寫,連欄位名稱也是
goctl model mongo -t AutoId --dir ./internal/model/mongo --style $(GO_ZERO_STYLE)
@echo "Generate mongo model files successfully"
#goctl model mysql ddl -s ./generate/database/mysql/20240819090248_create_role_permission_table.up.sql --style go_zero -d ./internal/model -i '' (沒cache)
#goctl model mysql ddl -c no -s ./generate/database/mysql/20240816014305_create_permission_table.up.sql --style go_zero -d ./internal/model -i '' (有cache)
.PHONY: mock-gen
mock-gen: # 建立 mock 資料
mockgen -source=./internal/domain/usecase/uid_generate.go -destination=./internal/mock/usecase/uid_generate.go -package=mock
mockgen -source=./internal/model/account_model_gen.go -destination=./internal/mock/model/account_model_gen.go -package=mock
mockgen -source=./internal/model/account_model.go -destination=./internal/mock/model/account_model.go -package=mock
mockgen -source=./internal/model/account_to_uid_model_gen.go -destination=./internal/mock/model/account_to_uid_model_gen.go -package=mock
mockgen -source=./internal/model/account_to_uid_model.go -destination=./internal/mock/model/account_to_uidmodel.go -package=mock
mockgen -source=./internal/model/machine_node_model_gen.go -destination=./internal/mock/model/machine_node_model_gen.go -package=mock
mockgen -source=./internal/model/machine_node_model.go -destination=./internal/mock/model/machine_node_model.go -package=mock
mockgen -source=./internal/model/user_table_model_gen.go -destination=./internal/mock/model/user_table_model_gen.go -package=mock
mockgen -source=./internal/model/user_table_model.go -destination=./internal/mock/model/user_table_model.go -package=mock
mockgen -source=./internal/model/mongo/auto_id_model_gen.go -destination=./internal/mock/model/auto_id_model_gen.go -package=mock
mockgen -source=./internal/model/mongo/auto_id_model.go -destination=./internal/mock/model/auto_id_model.go -package=mock
@echo "Generate mock files successfully"
.PHONY: migrate-database
migrate-database:
migrate -source file://generate/database/mysql -database 'mysql://root:yytt@tcp(127.0.0.1:3306)/digimon_member' up