From 4be80f228e55366b04cbac5988baab3f7a911fad Mon Sep 17 00:00:00 2001 From: Rzy <465386466@qq.com> Date: Thu, 1 Aug 2024 14:53:22 +0800 Subject: [PATCH] =?UTF-8?q?(=E8=A7=A3=E5=86=B3=E5=86=B2=E7=AA=81)?= =?UTF-8?q?=EF=BC=9A=E4=B9=8B=E5=90=8E=E4=BC=9A=E5=8F=A6=E8=B5=B7=E5=88=86?= =?UTF-8?q?=E6=94=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 28 ++++++++++++++++++++++++++++ app/http/controllers/base.go | 6 +++++- app/http/controllers/front/api.go | 10 ++++++++++ build/shell/build.sh | 2 +- go.mod | 7 ++++--- go.sum | 1 + 6 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 Makefile create mode 100644 app/http/controllers/front/api.go diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f327e5d --- /dev/null +++ b/Makefile @@ -0,0 +1,28 @@ +GOHOSTOS:=$(shell go env GOHOSTOS) +GOPATH:=$(shell go env GOPATH) +VERSION=$(shell git describe --tags --always) + + +ifeq ($(GOHOSTOS), windows) + #the `find.exe` is different from `find` in bash/shell. + #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. + #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. + #Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) + Git_Bash=$(subst \,/,$(subst cmd\,bin\bash.exe,$(dir $(shell where git)))) + INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") + API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") +else + INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) + API_PROTO_FILES=$(shell find api -name *.proto) +endif + +.PHONY: build +build: + sh build/shell/build.sh + +.PHONY: api +api: + sh build/shell/build.sh & build/bin/snow -a api + + + diff --git a/app/http/controllers/base.go b/app/http/controllers/base.go index 1e08b5e..354472c 100644 --- a/app/http/controllers/base.go +++ b/app/http/controllers/base.go @@ -26,7 +26,11 @@ import ( /** * 成功时返回 */ -func Success(c *gin.Context, data interface{}, message string) { +func Success(c *gin.Context, data interface{}, messageSlice ...string) { + var message string + if len(messageSlice) > 0 { + message = messageSlice[0] + } if message == "" { message = errorcode.GetMsg(errorcode.Success, c.GetHeader("local")) } diff --git a/app/http/controllers/front/api.go b/app/http/controllers/front/api.go new file mode 100644 index 0000000..3d4ea9b --- /dev/null +++ b/app/http/controllers/front/api.go @@ -0,0 +1,10 @@ +package front + +import ( + "PaymentCenter/app/http/controllers" + "github.com/gin-gonic/gin" +) + +func HelloHandler(c *gin.Context) { + controllers.Success(c, "aaaa") +} diff --git a/build/shell/build.sh b/build/shell/build.sh index d8e9dc2..545989e 100644 --- a/build/shell/build.sh +++ b/build/shell/build.sh @@ -6,4 +6,4 @@ arch=$2 #架构amd64 rootPath=$(cd `dirname $0`/../../; pwd) #编译 -GOOS=$os GOARCH=$arch go build -o build/bin/snow main.go +GOOS=$os GOARCH=$arch go build -o build/bin/snow main.go \ No newline at end of file diff --git a/go.mod b/go.mod index cec9675..4e629fe 100644 --- a/go.mod +++ b/go.mod @@ -6,6 +6,7 @@ require ( gitee.com/chengdu_blue_brothers/openapi-go-sdk v0.0.2 github.com/BurntSushi/toml v0.4.1 github.com/Shopify/sarama v1.19.0 + github.com/ahmetb/go-linq/v3 v3.2.0 github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible github.com/forgoer/openssl v1.6.0 github.com/gin-gonic/gin v1.7.7 @@ -29,13 +30,14 @@ require ( google.golang.org/grpc v1.56.3 google.golang.org/protobuf v1.30.0 gopkg.in/go-playground/validator.v9 v9.31.0 + xorm.io/builder v0.3.9 + xorm.io/xorm v1.2.5 ) require ( github.com/KyleBanks/depth v1.2.1 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect - github.com/ahmetb/go-linq/v3 v3.2.0 // indirect github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect github.com/alibabacloud-go/tea v1.1.17 // indirect github.com/alibabacloud-go/tea-utils v1.4.4 // indirect @@ -53,6 +55,7 @@ require ( github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect github.com/eapache/queue v1.1.0 // indirect github.com/emirpasic/gods v1.12.0 // indirect + github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 // indirect github.com/gin-contrib/sse v0.1.0 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonreference v0.19.6 // indirect @@ -111,7 +114,5 @@ require ( gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect stathat.com/c/consistent v1.0.0 // indirect - xorm.io/builder v0.3.9 // indirect xorm.io/core v0.7.3 // indirect - xorm.io/xorm v1.2.5 // indirect ) diff --git a/go.sum b/go.sum index 5020055..becba70 100644 --- a/go.sum +++ b/go.sum @@ -175,6 +175,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6 h1:6VSn3hB5U5GeA6kQw4TwWIWbOhtvR2hmbBJnTOtqTWc= github.com/fvbock/endless v0.0.0-20170109170031-447134032cb6/go.mod h1:YxOVT5+yHzKvwhsiSIWmbAYM3Dr9AEEbER2dVayfBkg= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/gzip v0.0.3 h1:etUaeesHhEORpZMp18zoOhepboiWnFtXrBZxszWUn4k=