Compare commits
merge into: wanglin:master
wanglin:dev
wanglin:lijikun
wanglin:majun
wanglin:master
wanglin:pindao-mj
wanglin:zhibo-mj
pull from: wanglin:lijikun
wanglin:dev
wanglin:lijikun
wanglin:majun
wanglin:master
wanglin:pindao-mj
wanglin:zhibo-mj
No commits in common. 'master' and 'lijikun' have entirely different histories.
72 changed files with 1839 additions and 0 deletions
-
1.gitattributes
-
25.gitignore
-
7Makefile
-
4README.MD
-
36go.mod
-
66go.sum
-
15hack/config.yaml
-
20hack/hack-cli.mk
-
75hack/hack.mk
-
75internal/cmd/cmd.go
-
1internal/consts/consts.go
-
66internal/controller/clubPage/clubPage.go
-
69internal/controller/mainPage/mainPage.go
-
0internal/dao/.gitkeep
-
27internal/dao/go_channel_subscriptions.go
-
27internal/dao/go_channels.go
-
27internal/dao/go_clubs.go
-
27internal/dao/go_live_reservations.go
-
27internal/dao/go_lives.go
-
27internal/dao/go_shows.go
-
27internal/dao/go_users.go
-
77internal/dao/internal/go_channel_subscriptions.go
-
81internal/dao/internal/go_channels.go
-
79internal/dao/internal/go_clubs.go
-
77internal/dao/internal/go_live_reservations.go
-
83internal/dao/internal/go_lives.go
-
95internal/dao/internal/go_shows.go
-
79internal/dao/internal/go_users.go
-
0internal/logic/.gitkeep
-
52internal/logic/clubs/clubs.go
-
8internal/logic/logic.go
-
59internal/logic/shows/shows.go
-
0internal/model/.gitkeep
-
0internal/model/do/.gitkeep
-
17internal/model/do/go_channel_subscriptions.go
-
19internal/model/do/go_channels.go
-
18internal/model/do/go_clubs.go
-
17internal/model/do/go_live_reservations.go
-
21internal/model/do/go_lives.go
-
27internal/model/do/go_shows.go
-
18internal/model/do/go_users.go
-
66internal/model/dto/Result.go
-
0internal/model/entity/.gitkeep
-
12internal/model/entity/go_channel_subscriptions.go
-
14internal/model/entity/go_channels.go
-
13internal/model/entity/go_clubs.go
-
12internal/model/entity/go_live_reservations.go
-
19internal/model/entity/go_lives.go
-
28internal/model/entity/go_shows.go
-
13internal/model/entity/go_users.go
-
1internal/packed/packed.go
-
0internal/service/.gitkeep
-
34internal/service/clubs.go
-
32internal/service/shows.go
-
16main.go
-
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
-
0utility/.gitkeep
@ -0,0 +1 @@ |
|||
* linguist-language=GO |
@ -0,0 +1,25 @@ |
|||
.buildpath |
|||
.hgignore.swp |
|||
.project |
|||
.orig |
|||
.swp |
|||
.idea/ |
|||
.settings/ |
|||
.vscode/ |
|||
bin/ |
|||
**/.DS_Store |
|||
gf |
|||
main |
|||
main.exe |
|||
output/ |
|||
manifest/output/ |
|||
temp/ |
|||
temp.yaml |
|||
bin |
|||
**/config/config.yaml |
|||
|
|||
*.exe |
|||
*.exe~ |
|||
*.dll |
|||
*.so |
|||
*.dylib |
@ -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,36 @@ |
|||
module practice_Go |
|||
|
|||
go 1.18 |
|||
|
|||
require ( |
|||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 |
|||
github.com/gogf/gf/v2 v2.8.1 |
|||
github.com/rs/cors v1.11.1 |
|||
) |
|||
|
|||
require ( |
|||
github.com/BurntSushi/toml v1.4.0 // indirect |
|||
github.com/clbanning/mxj/v2 v2.7.0 // indirect |
|||
github.com/emirpasic/gods v1.18.1 // indirect |
|||
github.com/fatih/color v1.17.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.7 // 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.15 // indirect |
|||
github.com/olekukonko/tablewriter v0.0.5 // 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.27.0 // indirect |
|||
golang.org/x/sys v0.22.0 // indirect |
|||
golang.org/x/text v0.16.0 // indirect |
|||
gopkg.in/yaml.v3 v3.0.1 // indirect |
|||
) |
@ -0,0 +1,66 @@ |
|||
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/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/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= |
|||
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= |
|||
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= |
|||
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= |
|||
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.1 h1:jbaPawkb8qmaYzrmBDbTa8Zkhzacq1RBOZw+qRJExI4= |
|||
github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1/go.mod h1:s2aI1fV9AvKi4NtMpv3pV0EHtazkvfUNVQmzapr7UJQ= |
|||
github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g= |
|||
github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc= |
|||
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.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= |
|||
github.com/magiconair/properties v1.8.7/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.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= |
|||
github.com/mattn/go-runewidth v0.0.15/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/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/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= |
|||
github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= |
|||
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.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= |
|||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= |
|||
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.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= |
|||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= |
|||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= |
|||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= |
|||
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,15 @@ |
|||
|
|||
# CLI tool, only in development environment. |
|||
# https://goframe.org/docs/cli |
|||
gfcli: |
|||
gen: |
|||
dao: |
|||
- link: "mysql:root:80083@tcp(127.0.0.1:3306)/linktest?charset=utf8mb4&parseTime=True&loc=Local" |
|||
table: "go_users, go_shows, go_lives, go_live_reservations, go_club, go_channels,go_channel_subscriptions" |
|||
descriptionTag: true |
|||
# jsonCase: "Snake" |
|||
|
|||
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,75 @@ |
|||
package cmd |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/internal/controller/clubPage" |
|||
"practice_Go/internal/controller/mainPage" |
|||
|
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"github.com/gogf/gf/v2/os/gcmd" |
|||
) |
|||
|
|||
/*自定义的允许跨域请求中间件*/ |
|||
func MiddlewareCORS(r *ghttp.Request) { |
|||
/* 没有起到应起到的作用,还是所有的都可以访问 |
|||
//自定义授权跨域的Origin
|
|||
corsOptions := r.Response.DefaultCORSOptions() |
|||
corsOptions.AllowDomain = []string{"localhost"} //数组中的为允许访问的
|
|||
if !r.Response.CORSAllowedOrigin(corsOptions) { |
|||
r.Response.WriteStatus(http.StatusForbidden) |
|||
return |
|||
} |
|||
r.Response.CORS(corsOptions) |
|||
r.Middleware.Next()*/ |
|||
//默认的跨域设置
|
|||
r.Response.CORSDefault() |
|||
r.Middleware.Next() |
|||
} |
|||
|
|||
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.BindHandler("/*any", func(r *ghttp.Request) { |
|||
r.Response.CORSDefault() |
|||
}) |
|||
|
|||
// 定义一个路由组,路径为/mainpage
|
|||
s.Group("/mainpage", func(group *ghttp.RouterGroup) { |
|||
// 添加中间件,用于处理响应
|
|||
//group.Middleware(ghttp.MiddlewareHandlerResponse)
|
|||
group.Middleware(MiddlewareCORS) |
|||
// 绑定路由,将mainPage.NewMainPage()绑定到该路由组
|
|||
group.Bind( |
|||
mainPage.NewMainPage(), |
|||
) |
|||
}) |
|||
|
|||
// 定义一个路由组,路径为/clubpage
|
|||
s.Group("/clubpage", func(group *ghttp.RouterGroup) { |
|||
// 添加中间件,用于处理响应
|
|||
//group.Middleware(ghttp.MiddlewareHandlerResponse)
|
|||
group.Middleware(MiddlewareCORS) |
|||
// 绑定路由,将mainPage.NewMainPage()绑定到该路由组
|
|||
group.Bind( |
|||
clubPage.NewClubPage(), |
|||
) |
|||
}) |
|||
|
|||
s.Run() |
|||
|
|||
//开启静态资源
|
|||
s.SetServerRoot("resource/public") |
|||
s.SetOpenApiPath("/api.json") //启用OpenAPIv3,并设置OpenAPI文档的路径
|
|||
s.SetSwaggerPath("/swagger") //启用内置的Swagger接口文档UI,并设置Swagger文档的路径
|
|||
s.Run() |
|||
|
|||
return nil |
|||
}, |
|||
} |
|||
) |
@ -0,0 +1 @@ |
|||
package consts |
@ -0,0 +1,66 @@ |
|||
package clubPage |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/internal/model/dto" |
|||
"practice_Go/internal/service" |
|||
) |
|||
|
|||
type ClubPage struct{} |
|||
|
|||
func NewClubPage() *ClubPage { |
|||
return &ClubPage{} |
|||
} |
|||
|
|||
// GetClub 获取俱乐部信息
|
|||
func (c ClubPage) GetClub(req *ghttp.Request) { |
|||
i := ghttp.RequestFromCtx(req.Context()).Get("id").Int() |
|||
|
|||
if i > 0 && i <= 4 { |
|||
club, err := service.GetClubs().GetClubs(req.Context()) |
|||
if err == nil { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 200, |
|||
Message: "success", |
|||
Data: club, |
|||
}) |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "error", |
|||
Data: err, |
|||
}) |
|||
} |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "传来俱乐部id信息不对", |
|||
}) |
|||
} |
|||
} |
|||
|
|||
func (c ClubPage) GetClubShows(req *ghttp.Request) { |
|||
i := g.RequestFromCtx(req.Context()).Get("id").Int() |
|||
if i > 0 && i <= 4 { |
|||
shows, err := service.GetClubs().GetClubShows(req.Context()) |
|||
if err == nil { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 200, |
|||
Message: "success", |
|||
Data: shows, |
|||
}) |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "error", |
|||
Data: err, |
|||
}) |
|||
} |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "传来俱乐部id信息不对", |
|||
}) |
|||
} |
|||
} |
@ -0,0 +1,69 @@ |
|||
package mainPage |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"github.com/gogf/gf/v2/net/ghttp" |
|||
"practice_Go/internal/model/dto" |
|||
"practice_Go/internal/service" |
|||
) |
|||
|
|||
// 定义一个MainPage结构体
|
|||
type MainPage struct{} |
|||
|
|||
// 创建一个新的MainPage实例 初始化
|
|||
func NewMainPage() *MainPage { |
|||
return &MainPage{} |
|||
} |
|||
|
|||
// 获取文章,视频
|
|||
func (c *MainPage) GetShows(req *ghttp.Request) { |
|||
i := g.RequestFromCtx(req.Context()).Get("flagType").Int() |
|||
if i >= 0 && i <= 2 { |
|||
|
|||
shows, err := service.GetShows().GetShows(req.Context()) |
|||
if err == nil { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 200, |
|||
Message: "success", |
|||
Data: shows, |
|||
}) |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "error", |
|||
Data: err, |
|||
}) |
|||
} |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "传参不对", |
|||
}) |
|||
} |
|||
} |
|||
|
|||
// 获取视频
|
|||
func (c *MainPage) GetVideos(req *ghttp.Request) { |
|||
i := g.RequestFromCtx(req.Context()).Get("flagType").Int() |
|||
if i == 0 || i == 1 || i == 2 { |
|||
shows, err := service.GetShows().GetVideos(req.Context()) |
|||
if err == nil { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 200, |
|||
Message: "success", |
|||
Data: shows, |
|||
}) |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "error", |
|||
Data: err, |
|||
}) |
|||
} |
|||
} else { |
|||
req.Response.WriteJson(dto.Result{ |
|||
Code: 500, |
|||
Message: "传参不对", |
|||
}) |
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
// =================================================================================
|
|||
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
|||
// =================================================================================
|
|||
|
|||
package dao |
|||
|
|||
import ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoChannelSubscriptionsDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoChannelSubscriptionsDao = *internal.GoChannelSubscriptionsDao |
|||
|
|||
// goChannelSubscriptionsDao is the data access object for table go_channel_subscriptions.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goChannelSubscriptionsDao struct { |
|||
internalGoChannelSubscriptionsDao |
|||
} |
|||
|
|||
var ( |
|||
// GoChannelSubscriptions is globally public accessible object for table go_channel_subscriptions operations.
|
|||
GoChannelSubscriptions = goChannelSubscriptionsDao{ |
|||
internal.NewGoChannelSubscriptionsDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoChannelsDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoChannelsDao = *internal.GoChannelsDao |
|||
|
|||
// goChannelsDao is the data access object for table go_channels.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goChannelsDao struct { |
|||
internalGoChannelsDao |
|||
} |
|||
|
|||
var ( |
|||
// GoChannels is globally public accessible object for table go_channels operations.
|
|||
GoChannels = goChannelsDao{ |
|||
internal.NewGoChannelsDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoClubsDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoClubsDao = *internal.GoClubsDao |
|||
|
|||
// goClubsDao is the data access object for table go_clubs.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goClubsDao struct { |
|||
internalGoClubsDao |
|||
} |
|||
|
|||
var ( |
|||
// GoClubs is globally public accessible object for table go_clubs operations.
|
|||
GoClubs = goClubsDao{ |
|||
internal.NewGoClubsDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoLiveReservationsDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoLiveReservationsDao = *internal.GoLiveReservationsDao |
|||
|
|||
// goLiveReservationsDao is the data access object for table go_live_reservations.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goLiveReservationsDao struct { |
|||
internalGoLiveReservationsDao |
|||
} |
|||
|
|||
var ( |
|||
// GoLiveReservations is globally public accessible object for table go_live_reservations operations.
|
|||
GoLiveReservations = goLiveReservationsDao{ |
|||
internal.NewGoLiveReservationsDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoLivesDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoLivesDao = *internal.GoLivesDao |
|||
|
|||
// goLivesDao is the data access object for table go_lives.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goLivesDao struct { |
|||
internalGoLivesDao |
|||
} |
|||
|
|||
var ( |
|||
// GoLives is globally public accessible object for table go_lives operations.
|
|||
GoLives = goLivesDao{ |
|||
internal.NewGoLivesDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoShowsDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoShowsDao = *internal.GoShowsDao |
|||
|
|||
// goShowsDao is the data access object for table go_shows.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goShowsDao struct { |
|||
internalGoShowsDao |
|||
} |
|||
|
|||
var ( |
|||
// GoShows is globally public accessible object for table go_shows operations.
|
|||
GoShows = goShowsDao{ |
|||
internal.NewGoShowsDao(), |
|||
} |
|||
) |
|||
|
|||
// 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 ( |
|||
"practice_Go/internal/dao/internal" |
|||
) |
|||
|
|||
// internalGoUsersDao is internal type for wrapping internal DAO implements.
|
|||
type internalGoUsersDao = *internal.GoUsersDao |
|||
|
|||
// goUsersDao is the data access object for table go_users.
|
|||
// You can define custom methods on it to extend its functionality as you wish.
|
|||
type goUsersDao struct { |
|||
internalGoUsersDao |
|||
} |
|||
|
|||
var ( |
|||
// GoUsers is globally public accessible object for table go_users operations.
|
|||
GoUsers = goUsersDao{ |
|||
internal.NewGoUsersDao(), |
|||
} |
|||
) |
|||
|
|||
// Fill with you ideas below.
|
@ -0,0 +1,77 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoChannelSubscriptionsDao is the data access object for table go_channel_subscriptions.
|
|||
type GoChannelSubscriptionsDao 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 GoChannelSubscriptionsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoChannelSubscriptionsColumns defines and stores column names for table go_channel_subscriptions.
|
|||
type GoChannelSubscriptionsColumns struct { |
|||
Id string // 频道订阅关系唯一ID,自增
|
|||
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ChannelId string // 关联的频道ID,指向go_channels表的id,不能为空
|
|||
} |
|||
|
|||
// goChannelSubscriptionsColumns holds the columns for table go_channel_subscriptions.
|
|||
var goChannelSubscriptionsColumns = GoChannelSubscriptionsColumns{ |
|||
Id: "id", |
|||
UserId: "user_id", |
|||
ChannelId: "channel_id", |
|||
} |
|||
|
|||
// NewGoChannelSubscriptionsDao creates and returns a new DAO object for table data access.
|
|||
func NewGoChannelSubscriptionsDao() *GoChannelSubscriptionsDao { |
|||
return &GoChannelSubscriptionsDao{ |
|||
group: "default", |
|||
table: "go_channel_subscriptions", |
|||
columns: goChannelSubscriptionsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoChannelSubscriptionsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoChannelSubscriptionsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoChannelSubscriptionsDao) Columns() GoChannelSubscriptionsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoChannelSubscriptionsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoChannelSubscriptionsDao) 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 *GoChannelSubscriptionsDao) 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,81 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoChannelsDao is the data access object for table go_channels.
|
|||
type GoChannelsDao 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 GoChannelsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoChannelsColumns defines and stores column names for table go_channels.
|
|||
type GoChannelsColumns struct { |
|||
Id string // 频道唯一ID,自增
|
|||
Image string // 频道图片路径或相关标识,可为空
|
|||
Name string // 频道名称,最大长度255字符,不能为空
|
|||
SubscriptionCount string // 频道订阅数量,初始值为0,可累加
|
|||
BackgroundImage string // 频道背景图路径或相关标识,可为空
|
|||
} |
|||
|
|||
// goChannelsColumns holds the columns for table go_channels.
|
|||
var goChannelsColumns = GoChannelsColumns{ |
|||
Id: "id", |
|||
Image: "image", |
|||
Name: "name", |
|||
SubscriptionCount: "subscription_count", |
|||
BackgroundImage: "background_image", |
|||
} |
|||
|
|||
// NewGoChannelsDao creates and returns a new DAO object for table data access.
|
|||
func NewGoChannelsDao() *GoChannelsDao { |
|||
return &GoChannelsDao{ |
|||
group: "default", |
|||
table: "go_channels", |
|||
columns: goChannelsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoChannelsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoChannelsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoChannelsDao) Columns() GoChannelsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoChannelsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoChannelsDao) 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 *GoChannelsDao) 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" |
|||
) |
|||
|
|||
// GoClubsDao is the data access object for table go_clubs.
|
|||
type GoClubsDao 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 GoClubsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoClubsColumns defines and stores column names for table go_clubs.
|
|||
type GoClubsColumns struct { |
|||
Id string // 俱乐部唯一ID,自增
|
|||
Image string // 俱乐部图片路径或相关标识,可为空
|
|||
Name string // 俱乐部名称,最大长度255字符,不能为空
|
|||
Introduction string // 俱乐部简介,文本内容,可为空
|
|||
} |
|||
|
|||
// goClubsColumns holds the columns for table go_clubs.
|
|||
var goClubsColumns = GoClubsColumns{ |
|||
Id: "id", |
|||
Image: "image", |
|||
Name: "name", |
|||
Introduction: "introduction", |
|||
} |
|||
|
|||
// NewGoClubsDao creates and returns a new DAO object for table data access.
|
|||
func NewGoClubsDao() *GoClubsDao { |
|||
return &GoClubsDao{ |
|||
group: "default", |
|||
table: "go_clubs", |
|||
columns: goClubsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoClubsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoClubsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoClubsDao) Columns() GoClubsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoClubsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoClubsDao) 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 *GoClubsDao) 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,77 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoLiveReservationsDao is the data access object for table go_live_reservations.
|
|||
type GoLiveReservationsDao 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 GoLiveReservationsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoLiveReservationsColumns defines and stores column names for table go_live_reservations.
|
|||
type GoLiveReservationsColumns struct { |
|||
Id string // 直播预约关系唯一ID,自增
|
|||
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveId string // 关联的直播ID,指向go_lives表的id,不能为空
|
|||
} |
|||
|
|||
// goLiveReservationsColumns holds the columns for table go_live_reservations.
|
|||
var goLiveReservationsColumns = GoLiveReservationsColumns{ |
|||
Id: "id", |
|||
UserId: "user_id", |
|||
LiveId: "live_id", |
|||
} |
|||
|
|||
// NewGoLiveReservationsDao creates and returns a new DAO object for table data access.
|
|||
func NewGoLiveReservationsDao() *GoLiveReservationsDao { |
|||
return &GoLiveReservationsDao{ |
|||
group: "default", |
|||
table: "go_live_reservations", |
|||
columns: goLiveReservationsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoLiveReservationsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoLiveReservationsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoLiveReservationsDao) Columns() GoLiveReservationsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoLiveReservationsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoLiveReservationsDao) 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 *GoLiveReservationsDao) 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,83 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoLivesDao is the data access object for table go_lives.
|
|||
type GoLivesDao 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 GoLivesColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoLivesColumns defines and stores column names for table go_lives.
|
|||
type GoLivesColumns struct { |
|||
Id string // 直播唯一ID,自增
|
|||
Cover string // 直播封面路径或相关标识,可为空
|
|||
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveName string // 直播名称,最大长度255字符,不能为空
|
|||
StartTime string // 直播开始时间,不能为空
|
|||
Status string // 直播状态,0:未开播 1:已开播,不能为空
|
|||
} |
|||
|
|||
// goLivesColumns holds the columns for table go_lives.
|
|||
var goLivesColumns = GoLivesColumns{ |
|||
Id: "id", |
|||
Cover: "cover", |
|||
UserId: "user_id", |
|||
LiveName: "live_name", |
|||
StartTime: "start_time", |
|||
Status: "status", |
|||
} |
|||
|
|||
// NewGoLivesDao creates and returns a new DAO object for table data access.
|
|||
func NewGoLivesDao() *GoLivesDao { |
|||
return &GoLivesDao{ |
|||
group: "default", |
|||
table: "go_lives", |
|||
columns: goLivesColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoLivesDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoLivesDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoLivesDao) Columns() GoLivesColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoLivesDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoLivesDao) 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 *GoLivesDao) 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,95 @@ |
|||
// ==========================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoShowsDao is the data access object for table go_shows.
|
|||
type GoShowsDao 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 GoShowsColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoShowsColumns defines and stores column names for table go_shows.
|
|||
type GoShowsColumns struct { |
|||
Id string // 展示内容唯一ID,自增
|
|||
Cover string // 展示内容封面路径或相关标识,可为空
|
|||
Name string // 展示内容名称,最大长度255字符,不能为空
|
|||
UserId string // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ReleaseTime string // 展示内容发布时间,可为空
|
|||
VideoDuration string // 展示内容视频时长,格式根据实际情况定,可为空
|
|||
ViewCount string // 展示内容观看数量,初始值为0,可累加
|
|||
Comments string // 展示内容评论数量,初始值为0,可累加
|
|||
Likes string // 展示内容点赞数量,初始值为0,可累加
|
|||
FlagType string // 展示内容标识类型,按业务规则确定,可为空
|
|||
ClubId string // 关联的俱乐部ID,指向go_clubs表的id,可为空
|
|||
ChannelId string // 关联的频道ID,指向go_channels表的id,可为空
|
|||
} |
|||
|
|||
// goShowsColumns holds the columns for table go_shows.
|
|||
var goShowsColumns = GoShowsColumns{ |
|||
Id: "id", |
|||
Cover: "cover", |
|||
Name: "name", |
|||
UserId: "user_id", |
|||
ReleaseTime: "release_time", |
|||
VideoDuration: "video_duration", |
|||
ViewCount: "view_count", |
|||
Comments: "comments", |
|||
Likes: "likes", |
|||
FlagType: "flag_type", |
|||
ClubId: "club_id", |
|||
ChannelId: "channel_id", |
|||
} |
|||
|
|||
// NewGoShowsDao creates and returns a new DAO object for table data access.
|
|||
func NewGoShowsDao() *GoShowsDao { |
|||
return &GoShowsDao{ |
|||
group: "default", |
|||
table: "go_shows", |
|||
columns: goShowsColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoShowsDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoShowsDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoShowsDao) Columns() GoShowsColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoShowsDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoShowsDao) 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 *GoShowsDao) 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" |
|||
) |
|||
|
|||
// GoUsersDao is the data access object for table go_users.
|
|||
type GoUsersDao 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 GoUsersColumns // columns contains all the column names of Table for convenient usage.
|
|||
} |
|||
|
|||
// GoUsersColumns defines and stores column names for table go_users.
|
|||
type GoUsersColumns struct { |
|||
Id string // 用户唯一ID,自增,长度为8位整数
|
|||
Username string // 用户名,最大长度255字符,不能为空
|
|||
Avatar string // 用户头像路径或相关标识,可为空
|
|||
Password string // 用户登录密码,最大长度255字符,不能为空
|
|||
} |
|||
|
|||
// goUsersColumns holds the columns for table go_users.
|
|||
var goUsersColumns = GoUsersColumns{ |
|||
Id: "id", |
|||
Username: "username", |
|||
Avatar: "avatar", |
|||
Password: "password", |
|||
} |
|||
|
|||
// NewGoUsersDao creates and returns a new DAO object for table data access.
|
|||
func NewGoUsersDao() *GoUsersDao { |
|||
return &GoUsersDao{ |
|||
group: "default", |
|||
table: "go_users", |
|||
columns: goUsersColumns, |
|||
} |
|||
} |
|||
|
|||
// DB retrieves and returns the underlying raw database management object of current DAO.
|
|||
func (dao *GoUsersDao) DB() gdb.DB { |
|||
return g.DB(dao.group) |
|||
} |
|||
|
|||
// Table returns the table name of current dao.
|
|||
func (dao *GoUsersDao) Table() string { |
|||
return dao.table |
|||
} |
|||
|
|||
// Columns returns all column names of current dao.
|
|||
func (dao *GoUsersDao) Columns() GoUsersColumns { |
|||
return dao.columns |
|||
} |
|||
|
|||
// Group returns the configuration group name of database of current dao.
|
|||
func (dao *GoUsersDao) Group() string { |
|||
return dao.group |
|||
} |
|||
|
|||
// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation.
|
|||
func (dao *GoUsersDao) 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 *GoUsersDao) 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,52 @@ |
|||
package clubs |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/do" |
|||
"practice_Go/internal/model/entity" |
|||
"practice_Go/internal/service" |
|||
) |
|||
|
|||
// 1.注册
|
|||
func init() { |
|||
service.RegisterClubs(&sClubs{}) |
|||
} |
|||
|
|||
type sClubs struct{} |
|||
|
|||
func (c sClubs) GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error) { |
|||
clubId := g.RequestFromCtx(ctx).Get("id").Int() |
|||
if clubId == 0 { |
|||
panic("获取俱乐部信息时id不能为空") |
|||
} else { |
|||
err = dao.GoClubs.Ctx(ctx).Where("id", clubId).Scan(&clubs) //查询数据库, 并将可能出现的错误赋给err
|
|||
} |
|||
return |
|||
} |
|||
|
|||
func (c sClubs) GetClubShows(ctx context.Context) (shows []entity.GoShows, err error) { |
|||
clubId := g.RequestFromCtx(ctx).Get("id").Int() |
|||
if clubId == 0 { |
|||
panic("获取俱乐部内容时id不能为空") |
|||
} else { |
|||
err = dao.GoShows.Ctx(ctx).FieldsEx("club").With(entity.GoUsers{}).Where("club_id", clubId).Scan(&shows) |
|||
} |
|||
return |
|||
} |
|||
|
|||
func (c sClubs) AddClub(ctx context.Context, club do.GoShows) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
|||
|
|||
func (c sClubs) EditClub(ctx context.Context, club do.GoClubs) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
|||
|
|||
func (c sClubs) DeleteClub(ctx context.Context) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
@ -0,0 +1,8 @@ |
|||
package logic |
|||
|
|||
import ( |
|||
_ "practice_Go/internal/logic/clubs" |
|||
_ "practice_Go/internal/logic/shows" |
|||
) |
|||
|
|||
//如果这里导入了文件后还是说未注册就将在main.go文件中导入logic包
|
@ -0,0 +1,59 @@ |
|||
package shows |
|||
|
|||
import ( |
|||
"context" |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
"practice_Go/internal/dao" |
|||
"practice_Go/internal/model/do" |
|||
"practice_Go/internal/model/entity" |
|||
"practice_Go/internal/service" |
|||
) |
|||
|
|||
func init() { |
|||
//GoFrame没有自动注册, 将sShow结构体的实例注册到服务中, 供其他部分访问
|
|||
service.RegisterShows(&sShow{}) //GoFrame没有自动注册 另外还需要在logic包下创建一个logic.go文件,并在其中导入本文件所在的shows包
|
|||
} |
|||
|
|||
// 定义一个sShow结构体,供其他部分访问下面的方法
|
|||
type sShow struct{} |
|||
|
|||
// 定义一个方法,用于获取所有节目
|
|||
func (s sShow) GetShows(ctx context.Context) (shows []entity.GoShows, err error) { |
|||
// 使用dao包中的GoShows结构体,在指定的上下文中扫描数据,并将结果存储在shows变量中
|
|||
flagType := g.RequestFromCtx(ctx).Get("flagType").Int() |
|||
if flagType != 0 { |
|||
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}, entity.GoClubs{}).Where("flag_type", flagType).Scan(&shows) //err用于存储过程中可能出现的错误,结果直接存到shows中了
|
|||
} else { |
|||
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).With(entity.GoClubs{}).Scan(&shows) |
|||
} |
|||
// 返回结果
|
|||
return |
|||
} |
|||
|
|||
// 定义一个方法,用于获取视频列表
|
|||
func (s sShow) GetVideos(ctx context.Context) (videos []entity.GoShows, err error) { |
|||
// 使用dao包中的GoShows结构体,在指定的上下文中扫描视频列表
|
|||
flagType := g.RequestFromCtx(ctx).Get("flagType").Int() |
|||
if flagType != 0 { |
|||
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}, entity.GoClubs{}).Where("flag_type", flagType).OrderDesc("release_time").Scan(&videos) //err用于存储过程中可能出现的错误,结果直接存到shows中了
|
|||
} else { |
|||
err = dao.GoShows.Ctx(ctx).With(entity.GoUsers{}).With(entity.GoClubs{}).OrderDesc("release_time").Scan(&videos) |
|||
} |
|||
// 返回视频列表和错误信息
|
|||
return |
|||
} |
|||
|
|||
func (s sShow) AddShow(ctx context.Context, show do.GoShows) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
|||
|
|||
func (s sShow) EditShow(ctx context.Context, show do.GoShows) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
|||
|
|||
func (s sShow) DeleteShow(ctx context.Context) (err error) { |
|||
//TODO implement me
|
|||
panic("implement me") |
|||
} |
@ -0,0 +1,17 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package do |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// GoChannelSubscriptions is the golang structure of table go_channel_subscriptions for DAO operations like Where/Data.
|
|||
type GoChannelSubscriptions struct { |
|||
g.Meta `orm:"table:go_channel_subscriptions, do:true"` |
|||
Id interface{} // 频道订阅关系唯一ID,自增
|
|||
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ChannelId interface{} // 关联的频道ID,指向go_channels表的id,不能为空
|
|||
} |
@ -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" |
|||
) |
|||
|
|||
// GoChannels is the golang structure of table go_channels for DAO operations like Where/Data.
|
|||
type GoChannels struct { |
|||
g.Meta `orm:"table:go_channels, do:true"` |
|||
Id interface{} // 频道唯一ID,自增
|
|||
Image interface{} // 频道图片路径或相关标识,可为空
|
|||
Name interface{} // 频道名称,最大长度255字符,不能为空
|
|||
SubscriptionCount interface{} // 频道订阅数量,初始值为0,可累加
|
|||
BackgroundImage interface{} // 频道背景图路径或相关标识,可为空
|
|||
} |
@ -0,0 +1,18 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package do |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// GoClubs is the golang structure of table go_clubs for DAO operations like Where/Data.
|
|||
type GoClubs struct { |
|||
g.Meta `orm:"table:go_clubs, do:true"` |
|||
Id interface{} // 俱乐部唯一ID,自增
|
|||
Image interface{} // 俱乐部图片路径或相关标识,可为空
|
|||
Name interface{} // 俱乐部名称,最大长度255字符,不能为空
|
|||
Introduction interface{} // 俱乐部简介,文本内容,可为空
|
|||
} |
@ -0,0 +1,17 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package do |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// GoLiveReservations is the golang structure of table go_live_reservations for DAO operations like Where/Data.
|
|||
type GoLiveReservations struct { |
|||
g.Meta `orm:"table:go_live_reservations, do:true"` |
|||
Id interface{} // 直播预约关系唯一ID,自增
|
|||
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveId interface{} // 关联的直播ID,指向go_lives表的id,不能为空
|
|||
} |
@ -0,0 +1,21 @@ |
|||
// =================================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoLives is the golang structure of table go_lives for DAO operations like Where/Data.
|
|||
type GoLives struct { |
|||
g.Meta `orm:"table:go_lives, do:true"` |
|||
Id interface{} // 直播唯一ID,自增
|
|||
Cover interface{} // 直播封面路径或相关标识,可为空
|
|||
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveName interface{} // 直播名称,最大长度255字符,不能为空
|
|||
StartTime *gtime.Time // 直播开始时间,不能为空
|
|||
Status interface{} // 直播状态,0:未开播 1:已开播,不能为空
|
|||
} |
@ -0,0 +1,27 @@ |
|||
// =================================================================================
|
|||
// 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" |
|||
) |
|||
|
|||
// GoShows is the golang structure of table go_shows for DAO operations like Where/Data.
|
|||
type GoShows struct { |
|||
g.Meta `orm:"table:go_shows, do:true"` |
|||
Id interface{} // 展示内容唯一ID,自增
|
|||
Cover interface{} // 展示内容封面路径或相关标识,可为空
|
|||
Name interface{} // 展示内容名称,最大长度255字符,不能为空
|
|||
UserId interface{} // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ReleaseTime *gtime.Time // 展示内容发布时间,可为空
|
|||
VideoDuration *gtime.Time // 展示内容视频时长,格式根据实际情况定,可为空
|
|||
ViewCount interface{} // 展示内容观看数量,初始值为0,可累加
|
|||
Comments interface{} // 展示内容评论数量,初始值为0,可累加
|
|||
Likes interface{} // 展示内容点赞数量,初始值为0,可累加
|
|||
FlagType interface{} // 展示内容标识类型,按业务规则确定,可为空
|
|||
ClubId interface{} // 关联的俱乐部ID,指向go_clubs表的id,可为空
|
|||
ChannelId interface{} // 关联的频道ID,指向go_channels表的id,可为空
|
|||
} |
@ -0,0 +1,18 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package do |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// GoUsers is the golang structure of table go_users for DAO operations like Where/Data.
|
|||
type GoUsers struct { |
|||
g.Meta `orm:"table:go_users, do:true"` |
|||
Id interface{} // 用户唯一ID,自增,长度为8位整数
|
|||
Username interface{} // 用户名,最大长度255字符,不能为空
|
|||
Avatar interface{} // 用户头像路径或相关标识,可为空
|
|||
Password interface{} // 用户登录密码,最大长度255字符,不能为空
|
|||
} |
@ -0,0 +1,66 @@ |
|||
package dto |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/frame/g" |
|||
) |
|||
|
|||
// 定义响应结构
|
|||
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: g.Map{}, |
|||
} |
|||
} |
|||
|
|||
/*成功,有数据*/ |
|||
func SuccessWithData(data interface{}) *Result { |
|||
return &Result{ |
|||
Code: 200, |
|||
Message: "success", |
|||
Data: data, |
|||
} |
|||
} |
|||
|
|||
/*错误,只有错误信息,错误码0*/ |
|||
func Error(msg string) *Result { |
|||
return &Result{ |
|||
Code: 0, // 错误码
|
|||
Message: msg, // 错误信息
|
|||
Data: g.Map{}, |
|||
} |
|||
} |
|||
|
|||
/*错误,有错误信息,有错误码*/ |
|||
func ErrorWithCode(code int, msg string) *Result { |
|||
return &Result{ |
|||
Code: code, // 错误码
|
|||
Message: msg, // 错误信息
|
|||
Data: g.Map{}, |
|||
} |
|||
} |
|||
|
|||
/*未授权,有错误信息,错误码为401*/ |
|||
func Unauthorized(msg string) *Result { |
|||
return &Result{ |
|||
Code: 401, // 错误码
|
|||
Message: msg, // 错误信息
|
|||
Data: g.Map{}, |
|||
} |
|||
} |
|||
|
|||
/*未授权,有错误信息,允许自定义错误码*/ |
|||
func UnauthorizedWithCode(code int, msg string) *Result { |
|||
return &Result{ |
|||
Code: code, // 错误码
|
|||
Message: msg, // 错误信息
|
|||
Data: g.Map{}, |
|||
} |
|||
} |
@ -0,0 +1,12 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// GoChannelSubscriptions is the golang structure for table go_channel_subscriptions.
|
|||
type GoChannelSubscriptions struct { |
|||
Id int `json:"id" orm:"id" description:"频道订阅关系唯一ID,自增"` // 频道订阅关系唯一ID,自增
|
|||
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ChannelId int `json:"channelId" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,不能为空"` // 关联的频道ID,指向go_channels表的id,不能为空
|
|||
} |
@ -0,0 +1,14 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// GoChannels is the golang structure for table go_channels.
|
|||
type GoChannels struct { |
|||
Id int `json:"id" orm:"id" description:"频道唯一ID,自增"` // 频道唯一ID,自增
|
|||
Image string `json:"image" orm:"image" description:"频道图片路径或相关标识,可为空"` // 频道图片路径或相关标识,可为空
|
|||
Name string `json:"name" orm:"name" description:"频道名称,最大长度255字符,不能为空"` // 频道名称,最大长度255字符,不能为空
|
|||
SubscriptionCount int `json:"subscriptionCount" orm:"subscription_count" description:"频道订阅数量,初始值为0,可累加"` // 频道订阅数量,初始值为0,可累加
|
|||
BackgroundImage string `json:"backgroundImage" orm:"background_image" description:"频道背景图路径或相关标识,可为空"` // 频道背景图路径或相关标识,可为空
|
|||
} |
@ -0,0 +1,13 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// GoClubs is the golang structure for table go_clubs.
|
|||
type GoClubs struct { |
|||
Id int `json:"id" orm:"id" description:"俱乐部唯一ID,自增"` // 俱乐部唯一ID,自增
|
|||
Image string `json:"image" orm:"image" description:"俱乐部图片路径或相关标识,可为空"` // 俱乐部图片路径或相关标识,可为空
|
|||
Name string `json:"name" orm:"name" description:"俱乐部名称,最大长度255字符,不能为空"` // 俱乐部名称,最大长度255字符,不能为空
|
|||
Introduction string `json:"introduction" orm:"introduction" description:"俱乐部简介,文本内容,可为空"` // 俱乐部简介,文本内容,可为空
|
|||
} |
@ -0,0 +1,12 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// GoLiveReservations is the golang structure for table go_live_reservations.
|
|||
type GoLiveReservations struct { |
|||
Id int `json:"id" orm:"id" description:"直播预约关系唯一ID,自增"` // 直播预约关系唯一ID,自增
|
|||
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveId int `json:"liveId" orm:"live_id" description:"关联的直播ID,指向go_lives表的id,不能为空"` // 关联的直播ID,指向go_lives表的id,不能为空
|
|||
} |
@ -0,0 +1,19 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// GoLives is the golang structure for table go_lives.
|
|||
type GoLives struct { |
|||
Id int `json:"id" orm:"id" description:"直播唯一ID,自增"` // 直播唯一ID,自增
|
|||
Cover string `json:"cover" orm:"cover" description:"直播封面路径或相关标识,可为空"` // 直播封面路径或相关标识,可为空
|
|||
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
LiveName string `json:"liveName" orm:"live_name" description:"直播名称,最大长度255字符,不能为空"` // 直播名称,最大长度255字符,不能为空
|
|||
StartTime *gtime.Time `json:"startTime" orm:"start_time" description:"直播开始时间,不能为空"` // 直播开始时间,不能为空
|
|||
Status int `json:"status" orm:"status" description:"直播状态,0:未开播 1:已开播,不能为空"` // 直播状态,0:未开播 1:已开播,不能为空
|
|||
} |
@ -0,0 +1,28 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
import ( |
|||
"github.com/gogf/gf/v2/os/gtime" |
|||
) |
|||
|
|||
// GoShows is the golang structure for table go_shows.
|
|||
type GoShows struct { |
|||
Id int `json:"id" orm:"id" description:"展示内容唯一ID,自增"` // 展示内容唯一ID,自增
|
|||
Cover string `json:"cover" orm:"cover" description:"展示内容封面路径或相关标识,可为空"` // 展示内容封面路径或相关标识,可为空
|
|||
Name string `json:"name" orm:"name" description:"展示内容名称,最大长度255字符,不能为空"` // 展示内容名称,最大长度255字符,不能为空
|
|||
UserId int `json:"userId" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空
|
|||
ReleaseTime *gtime.Time `json:"releaseTime" orm:"release_time" description:"展示内容发布时间,可为空"` // 展示内容发布时间,可为空
|
|||
VideoDuration *gtime.Time `json:"videoDuration" orm:"video_duration" description:"展示内容视频时长,格式根据实际情况定,可为空"` // 展示内容视频时长,格式根据实际情况定,可为空
|
|||
ViewCount int `json:"viewCount" orm:"view_count" description:"展示内容观看数量,初始值为0,可累加"` // 展示内容观看数量,初始值为0,可累加
|
|||
Comments int `json:"comments" orm:"comments" description:"展示内容评论数量,初始值为0,可累加"` // 展示内容评论数量,初始值为0,可累加
|
|||
Likes int `json:"likes" orm:"likes" description:"展示内容点赞数量,初始值为0,可累加"` // 展示内容点赞数量,初始值为0,可累加
|
|||
FlagType int `json:"flagType" orm:"flag_type" description:"展示内容标识类型,按业务规则确定,可为空"` // 展示内容标识类型,按业务规则确定,可为空
|
|||
ClubId int `json:"clubId" orm:"club_id" description:"关联的俱乐部ID,指向go_clubs表的id,可为空"` // 关联的俱乐部ID,指向go_clubs表的id,可为空
|
|||
ChannelId int `json:"channelId" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,可为空"` // 关联的频道ID,指向go_channels表的id,可为空
|
|||
|
|||
User *GoUsers `json:"user" orm:"with:id=user_id"` |
|||
Club *GoClubs `json:"club" orm:"with:id=club_id"` |
|||
} |
@ -0,0 +1,13 @@ |
|||
// =================================================================================
|
|||
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
|||
// =================================================================================
|
|||
|
|||
package entity |
|||
|
|||
// GoUsers is the golang structure for table go_users.
|
|||
type GoUsers struct { |
|||
Id int `json:"id" orm:"id" description:"用户唯一ID,自增,长度为8位整数"` // 用户唯一ID,自增,长度为8位整数
|
|||
Username string `json:"username" orm:"username" description:"用户名,最大长度255字符,不能为空"` // 用户名,最大长度255字符,不能为空
|
|||
Avatar string `json:"avatar" orm:"avatar" description:"用户头像路径或相关标识,可为空"` // 用户头像路径或相关标识,可为空
|
|||
//Password string `json:"password" orm:"password" description:"用户登录密码,最大长度255字符,不能为空"` // 用户登录密码,最大长度255字符,不能为空
|
|||
} |
@ -0,0 +1 @@ |
|||
package packed |
@ -0,0 +1,34 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/internal/model/do" |
|||
"practice_Go/internal/model/entity" |
|||
) |
|||
|
|||
// 1.定义接口
|
|||
type IClubs interface { |
|||
GetClubs(ctx context.Context) (clubs []entity.GoClubs, err error) |
|||
GetClubShows(ctx context.Context) (shows []entity.GoShows, err error) |
|||
AddClub(ctx context.Context, club do.GoShows) (err error) |
|||
EditClub(ctx context.Context, club do.GoClubs) (err error) |
|||
DeleteClub(ctx context.Context) (err error) |
|||
} |
|||
|
|||
// 2.定义接口变量
|
|||
var localClub IClubs |
|||
|
|||
// 3.定义获取接口实例的函数
|
|||
func GetClubs() IClubs { |
|||
if localClub == nil { |
|||
panic("IClubs接口未实现或未注册") |
|||
} else { |
|||
return localClub |
|||
|
|||
} |
|||
} |
|||
|
|||
// 4.定义一个接口实现的注册方法
|
|||
func RegisterClubs(club IClubs) { |
|||
localClub = club |
|||
} |
@ -0,0 +1,32 @@ |
|||
package service |
|||
|
|||
import ( |
|||
"context" |
|||
"practice_Go/internal/model/do" |
|||
"practice_Go/internal/model/entity" |
|||
) |
|||
|
|||
// 1.定义接口
|
|||
type IShows interface { |
|||
GetShows(ctx context.Context) (shows []entity.GoShows, err error) |
|||
GetVideos(ctx context.Context) (videos []entity.GoShows, err error) |
|||
AddShow(ctx context.Context, show do.GoShows) (err error) |
|||
EditShow(ctx context.Context, show do.GoShows) (err error) |
|||
DeleteShow(ctx context.Context) (err error) //id通过路径中获取
|
|||
} |
|||
|
|||
// 2.定义接口变量
|
|||
var localShow IShows |
|||
|
|||
// 3.定义获取接口实例的函数
|
|||
func GetShows() IShows { |
|||
if localShow == nil { |
|||
panic("IShows未实现或未注册") |
|||
} |
|||
return localShow |
|||
} |
|||
|
|||
// 4.定义一个接口实现的注册方法
|
|||
func RegisterShows(show IShows) { |
|||
localShow = show |
|||
} |
@ -0,0 +1,16 @@ |
|||
package main |
|||
|
|||
import ( |
|||
_ "practice_Go/internal/logic" |
|||
_ "practice_Go/internal/packed" |
|||
|
|||
"github.com/gogf/gf/v2/os/gctx" |
|||
|
|||
_ "github.com/gogf/gf/contrib/drivers/mysql/v2" |
|||
|
|||
"practice_Go/internal/cmd" |
|||
) |
|||
|
|||
func main() { |
|||
cmd.Main.Run(gctx.GetInitCtx()) |
|||
} |
@ -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. |
|||
|
|||
|
|||
|
|||
|
|||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue