commit
0c443efba6
48 changed files with 1217 additions and 0 deletions
-
1.gitattributes
-
18.gitignore
-
7Makefile
-
4README.MD
-
0api/v1/.gitkeep
-
39go.mod
-
74go.sum
-
18hack/config.yaml
-
20hack/hack-cli.mk
-
75hack/hack.mk
-
27internal/cmd/cmd.go
-
10internal/consts/consts.go
-
0internal/controller/.gitkeep
-
139internal/dao/internal/member_info.go
-
87internal/dao/internal/prize.go
-
79internal/dao/internal/prize_record.go
-
27internal/dao/member_info.go
-
27internal/dao/prize.go
-
27internal/dao/prize_record.go
-
10internal/logic/middleware/interceptor.go
-
49internal/model/do/member_info.go
-
23internal/model/do/prize.go
-
19internal/model/do/prize_record.go
-
80internal/model/dto/Result.go
-
47internal/model/entity/member_info.go
-
21internal/model/entity/prize.go
-
17internal/model/entity/prize_record.go
-
1internal/packed/packed.go
-
0internal/service/.gitkeep
-
15main.go
-
24manifest/config/config.yaml
-
21manifest/deploy/kustomize/base/deployment.yaml
-
8manifest/deploy/kustomize/base/kustomization.yaml
-
12manifest/deploy/kustomize/base/service.yaml
-
14manifest/deploy/kustomize/overlays/develop/configmap.yaml
-
10manifest/deploy/kustomize/overlays/develop/deployment.yaml
-
14manifest/deploy/kustomize/overlays/develop/kustomization.yaml
-
16manifest/docker/Dockerfile
-
8manifest/docker/docker.sh
-
0manifest/i18n/.gitkeep
-
0manifest/protobuf/.keep-if-necessary
-
0resource/public/html/.gitkeep
-
0resource/public/plugin/.gitkeep
-
0resource/public/resource/css/.gitkeep
-
0resource/public/resource/image/.gitkeep
-
0resource/public/resource/js/.gitkeep
-
0resource/template/.gitkeep
-
129utility/utility.go
@ -0,0 +1 @@ |
|||||
|
* linguist-language=GO |
@ -0,0 +1,18 @@ |
|||||
|
.buildpath |
||||
|
.hgignore.swp |
||||
|
.project |
||||
|
.orig |
||||
|
.swp |
||||
|
.idea/ |
||||
|
.settings/ |
||||
|
.vscode/ |
||||
|
bin/ |
||||
|
**/.DS_Store |
||||
|
gf |
||||
|
main |
||||
|
main.exe |
||||
|
output/ |
||||
|
manifest/output/ |
||||
|
temp/ |
||||
|
temp.yaml |
||||
|
bin |
@ -0,0 +1,7 @@ |
|||||
|
ROOT_DIR = $(shell pwd) |
||||
|
NAMESPACE = "default" |
||||
|
DEPLOY_NAME = "template-single" |
||||
|
DOCKER_NAME = "template-single" |
||||
|
|
||||
|
include ./hack/hack-cli.mk |
||||
|
include ./hack/hack.mk |
@ -0,0 +1,4 @@ |
|||||
|
# GoFrame Template For SingleRepo |
||||
|
|
||||
|
Quick Start: |
||||
|
- https://goframe.org/quick |
@ -0,0 +1,39 @@ |
|||||
|
module MangheGo |
||||
|
|
||||
|
go 1.18 |
||||
|
|
||||
|
require ( |
||||
|
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 |
||||
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.3 |
||||
|
github.com/gogf/gf/v2 v2.8.3 |
||||
|
) |
||||
|
|
||||
|
require ( |
||||
|
github.com/BurntSushi/toml v1.4.0 // indirect |
||||
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect |
||||
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect |
||||
|
github.com/emirpasic/gods v1.18.1 // indirect |
||||
|
github.com/fatih/color v1.18.0 // indirect |
||||
|
github.com/fsnotify/fsnotify v1.7.0 // indirect |
||||
|
github.com/go-logr/logr v1.4.2 // indirect |
||||
|
github.com/go-logr/stdr v1.2.2 // indirect |
||||
|
github.com/go-sql-driver/mysql v1.7.1 // indirect |
||||
|
github.com/gorilla/websocket v1.5.3 // indirect |
||||
|
github.com/grokify/html-strip-tags-go v0.1.0 // indirect |
||||
|
github.com/magiconair/properties v1.8.9 // indirect |
||||
|
github.com/mattn/go-colorable v0.1.13 // indirect |
||||
|
github.com/mattn/go-isatty v0.0.20 // indirect |
||||
|
github.com/mattn/go-runewidth v0.0.16 // indirect |
||||
|
github.com/olekukonko/tablewriter v0.0.5 // indirect |
||||
|
github.com/redis/go-redis/v9 v9.7.0 // indirect |
||||
|
github.com/rivo/uniseg v0.4.7 // indirect |
||||
|
go.opentelemetry.io/otel v1.24.0 // indirect |
||||
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect |
||||
|
go.opentelemetry.io/otel/sdk v1.24.0 // indirect |
||||
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect |
||||
|
golang.org/x/net v0.32.0 // indirect |
||||
|
golang.org/x/sys v0.28.0 // indirect |
||||
|
golang.org/x/text v0.21.0 // indirect |
||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect |
||||
|
) |
@ -0,0 +1,74 @@ |
|||||
|
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= |
||||
|
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= |
||||
|
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= |
||||
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= |
||||
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= |
||||
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= |
||||
|
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= |
||||
|
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= |
||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= |
||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= |
||||
|
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= |
||||
|
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= |
||||
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= |
||||
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= |
||||
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= |
||||
|
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= |
||||
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= |
||||
|
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= |
||||
|
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= |
||||
|
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= |
||||
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= |
||||
|
github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= |
||||
|
github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= |
||||
|
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 h1:RtoBg5HWACFrgIrFkpzH94kxSd5EWefNAq5k6olNY6c= |
||||
|
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3/go.mod h1:elZjckHRCejwml5Kdx2zfhOUDiAV3r5i4BgXcKAeH00= |
||||
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.3 h1:SpstyaADpaJmTgv55Teb8i7mpQrKH9IMzL0TwnhGcHI= |
||||
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.3/go.mod h1:kPSHCSoDQZNKcJ/ZlLd/c1sGKR+0BJRa5nCP3YkSteo= |
||||
|
github.com/gogf/gf/v2 v2.8.3 h1:h9Px3lqJnnH6It0AqHRz4/1hx0JmvaSf1IvUir5x1rA= |
||||
|
github.com/gogf/gf/v2 v2.8.3/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY= |
||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= |
||||
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= |
||||
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= |
||||
|
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= |
||||
|
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= |
||||
|
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= |
||||
|
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= |
||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= |
||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= |
||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= |
||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= |
||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= |
||||
|
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= |
||||
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= |
||||
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= |
||||
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= |
||||
|
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= |
||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= |
||||
|
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= |
||||
|
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= |
||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= |
||||
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= |
||||
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= |
||||
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= |
||||
|
go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= |
||||
|
go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= |
||||
|
go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= |
||||
|
go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= |
||||
|
go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= |
||||
|
go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= |
||||
|
go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= |
||||
|
go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= |
||||
|
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= |
||||
|
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= |
||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= |
||||
|
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= |
||||
|
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
||||
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= |
||||
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= |
||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= |
||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= |
||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
@ -0,0 +1,18 @@ |
|||||
|
|
||||
|
# CLI tool, only in development environment. |
||||
|
# https://goframe.org/docs/cli |
||||
|
gfcli: |
||||
|
gen: |
||||
|
dao: |
||||
|
- link: "mysql:link:tEhdERkaGprEA7nT@tcp(39.101.133.168:3306)/link?charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
group: "default" |
||||
|
descriptionTag: true |
||||
|
- link: "mysql:live:p4jMAMShNM8HTrbX@tcp(39.101.133.168:3306)/live?charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
group: "live" |
||||
|
tables: "member_info" |
||||
|
descriptionTag: true |
||||
|
|
||||
|
docker: |
||||
|
build: "-a amd64 -s linux -p temp -ew" |
||||
|
tagPrefixes: |
||||
|
- my.image.pub/my-app |
@ -0,0 +1,20 @@ |
|||||
|
|
||||
|
# Install/Update to the latest CLI tool.
|
||||
|
.PHONY: cli |
||||
|
cli: |
||||
|
@set -e; \
|
||||
|
wget -O gf \
|
||||
|
https://github.com/gogf/gf/releases/latest/download/gf_$(shell go env GOOS)_$(shell go env GOARCH) && \
|
||||
|
chmod +x gf && \
|
||||
|
./gf install -y && \
|
||||
|
rm ./gf |
||||
|
|
||||
|
|
||||
|
# Check and install CLI tool.
|
||||
|
.PHONY: cli.install |
||||
|
cli.install: |
||||
|
@set -e; \
|
||||
|
gf -v > /dev/null 2>&1 || if [[ "$?" -ne "0" ]]; then \
|
||||
|
echo "GoFame CLI is not installed, start proceeding auto installation..."; \
|
||||
|
make cli; \
|
||||
|
fi; |
@ -0,0 +1,75 @@ |
|||||
|
.DEFAULT_GOAL := build |
||||
|
|
||||
|
# Update GoFrame and its CLI to latest stable version.
|
||||
|
.PHONY: up |
||||
|
up: cli.install |
||||
|
@gf up -a |
||||
|
|
||||
|
# Build binary using configuration from hack/config.yaml.
|
||||
|
.PHONY: build |
||||
|
build: cli.install |
||||
|
@gf build -ew |
||||
|
|
||||
|
# Parse api and generate controller/sdk.
|
||||
|
.PHONY: ctrl |
||||
|
ctrl: cli.install |
||||
|
@gf gen ctrl |
||||
|
|
||||
|
# Generate Go files for DAO/DO/Entity.
|
||||
|
.PHONY: dao |
||||
|
dao: cli.install |
||||
|
@gf gen dao |
||||
|
|
||||
|
# Parse current project go files and generate enums go file.
|
||||
|
.PHONY: enums |
||||
|
enums: cli.install |
||||
|
@gf gen enums |
||||
|
|
||||
|
# Generate Go files for Service.
|
||||
|
.PHONY: service |
||||
|
service: cli.install |
||||
|
@gf gen service |
||||
|
|
||||
|
|
||||
|
# Build docker image.
|
||||
|
.PHONY: image |
||||
|
image: cli.install |
||||
|
$(eval _TAG = $(shell git rev-parse --short HEAD)) |
||||
|
ifneq (, $(shell git status --porcelain 2>/dev/null)) |
||||
|
$(eval _TAG = $(_TAG).dirty) |
||||
|
endif |
||||
|
$(eval _TAG = $(if ${TAG}, ${TAG}, $(_TAG))) |
||||
|
$(eval _PUSH = $(if ${PUSH}, ${PUSH}, )) |
||||
|
@gf docker ${_PUSH} -tn $(DOCKER_NAME):${_TAG}; |
||||
|
|
||||
|
|
||||
|
# Build docker image and automatically push to docker repo.
|
||||
|
.PHONY: image.push |
||||
|
image.push: cli.install |
||||
|
@make image PUSH=-p; |
||||
|
|
||||
|
|
||||
|
# Deploy image and yaml to current kubectl environment.
|
||||
|
.PHONY: deploy |
||||
|
deploy: cli.install |
||||
|
$(eval _TAG = $(if ${TAG}, ${TAG}, develop)) |
||||
|
|
||||
|
@set -e; \
|
||||
|
mkdir -p $(ROOT_DIR)/temp/kustomize;\
|
||||
|
cd $(ROOT_DIR)/manifest/deploy/kustomize/overlays/${_ENV};\
|
||||
|
kustomize build > $(ROOT_DIR)/temp/kustomize.yaml;\
|
||||
|
kubectl apply -f $(ROOT_DIR)/temp/kustomize.yaml; \
|
||||
|
if [ $(DEPLOY_NAME) != "" ]; then \
|
||||
|
kubectl patch -n $(NAMESPACE) deployment/$(DEPLOY_NAME) -p "{\"spec\":{\"template\":{\"metadata\":{\"labels\":{\"date\":\"$(shell date +%s)\"}}}}}"; \
|
||||
|
fi; |
||||
|
|
||||
|
|
||||
|
# Parsing protobuf files and generating go files.
|
||||
|
.PHONY: pb |
||||
|
pb: cli.install |
||||
|
@gf gen pb |
||||
|
|
||||
|
# Generate protobuf files for database tables.
|
||||
|
.PHONY: pbentity |
||||
|
pbentity: cli.install |
||||
|
@gf gen pbentity |
@ -0,0 +1,27 @@ |
|||||
|
package cmd |
||||
|
|
||||
|
import ( |
||||
|
"MangheGo/internal/logic/middleware" |
||||
|
"context" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
"github.com/gogf/gf/v2/os/gcmd" |
||||
|
) |
||||
|
|
||||
|
var ( |
||||
|
Main = gcmd.Command{ |
||||
|
Name: "main", |
||||
|
Usage: "main", |
||||
|
Brief: "start http server", |
||||
|
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { |
||||
|
s := g.Server() |
||||
|
s.Group("/", func(group *ghttp.RouterGroup) { |
||||
|
group.Middleware(middleware.MiddlewareCORS) |
||||
|
|
||||
|
}) |
||||
|
s.Run() |
||||
|
return nil |
||||
|
}, |
||||
|
} |
||||
|
) |
@ -0,0 +1,10 @@ |
|||||
|
package consts |
||||
|
|
||||
|
const ( |
||||
|
URL_KEY = "jingwang:cms:env" //Redis中的键
|
||||
|
//内容: http://39.101.133.168:8828/hljw
|
||||
|
//测试环境解析token接口: http://39.101.133.168:8828/hljw/api/v2/member/info
|
||||
|
//正式环境解析token接口: http://api.homilychart.com/hljw/api/v2/member/info
|
||||
|
//URL_HASH_KEY = "HLJW_BASE_URL"
|
||||
|
URL_HASH_KEY = "HLJW_URL" |
||||
|
) |
@ -0,0 +1,139 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
package internal |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/database/gdb" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
) |
||||
|
|
||||
|
// MemberInfoDao is the data access object for table member_info.
|
||||
|
type MemberInfoDao struct { |
||||
|
table string // table is the underlying table name of the DAO.
|
||||
|
group string // group is the database configuration group name of current DAO.
|
||||
|
columns MemberInfoColumns // columns contains all the column names of Table for convenient usage.
|
||||
|
} |
||||
|
|
||||
|
// MemberInfoColumns defines and stores column names for table member_info.
|
||||
|
type MemberInfoColumns struct { |
||||
|
Id string //
|
||||
|
Jwcode string //
|
||||
|
Name string //
|
||||
|
Sex string // 0:未知,1:男,2:女
|
||||
|
Avatar string // 用户头像
|
||||
|
Widget string // 头像挂件
|
||||
|
DeptId string //
|
||||
|
DeptName string //
|
||||
|
ShopId string //
|
||||
|
ShopName string //
|
||||
|
MembershipTime string //
|
||||
|
LiveLock string // 0:解锁 1:锁住
|
||||
|
LocMarket string // 用户市场归属
|
||||
|
Level string // 等级
|
||||
|
LevelIcon string // 等级图标
|
||||
|
Star string // 星级
|
||||
|
AccountOwner string //
|
||||
|
AccountOwnerText string //
|
||||
|
Employee string // 1:员工
|
||||
|
Dachang string // 0:不是大厂员工 1:是大厂员工
|
||||
|
BoguMember string // 1:博股会员
|
||||
|
LearningIcon string // 学习等级icon
|
||||
|
Mobile string // 手机号
|
||||
|
UserIdentity string // 0:无认证 1:红V 2:蓝V 3:黄V
|
||||
|
UserIdentityTitle string // 用户身份头衔
|
||||
|
Openid string // 微信openid
|
||||
|
UserRole string // 用户身份(1:网员 2:非网)
|
||||
|
IsBlacklist string // 是否是黑名单用户
|
||||
|
IsLecturer string // 讲师
|
||||
|
Shenqiangshou string // 神枪手
|
||||
|
Huanqiu string // 环球
|
||||
|
Age string // 年纪
|
||||
|
CreatedAt string //
|
||||
|
UpdatedAt string //
|
||||
|
} |
||||
|
|
||||
|
// memberInfoColumns holds the columns for table member_info.
|
||||
|
var memberInfoColumns = MemberInfoColumns{ |
||||
|
Id: "id", |
||||
|
Jwcode: "jwcode", |
||||
|
Name: "name", |
||||
|
Sex: "sex", |
||||
|
Avatar: "avatar", |
||||
|
Widget: "widget", |
||||
|
DeptId: "deptId", |
||||
|
DeptName: "deptName", |
||||
|
ShopId: "shopId", |
||||
|
ShopName: "shopName", |
||||
|
MembershipTime: "membership_time", |
||||
|
LiveLock: "live_lock", |
||||
|
LocMarket: "loc_market", |
||||
|
Level: "level", |
||||
|
LevelIcon: "level_icon", |
||||
|
Star: "star", |
||||
|
AccountOwner: "account_owner", |
||||
|
AccountOwnerText: "account_owner_text", |
||||
|
Employee: "employee", |
||||
|
Dachang: "dachang", |
||||
|
BoguMember: "bogu_member", |
||||
|
LearningIcon: "learning_icon", |
||||
|
Mobile: "mobile", |
||||
|
UserIdentity: "user_identity", |
||||
|
UserIdentityTitle: "user_identity_title", |
||||
|
Openid: "openid", |
||||
|
UserRole: "user_role", |
||||
|
IsBlacklist: "is_blacklist", |
||||
|
IsLecturer: "is_lecturer", |
||||
|
Shenqiangshou: "shenqiangshou", |
||||
|
Huanqiu: "huanqiu", |
||||
|
Age: "age", |
||||
|
CreatedAt: "created_at", |
||||
|
UpdatedAt: "updated_at", |
||||
|
} |
||||
|
|
||||
|
// NewMemberInfoDao creates and returns a new DAO object for table data access.
|
||||
|
func NewMemberInfoDao() *MemberInfoDao { |
||||
|
return &MemberInfoDao{ |
||||
|
group: "live", |
||||
|
table: "member_info", |
||||
|
columns: memberInfoColumns, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
|
func (dao *MemberInfoDao) DB() gdb.DB { |
||||
|
return g.DB(dao.group) |
||||
|
} |
||||
|
|
||||
|
// Table returns the table name of current dao.
|
||||
|
func (dao *MemberInfoDao) Table() string { |
||||
|
return dao.table |
||||
|
} |
||||
|
|
||||
|
// Columns returns all column names of current dao.
|
||||
|
func (dao *MemberInfoDao) Columns() MemberInfoColumns { |
||||
|
return dao.columns |
||||
|
} |
||||
|
|
||||
|
// Group returns the configuration group name of database of current dao.
|
||||
|
func (dao *MemberInfoDao) Group() string { |
||||
|
return dao.group |
||||
|
} |
||||
|
|
||||
|
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
|
func (dao *MemberInfoDao) Ctx(ctx context.Context) *gdb.Model { |
||||
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx) |
||||
|
} |
||||
|
|
||||
|
// Transaction wraps the transaction logic using function f.
|
||||
|
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||
|
//
|
||||
|
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
|
// as it is automatically handled by this function.
|
||||
|
func (dao *MemberInfoDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
||||
|
return dao.Ctx(ctx).Transaction(ctx, f) |
||||
|
} |
@ -0,0 +1,87 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
package internal |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/database/gdb" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
) |
||||
|
|
||||
|
// PrizeDao is the data access object for table prize.
|
||||
|
type PrizeDao struct { |
||||
|
table string // table is the underlying table name of the DAO.
|
||||
|
group string // group is the database configuration group name of current DAO.
|
||||
|
columns PrizeColumns // columns contains all the column names of Table for convenient usage.
|
||||
|
} |
||||
|
|
||||
|
// PrizeColumns defines and stores column names for table prize.
|
||||
|
type PrizeColumns struct { |
||||
|
Id string // 奖品ID
|
||||
|
Name string // 奖品名称
|
||||
|
ImgUrl string // 奖品图片
|
||||
|
Limit string // 奖品期限
|
||||
|
Level string // 奖品等级
|
||||
|
Odds string // 奖品抽取概率
|
||||
|
CreatedAt string // 创建时间
|
||||
|
UpdatedAt string // 修改时间
|
||||
|
} |
||||
|
|
||||
|
// prizeColumns holds the columns for table prize.
|
||||
|
var prizeColumns = PrizeColumns{ |
||||
|
Id: "id", |
||||
|
Name: "name", |
||||
|
ImgUrl: "img_url", |
||||
|
Limit: "limit", |
||||
|
Level: "level", |
||||
|
Odds: "odds", |
||||
|
CreatedAt: "created_at", |
||||
|
UpdatedAt: "updated_at", |
||||
|
} |
||||
|
|
||||
|
// NewPrizeDao creates and returns a new DAO object for table data access.
|
||||
|
func NewPrizeDao() *PrizeDao { |
||||
|
return &PrizeDao{ |
||||
|
group: "default", |
||||
|
table: "prize", |
||||
|
columns: prizeColumns, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
|
func (dao *PrizeDao) DB() gdb.DB { |
||||
|
return g.DB(dao.group) |
||||
|
} |
||||
|
|
||||
|
// Table returns the table name of current dao.
|
||||
|
func (dao *PrizeDao) Table() string { |
||||
|
return dao.table |
||||
|
} |
||||
|
|
||||
|
// Columns returns all column names of current dao.
|
||||
|
func (dao *PrizeDao) Columns() PrizeColumns { |
||||
|
return dao.columns |
||||
|
} |
||||
|
|
||||
|
// Group returns the configuration group name of database of current dao.
|
||||
|
func (dao *PrizeDao) Group() string { |
||||
|
return dao.group |
||||
|
} |
||||
|
|
||||
|
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
|
func (dao *PrizeDao) Ctx(ctx context.Context) *gdb.Model { |
||||
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx) |
||||
|
} |
||||
|
|
||||
|
// Transaction wraps the transaction logic using function f.
|
||||
|
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||
|
//
|
||||
|
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
|
// as it is automatically handled by this function.
|
||||
|
func (dao *PrizeDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
||||
|
return dao.Ctx(ctx).Transaction(ctx, f) |
||||
|
} |
@ -0,0 +1,79 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
package internal |
||||
|
|
||||
|
import ( |
||||
|
"context" |
||||
|
|
||||
|
"github.com/gogf/gf/v2/database/gdb" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
) |
||||
|
|
||||
|
// PrizeRecordDao is the data access object for table prize_record.
|
||||
|
type PrizeRecordDao struct { |
||||
|
table string // table is the underlying table name of the DAO.
|
||||
|
group string // group is the database configuration group name of current DAO.
|
||||
|
columns PrizeRecordColumns // columns contains all the column names of Table for convenient usage.
|
||||
|
} |
||||
|
|
||||
|
// PrizeRecordColumns defines and stores column names for table prize_record.
|
||||
|
type PrizeRecordColumns struct { |
||||
|
Id string //
|
||||
|
Jwcode string // 精网号
|
||||
|
PrizeId string // 奖品ID
|
||||
|
Time string // 抽取时间
|
||||
|
} |
||||
|
|
||||
|
// prizeRecordColumns holds the columns for table prize_record.
|
||||
|
var prizeRecordColumns = PrizeRecordColumns{ |
||||
|
Id: "id", |
||||
|
Jwcode: "jwcode", |
||||
|
PrizeId: "prize_id", |
||||
|
Time: "time", |
||||
|
} |
||||
|
|
||||
|
// NewPrizeRecordDao creates and returns a new DAO object for table data access.
|
||||
|
func NewPrizeRecordDao() *PrizeRecordDao { |
||||
|
return &PrizeRecordDao{ |
||||
|
group: "default", |
||||
|
table: "prize_record", |
||||
|
columns: prizeRecordColumns, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// DB retrieves and returns the underlying raw database management object of current DAO.
|
||||
|
func (dao *PrizeRecordDao) DB() gdb.DB { |
||||
|
return g.DB(dao.group) |
||||
|
} |
||||
|
|
||||
|
// Table returns the table name of current dao.
|
||||
|
func (dao *PrizeRecordDao) Table() string { |
||||
|
return dao.table |
||||
|
} |
||||
|
|
||||
|
// Columns returns all column names of current dao.
|
||||
|
func (dao *PrizeRecordDao) Columns() PrizeRecordColumns { |
||||
|
return dao.columns |
||||
|
} |
||||
|
|
||||
|
// Group returns the configuration group name of database of current dao.
|
||||
|
func (dao *PrizeRecordDao) Group() string { |
||||
|
return dao.group |
||||
|
} |
||||
|
|
||||
|
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
||||
|
func (dao *PrizeRecordDao) Ctx(ctx context.Context) *gdb.Model { |
||||
|
return dao.DB().Model(dao.table).Safe().Ctx(ctx) |
||||
|
} |
||||
|
|
||||
|
// Transaction wraps the transaction logic using function f.
|
||||
|
// It rollbacks the transaction and returns the error from function f if it returns non-nil error.
|
||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||
|
//
|
||||
|
// Note that, you should not Commit or Rollback the transaction in function f
|
||||
|
// as it is automatically handled by this function.
|
||||
|
func (dao *PrizeRecordDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { |
||||
|
return dao.Ctx(ctx).Transaction(ctx, f) |
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
// =================================================================================
|
||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package dao |
||||
|
|
||||
|
import ( |
||||
|
"MangheGo/internal/dao/internal" |
||||
|
) |
||||
|
|
||||
|
// internalMemberInfoDao is internal type for wrapping internal DAO implements.
|
||||
|
type internalMemberInfoDao = *internal.MemberInfoDao |
||||
|
|
||||
|
// memberInfoDao is the data access object for table member_info.
|
||||
|
// You can define custom methods on it to extend its functionality as you wish.
|
||||
|
type memberInfoDao struct { |
||||
|
internalMemberInfoDao |
||||
|
} |
||||
|
|
||||
|
var ( |
||||
|
// MemberInfo is globally public accessible object for table member_info operations.
|
||||
|
MemberInfo = memberInfoDao{ |
||||
|
internal.NewMemberInfoDao(), |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
// Fill with you ideas below.
|
@ -0,0 +1,27 @@ |
|||||
|
// =================================================================================
|
||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package dao |
||||
|
|
||||
|
import ( |
||||
|
"MangheGo/internal/dao/internal" |
||||
|
) |
||||
|
|
||||
|
// internalPrizeDao is internal type for wrapping internal DAO implements.
|
||||
|
type internalPrizeDao = *internal.PrizeDao |
||||
|
|
||||
|
// prizeDao is the data access object for table prize.
|
||||
|
// You can define custom methods on it to extend its functionality as you wish.
|
||||
|
type prizeDao struct { |
||||
|
internalPrizeDao |
||||
|
} |
||||
|
|
||||
|
var ( |
||||
|
// Prize is globally public accessible object for table prize operations.
|
||||
|
Prize = prizeDao{ |
||||
|
internal.NewPrizeDao(), |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
// Fill with you ideas below.
|
@ -0,0 +1,27 @@ |
|||||
|
// =================================================================================
|
||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package dao |
||||
|
|
||||
|
import ( |
||||
|
"MangheGo/internal/dao/internal" |
||||
|
) |
||||
|
|
||||
|
// internalPrizeRecordDao is internal type for wrapping internal DAO implements.
|
||||
|
type internalPrizeRecordDao = *internal.PrizeRecordDao |
||||
|
|
||||
|
// prizeRecordDao is the data access object for table prize_record.
|
||||
|
// You can define custom methods on it to extend its functionality as you wish.
|
||||
|
type prizeRecordDao struct { |
||||
|
internalPrizeRecordDao |
||||
|
} |
||||
|
|
||||
|
var ( |
||||
|
// PrizeRecord is globally public accessible object for table prize_record operations.
|
||||
|
PrizeRecord = prizeRecordDao{ |
||||
|
internal.NewPrizeRecordDao(), |
||||
|
} |
||||
|
) |
||||
|
|
||||
|
// Fill with you ideas below.
|
@ -0,0 +1,10 @@ |
|||||
|
package middleware |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/net/ghttp" |
||||
|
) |
||||
|
|
||||
|
func MiddlewareCORS(r *ghttp.Request) { |
||||
|
r.Response.CORSDefault() |
||||
|
r.Middleware.Next() |
||||
|
} |
@ -0,0 +1,49 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package do |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// MemberInfo is the golang structure of table member_info for DAO operations like Where/Data.
|
||||
|
type MemberInfo struct { |
||||
|
g.Meta `orm:"table:member_info, do:true"` |
||||
|
Id interface{} //
|
||||
|
Jwcode interface{} //
|
||||
|
Name interface{} //
|
||||
|
Sex interface{} // 0:未知,1:男,2:女
|
||||
|
Avatar interface{} // 用户头像
|
||||
|
Widget interface{} // 头像挂件
|
||||
|
DeptId interface{} //
|
||||
|
DeptName interface{} //
|
||||
|
ShopId interface{} //
|
||||
|
ShopName interface{} //
|
||||
|
MembershipTime *gtime.Time //
|
||||
|
LiveLock interface{} // 0:解锁 1:锁住
|
||||
|
LocMarket interface{} // 用户市场归属
|
||||
|
Level interface{} // 等级
|
||||
|
LevelIcon interface{} // 等级图标
|
||||
|
Star interface{} // 星级
|
||||
|
AccountOwner interface{} //
|
||||
|
AccountOwnerText interface{} //
|
||||
|
Employee interface{} // 1:员工
|
||||
|
Dachang interface{} // 0:不是大厂员工 1:是大厂员工
|
||||
|
BoguMember interface{} // 1:博股会员
|
||||
|
LearningIcon interface{} // 学习等级icon
|
||||
|
Mobile interface{} // 手机号
|
||||
|
UserIdentity interface{} // 0:无认证 1:红V 2:蓝V 3:黄V
|
||||
|
UserIdentityTitle interface{} // 用户身份头衔
|
||||
|
Openid interface{} // 微信openid
|
||||
|
UserRole interface{} // 用户身份(1:网员 2:非网)
|
||||
|
IsBlacklist interface{} // 是否是黑名单用户
|
||||
|
IsLecturer interface{} // 讲师
|
||||
|
Shenqiangshou interface{} // 神枪手
|
||||
|
Huanqiu interface{} // 环球
|
||||
|
Age interface{} // 年纪
|
||||
|
CreatedAt *gtime.Time //
|
||||
|
UpdatedAt *gtime.Time //
|
||||
|
} |
@ -0,0 +1,23 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package do |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// Prize is the golang structure of table prize for DAO operations like Where/Data.
|
||||
|
type Prize struct { |
||||
|
g.Meta `orm:"table:prize, do:true"` |
||||
|
Id interface{} // 奖品ID
|
||||
|
Name interface{} // 奖品名称
|
||||
|
ImgUrl interface{} // 奖品图片
|
||||
|
Limit interface{} // 奖品期限
|
||||
|
Level interface{} // 奖品等级
|
||||
|
Odds interface{} // 奖品抽取概率
|
||||
|
CreatedAt *gtime.Time // 创建时间
|
||||
|
UpdatedAt *gtime.Time // 修改时间
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package do |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// PrizeRecord is the golang structure of table prize_record for DAO operations like Where/Data.
|
||||
|
type PrizeRecord struct { |
||||
|
g.Meta `orm:"table:prize_record, do:true"` |
||||
|
Id interface{} //
|
||||
|
Jwcode interface{} // 精网号
|
||||
|
PrizeId interface{} // 奖品ID
|
||||
|
Time *gtime.Time // 抽取时间
|
||||
|
} |
@ -0,0 +1,80 @@ |
|||||
|
package dto |
||||
|
|
||||
|
// 定义响应结构
|
||||
|
type Result struct { |
||||
|
Code int `json:"code"` |
||||
|
Message string `json:"message"` |
||||
|
Data interface{} `json:"data"` // 修改为实体类型
|
||||
|
} |
||||
|
|
||||
|
/*成功,没有数据*/ |
||||
|
func Success() *Result { |
||||
|
return &Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*成功,自定义相应信息*/ |
||||
|
func SuccessWithMsg(msg string) *Result { |
||||
|
return &Result{ |
||||
|
Code: 200, |
||||
|
Message: msg, |
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*成功,有数据*/ |
||||
|
func SuccessWithData(data interface{}) *Result { |
||||
|
return &Result{ |
||||
|
Code: 200, |
||||
|
Message: "success", |
||||
|
Data: data, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*成功,自定义信息和数据*/ |
||||
|
func SuccessWithMsgAndData(msg string, data interface{}) *Result { |
||||
|
return &Result{ |
||||
|
Code: 200, |
||||
|
Message: msg, |
||||
|
Data: data, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*错误,只有错误信息,错误码0*/ |
||||
|
func Error(msg string) *Result { |
||||
|
return &Result{ |
||||
|
Code: 400, // 错误码
|
||||
|
Message: msg, // 错误信息
|
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*错误,有错误信息,有错误码*/ |
||||
|
func ErrorWithCode(code int, msg string) *Result { |
||||
|
return &Result{ |
||||
|
Code: code, // 错误码
|
||||
|
Message: msg, // 错误信息
|
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*未授权,有错误信息,错误码为401*/ |
||||
|
func Unauthorized(msg string) *Result { |
||||
|
return &Result{ |
||||
|
Code: 401, // 错误码
|
||||
|
Message: msg, // 错误信息
|
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/*未授权,有错误信息,允许自定义错误码*/ |
||||
|
func UnauthorizedWithCode(code int, msg string) *Result { |
||||
|
return &Result{ |
||||
|
Code: code, // 错误码
|
||||
|
Message: msg, // 错误信息
|
||||
|
Data: nil, |
||||
|
} |
||||
|
} |
@ -0,0 +1,47 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package entity |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// MemberInfo is the golang structure for table member_info.
|
||||
|
type MemberInfo struct { |
||||
|
Id int `json:"id" orm:"id" description:""` //
|
||||
|
Jwcode int `json:"jwcode" orm:"jwcode" description:""` //
|
||||
|
Name string `json:"name" orm:"name" description:""` //
|
||||
|
Sex int `json:"sex" orm:"sex" description:"0:未知,1:男,2:女"` // 0:未知,1:男,2:女
|
||||
|
Avatar string `json:"avatar" orm:"avatar" description:"用户头像"` // 用户头像
|
||||
|
Widget string `json:"widget" orm:"widget" description:"头像挂件"` // 头像挂件
|
||||
|
DeptId string `json:"deptId" orm:"deptId" description:""` //
|
||||
|
DeptName string `json:"deptName" orm:"deptName" description:""` //
|
||||
|
ShopId string `json:"shopId" orm:"shopId" description:""` //
|
||||
|
ShopName string `json:"shopName" orm:"shopName" description:""` //
|
||||
|
MembershipTime *gtime.Time `json:"membershipTime" orm:"membership_time" description:""` //
|
||||
|
LiveLock int `json:"liveLock" orm:"live_lock" description:"0:解锁 1:锁住"` // 0:解锁 1:锁住
|
||||
|
LocMarket string `json:"locMarket" orm:"loc_market" description:"用户市场归属"` // 用户市场归属
|
||||
|
Level int `json:"level" orm:"level" description:"等级"` // 等级
|
||||
|
LevelIcon string `json:"levelIcon" orm:"level_icon" description:"等级图标"` // 等级图标
|
||||
|
Star int `json:"star" orm:"star" description:"星级"` // 星级
|
||||
|
AccountOwner string `json:"accountOwner" orm:"account_owner" description:""` //
|
||||
|
AccountOwnerText string `json:"accountOwnerText" orm:"account_owner_text" description:""` //
|
||||
|
Employee int `json:"employee" orm:"employee" description:"1:员工"` // 1:员工
|
||||
|
Dachang int `json:"dachang" orm:"dachang" description:"0:不是大厂员工 1:是大厂员工"` // 0:不是大厂员工 1:是大厂员工
|
||||
|
BoguMember int `json:"boguMember" orm:"bogu_member" description:"1:博股会员"` // 1:博股会员
|
||||
|
LearningIcon string `json:"learningIcon" orm:"learning_icon" description:"学习等级icon"` // 学习等级icon
|
||||
|
Mobile string `json:"mobile" orm:"mobile" description:"手机号"` // 手机号
|
||||
|
UserIdentity int `json:"userIdentity" orm:"user_identity" description:"0:无认证 1:红V 2:蓝V 3:黄V"` // 0:无认证 1:红V 2:蓝V 3:黄V
|
||||
|
UserIdentityTitle string `json:"userIdentityTitle" orm:"user_identity_title" description:"用户身份头衔"` // 用户身份头衔
|
||||
|
Openid string `json:"openid" orm:"openid" description:"微信openid"` // 微信openid
|
||||
|
UserRole int `json:"userRole" orm:"user_role" description:"用户身份(1:网员 2:非网)"` // 用户身份(1:网员 2:非网)
|
||||
|
IsBlacklist int `json:"isBlacklist" orm:"is_blacklist" description:"是否是黑名单用户"` // 是否是黑名单用户
|
||||
|
IsLecturer int `json:"isLecturer" orm:"is_lecturer" description:"讲师"` // 讲师
|
||||
|
Shenqiangshou int `json:"shenqiangshou" orm:"shenqiangshou" description:"神枪手"` // 神枪手
|
||||
|
Huanqiu int `json:"huanqiu" orm:"huanqiu" description:"环球"` // 环球
|
||||
|
Age uint `json:"age" orm:"age" description:"年纪"` // 年纪
|
||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||
|
} |
@ -0,0 +1,21 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package entity |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// Prize is the golang structure for table prize.
|
||||
|
type Prize struct { |
||||
|
Id uint `json:"id" orm:"id" description:"奖品ID"` // 奖品ID
|
||||
|
Name string `json:"name" orm:"name" description:"奖品名称"` // 奖品名称
|
||||
|
ImgUrl string `json:"imgUrl" orm:"img_url" description:"奖品图片"` // 奖品图片
|
||||
|
Limit string `json:"limit" orm:"limit" description:"奖品期限"` // 奖品期限
|
||||
|
Level int `json:"level" orm:"level" description:"奖品等级"` // 奖品等级
|
||||
|
Odds float64 `json:"odds" orm:"odds" description:"奖品抽取概率"` // 奖品抽取概率
|
||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"修改时间"` // 修改时间
|
||||
|
} |
@ -0,0 +1,17 @@ |
|||||
|
// =================================================================================
|
||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||
|
// =================================================================================
|
||||
|
|
||||
|
package entity |
||||
|
|
||||
|
import ( |
||||
|
"github.com/gogf/gf/v2/os/gtime" |
||||
|
) |
||||
|
|
||||
|
// PrizeRecord is the golang structure for table prize_record.
|
||||
|
type PrizeRecord struct { |
||||
|
Id uint `json:"id" orm:"id" description:""` //
|
||||
|
Jwcode int `json:"jwcode" orm:"jwcode" description:"精网号"` // 精网号
|
||||
|
PrizeId int `json:"prizeId" orm:"prize_id" description:"奖品ID"` // 奖品ID
|
||||
|
Time *gtime.Time `json:"time" orm:"time" description:"抽取时间"` // 抽取时间
|
||||
|
} |
@ -0,0 +1 @@ |
|||||
|
package packed |
@ -0,0 +1,15 @@ |
|||||
|
package main |
||||
|
|
||||
|
import ( |
||||
|
_ "MangheGo/internal/packed" |
||||
|
|
||||
|
_ "github.com/gogf/gf/contrib/drivers/mysql/v2" |
||||
|
_ "github.com/gogf/gf/contrib/nosql/redis/v2" |
||||
|
"github.com/gogf/gf/v2/os/gctx" |
||||
|
|
||||
|
"MangheGo/internal/cmd" |
||||
|
) |
||||
|
|
||||
|
func main() { |
||||
|
cmd.Main.Run(gctx.GetInitCtx()) |
||||
|
} |
@ -0,0 +1,24 @@ |
|||||
|
# https://goframe.org/docs/web/server-config-file-template |
||||
|
server: |
||||
|
address: ":8080" |
||||
|
|
||||
|
# https://goframe.org/docs/core/glog-config |
||||
|
logger: |
||||
|
level : "all" |
||||
|
stdout: true |
||||
|
|
||||
|
# https://goframe.org/docs/core/gdb-config-file |
||||
|
database: |
||||
|
default: |
||||
|
link: "mysql:link:tEhdERkaGprEA7nT@tcp(39.101.133.168:3306)/link?charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
debug: true |
||||
|
live: |
||||
|
link: "mysql:live:p4jMAMShNM8HTrbX@tcp(39.101.133.168:3306)/live?charset=utf8mb4&parseTime=True&loc=Local" |
||||
|
debug: true |
||||
|
|
||||
|
# redis配置 |
||||
|
redis: |
||||
|
default: |
||||
|
address: 121.89.234.155:7001 |
||||
|
pass: RH0YTFo0ByLD |
||||
|
db: 0 |
@ -0,0 +1,21 @@ |
|||||
|
apiVersion: apps/v1 |
||||
|
kind: Deployment |
||||
|
metadata: |
||||
|
name: template-single |
||||
|
labels: |
||||
|
app: template-single |
||||
|
spec: |
||||
|
replicas: 1 |
||||
|
selector: |
||||
|
matchLabels: |
||||
|
app: template-single |
||||
|
template: |
||||
|
metadata: |
||||
|
labels: |
||||
|
app: template-single |
||||
|
spec: |
||||
|
containers: |
||||
|
- name : main |
||||
|
image: template-single |
||||
|
imagePullPolicy: Always |
||||
|
|
@ -0,0 +1,8 @@ |
|||||
|
apiVersion: kustomize.config.k8s.io/v1beta1 |
||||
|
kind: Kustomization |
||||
|
resources: |
||||
|
- deployment.yaml |
||||
|
- service.yaml |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,12 @@ |
|||||
|
apiVersion: v1 |
||||
|
kind: Service |
||||
|
metadata: |
||||
|
name: template-single |
||||
|
spec: |
||||
|
ports: |
||||
|
- port: 80 |
||||
|
protocol: TCP |
||||
|
targetPort: 8000 |
||||
|
selector: |
||||
|
app: template-single |
||||
|
|
@ -0,0 +1,14 @@ |
|||||
|
apiVersion: v1 |
||||
|
kind: ConfigMap |
||||
|
metadata: |
||||
|
name: template-single-configmap |
||||
|
data: |
||||
|
config.yaml: | |
||||
|
server: |
||||
|
address: ":8000" |
||||
|
openapiPath: "/api.json" |
||||
|
swaggerPath: "/swagger" |
||||
|
|
||||
|
logger: |
||||
|
level : "all" |
||||
|
stdout: true |
@ -0,0 +1,10 @@ |
|||||
|
apiVersion: apps/v1 |
||||
|
kind: Deployment |
||||
|
metadata: |
||||
|
name: template-single |
||||
|
spec: |
||||
|
template: |
||||
|
spec: |
||||
|
containers: |
||||
|
- name : main |
||||
|
image: template-single:develop |
@ -0,0 +1,14 @@ |
|||||
|
apiVersion: kustomize.config.k8s.io/v1beta1 |
||||
|
kind: Kustomization |
||||
|
|
||||
|
resources: |
||||
|
- ../../base |
||||
|
- configmap.yaml |
||||
|
|
||||
|
patchesStrategicMerge: |
||||
|
- deployment.yaml |
||||
|
|
||||
|
namespace: default |
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,16 @@ |
|||||
|
FROM loads/alpine:3.8 |
||||
|
|
||||
|
############################################################################### |
||||
|
# INSTALLATION |
||||
|
############################################################################### |
||||
|
|
||||
|
ENV WORKDIR /app |
||||
|
ADD resource $WORKDIR/ |
||||
|
ADD ./temp/linux_amd64/main $WORKDIR/main |
||||
|
RUN chmod +x $WORKDIR/main |
||||
|
|
||||
|
############################################################################### |
||||
|
# START |
||||
|
############################################################################### |
||||
|
WORKDIR $WORKDIR |
||||
|
CMD ./main |
@ -0,0 +1,8 @@ |
|||||
|
#!/bin/bash |
||||
|
|
||||
|
# This shell is executed before docker build. |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
@ -0,0 +1,129 @@ |
|||||
|
package utility |
||||
|
|
||||
|
import ( |
||||
|
"MangheGo/internal/consts" |
||||
|
"MangheGo/internal/model/dto" |
||||
|
"encoding/json" |
||||
|
"errors" |
||||
|
"fmt" |
||||
|
"github.com/gogf/gf/v2/frame/g" |
||||
|
"github.com/gogf/gf/v2/os/gctx" |
||||
|
"io/ioutil" |
||||
|
"net/http" |
||||
|
"strconv" |
||||
|
"strings" |
||||
|
) |
||||
|
|
||||
|
// 查询数据库中的URL
|
||||
|
func selectBaseUrl(hashKey string) *dto.Result { |
||||
|
|
||||
|
//查询数据库
|
||||
|
//env表中存储着一些所需要的地址,值等,可能是需要查出来存放到redis中(value字段中是值)
|
||||
|
//key为"HLJW_URL"时,value为:http://39.101.133.168:8828/hljw,为测试环境时前置地址
|
||||
|
value, err := g.DB().Model("env").Where("`key` = ?", hashKey).Value("value") |
||||
|
if err != nil { |
||||
|
return dto.Error("数据库env查询失败") |
||||
|
} |
||||
|
if value.IsNil() || value.String() == "" { |
||||
|
return dto.Error("未找到对应数据") |
||||
|
} |
||||
|
return dto.SuccessWithData(value.String()) |
||||
|
} |
||||
|
|
||||
|
// 获取URL
|
||||
|
func getUrl(key, hashKey string) *dto.Result { |
||||
|
ctx := gctx.New() |
||||
|
|
||||
|
//测试环境: http://39.101.133.168:8828/hljw/api/v2/member/info
|
||||
|
//正式环境: http://api.homilychart.com:8828/hljw/api/v2/member/info
|
||||
|
|
||||
|
//1. 从Redis获取URL
|
||||
|
redisUrl, err := g.Redis().Do(ctx, "HGET", key, hashKey) |
||||
|
if err == nil && redisUrl.String() != "" { |
||||
|
return dto.SuccessWithMsgAndData(fmt.Sprintf("从Redis获取URL: %s", redisUrl.String()), redisUrl.String()) |
||||
|
} |
||||
|
|
||||
|
//2. 如果Redis中没有, 查询数据库
|
||||
|
urlResult := selectBaseUrl(hashKey) |
||||
|
if urlResult.Code != 200 { |
||||
|
return urlResult |
||||
|
} |
||||
|
url := urlResult.Data.(string) |
||||
|
|
||||
|
//3. 将URL存入Redis
|
||||
|
_, err = g.Redis().Do(ctx, "HSET", key, hashKey, url) |
||||
|
if err != nil { |
||||
|
return dto.Error("将数据存入Redis失败") |
||||
|
} |
||||
|
|
||||
|
return dto.SuccessWithData(url) |
||||
|
} |
||||
|
|
||||
|
// 获取jwcode
|
||||
|
func GetJwcodeJSON(token string) (int, error) { |
||||
|
|
||||
|
//获取基础URL 用于解析token的接口地址
|
||||
|
urlResult := getUrl(consts.URL_KEY, consts.URL_HASH_KEY) |
||||
|
if urlResult.Code != 200 { |
||||
|
return 0, errors.New(fmt.Sprintf("获取基础URL失败: %s", urlResult.Message)) |
||||
|
} |
||||
|
baseUrl := urlResult.Data.(string) |
||||
|
|
||||
|
//拼接完整的URL, 用于发送请求并解析token
|
||||
|
url := baseUrl + "/api/v2/member/info" |
||||
|
requestBody := strings.NewReader(`{"token":"` + token + `"}`) |
||||
|
|
||||
|
//创建HTTP请求(POST)
|
||||
|
req, err := http.NewRequest("POST", url, requestBody) |
||||
|
if err != nil { |
||||
|
return 0, fmt.Errorf("创建HTTP请求失败: %w", err) |
||||
|
} |
||||
|
//设置请求头
|
||||
|
req.Header.Set("Content-Type", "application/json") |
||||
|
|
||||
|
//发送请求
|
||||
|
client := &http.Client{} |
||||
|
resp, err := client.Do(req) |
||||
|
if err != nil { |
||||
|
return 0, fmt.Errorf("发送HTTP请求失败: %w", err) //
|
||||
|
} |
||||
|
//延时关闭响应体
|
||||
|
defer resp.Body.Close() |
||||
|
|
||||
|
//检查HTTP状态码
|
||||
|
if resp.StatusCode != http.StatusOK { |
||||
|
return 0, fmt.Errorf("HTTP请求失败, 状态码: %d", resp.StatusCode) |
||||
|
} |
||||
|
|
||||
|
//读取并解析响应体
|
||||
|
body, err := ioutil.ReadAll(resp.Body) |
||||
|
if err != nil { |
||||
|
return 0, fmt.Errorf("读取响应体失败: %w", err) |
||||
|
} |
||||
|
|
||||
|
//解析JSON数据
|
||||
|
var jsonResponse map[string]interface{} |
||||
|
err = json.Unmarshal(body, &jsonResponse) |
||||
|
if err != nil { |
||||
|
return 0, fmt.Errorf("解析JSON数据失败: %w", err) |
||||
|
} |
||||
|
|
||||
|
//提取data节点
|
||||
|
data, ok := jsonResponse["data"].(map[string]interface{}) |
||||
|
if !ok { |
||||
|
return 0, errors.New("响应体中没有有效的data节点") |
||||
|
} |
||||
|
|
||||
|
//提取jwcode字段节点并转换为整数
|
||||
|
jwcode, ok := data["jwcode"].(string) //首先尝试解析为字符串
|
||||
|
if ok { |
||||
|
jwcodeInt, err := strconv.Atoi(jwcode) //将字符串转换为整数
|
||||
|
if err != nil { |
||||
|
return 0, fmt.Errorf("解析jwcode字段为整数失败: %w", err) |
||||
|
} |
||||
|
return jwcodeInt, nil |
||||
|
} |
||||
|
|
||||
|
//如果jwcode不是字符串,返回错误日志
|
||||
|
return 0, errors.New("响应体中没有有效的jwcode字段") |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue