diff --git a/api/hello/hello.go b/api/hello/hello.go deleted file mode 100644 index 22743a0..0000000 --- a/api/hello/hello.go +++ /dev/null @@ -1,15 +0,0 @@ -// ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ================================================================================= - -package hello - -import ( - "context" - - "practice_Go/api/hello/v1" -) - -type IHelloV1 interface { - Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) -} diff --git a/api/hello/v1/hello.go b/api/hello/v1/hello.go deleted file mode 100644 index b4dd233..0000000 --- a/api/hello/v1/hello.go +++ /dev/null @@ -1,12 +0,0 @@ -package v1 - -import ( - "github.com/gogf/gf/v2/frame/g" -) - -type HelloReq struct { - g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"You first hello api"` -} -type HelloRes struct { - g.Meta `mime:"text/html" example:"string"` -} diff --git a/api/v1/ebooks/ebooks.go b/api/v1/ebooks/ebooks.go new file mode 100644 index 0000000..c86996a --- /dev/null +++ b/api/v1/ebooks/ebooks.go @@ -0,0 +1,8 @@ +package ebooks + +import "practice_Go/internal/model/entity" + +type GetEbooksListReq struct{} +type GetEbooksListRes struct { + List []*entity.Ebooks `json:"list" dc:"ebooks list"` +} diff --git a/api/v1/live_streams/live_streams.go b/api/v1/live_streams/live_streams.go new file mode 100644 index 0000000..bd91bc3 --- /dev/null +++ b/api/v1/live_streams/live_streams.go @@ -0,0 +1,10 @@ +package live_streams + +import "practice_Go/internal/model/entity" + +type GetListReq struct { + Status *int `v:"in:0,1" dc:"开播状态(0=未开播,1=直播中)"` +} +type GetListRes struct { + List []*entity.LiveStreams `json:"list" dc:"LiveStreams list"` +} diff --git a/api/v1/shows/shows.go b/api/v1/shows/shows.go new file mode 100644 index 0000000..479d207 --- /dev/null +++ b/api/v1/shows/shows.go @@ -0,0 +1,12 @@ +package shows + +import ( + "practice_Go/internal/model/entity" +) + +type GetListReq struct { + Type *int `v:"in:1,2" dc:"类型(1=文章,2=视频)"` +} +type GetListRes struct { + List []*entity.Shows `json:"list" dc:"shows list"` +} diff --git a/go.mod b/go.mod index 8f0ec54..cf33210 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.18 require github.com/gogf/gf/v2 v2.7.1 +require github.com/go-sql-driver/mysql v1.6.0 // indirect + require ( github.com/BurntSushi/toml v1.3.2 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect @@ -11,6 +13,7 @@ require ( github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.4.1 github.com/gorilla/websocket v1.5.1 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -25,4 +28,5 @@ require ( golang.org/x/sys v0.19.0 // indirect golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + ) diff --git a/go.sum b/go.sum index c1d3bdc..44c0363 100644 --- a/go.sum +++ b/go.sum @@ -1,10 +1,15 @@ +github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/clbanning/mxj/v2 v2.5.5/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= 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/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM= github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= 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= @@ -12,17 +17,29 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= 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 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= +github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.4.1 h1:ra6aO6+KUufCg9eK52oj6Q2SnCdrmkSZF9pd32EIivQ= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.4.1/go.mod h1:xubKxCvgbPt9r4yD3ecJoP3DC3sHqcJoMyS0eX837Zg= +github.com/gogf/gf/v2 v2.4.1/go.mod h1:tsbmtwcAl2chcYoq/fP9W2FZf06aw4i89X34nbSHo9Y= github.com/gogf/gf/v2 v2.7.1 h1:Ukp7vzwh6VKnivEEx/xiMc61dL1HVZqCCHl//3GBRxc= github.com/gogf/gf/v2 v2.7.1/go.mod h1:3oyGjyLHtSSo8kQ57Nj1TPdUNc0e2HS0A2J+KkXoW+I= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY= github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY= +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.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= 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.9/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.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= 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= @@ -31,22 +48,61 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m 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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= go.opentelemetry.io/otel v1.14.0 h1:/79Huy8wbf5DnIPhemGB+zEPVwnN6fuQybr/SRXa6hM= go.opentelemetry.io/otel v1.14.0/go.mod h1:o4buv+dJzx8rohcUeRmWUZhqupFvzWis188WlggnNeU= +go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= go.opentelemetry.io/otel/sdk v1.14.0 h1:PDCppFRDq8A1jL9v6KMI6dYesaq+DFcDZvjsoGvxGzY= go.opentelemetry.io/otel/sdk v1.14.0/go.mod h1:bwIC5TjrNG6QDCHNWvW4HLHtUQ4I+VQDsnjhvyZCALM= +go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= go.opentelemetry.io/otel/trace v1.14.0 h1:wp2Mmvj41tDsyAJXiWDWpfNsOiIyd38fy85pyKcFq/M= go.opentelemetry.io/otel/trace v1.14.0/go.mod h1:8avnQLK+CG77yNLUae4ea2JDQ6iT+gozhnZjy/rw9G8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/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-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.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.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/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.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 index 83c7dc6..8dad745 100644 --- a/hack/config.yaml +++ b/hack/config.yaml @@ -4,9 +4,9 @@ gfcli: gen: dao: - - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + - link: "mysql:root:zzn20020930@tcp(127.0.0.1:3306)/homily_link?parseTime=True&loc=Local" + tables: "ebooks,live_streams,shows" descriptionTag: true - docker: build: "-a amd64 -s linux -p temp -ew" tagPrefixes: diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 07c821e..419ec86 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -2,12 +2,11 @@ package cmd import ( "context" + controller "practice_Go/internal/controller/ebooks" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gcmd" - - "practice_Go/internal/controller/hello" ) var ( @@ -17,11 +16,8 @@ var ( Brief: "start http server", Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { s := g.Server() - s.Group("/", func(group *ghttp.RouterGroup) { - group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind( - hello.NewV1(), - ) + s.Group("/api", func(group *ghttp.RouterGroup) { + group.POST("/ebooks/getEbookList", controller.Ebooks.GetEbooksList) }) s.Run() return nil diff --git a/internal/controller/ebooks/ebooks.go b/internal/controller/ebooks/ebooks.go new file mode 100644 index 0000000..98bb67c --- /dev/null +++ b/internal/controller/ebooks/ebooks.go @@ -0,0 +1,23 @@ +package controller + +import ( + "github.com/gogf/gf/v2/net/ghttp" + "practice_Go/api/v1/ebooks" + "practice_Go/internal/service/ebooks" +) + +type cEbooks struct{} + +var Ebooks = cEbooks{} + +func (c *cEbooks) GetEbooksList(r *ghttp.Request) { + var req *ebooks.GetEbooksListReq + if err := r.Parse(&req); err != nil { + r.Response.WriteJsonExit(err.Error()) + } + res, err := service.Ebooks().GetEbooksList(r.Context(), req) + if err != nil { + r.Response.WriteJsonExit(err.Error()) + } + r.Response.WriteJsonExit(res) +} diff --git a/internal/controller/hello/hello.go b/internal/controller/hello/hello.go deleted file mode 100644 index f72082f..0000000 --- a/internal/controller/hello/hello.go +++ /dev/null @@ -1,5 +0,0 @@ -// ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. -// ================================================================================= - -package hello diff --git a/internal/controller/hello/hello_new.go b/internal/controller/hello/hello_new.go deleted file mode 100644 index e75d580..0000000 --- a/internal/controller/hello/hello_new.go +++ /dev/null @@ -1,15 +0,0 @@ -// ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. -// ================================================================================= - -package hello - -import ( - "practice_Go/api/hello" -) - -type ControllerV1 struct{} - -func NewV1() hello.IHelloV1 { - return &ControllerV1{} -} diff --git a/internal/controller/hello/hello_v1_hello.go b/internal/controller/hello/hello_v1_hello.go deleted file mode 100644 index 04e0195..0000000 --- a/internal/controller/hello/hello_v1_hello.go +++ /dev/null @@ -1,13 +0,0 @@ -package hello - -import ( - "context" - "github.com/gogf/gf/v2/frame/g" - - "practice_Go/api/hello/v1" -) - -func (c *ControllerV1) Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) { - g.RequestFromCtx(ctx).Response.Writeln("Hello World!") - return -} diff --git a/internal/controller/live_streams/live_streams.go b/internal/controller/live_streams/live_streams.go new file mode 100644 index 0000000..acbeb44 --- /dev/null +++ b/internal/controller/live_streams/live_streams.go @@ -0,0 +1 @@ +package live_streams diff --git a/internal/controller/shows/shows.go b/internal/controller/shows/shows.go new file mode 100644 index 0000000..01b2981 --- /dev/null +++ b/internal/controller/shows/shows.go @@ -0,0 +1 @@ +package shows diff --git a/internal/dao/ebooks.go b/internal/dao/ebooks.go new file mode 100644 index 0000000..ca9ab0a --- /dev/null +++ b/internal/dao/ebooks.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" +) + +// internalEbooksDao is internal type for wrapping internal DAO implements. +type internalEbooksDao = *internal.EbooksDao + +// ebooksDao is the data access object for table ebooks. +// You can define custom methods on it to extend its functionality as you wish. +type ebooksDao struct { + internalEbooksDao +} + +var ( + // Ebooks is globally public accessible object for table ebooks operations. + Ebooks = ebooksDao{ + internal.NewEbooksDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/internal/ebooks.go b/internal/dao/internal/ebooks.go new file mode 100644 index 0000000..c3a12cb --- /dev/null +++ b/internal/dao/internal/ebooks.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" +) + +// EbooksDao is the data access object for table ebooks. +type EbooksDao 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 EbooksColumns // columns contains all the column names of Table for convenient usage. +} + +// EbooksColumns defines and stores column names for table ebooks. +type EbooksColumns struct { + Id string // 主键 + Cover string // 封面图URL + Title string // 书名(唯一约束) + Description string // 简介 + ViewCount string // 观看人数 +} + +// ebooksColumns holds the columns for table ebooks. +var ebooksColumns = EbooksColumns{ + Id: "id", + Cover: "cover", + Title: "title", + Description: "description", + ViewCount: "view_count", +} + +// NewEbooksDao creates and returns a new DAO object for table data access. +func NewEbooksDao() *EbooksDao { + return &EbooksDao{ + group: "default", + table: "ebooks", + columns: ebooksColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *EbooksDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *EbooksDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *EbooksDao) Columns() EbooksColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *EbooksDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *EbooksDao) 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 *EbooksDao) 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/live_streams.go b/internal/dao/internal/live_streams.go new file mode 100644 index 0000000..6002938 --- /dev/null +++ b/internal/dao/internal/live_streams.go @@ -0,0 +1,85 @@ +// ========================================================================== +// 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" +) + +// LiveStreamsDao is the data access object for table live_streams. +type LiveStreamsDao 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 LiveStreamsColumns // columns contains all the column names of Table for convenient usage. +} + +// LiveStreamsColumns defines and stores column names for table live_streams. +type LiveStreamsColumns struct { + Id string // 主键 + Cover string // 直播封面URL + Title string // 直播标题 + Avatar string // 主播头像URL + PublisherId string // 主播ID + StartTime string // 计划开播时间 + Status string // 开播状态(0=未开播,1=直播中) +} + +// liveStreamsColumns holds the columns for table live_streams. +var liveStreamsColumns = LiveStreamsColumns{ + Id: "id", + Cover: "cover", + Title: "title", + Avatar: "avatar", + PublisherId: "publisher_id", + StartTime: "start_time", + Status: "status", +} + +// NewLiveStreamsDao creates and returns a new DAO object for table data access. +func NewLiveStreamsDao() *LiveStreamsDao { + return &LiveStreamsDao{ + group: "default", + table: "live_streams", + columns: liveStreamsColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *LiveStreamsDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *LiveStreamsDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *LiveStreamsDao) Columns() LiveStreamsColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *LiveStreamsDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *LiveStreamsDao) 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 *LiveStreamsDao) 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/shows.go b/internal/dao/internal/shows.go new file mode 100644 index 0000000..7b5fb2a --- /dev/null +++ b/internal/dao/internal/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" +) + +// ShowsDao is the data access object for table shows. +type ShowsDao 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 ShowsColumns // columns contains all the column names of Table for convenient usage. +} + +// ShowsColumns defines and stores column names for table shows. +type ShowsColumns struct { + Id string // 主键 + Cover string // 封面图URL + Title string // 标题 + PublisherId string // 发布人ID + PublisherAvatar string // 发布人头像URL + PublishTime string // 发布时间 + ViewCount string // 观看人数 + CommentCount string // 评论数 + LikeCount string // 点赞数 + Type string // 类型(1=文章,2=视频) + ClubId string // 所属俱乐部(0=无,1=博古) + VideoDuration string // 视频时长(秒) +} + +// showsColumns holds the columns for table shows. +var showsColumns = ShowsColumns{ + Id: "id", + Cover: "cover", + Title: "title", + PublisherId: "publisher_id", + PublisherAvatar: "publisher_avatar", + PublishTime: "publish_time", + ViewCount: "view_count", + CommentCount: "comment_count", + LikeCount: "like_count", + Type: "type", + ClubId: "club_id", + VideoDuration: "video_duration", +} + +// NewShowsDao creates and returns a new DAO object for table data access. +func NewShowsDao() *ShowsDao { + return &ShowsDao{ + group: "default", + table: "shows", + columns: showsColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of current DAO. +func (dao *ShowsDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of current dao. +func (dao *ShowsDao) Table() string { + return dao.table +} + +// Columns returns all column names of current dao. +func (dao *ShowsDao) Columns() ShowsColumns { + return dao.columns +} + +// Group returns the configuration group name of database of current dao. +func (dao *ShowsDao) Group() string { + return dao.group +} + +// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +func (dao *ShowsDao) 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 *ShowsDao) 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/live_streams.go b/internal/dao/live_streams.go new file mode 100644 index 0000000..57d937e --- /dev/null +++ b/internal/dao/live_streams.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" +) + +// internalLiveStreamsDao is internal type for wrapping internal DAO implements. +type internalLiveStreamsDao = *internal.LiveStreamsDao + +// liveStreamsDao is the data access object for table live_streams. +// You can define custom methods on it to extend its functionality as you wish. +type liveStreamsDao struct { + internalLiveStreamsDao +} + +var ( + // LiveStreams is globally public accessible object for table live_streams operations. + LiveStreams = liveStreamsDao{ + internal.NewLiveStreamsDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/dao/shows.go b/internal/dao/shows.go new file mode 100644 index 0000000..8fc0099 --- /dev/null +++ b/internal/dao/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" +) + +// internalShowsDao is internal type for wrapping internal DAO implements. +type internalShowsDao = *internal.ShowsDao + +// showsDao is the data access object for table shows. +// You can define custom methods on it to extend its functionality as you wish. +type showsDao struct { + internalShowsDao +} + +var ( + // Shows is globally public accessible object for table shows operations. + Shows = showsDao{ + internal.NewShowsDao(), + } +) + +// Fill with you ideas below. diff --git a/internal/logic/ebooks/ebooks.go b/internal/logic/ebooks/ebooks.go new file mode 100644 index 0000000..30b4c7c --- /dev/null +++ b/internal/logic/ebooks/ebooks.go @@ -0,0 +1,25 @@ +package logic + +import ( + "context" + "practice_Go/api/v1/ebooks" + "practice_Go/internal/dao" + "practice_Go/internal/service/ebooks" +) + +type sEbooks struct{} + +func init() { + service.RegisterEbooks(New()) +} +func New() *sEbooks { + return &sEbooks{} +} + +func (c *sEbooks) GetEbooksList(ctx context.Context, req *ebooks.GetEbooksListReq) (res ebooks.GetEbooksListRes, err error) { + err = dao.Ebooks.Ctx(ctx).Scan(&res.List) + if err != nil { + return + } + return +} diff --git a/internal/logic/live_streams/live_streams.go b/internal/logic/live_streams/live_streams.go new file mode 100644 index 0000000..acbeb44 --- /dev/null +++ b/internal/logic/live_streams/live_streams.go @@ -0,0 +1 @@ +package live_streams diff --git a/internal/logic/shows/shows.go b/internal/logic/shows/shows.go new file mode 100644 index 0000000..01b2981 --- /dev/null +++ b/internal/logic/shows/shows.go @@ -0,0 +1 @@ +package shows diff --git a/internal/model/do/ebooks.go b/internal/model/do/ebooks.go new file mode 100644 index 0000000..cfea3d0 --- /dev/null +++ b/internal/model/do/ebooks.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" +) + +// Ebooks is the golang structure of table ebooks for DAO operations like Where/Data. +type Ebooks struct { + g.Meta `orm:"table:ebooks, do:true"` + Id interface{} // 主键 + Cover interface{} // 封面图URL + Title interface{} // 书名(唯一约束) + Description interface{} // 简介 + ViewCount interface{} // 观看人数 +} diff --git a/internal/model/do/live_streams.go b/internal/model/do/live_streams.go new file mode 100644 index 0000000..e769851 --- /dev/null +++ b/internal/model/do/live_streams.go @@ -0,0 +1,22 @@ +// ================================================================================= +// 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" +) + +// LiveStreams is the golang structure of table live_streams for DAO operations like Where/Data. +type LiveStreams struct { + g.Meta `orm:"table:live_streams, do:true"` + Id interface{} // 主键 + Cover interface{} // 直播封面URL + Title interface{} // 直播标题 + Avatar interface{} // 主播头像URL + PublisherId interface{} // 主播ID + StartTime *gtime.Time // 计划开播时间 + Status interface{} // 开播状态(0=未开播,1=直播中) +} diff --git a/internal/model/do/shows.go b/internal/model/do/shows.go new file mode 100644 index 0000000..ddcd448 --- /dev/null +++ b/internal/model/do/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" +) + +// Shows is the golang structure of table shows for DAO operations like Where/Data. +type Shows struct { + g.Meta `orm:"table:shows, do:true"` + Id interface{} // 主键 + Cover interface{} // 封面图URL + Title interface{} // 标题 + PublisherId interface{} // 发布人ID + PublisherAvatar interface{} // 发布人头像URL + PublishTime *gtime.Time // 发布时间 + ViewCount interface{} // 观看人数 + CommentCount interface{} // 评论数 + LikeCount interface{} // 点赞数 + Type interface{} // 类型(1=文章,2=视频) + ClubId interface{} // 所属俱乐部(0=无,1=博古) + VideoDuration interface{} // 视频时长(秒) +} diff --git a/internal/model/entity/ebooks.go b/internal/model/entity/ebooks.go new file mode 100644 index 0000000..a8f2f27 --- /dev/null +++ b/internal/model/entity/ebooks.go @@ -0,0 +1,14 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// Ebooks is the golang structure for table ebooks. +type Ebooks struct { + Id uint64 `json:"id" orm:"id" ` // 主键 + Cover string `json:"cover" orm:"cover" ` // 封面图URL + Title string `json:"title" orm:"title" ` // 书名(唯一约束) + Description string `json:"description" orm:"description" ` // 简介 + ViewCount uint `json:"viewCount" orm:"view_count" ` // 观看人数 +} diff --git a/internal/model/entity/live_streams.go b/internal/model/entity/live_streams.go new file mode 100644 index 0000000..9d94f7a --- /dev/null +++ b/internal/model/entity/live_streams.go @@ -0,0 +1,20 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// LiveStreams is the golang structure for table live_streams. +type LiveStreams struct { + Id uint64 `json:"id" orm:"id" ` // 主键 + Cover string `json:"cover" orm:"cover" ` // 直播封面URL + Title string `json:"title" orm:"title" ` // 直播标题 + Avatar string `json:"avatar" orm:"avatar" ` // 主播头像URL + PublisherId uint64 `json:"publisherId" orm:"publisher_id" ` // 主播ID + StartTime *gtime.Time `json:"startTime" orm:"start_time" ` // 计划开播时间 + Status int `json:"status" orm:"status" ` // 开播状态(0=未开播,1=直播中) +} diff --git a/internal/model/entity/shows.go b/internal/model/entity/shows.go new file mode 100644 index 0000000..afb760e --- /dev/null +++ b/internal/model/entity/shows.go @@ -0,0 +1,25 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +import ( + "github.com/gogf/gf/v2/os/gtime" +) + +// Shows is the golang structure for table shows. +type Shows struct { + Id uint64 `json:"id" orm:"id" ` // 主键 + Cover string `json:"cover" orm:"cover" ` // 封面图URL + Title string `json:"title" orm:"title" ` // 标题 + PublisherId uint64 `json:"publisherId" orm:"publisher_id" ` // 发布人ID + PublisherAvatar string `json:"publisherAvatar" orm:"publisher_avatar" ` // 发布人头像URL + PublishTime *gtime.Time `json:"publishTime" orm:"publish_time" ` // 发布时间 + ViewCount uint `json:"viewCount" orm:"view_count" ` // 观看人数 + CommentCount uint `json:"commentCount" orm:"comment_count" ` // 评论数 + LikeCount uint `json:"likeCount" orm:"like_count" ` // 点赞数 + Type int `json:"type" orm:"type" ` // 类型(1=文章,2=视频) + ClubId int `json:"clubId" orm:"club_id" ` // 所属俱乐部(0=无,1=博古) + VideoDuration uint `json:"videoDuration" orm:"video_duration" ` // 视频时长(秒) +} diff --git a/internal/service/ebooks/ebooks.go b/internal/service/ebooks/ebooks.go new file mode 100644 index 0000000..6dfa02f --- /dev/null +++ b/internal/service/ebooks/ebooks.go @@ -0,0 +1,27 @@ +package service + +import ( + "context" + "practice_Go/api/v1/ebooks" +) + +type ( + IEbooks interface { + GetEbooksList(ctx context.Context, req *ebooks.GetEbooksListReq) (res ebooks.GetEbooksListRes, err error) + } +) + +var ( + localBooks IEbooks +) + +func Ebooks() IEbooks { + if localBooks == nil { + panic("implement not found for interface IUser, forgot register?") + } + return localBooks +} + +func RegisterEbooks(i IEbooks) { + localBooks = i +} diff --git a/internal/service/live_streams/live_streams.go b/internal/service/live_streams/live_streams.go new file mode 100644 index 0000000..acbeb44 --- /dev/null +++ b/internal/service/live_streams/live_streams.go @@ -0,0 +1 @@ +package live_streams diff --git a/internal/service/shows/shows.go b/internal/service/shows/shows.go new file mode 100644 index 0000000..01b2981 --- /dev/null +++ b/internal/service/shows/shows.go @@ -0,0 +1 @@ +package shows diff --git a/main.go b/main.go index cff9434..8040101 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,11 @@ package main import ( - _ "practice_Go/internal/packed" - + _ "github.com/gogf/gf/contrib/drivers/mysql/v2" "github.com/gogf/gf/v2/os/gctx" - "practice_Go/internal/cmd" + _ "practice_Go/internal/logic/ebooks" + _ "practice_Go/internal/packed" ) func main() { diff --git a/resource/public/resource/image/ebook1.png b/resource/public/resource/image/ebook1.png new file mode 100644 index 0000000..69a0c3c Binary files /dev/null and b/resource/public/resource/image/ebook1.png differ diff --git a/resource/public/resource/image/ebook2.png b/resource/public/resource/image/ebook2.png new file mode 100644 index 0000000..e7bbdde Binary files /dev/null and b/resource/public/resource/image/ebook2.png differ diff --git a/resource/public/resource/image/ebook3.png b/resource/public/resource/image/ebook3.png new file mode 100644 index 0000000..3be0bf4 Binary files /dev/null and b/resource/public/resource/image/ebook3.png differ diff --git a/resource/public/resource/image/ebook4.png b/resource/public/resource/image/ebook4.png new file mode 100644 index 0000000..d78bb30 Binary files /dev/null and b/resource/public/resource/image/ebook4.png differ