From 5314db0194fe0658532afc908121dd8a24724639 Mon Sep 17 00:00:00 2001 From: lijikun Date: Tue, 3 Dec 2024 14:38:43 +0800 Subject: [PATCH] =?UTF-8?q?12.3=E6=97=A5=E4=B8=8B=E5=8D=88go=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E4=BF=AE=E6=94=B9=E5=90=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 7 ++ README.MD | 4 + go.mod | 37 ++++++++ go.sum | 99 ++++++++++++++++++++++ hack/config.yaml | 15 ++++ hack/hack-cli.mk | 20 +++++ hack/hack.mk | 75 ++++++++++++++++ internal/cmd/cmd.go | 52 ++++++++++++ internal/consts/consts.go | 1 + internal/controller/clubPage/clubPage.go | 31 +++++++ internal/controller/mainPage/mainPage.go | 34 ++++++++ internal/dao/go_channel_subscriptions.go | 27 ++++++ internal/dao/go_channels.go | 27 ++++++ internal/dao/go_clubs.go | 27 ++++++ internal/dao/go_live_reservations.go | 27 ++++++ internal/dao/go_lives.go | 27 ++++++ internal/dao/go_shows.go | 27 ++++++ internal/dao/go_users.go | 27 ++++++ internal/dao/internal/go_channel_subscriptions.go | 77 +++++++++++++++++ internal/dao/internal/go_channels.go | 81 ++++++++++++++++++ internal/dao/internal/go_clubs.go | 79 +++++++++++++++++ internal/dao/internal/go_live_reservations.go | 77 +++++++++++++++++ internal/dao/internal/go_lives.go | 83 ++++++++++++++++++ internal/dao/internal/go_shows.go | 95 +++++++++++++++++++++ internal/dao/internal/go_users.go | 79 +++++++++++++++++ internal/logic/clubs/clubs.go | 52 ++++++++++++ internal/logic/logic.go | 8 ++ internal/logic/shows/shows.go | 59 +++++++++++++ internal/model/do/go_channel_subscriptions.go | 17 ++++ internal/model/do/go_channels.go | 19 +++++ internal/model/do/go_clubs.go | 18 ++++ internal/model/do/go_live_reservations.go | 17 ++++ internal/model/do/go_lives.go | 21 +++++ internal/model/do/go_shows.go | 27 ++++++ internal/model/do/go_users.go | 18 ++++ internal/model/entity/go_channel_subscriptions.go | 12 +++ internal/model/entity/go_channels.go | 14 +++ internal/model/entity/go_clubs.go | 13 +++ internal/model/entity/go_live_reservations.go | 12 +++ internal/model/entity/go_lives.go | 19 +++++ internal/model/entity/go_shows.go | 28 ++++++ internal/model/entity/go_users.go | 13 +++ internal/packed/packed.go | 1 + internal/service/clubs.go | 34 ++++++++ internal/service/shows.go | 32 +++++++ main.go | 16 ++++ manifest/deploy/kustomize/base/deployment.yaml | 21 +++++ manifest/deploy/kustomize/base/kustomization.yaml | 8 ++ manifest/deploy/kustomize/base/service.yaml | 12 +++ .../kustomize/overlays/develop/configmap.yaml | 14 +++ .../kustomize/overlays/develop/deployment.yaml | 10 +++ .../kustomize/overlays/develop/kustomization.yaml | 14 +++ manifest/docker/Dockerfile | 16 ++++ manifest/docker/docker.sh | 8 ++ 54 files changed, 1688 insertions(+) create mode 100644 Makefile create mode 100644 README.MD create mode 100644 go.mod create mode 100644 go.sum create mode 100644 hack/config.yaml create mode 100644 hack/hack-cli.mk create mode 100644 hack/hack.mk create mode 100644 internal/cmd/cmd.go create mode 100644 internal/consts/consts.go create mode 100644 internal/controller/clubPage/clubPage.go create mode 100644 internal/controller/mainPage/mainPage.go create mode 100644 internal/dao/go_channel_subscriptions.go create mode 100644 internal/dao/go_channels.go create mode 100644 internal/dao/go_clubs.go create mode 100644 internal/dao/go_live_reservations.go create mode 100644 internal/dao/go_lives.go create mode 100644 internal/dao/go_shows.go create mode 100644 internal/dao/go_users.go create mode 100644 internal/dao/internal/go_channel_subscriptions.go create mode 100644 internal/dao/internal/go_channels.go create mode 100644 internal/dao/internal/go_clubs.go create mode 100644 internal/dao/internal/go_live_reservations.go create mode 100644 internal/dao/internal/go_lives.go create mode 100644 internal/dao/internal/go_shows.go create mode 100644 internal/dao/internal/go_users.go create mode 100644 internal/logic/clubs/clubs.go create mode 100644 internal/logic/logic.go create mode 100644 internal/logic/shows/shows.go create mode 100644 internal/model/do/go_channel_subscriptions.go create mode 100644 internal/model/do/go_channels.go create mode 100644 internal/model/do/go_clubs.go create mode 100644 internal/model/do/go_live_reservations.go create mode 100644 internal/model/do/go_lives.go create mode 100644 internal/model/do/go_shows.go create mode 100644 internal/model/do/go_users.go create mode 100644 internal/model/entity/go_channel_subscriptions.go create mode 100644 internal/model/entity/go_channels.go create mode 100644 internal/model/entity/go_clubs.go create mode 100644 internal/model/entity/go_live_reservations.go create mode 100644 internal/model/entity/go_lives.go create mode 100644 internal/model/entity/go_shows.go create mode 100644 internal/model/entity/go_users.go create mode 100644 internal/packed/packed.go create mode 100644 internal/service/clubs.go create mode 100644 internal/service/shows.go create mode 100644 main.go create mode 100644 manifest/deploy/kustomize/base/deployment.yaml create mode 100644 manifest/deploy/kustomize/base/kustomization.yaml create mode 100644 manifest/deploy/kustomize/base/service.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/configmap.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/deployment.yaml create mode 100644 manifest/deploy/kustomize/overlays/develop/kustomization.yaml create mode 100644 manifest/docker/Dockerfile create mode 100644 manifest/docker/docker.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2a6e6e9 --- /dev/null +++ b/Makefile @@ -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 \ No newline at end of file diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..d36cedd --- /dev/null +++ b/README.MD @@ -0,0 +1,4 @@ +# GoFrame Template For SingleRepo + +Quick Start: +- https://goframe.org/quick \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..51588f9 --- /dev/null +++ b/go.mod @@ -0,0 +1,37 @@ +module practice_Go + +go 1.18 + +require ( + github.com/gogf/gf v1.16.9 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.1 +) + +require ( + github.com/BurntSushi/toml v1.4.0 // indirect + github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28 // 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 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2ec12ee --- /dev/null +++ b/go.sum @@ -0,0 +1,99 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +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 v1.8.5-0.20200714211355-ff02cfb8ea28 h1:LdXxtjzvZYhhUaonAaAKArG3pyC67kGL3YY+6hGG8G4= +github.com/clbanning/mxj v1.8.5-0.20200714211355-ff02cfb8ea28/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= +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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= +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.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= +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.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +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 v1.16.9 h1:Q803UmmRo59+Ws08sMVFOcd8oNpkSWL9vS33hlo/Cyk= +github.com/gogf/gf v1.16.9/go.mod h1:8Q/kw05nlVRp+4vv7XASBsMe9L1tsVKiGoeP2AHnlkk= +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/gomodule/redigo v1.8.5 h1:nRAxCa+SVsyjSBrtZmG/cqb6VbTmuRzpg/PoTFlpumc= +github.com/gomodule/redigo v1.8.5/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +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.0.1/go.mod h1:2Su6romC5/1VXOQMaWL2yb618ARB8iVo6/DR99A6d78= +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.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +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.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +go.opentelemetry.io/otel v1.0.0/go.mod h1:AjRVh9A5/5DE7S+mZtTR6t8vpKKryam+0lREnfmS4cg= +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.0.0/go.mod h1:PXTWqayeFUlJV1YDNhsJYB184+IvAH814St6o6ajzIs= +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.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +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-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +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/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/hack/config.yaml b/hack/config.yaml new file mode 100644 index 0000000..8269ec5 --- /dev/null +++ b/hack/config.yaml @@ -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 \ No newline at end of file diff --git a/hack/hack-cli.mk b/hack/hack-cli.mk new file mode 100644 index 0000000..f4e2ad2 --- /dev/null +++ b/hack/hack-cli.mk @@ -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; \ No newline at end of file diff --git a/hack/hack.mk b/hack/hack.mk new file mode 100644 index 0000000..2f68179 --- /dev/null +++ b/hack/hack.mk @@ -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 \ No newline at end of file diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go new file mode 100644 index 0000000..e0e1bef --- /dev/null +++ b/internal/cmd/cmd.go @@ -0,0 +1,52 @@ +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" +) + +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() + + // 定义一个路由组,路径为/mainpage + s.Group("/mainpage", func(group *ghttp.RouterGroup) { + // 添加中间件,用于处理响应 + group.Middleware(ghttp.MiddlewareHandlerResponse) + // 绑定路由,将mainPage.NewMainPage()绑定到该路由组 + group.Bind( + mainPage.NewMainPage(), + ) + }) + + // 定义一个路由组,路径为/clubpage + s.Group("/clubpage", func(group *ghttp.RouterGroup) { + // 添加中间件,用于处理响应 + group.Middleware(ghttp.MiddlewareHandlerResponse) + // 绑定路由,将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 + }, + } +) diff --git a/internal/consts/consts.go b/internal/consts/consts.go new file mode 100644 index 0000000..d709a2b --- /dev/null +++ b/internal/consts/consts.go @@ -0,0 +1 @@ +package consts diff --git a/internal/controller/clubPage/clubPage.go b/internal/controller/clubPage/clubPage.go new file mode 100644 index 0000000..48f3d5d --- /dev/null +++ b/internal/controller/clubPage/clubPage.go @@ -0,0 +1,31 @@ +package clubPage + +import ( + "github.com/gogf/gf/v2/net/ghttp" + "practice_Go/internal/service" +) + +type ClubPage struct{} + +func NewClubPage() *ClubPage { + return &ClubPage{} +} + +// GetClub 获取俱乐部信息 +func (c ClubPage) GetClub(req *ghttp.Request) { + club, err := service.GetClubs().GetClubs(req.Context()) + if err == nil { + req.Response.WriteJson(club) + } else { + req.Response.WriteJson(err) + } +} + +func (c ClubPage) GetClubShows(req *ghttp.Request) { + shows, err := service.GetClubs().GetClubShows(req.Context()) + if err == nil { + req.Response.WriteJson(shows) + } else { + req.Response.WriteJson(err) + } +} diff --git a/internal/controller/mainPage/mainPage.go b/internal/controller/mainPage/mainPage.go new file mode 100644 index 0000000..65b1e8b --- /dev/null +++ b/internal/controller/mainPage/mainPage.go @@ -0,0 +1,34 @@ +package mainPage + +import ( + "github.com/gogf/gf/v2/net/ghttp" + "practice_Go/internal/service" +) + +// 定义一个MainPage结构体 +type MainPage struct{} + +// 创建一个新的MainPage实例 初始化 +func NewMainPage() *MainPage { + return &MainPage{} +} + +// 获取文章,视频 +func (c *MainPage) GetShows(req *ghttp.Request) { + shows, err := service.GetShows().GetShows(req.Context()) + if err == nil { + req.Response.WriteJson(shows) + } else { + req.Response.WriteJson(err) + } +} + +// 获取视频 +func (c *MainPage) GetVideos(req *ghttp.Request) { + shows, err := service.GetShows().GetVideos(req.Context()) + if err == nil { + req.Response.WriteJson(shows) + } else { + req.Response.WriteJson(err) + } +} diff --git a/internal/dao/go_channel_subscriptions.go b/internal/dao/go_channel_subscriptions.go new file mode 100644 index 0000000..e6a15c1 --- /dev/null +++ b/internal/dao/go_channel_subscriptions.go @@ -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. diff --git a/internal/dao/go_channels.go b/internal/dao/go_channels.go new file mode 100644 index 0000000..96623c3 --- /dev/null +++ b/internal/dao/go_channels.go @@ -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. diff --git a/internal/dao/go_clubs.go b/internal/dao/go_clubs.go new file mode 100644 index 0000000..c4d95de --- /dev/null +++ b/internal/dao/go_clubs.go @@ -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. diff --git a/internal/dao/go_live_reservations.go b/internal/dao/go_live_reservations.go new file mode 100644 index 0000000..caed41a --- /dev/null +++ b/internal/dao/go_live_reservations.go @@ -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. diff --git a/internal/dao/go_lives.go b/internal/dao/go_lives.go new file mode 100644 index 0000000..eac5f45 --- /dev/null +++ b/internal/dao/go_lives.go @@ -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. diff --git a/internal/dao/go_shows.go b/internal/dao/go_shows.go new file mode 100644 index 0000000..c2863a7 --- /dev/null +++ b/internal/dao/go_shows.go @@ -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. diff --git a/internal/dao/go_users.go b/internal/dao/go_users.go new file mode 100644 index 0000000..ca97b1c --- /dev/null +++ b/internal/dao/go_users.go @@ -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. diff --git a/internal/dao/internal/go_channel_subscriptions.go b/internal/dao/internal/go_channel_subscriptions.go new file mode 100644 index 0000000..1945383 --- /dev/null +++ b/internal/dao/internal/go_channel_subscriptions.go @@ -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) +} diff --git a/internal/dao/internal/go_channels.go b/internal/dao/internal/go_channels.go new file mode 100644 index 0000000..ba6f52a --- /dev/null +++ b/internal/dao/internal/go_channels.go @@ -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) +} diff --git a/internal/dao/internal/go_clubs.go b/internal/dao/internal/go_clubs.go new file mode 100644 index 0000000..77d8099 --- /dev/null +++ b/internal/dao/internal/go_clubs.go @@ -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) +} diff --git a/internal/dao/internal/go_live_reservations.go b/internal/dao/internal/go_live_reservations.go new file mode 100644 index 0000000..12929c7 --- /dev/null +++ b/internal/dao/internal/go_live_reservations.go @@ -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) +} diff --git a/internal/dao/internal/go_lives.go b/internal/dao/internal/go_lives.go new file mode 100644 index 0000000..ab6bf3b --- /dev/null +++ b/internal/dao/internal/go_lives.go @@ -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) +} diff --git a/internal/dao/internal/go_shows.go b/internal/dao/internal/go_shows.go new file mode 100644 index 0000000..fd56563 --- /dev/null +++ b/internal/dao/internal/go_shows.go @@ -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) +} diff --git a/internal/dao/internal/go_users.go b/internal/dao/internal/go_users.go new file mode 100644 index 0000000..370e69a --- /dev/null +++ b/internal/dao/internal/go_users.go @@ -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) +} diff --git a/internal/logic/clubs/clubs.go b/internal/logic/clubs/clubs.go new file mode 100644 index 0000000..450095e --- /dev/null +++ b/internal/logic/clubs/clubs.go @@ -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") +} diff --git a/internal/logic/logic.go b/internal/logic/logic.go new file mode 100644 index 0000000..fa4fb80 --- /dev/null +++ b/internal/logic/logic.go @@ -0,0 +1,8 @@ +package logic + +import ( + _ "practice_Go/internal/logic/clubs" + _ "practice_Go/internal/logic/shows" +) + +//如果这里导入了文件后还是说未注册就将在main.go文件中导入logic包 diff --git a/internal/logic/shows/shows.go b/internal/logic/shows/shows.go new file mode 100644 index 0000000..b2c14e8 --- /dev/null +++ b/internal/logic/shows/shows.go @@ -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("flag_type").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("flag_type").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") +} diff --git a/internal/model/do/go_channel_subscriptions.go b/internal/model/do/go_channel_subscriptions.go new file mode 100644 index 0000000..fd8d1fa --- /dev/null +++ b/internal/model/do/go_channel_subscriptions.go @@ -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,不能为空 +} diff --git a/internal/model/do/go_channels.go b/internal/model/do/go_channels.go new file mode 100644 index 0000000..bf610d5 --- /dev/null +++ b/internal/model/do/go_channels.go @@ -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{} // 频道背景图路径或相关标识,可为空 +} diff --git a/internal/model/do/go_clubs.go b/internal/model/do/go_clubs.go new file mode 100644 index 0000000..b25a138 --- /dev/null +++ b/internal/model/do/go_clubs.go @@ -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{} // 俱乐部简介,文本内容,可为空 +} diff --git a/internal/model/do/go_live_reservations.go b/internal/model/do/go_live_reservations.go new file mode 100644 index 0000000..6bd61f6 --- /dev/null +++ b/internal/model/do/go_live_reservations.go @@ -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,不能为空 +} diff --git a/internal/model/do/go_lives.go b/internal/model/do/go_lives.go new file mode 100644 index 0000000..cc50a71 --- /dev/null +++ b/internal/model/do/go_lives.go @@ -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:已开播,不能为空 +} diff --git a/internal/model/do/go_shows.go b/internal/model/do/go_shows.go new file mode 100644 index 0000000..d70a210 --- /dev/null +++ b/internal/model/do/go_shows.go @@ -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,可为空 +} diff --git a/internal/model/do/go_users.go b/internal/model/do/go_users.go new file mode 100644 index 0000000..1355588 --- /dev/null +++ b/internal/model/do/go_users.go @@ -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字符,不能为空 +} diff --git a/internal/model/entity/go_channel_subscriptions.go b/internal/model/entity/go_channel_subscriptions.go new file mode 100644 index 0000000..6125ee4 --- /dev/null +++ b/internal/model/entity/go_channel_subscriptions.go @@ -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:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空 + ChannelId int `json:"channel_id" orm:"channel_id" description:"关联的频道ID,指向go_channels表的id,不能为空"` // 关联的频道ID,指向go_channels表的id,不能为空 +} diff --git a/internal/model/entity/go_channels.go b/internal/model/entity/go_channels.go new file mode 100644 index 0000000..145a286 --- /dev/null +++ b/internal/model/entity/go_channels.go @@ -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:"subscription_count" orm:"subscription_count" description:"频道订阅数量,初始值为0,可累加"` // 频道订阅数量,初始值为0,可累加 + BackgroundImage string `json:"background_image" orm:"background_image" description:"频道背景图路径或相关标识,可为空"` // 频道背景图路径或相关标识,可为空 +} diff --git a/internal/model/entity/go_clubs.go b/internal/model/entity/go_clubs.go new file mode 100644 index 0000000..7b7e675 --- /dev/null +++ b/internal/model/entity/go_clubs.go @@ -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:"俱乐部简介,文本内容,可为空"` // 俱乐部简介,文本内容,可为空 +} diff --git a/internal/model/entity/go_live_reservations.go b/internal/model/entity/go_live_reservations.go new file mode 100644 index 0000000..eca03f1 --- /dev/null +++ b/internal/model/entity/go_live_reservations.go @@ -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:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空 + LiveId int `json:"live_id" orm:"live_id" description:"关联的直播ID,指向go_lives表的id,不能为空"` // 关联的直播ID,指向go_lives表的id,不能为空 +} diff --git a/internal/model/entity/go_lives.go b/internal/model/entity/go_lives.go new file mode 100644 index 0000000..deeea4c --- /dev/null +++ b/internal/model/entity/go_lives.go @@ -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:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空 + LiveName string `json:"live_name" orm:"live_name" description:"直播名称,最大长度255字符,不能为空"` // 直播名称,最大长度255字符,不能为空 + StartTime *gtime.Time `json:"start_time" orm:"start_time" description:"直播开始时间,不能为空"` // 直播开始时间,不能为空 + Status int `json:"status" orm:"status" description:"直播状态,0:未开播 1:已开播,不能为空"` // 直播状态,0:未开播 1:已开播,不能为空 +} diff --git a/internal/model/entity/go_shows.go b/internal/model/entity/go_shows.go new file mode 100644 index 0000000..db31b56 --- /dev/null +++ b/internal/model/entity/go_shows.go @@ -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:"user_id" orm:"user_id" description:"关联的用户ID,指向go_users表的id,长度为8位整数,不能为空"` // 关联的用户ID,指向go_users表的id,长度为8位整数,不能为空 + ReleaseTime *gtime.Time `json:"release_time" orm:"release_time" description:"展示内容发布时间,可为空"` // 展示内容发布时间,可为空 + VideoDuration *gtime.Time `json:"video_duration" orm:"video_duration" description:"展示内容视频时长,格式根据实际情况定,可为空"` // 展示内容视频时长,格式根据实际情况定,可为空 + ViewCount int `json:"view_count" 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:"flag_type" orm:"flag_type" description:"展示内容标识类型,按业务规则确定,可为空"` // 展示内容标识类型,按业务规则确定,可为空 + ClubId int `json:"club_id" orm:"club_id" description:"关联的俱乐部ID,指向go_clubs表的id,可为空"` // 关联的俱乐部ID,指向go_clubs表的id,可为空 + ChannelId int `json:"channel_id" 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"` +} diff --git a/internal/model/entity/go_users.go b/internal/model/entity/go_users.go new file mode 100644 index 0000000..e732e67 --- /dev/null +++ b/internal/model/entity/go_users.go @@ -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字符,不能为空 +} diff --git a/internal/packed/packed.go b/internal/packed/packed.go new file mode 100644 index 0000000..e20ab1e --- /dev/null +++ b/internal/packed/packed.go @@ -0,0 +1 @@ +package packed diff --git a/internal/service/clubs.go b/internal/service/clubs.go new file mode 100644 index 0000000..bd0506f --- /dev/null +++ b/internal/service/clubs.go @@ -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 +} diff --git a/internal/service/shows.go b/internal/service/shows.go new file mode 100644 index 0000000..eb70f3d --- /dev/null +++ b/internal/service/shows.go @@ -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 +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..7e495ad --- /dev/null +++ b/main.go @@ -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()) +} diff --git a/manifest/deploy/kustomize/base/deployment.yaml b/manifest/deploy/kustomize/base/deployment.yaml new file mode 100644 index 0000000..28f1d69 --- /dev/null +++ b/manifest/deploy/kustomize/base/deployment.yaml @@ -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 + diff --git a/manifest/deploy/kustomize/base/kustomization.yaml b/manifest/deploy/kustomize/base/kustomization.yaml new file mode 100644 index 0000000..302d92d --- /dev/null +++ b/manifest/deploy/kustomize/base/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: +- deployment.yaml +- service.yaml + + + diff --git a/manifest/deploy/kustomize/base/service.yaml b/manifest/deploy/kustomize/base/service.yaml new file mode 100644 index 0000000..608771c --- /dev/null +++ b/manifest/deploy/kustomize/base/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 + diff --git a/manifest/deploy/kustomize/overlays/develop/configmap.yaml b/manifest/deploy/kustomize/overlays/develop/configmap.yaml new file mode 100644 index 0000000..3b1d0af --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/configmap.yaml @@ -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 diff --git a/manifest/deploy/kustomize/overlays/develop/deployment.yaml b/manifest/deploy/kustomize/overlays/develop/deployment.yaml new file mode 100644 index 0000000..04e4851 --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/deployment.yaml @@ -0,0 +1,10 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: template-single +spec: + template: + spec: + containers: + - name : main + image: template-single:develop \ No newline at end of file diff --git a/manifest/deploy/kustomize/overlays/develop/kustomization.yaml b/manifest/deploy/kustomize/overlays/develop/kustomization.yaml new file mode 100644 index 0000000..4731c47 --- /dev/null +++ b/manifest/deploy/kustomize/overlays/develop/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +resources: +- ../../base +- configmap.yaml + +patchesStrategicMerge: +- deployment.yaml + +namespace: default + + + diff --git a/manifest/docker/Dockerfile b/manifest/docker/Dockerfile new file mode 100644 index 0000000..d3abe8f --- /dev/null +++ b/manifest/docker/Dockerfile @@ -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 diff --git a/manifest/docker/docker.sh b/manifest/docker/docker.sh new file mode 100644 index 0000000..ff393f9 --- /dev/null +++ b/manifest/docker/docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# This shell is executed before docker build. + + + + +