feat(dev): 项目初始化。
This commit is contained in:
commit
54135d2be5
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* linguist-language=GO
|
||||||
19
.gitignore
vendored
Normal file
19
.gitignore
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
.buildpath
|
||||||
|
.hgignore.swp
|
||||||
|
.project
|
||||||
|
.orig
|
||||||
|
.swp
|
||||||
|
.idea/
|
||||||
|
.settings/
|
||||||
|
.vscode/
|
||||||
|
bin/
|
||||||
|
**/.DS_Store
|
||||||
|
gf
|
||||||
|
main
|
||||||
|
main.exe
|
||||||
|
output/
|
||||||
|
manifest/output/
|
||||||
|
temp/
|
||||||
|
temp.yaml
|
||||||
|
bin
|
||||||
|
**/config/config.yaml
|
||||||
7
Makefile
Normal file
7
Makefile
Normal file
@ -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
|
||||||
27
PROJECT_STRUCTURE.md
Normal file
27
PROJECT_STRUCTURE.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Production layout
|
||||||
|
|
||||||
|
```text
|
||||||
|
service.xpcool.com/
|
||||||
|
├── api/ # HTTP contracts and Swagger metadata
|
||||||
|
│ ├── user/v1/ # /api/v1 - client-facing API
|
||||||
|
│ └── admin/v1/ # /admin/v1 - administration API
|
||||||
|
├── internal/
|
||||||
|
│ ├── cmd/ # application bootstrap and route isolation
|
||||||
|
│ ├── consts/ # application error codes and constants
|
||||||
|
│ ├── controller/ # API-to-service adapters only
|
||||||
|
│ ├── service/ # domain use cases and provider interfaces
|
||||||
|
│ ├── dao/ # generated by gf gen dao; never hand edited
|
||||||
|
│ ├── model/
|
||||||
|
│ │ ├── entity/ # generated database entities
|
||||||
|
│ │ ├── do/ # generated Data Objects
|
||||||
|
│ │ ├── dto/ # service boundary input/output
|
||||||
|
│ │ └── vo/ # API view models
|
||||||
|
│ ├── middleware/ # configurable route-group middleware
|
||||||
|
│ └── library/ # JWT, response, pagination primitives
|
||||||
|
├── manifest/
|
||||||
|
│ ├── config/ # config.dev/test/prod.yaml
|
||||||
|
│ └── sql/ # ordered MySQL migrations
|
||||||
|
└── utility/ # optional cross-cutting helpers
|
||||||
|
```
|
||||||
|
|
||||||
|
`dao`, `model/do` and `model/entity` are generated after migration, so their schema never drifts from MySQL. Controllers do not access DAO; only services do.
|
||||||
22
README.MD
Normal file
22
README.MD
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Personal multi-client service
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
`api → internal/controller → internal/service → internal/dao → internal/model(entity/do)` is enforced. DTO and VO live in `internal/model/dto` and `internal/model/vo`; neither API types nor entities cross that boundary.
|
||||||
|
|
||||||
|
## Database model generation
|
||||||
|
|
||||||
|
Run `manifest/sql/001_core.sql` on MySQL, set `DB_DSN`, then run:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
gf gen dao -p internal -g default -gt -c
|
||||||
|
```
|
||||||
|
|
||||||
|
The command is intentionally the only source of `internal/dao`, `internal/model/do`, and `internal/model/entity`.
|
||||||
|
|
||||||
|
## API isolation
|
||||||
|
|
||||||
|
- `/api/v1/*`: user API, terminal header/body supports `mini`, `h5`, and `app`.
|
||||||
|
- `/admin/v1/*`: admin API. Protected endpoints require both an admin access token and an `X-Permission` identifier.
|
||||||
|
|
||||||
|
Use `GF_GCFG_FILE=config.dev.yaml` (or `config.test.yaml` / `config.prod.yaml`) and set `DB_DSN` plus a strong `JWT_SECRET` before startup.
|
||||||
15
api/admin/v1/auth.go
Normal file
15
api/admin/v1/auth.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package v1
|
||||||
|
|
||||||
|
import "github.com/gogf/gf/v2/frame/g"
|
||||||
|
|
||||||
|
type LoginReq struct {
|
||||||
|
g.Meta `path:"/auth/login" method:"post" tags:"Admin/Auth" summary:"Administrator login"`
|
||||||
|
Username string `json:"username" v:"required"`
|
||||||
|
Password string `json:"password" v:"required"`
|
||||||
|
}
|
||||||
|
type LoginRes struct {
|
||||||
|
AccessToken string `json:"accessToken"`
|
||||||
|
RefreshToken string `json:"refreshToken"`
|
||||||
|
ExpiresIn int64 `json:"expiresIn"`
|
||||||
|
AdminID uint64 `json:"adminId"`
|
||||||
|
}
|
||||||
15
api/hello/hello.go
Normal file
15
api/hello/hello.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package hello
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"service.xpcool.com/api/hello/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IHelloV1 interface {
|
||||||
|
Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error)
|
||||||
|
}
|
||||||
12
api/hello/v1/hello.go
Normal file
12
api/hello/v1/hello.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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"`
|
||||||
|
}
|
||||||
25
api/user/v1/auth.go
Normal file
25
api/user/v1/auth.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package v1
|
||||||
|
|
||||||
|
import "github.com/gogf/gf/v2/frame/g"
|
||||||
|
|
||||||
|
type LoginReq struct {
|
||||||
|
g.Meta `path:"/auth/login" method:"post" tags:"User/Auth" summary:"User login"`
|
||||||
|
LoginType string `json:"loginType" v:"required|in:wechat,mobile,password#login type required|unsupported login type"`
|
||||||
|
Code string `json:"code"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
VerifyCode string `json:"verifyCode"`
|
||||||
|
Account string `json:"account"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Terminal string `json:"terminal" v:"required|in:mini,h5,app#terminal required|invalid terminal"`
|
||||||
|
}
|
||||||
|
type LoginRes struct {
|
||||||
|
AccessToken string `json:"accessToken"`
|
||||||
|
RefreshToken string `json:"refreshToken"`
|
||||||
|
ExpiresIn int64 `json:"expiresIn"`
|
||||||
|
UserID uint64 `json:"userId"`
|
||||||
|
}
|
||||||
|
type RefreshReq struct {
|
||||||
|
g.Meta `path:"/auth/refresh" method:"post" tags:"User/Auth" summary:"Rotate user token"`
|
||||||
|
RefreshToken string `json:"refreshToken" v:"required"`
|
||||||
|
}
|
||||||
|
type RefreshRes LoginRes
|
||||||
36
go.mod
Normal file
36
go.mod
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
module service.xpcool.com
|
||||||
|
|
||||||
|
go 1.23.0
|
||||||
|
|
||||||
|
require github.com/gogf/gf/v2 v2.10.2
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/BurntSushi/toml v1.5.0 // indirect
|
||||||
|
github.com/clbanning/mxj/v2 v2.7.0 // indirect
|
||||||
|
github.com/emirpasic/gods/v2 v2.0.0-alpha // indirect
|
||||||
|
github.com/fatih/color v1.18.0 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 // indirect
|
||||||
|
github.com/go-logr/logr v1.4.3 // indirect
|
||||||
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
|
github.com/google/uuid v1.6.0 // 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.10 // indirect
|
||||||
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mattn/go-runewidth v0.0.16 // indirect
|
||||||
|
github.com/olekukonko/errors v1.1.0 // indirect
|
||||||
|
github.com/olekukonko/ll v0.0.9 // indirect
|
||||||
|
github.com/olekukonko/tablewriter v1.1.0 // indirect
|
||||||
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
|
||||||
|
go.opentelemetry.io/otel v1.38.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/metric v1.38.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/sdk v1.38.0 // indirect
|
||||||
|
go.opentelemetry.io/otel/trace v1.38.0 // indirect
|
||||||
|
golang.org/x/crypto v0.38.0
|
||||||
|
golang.org/x/net v0.40.0 // indirect
|
||||||
|
golang.org/x/sys v0.35.0 // indirect
|
||||||
|
golang.org/x/text v0.25.0 // indirect
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
)
|
||||||
83
go.sum
Normal file
83
go.sum
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
|
||||||
|
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
|
||||||
|
github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME=
|
||||||
|
github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/emirpasic/gods/v2 v2.0.0-alpha h1:dwFlh8pBg1VMOXWGipNMRt8v96dKAIvBehtCt6OtunU=
|
||||||
|
github.com/emirpasic/gods/v2 v2.0.0-alpha/go.mod h1:W0y4M2dtBB9U5z3YlghmpuUhiaZT2h6yoeE+C1sCp6A=
|
||||||
|
github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM=
|
||||||
|
github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
|
||||||
|
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||||
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
|
github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
|
||||||
|
github.com/go-logr/logr v1.4.3/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/gogf/gf/v2 v2.10.2 h1:46IO0Uc8e85/FqdftJFskfDejJLBL0JBnGS5qOftUu8=
|
||||||
|
github.com/gogf/gf/v2 v2.10.2/go.mod h1:Svl1N+E8G/QshU2DUbh/3J/AJauqCgUnxHurXWR4Qx0=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4=
|
||||||
|
github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/magiconair/properties v1.8.10 h1:s31yESBquKXCV9a/ScB3ESkOjUYYv+X0rg8SYxI99mE=
|
||||||
|
github.com/magiconair/properties v1.8.10/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||||
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
|
||||||
|
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
github.com/olekukonko/errors v1.1.0 h1:RNuGIh15QdDenh+hNvKrJkmxxjV4hcS50Db478Ou5sM=
|
||||||
|
github.com/olekukonko/errors v1.1.0/go.mod h1:ppzxA5jBKcO1vIpCXQ9ZqgDh8iwODz6OXIGKU8r5m4Y=
|
||||||
|
github.com/olekukonko/ll v0.0.9 h1:Y+1YqDfVkqMWuEQMclsF9HUR5+a82+dxJuL1HHSRpxI=
|
||||||
|
github.com/olekukonko/ll v0.0.9/go.mod h1:En+sEW0JNETl26+K8eZ6/W4UQ7CYSrrgg/EdIYT2H8g=
|
||||||
|
github.com/olekukonko/tablewriter v1.1.0 h1:N0LHrshF4T39KvI96fn6GT8HEjXRXYNDrDjKFDB7RIY=
|
||||||
|
github.com/olekukonko/tablewriter v1.1.0/go.mod h1:5c+EBPeSqvXnLLgkm9isDdzR3wjfBkHR9Nhfp3NWrzo=
|
||||||
|
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 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
|
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||||
|
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
|
||||||
|
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
|
||||||
|
go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8=
|
||||||
|
go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM=
|
||||||
|
go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA=
|
||||||
|
go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.38.0 h1:l48sr5YbNf2hpCUj/FoGhW9yDkl+Ma+LrVl8qaM5b+E=
|
||||||
|
go.opentelemetry.io/otel/sdk v1.38.0/go.mod h1:ghmNdGlVemJI3+ZB5iDEuk4bWA3GkTpW+DOoZMYBVVg=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.38.0 h1:aSH66iL0aZqo//xXzQLYozmWrXxyFkBJ6qT5wthqPoM=
|
||||||
|
go.opentelemetry.io/otel/sdk/metric v1.38.0/go.mod h1:dg9PBnW9XdQ1Hd6ZnRz689CbtrUp0wMMs9iPcgT9EZA=
|
||||||
|
go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE=
|
||||||
|
go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs=
|
||||||
|
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
|
golang.org/x/crypto v0.38.0 h1:jt+WWG8IZlBnVbomuhg2Mdq0+BBQaHbtqHEFEigjUV8=
|
||||||
|
golang.org/x/crypto v0.38.0/go.mod h1:MvrbAqul58NNYPKnOra203SB9vpuZW0e+RRZV+Ggqjw=
|
||||||
|
golang.org/x/net v0.40.0 h1:79Xs7wF06Gbdcg4kdCCIQArK11Z1hr5POQ6+fIYHNuY=
|
||||||
|
golang.org/x/net v0.40.0/go.mod h1:y0hY0exeL2Pku80/zKK7tpntoX23cqL3Oa6njdgRtds=
|
||||||
|
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.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
|
||||||
|
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
|
||||||
|
golang.org/x/text v0.25.0 h1:qVyWApTSYLk/drJRO5mDlNYskwQznZmkpV2c8q9zls4=
|
||||||
|
golang.org/x/text v0.25.0/go.mod h1:WEdwpYrmk1qmdHvhkSTNPm3app7v4rsT8F2UD6+VHIA=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
13
hack/config.yaml
Normal file
13
hack/config.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
# CLI tool, only in development environment.
|
||||||
|
# https://goframe.org/docs/cli
|
||||||
|
gfcli:
|
||||||
|
gen:
|
||||||
|
dao:
|
||||||
|
- link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test"
|
||||||
|
descriptionTag: true
|
||||||
|
|
||||||
|
docker:
|
||||||
|
build: "-a amd64 -s linux -p temp -ew"
|
||||||
|
tagPrefixes:
|
||||||
|
- my.image.pub/my-app
|
||||||
18
hack/hack-cli.mk
Normal file
18
hack/hack-cli.mk
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
# Install/Update to the latest CLI tool.
|
||||||
|
.PHONY: cli
|
||||||
|
cli:
|
||||||
|
@set -e; \
|
||||||
|
echo "go install github.com/gogf/gf/cmd/gf/v2@latest"; \
|
||||||
|
go install github.com/gogf/gf/cmd/gf/v2@latest; \
|
||||||
|
echo "GoFame CLI installed successfully!"
|
||||||
|
|
||||||
|
|
||||||
|
# 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;
|
||||||
75
hack/hack.mk
Normal file
75
hack/hack.mk
Normal file
@ -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
|
||||||
54
internal/cmd/cmd.go
Normal file
54
internal/cmd/cmd.go
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"github.com/gogf/gf/v2/os/gcmd"
|
||||||
|
|
||||||
|
adminctl "service.xpcool.com/internal/controller/admin"
|
||||||
|
"service.xpcool.com/internal/controller/hello"
|
||||||
|
userctl "service.xpcool.com/internal/controller/user"
|
||||||
|
"service.xpcool.com/internal/library/jwt"
|
||||||
|
"service.xpcool.com/internal/middleware"
|
||||||
|
"service.xpcool.com/internal/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
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()
|
||||||
|
tokens := jwt.New(ctx)
|
||||||
|
service.RegisterUserAuth(service.NewUserAuth(tokens, nil, nil))
|
||||||
|
service.RegisterAdminAuth(service.NewAdminAuth(tokens))
|
||||||
|
service.RegisterAdminAudit(service.NewAdminAudit())
|
||||||
|
s.Group("/", func(group *ghttp.RouterGroup) {
|
||||||
|
group.Middleware(middleware.Recover, middleware.CORS)
|
||||||
|
group.Middleware(ghttp.MiddlewareHandlerResponse)
|
||||||
|
group.Bind(
|
||||||
|
hello.NewV1(),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
s.Group("/api/v1", func(group *ghttp.RouterGroup) {
|
||||||
|
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
|
||||||
|
group.Bind(userctl.New()) // Login and refresh routes are public.
|
||||||
|
group.Group("/", func(protected *ghttp.RouterGroup) { protected.Middleware(middleware.UserAuth(tokens)) })
|
||||||
|
})
|
||||||
|
s.Group("/admin/v1", func(group *ghttp.RouterGroup) {
|
||||||
|
group.Middleware(middleware.Recover, middleware.CORS, ghttp.MiddlewareHandlerResponse)
|
||||||
|
group.Bind(adminctl.New()) // Admin login remains public; protected controllers mount separately.
|
||||||
|
group.Group("/", func(protected *ghttp.RouterGroup) {
|
||||||
|
protected.Middleware(middleware.AdminAuth(tokens, service.AdminAuth().HasPermission, func(ctx context.Context, id uint64, permission, method, path, ip, param string, duration, status int) {
|
||||||
|
service.AdminAudit().Record(ctx, service.AuditEvent{AdminID: id, Permission: permission, Method: method, Path: path, IP: ip, Param: param, DurationMS: duration, StatusCode: status})
|
||||||
|
}))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
s.Run()
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
)
|
||||||
1
internal/consts/consts.go
Normal file
1
internal/consts/consts.go
Normal file
@ -0,0 +1 @@
|
|||||||
|
package consts
|
||||||
15
internal/consts/error_code.go
Normal file
15
internal/consts/error_code.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package consts
|
||||||
|
|
||||||
|
const (
|
||||||
|
CodeOK = 0
|
||||||
|
CodeInvalidParam = 10001
|
||||||
|
CodeUnauthorized = 10002
|
||||||
|
CodeForbidden = 10003
|
||||||
|
CodeInternal = 10004
|
||||||
|
CodeUserNotFound = 20001
|
||||||
|
CodeUserPasswordWrong = 20002
|
||||||
|
CodeUserLoginType = 20003
|
||||||
|
CodeAdminNotFound = 30001
|
||||||
|
CodeAdminPasswordWrong = 30002
|
||||||
|
CodeAdminPermissionDenied = 30003
|
||||||
|
)
|
||||||
19
internal/controller/admin/auth.go
Normal file
19
internal/controller/admin/auth.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
adminv1 "service.xpcool.com/api/admin/v1"
|
||||||
|
"service.xpcool.com/internal/model/dto"
|
||||||
|
"service.xpcool.com/internal/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Controller struct{}
|
||||||
|
|
||||||
|
func New() *Controller { return &Controller{} }
|
||||||
|
func (c *Controller) Login(ctx context.Context, req *adminv1.LoginReq) (res *adminv1.LoginRes, err error) {
|
||||||
|
p, id, err := service.AdminAuth().Login(ctx, dto.AdminLoginInput{Username: req.Username, Password: req.Password})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &adminv1.LoginRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, AdminID: id}, nil
|
||||||
|
}
|
||||||
5
internal/controller/hello/hello.go
Normal file
5
internal/controller/hello/hello.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package hello
|
||||||
15
internal/controller/hello/hello_new.go
Normal file
15
internal/controller/hello/hello_new.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package hello
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/api/hello"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ControllerV1 struct{}
|
||||||
|
|
||||||
|
func NewV1() hello.IHelloV1 {
|
||||||
|
return &ControllerV1{}
|
||||||
|
}
|
||||||
13
internal/controller/hello/hello_v1_hello.go
Normal file
13
internal/controller/hello/hello_v1_hello.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package hello
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
|
||||||
|
"service.xpcool.com/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
|
||||||
|
}
|
||||||
26
internal/controller/user/auth.go
Normal file
26
internal/controller/user/auth.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
userv1 "service.xpcool.com/api/user/v1"
|
||||||
|
"service.xpcool.com/internal/model/dto"
|
||||||
|
"service.xpcool.com/internal/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Controller struct{}
|
||||||
|
|
||||||
|
func New() *Controller { return &Controller{} }
|
||||||
|
func (c *Controller) Login(ctx context.Context, req *userv1.LoginReq) (res *userv1.LoginRes, err error) {
|
||||||
|
p, id, err := service.UserAuth().Login(ctx, dto.UserLoginInput{LoginType: req.LoginType, Code: req.Code, Mobile: req.Mobile, VerifyCode: req.VerifyCode, Account: req.Account, Password: req.Password, Terminal: req.Terminal})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &userv1.LoginRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, UserID: id}, nil
|
||||||
|
}
|
||||||
|
func (c *Controller) Refresh(ctx context.Context, req *userv1.RefreshReq) (res *userv1.RefreshRes, err error) {
|
||||||
|
p, id, err := service.UserAuth().Refresh(ctx, req.RefreshToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &userv1.RefreshRes{AccessToken: p.AccessToken, RefreshToken: p.RefreshToken, ExpiresIn: p.ExpiresIn, UserID: id}, nil
|
||||||
|
}
|
||||||
0
internal/dao/.gitkeep
Normal file
0
internal/dao/.gitkeep
Normal file
22
internal/dao/admin_menu.go
Normal file
22
internal/dao/admin_menu.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminMenuDao is the data access object for the table admin_menu.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminMenuDao struct {
|
||||||
|
*internal.AdminMenuDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminMenu is a globally accessible object for table admin_menu operations.
|
||||||
|
AdminMenu = adminMenuDao{internal.NewAdminMenuDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/admin_operation_log.go
Normal file
22
internal/dao/admin_operation_log.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminOperationLogDao is the data access object for the table admin_operation_log.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminOperationLogDao struct {
|
||||||
|
*internal.AdminOperationLogDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminOperationLog is a globally accessible object for table admin_operation_log operations.
|
||||||
|
AdminOperationLog = adminOperationLogDao{internal.NewAdminOperationLogDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/admin_role.go
Normal file
22
internal/dao/admin_role.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRoleDao is the data access object for the table admin_role.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminRoleDao struct {
|
||||||
|
*internal.AdminRoleDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminRole is a globally accessible object for table admin_role operations.
|
||||||
|
AdminRole = adminRoleDao{internal.NewAdminRoleDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/admin_role_menu.go
Normal file
22
internal/dao/admin_role_menu.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminRoleMenuDao is the data access object for the table admin_role_menu.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminRoleMenuDao struct {
|
||||||
|
*internal.AdminRoleMenuDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminRoleMenu is a globally accessible object for table admin_role_menu operations.
|
||||||
|
AdminRoleMenu = adminRoleMenuDao{internal.NewAdminRoleMenuDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/admin_user.go
Normal file
22
internal/dao/admin_user.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminUserDao is the data access object for the table admin_user.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminUserDao struct {
|
||||||
|
*internal.AdminUserDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminUser is a globally accessible object for table admin_user operations.
|
||||||
|
AdminUser = adminUserDao{internal.NewAdminUserDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/admin_user_role.go
Normal file
22
internal/dao/admin_user_role.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// adminUserRoleDao is the data access object for the table admin_user_role.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type adminUserRoleDao struct {
|
||||||
|
*internal.AdminUserRoleDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AdminUserRole is a globally accessible object for table admin_user_role operations.
|
||||||
|
AdminUserRole = adminUserRoleDao{internal.NewAdminUserRoleDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/auth_refresh_session.go
Normal file
22
internal/dao/auth_refresh_session.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// authRefreshSessionDao is the data access object for the table auth_refresh_session.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type authRefreshSessionDao struct {
|
||||||
|
*internal.AuthRefreshSessionDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// AuthRefreshSession is a globally accessible object for table auth_refresh_session operations.
|
||||||
|
AuthRefreshSession = authRefreshSessionDao{internal.NewAuthRefreshSessionDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/content.go
Normal file
22
internal/dao/content.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// contentDao is the data access object for the table content.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type contentDao struct {
|
||||||
|
*internal.ContentDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Content is a globally accessible object for table content operations.
|
||||||
|
Content = contentDao{internal.NewContentDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
99
internal/dao/internal/admin_menu.go
Normal file
99
internal/dao/internal/admin_menu.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMenuDao is the data access object for the table admin_menu.
|
||||||
|
type AdminMenuDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminMenuColumns defines and stores column names for the table admin_menu.
|
||||||
|
type AdminMenuColumns struct {
|
||||||
|
Id string //
|
||||||
|
ParentId string //
|
||||||
|
Name string //
|
||||||
|
Type string // 1 menu,2 api
|
||||||
|
Path string //
|
||||||
|
Permission string //
|
||||||
|
Sort string //
|
||||||
|
Status string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminMenuColumns holds the columns for the table admin_menu.
|
||||||
|
var adminMenuColumns = AdminMenuColumns{
|
||||||
|
Id: "id",
|
||||||
|
ParentId: "parent_id",
|
||||||
|
Name: "name",
|
||||||
|
Type: "type",
|
||||||
|
Path: "path",
|
||||||
|
Permission: "permission",
|
||||||
|
Sort: "sort",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminMenuDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminMenuDao(handlers ...gdb.ModelHandler) *AdminMenuDao {
|
||||||
|
return &AdminMenuDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_menu",
|
||||||
|
columns: adminMenuColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Columns() AdminMenuColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminMenuDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminMenuDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
101
internal/dao/internal/admin_operation_log.go
Normal file
101
internal/dao/internal/admin_operation_log.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOperationLogDao is the data access object for the table admin_operation_log.
|
||||||
|
type AdminOperationLogDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminOperationLogColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminOperationLogColumns defines and stores column names for the table admin_operation_log.
|
||||||
|
type AdminOperationLogColumns struct {
|
||||||
|
Id string //
|
||||||
|
AdminUserId string //
|
||||||
|
Permission string //
|
||||||
|
Method string //
|
||||||
|
Path string //
|
||||||
|
Ip string //
|
||||||
|
RequestParam string //
|
||||||
|
DurationMs string //
|
||||||
|
StatusCode string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminOperationLogColumns holds the columns for the table admin_operation_log.
|
||||||
|
var adminOperationLogColumns = AdminOperationLogColumns{
|
||||||
|
Id: "id",
|
||||||
|
AdminUserId: "admin_user_id",
|
||||||
|
Permission: "permission",
|
||||||
|
Method: "method",
|
||||||
|
Path: "path",
|
||||||
|
Ip: "ip",
|
||||||
|
RequestParam: "request_param",
|
||||||
|
DurationMs: "duration_ms",
|
||||||
|
StatusCode: "status_code",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminOperationLogDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminOperationLogDao(handlers ...gdb.ModelHandler) *AdminOperationLogDao {
|
||||||
|
return &AdminOperationLogDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_operation_log",
|
||||||
|
columns: adminOperationLogColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminOperationLogDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminOperationLogDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminOperationLogDao) Columns() AdminOperationLogColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminOperationLogDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminOperationLogDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminOperationLogDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
91
internal/dao/internal/admin_role.go
Normal file
91
internal/dao/internal/admin_role.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleDao is the data access object for the table admin_role.
|
||||||
|
type AdminRoleDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminRoleColumns defines and stores column names for the table admin_role.
|
||||||
|
type AdminRoleColumns struct {
|
||||||
|
Id string //
|
||||||
|
Code string //
|
||||||
|
Name string //
|
||||||
|
Status string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminRoleColumns holds the columns for the table admin_role.
|
||||||
|
var adminRoleColumns = AdminRoleColumns{
|
||||||
|
Id: "id",
|
||||||
|
Code: "code",
|
||||||
|
Name: "name",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminRoleDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminRoleDao(handlers ...gdb.ModelHandler) *AdminRoleDao {
|
||||||
|
return &AdminRoleDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_role",
|
||||||
|
columns: adminRoleColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Columns() AdminRoleColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminRoleDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminRoleDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
89
internal/dao/internal/admin_role_menu.go
Normal file
89
internal/dao/internal/admin_role_menu.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleMenuDao is the data access object for the table admin_role_menu.
|
||||||
|
type AdminRoleMenuDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminRoleMenuColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminRoleMenuColumns defines and stores column names for the table admin_role_menu.
|
||||||
|
type AdminRoleMenuColumns struct {
|
||||||
|
Id string //
|
||||||
|
RoleId string //
|
||||||
|
MenuId string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminRoleMenuColumns holds the columns for the table admin_role_menu.
|
||||||
|
var adminRoleMenuColumns = AdminRoleMenuColumns{
|
||||||
|
Id: "id",
|
||||||
|
RoleId: "role_id",
|
||||||
|
MenuId: "menu_id",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminRoleMenuDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminRoleMenuDao(handlers ...gdb.ModelHandler) *AdminRoleMenuDao {
|
||||||
|
return &AdminRoleMenuDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_role_menu",
|
||||||
|
columns: adminRoleMenuColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Columns() AdminRoleMenuColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminRoleMenuDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminRoleMenuDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminRoleMenuDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
95
internal/dao/internal/admin_user.go
Normal file
95
internal/dao/internal/admin_user.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUserDao is the data access object for the table admin_user.
|
||||||
|
type AdminUserDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminUserColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminUserColumns defines and stores column names for the table admin_user.
|
||||||
|
type AdminUserColumns struct {
|
||||||
|
Id string //
|
||||||
|
Username string //
|
||||||
|
PasswordHash string //
|
||||||
|
Nickname string //
|
||||||
|
Status string //
|
||||||
|
LastLoginAt string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminUserColumns holds the columns for the table admin_user.
|
||||||
|
var adminUserColumns = AdminUserColumns{
|
||||||
|
Id: "id",
|
||||||
|
Username: "username",
|
||||||
|
PasswordHash: "password_hash",
|
||||||
|
Nickname: "nickname",
|
||||||
|
Status: "status",
|
||||||
|
LastLoginAt: "last_login_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminUserDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminUserDao(handlers ...gdb.ModelHandler) *AdminUserDao {
|
||||||
|
return &AdminUserDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_user",
|
||||||
|
columns: adminUserColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminUserDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminUserDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminUserDao) Columns() AdminUserColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminUserDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminUserDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
89
internal/dao/internal/admin_user_role.go
Normal file
89
internal/dao/internal/admin_user_role.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUserRoleDao is the data access object for the table admin_user_role.
|
||||||
|
type AdminUserRoleDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AdminUserRoleColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AdminUserRoleColumns defines and stores column names for the table admin_user_role.
|
||||||
|
type AdminUserRoleColumns struct {
|
||||||
|
Id string //
|
||||||
|
AdminUserId string //
|
||||||
|
RoleId string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// adminUserRoleColumns holds the columns for the table admin_user_role.
|
||||||
|
var adminUserRoleColumns = AdminUserRoleColumns{
|
||||||
|
Id: "id",
|
||||||
|
AdminUserId: "admin_user_id",
|
||||||
|
RoleId: "role_id",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAdminUserRoleDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAdminUserRoleDao(handlers ...gdb.ModelHandler) *AdminUserRoleDao {
|
||||||
|
return &AdminUserRoleDao{
|
||||||
|
group: "default",
|
||||||
|
table: "admin_user_role",
|
||||||
|
columns: adminUserRoleColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AdminUserRoleDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AdminUserRoleDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AdminUserRoleDao) Columns() AdminUserRoleColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AdminUserRoleDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AdminUserRoleDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AdminUserRoleDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
97
internal/dao/internal/auth_refresh_session.go
Normal file
97
internal/dao/internal/auth_refresh_session.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthRefreshSessionDao is the data access object for the table auth_refresh_session.
|
||||||
|
type AuthRefreshSessionDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns AuthRefreshSessionColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// AuthRefreshSessionColumns defines and stores column names for the table auth_refresh_session.
|
||||||
|
type AuthRefreshSessionColumns struct {
|
||||||
|
Id string //
|
||||||
|
SubjectId string // ????????? ID
|
||||||
|
Scope string // user/admin
|
||||||
|
Terminal string // mini/h5/app
|
||||||
|
Jti string // JWT ??????
|
||||||
|
ExpiredAt string //
|
||||||
|
RevokedAt string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// authRefreshSessionColumns holds the columns for the table auth_refresh_session.
|
||||||
|
var authRefreshSessionColumns = AuthRefreshSessionColumns{
|
||||||
|
Id: "id",
|
||||||
|
SubjectId: "subject_id",
|
||||||
|
Scope: "scope",
|
||||||
|
Terminal: "terminal",
|
||||||
|
Jti: "jti",
|
||||||
|
ExpiredAt: "expired_at",
|
||||||
|
RevokedAt: "revoked_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAuthRefreshSessionDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewAuthRefreshSessionDao(handlers ...gdb.ModelHandler) *AuthRefreshSessionDao {
|
||||||
|
return &AuthRefreshSessionDao{
|
||||||
|
group: "default",
|
||||||
|
table: "auth_refresh_session",
|
||||||
|
columns: authRefreshSessionColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *AuthRefreshSessionDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *AuthRefreshSessionDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *AuthRefreshSessionDao) Columns() AuthRefreshSessionColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *AuthRefreshSessionDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *AuthRefreshSessionDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *AuthRefreshSessionDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
91
internal/dao/internal/content.go
Normal file
91
internal/dao/internal/content.go
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContentDao is the data access object for the table content.
|
||||||
|
type ContentDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns ContentColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// ContentColumns defines and stores column names for the table content.
|
||||||
|
type ContentColumns struct {
|
||||||
|
Id string //
|
||||||
|
Title string //
|
||||||
|
Body string //
|
||||||
|
Status string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// contentColumns holds the columns for the table content.
|
||||||
|
var contentColumns = ContentColumns{
|
||||||
|
Id: "id",
|
||||||
|
Title: "title",
|
||||||
|
Body: "body",
|
||||||
|
Status: "status",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContentDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewContentDao(handlers ...gdb.ModelHandler) *ContentDao {
|
||||||
|
return &ContentDao{
|
||||||
|
group: "default",
|
||||||
|
table: "content",
|
||||||
|
columns: contentColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *ContentDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *ContentDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *ContentDao) Columns() ContentColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *ContentDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *ContentDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *ContentDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
103
internal/dao/internal/user.go
Normal file
103
internal/dao/internal/user.go
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserDao is the data access object for the table user.
|
||||||
|
type UserDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns UserColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserColumns defines and stores column names for the table user.
|
||||||
|
type UserColumns struct {
|
||||||
|
Id string //
|
||||||
|
UnionId string //
|
||||||
|
OpenId string //
|
||||||
|
Mobile string //
|
||||||
|
Account string //
|
||||||
|
PasswordHash string //
|
||||||
|
Nickname string //
|
||||||
|
Avatar string //
|
||||||
|
Status string //
|
||||||
|
LastLoginAt string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// userColumns holds the columns for the table user.
|
||||||
|
var userColumns = UserColumns{
|
||||||
|
Id: "id",
|
||||||
|
UnionId: "union_id",
|
||||||
|
OpenId: "open_id",
|
||||||
|
Mobile: "mobile",
|
||||||
|
Account: "account",
|
||||||
|
PasswordHash: "password_hash",
|
||||||
|
Nickname: "nickname",
|
||||||
|
Avatar: "avatar",
|
||||||
|
Status: "status",
|
||||||
|
LastLoginAt: "last_login_at",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewUserDao(handlers ...gdb.ModelHandler) *UserDao {
|
||||||
|
return &UserDao{
|
||||||
|
group: "default",
|
||||||
|
table: "user",
|
||||||
|
columns: userColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *UserDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *UserDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *UserDao) Columns() UserColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *UserDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *UserDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *UserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
89
internal/dao/internal/user_favorite.go
Normal file
89
internal/dao/internal/user_favorite.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserFavoriteDao is the data access object for the table user_favorite.
|
||||||
|
type UserFavoriteDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns UserFavoriteColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserFavoriteColumns defines and stores column names for the table user_favorite.
|
||||||
|
type UserFavoriteColumns struct {
|
||||||
|
Id string //
|
||||||
|
UserId string //
|
||||||
|
ContentId string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// userFavoriteColumns holds the columns for the table user_favorite.
|
||||||
|
var userFavoriteColumns = UserFavoriteColumns{
|
||||||
|
Id: "id",
|
||||||
|
UserId: "user_id",
|
||||||
|
ContentId: "content_id",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserFavoriteDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewUserFavoriteDao(handlers ...gdb.ModelHandler) *UserFavoriteDao {
|
||||||
|
return &UserFavoriteDao{
|
||||||
|
group: "default",
|
||||||
|
table: "user_favorite",
|
||||||
|
columns: userFavoriteColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *UserFavoriteDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *UserFavoriteDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *UserFavoriteDao) Columns() UserFavoriteColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *UserFavoriteDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *UserFavoriteDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *UserFavoriteDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
93
internal/dao/internal/user_message.go
Normal file
93
internal/dao/internal/user_message.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// ==========================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserMessageDao is the data access object for the table user_message.
|
||||||
|
type UserMessageDao struct {
|
||||||
|
table string // table is the underlying table name of the DAO.
|
||||||
|
group string // group is the database configuration group name of the current DAO.
|
||||||
|
columns UserMessageColumns // columns contains all the column names of Table for convenient usage.
|
||||||
|
handlers []gdb.ModelHandler // handlers for customized model modification.
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserMessageColumns defines and stores column names for the table user_message.
|
||||||
|
type UserMessageColumns struct {
|
||||||
|
Id string //
|
||||||
|
UserId string //
|
||||||
|
Title string //
|
||||||
|
Content string //
|
||||||
|
IsRead string //
|
||||||
|
CreatedAt string //
|
||||||
|
UpdatedAt string //
|
||||||
|
DeletedAt string //
|
||||||
|
}
|
||||||
|
|
||||||
|
// userMessageColumns holds the columns for the table user_message.
|
||||||
|
var userMessageColumns = UserMessageColumns{
|
||||||
|
Id: "id",
|
||||||
|
UserId: "user_id",
|
||||||
|
Title: "title",
|
||||||
|
Content: "content",
|
||||||
|
IsRead: "is_read",
|
||||||
|
CreatedAt: "created_at",
|
||||||
|
UpdatedAt: "updated_at",
|
||||||
|
DeletedAt: "deleted_at",
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUserMessageDao creates and returns a new DAO object for table data access.
|
||||||
|
func NewUserMessageDao(handlers ...gdb.ModelHandler) *UserMessageDao {
|
||||||
|
return &UserMessageDao{
|
||||||
|
group: "default",
|
||||||
|
table: "user_message",
|
||||||
|
columns: userMessageColumns,
|
||||||
|
handlers: handlers,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DB retrieves and returns the underlying raw database management object of the current DAO.
|
||||||
|
func (dao *UserMessageDao) DB() gdb.DB {
|
||||||
|
return g.DB(dao.group)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Table returns the table name of the current DAO.
|
||||||
|
func (dao *UserMessageDao) Table() string {
|
||||||
|
return dao.table
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns returns all column names of the current DAO.
|
||||||
|
func (dao *UserMessageDao) Columns() UserMessageColumns {
|
||||||
|
return dao.columns
|
||||||
|
}
|
||||||
|
|
||||||
|
// Group returns the database configuration group name of the current DAO.
|
||||||
|
func (dao *UserMessageDao) Group() string {
|
||||||
|
return dao.group
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation.
|
||||||
|
func (dao *UserMessageDao) Ctx(ctx context.Context) *gdb.Model {
|
||||||
|
model := dao.DB().Model(dao.table)
|
||||||
|
for _, handler := range dao.handlers {
|
||||||
|
model = handler(model)
|
||||||
|
}
|
||||||
|
return model.Safe().Ctx(ctx)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Transaction wraps the transaction logic using function f.
|
||||||
|
// It rolls back the transaction and returns the error if function f returns a non-nil error.
|
||||||
|
// It commits the transaction and returns nil if function f returns nil.
|
||||||
|
//
|
||||||
|
// Note: Do not commit or roll back the transaction in function f,
|
||||||
|
// as it is automatically handled by this function.
|
||||||
|
func (dao *UserMessageDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) {
|
||||||
|
return dao.Ctx(ctx).Transaction(ctx, f)
|
||||||
|
}
|
||||||
22
internal/dao/user.go
Normal file
22
internal/dao/user.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// userDao is the data access object for the table user.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type userDao struct {
|
||||||
|
*internal.UserDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// User is a globally accessible object for table user operations.
|
||||||
|
User = userDao{internal.NewUserDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/user_favorite.go
Normal file
22
internal/dao/user_favorite.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// userFavoriteDao is the data access object for the table user_favorite.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type userFavoriteDao struct {
|
||||||
|
*internal.UserFavoriteDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// UserFavorite is a globally accessible object for table user_favorite operations.
|
||||||
|
UserFavorite = userFavoriteDao{internal.NewUserFavoriteDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
22
internal/dao/user_message.go
Normal file
22
internal/dao/user_message.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"service.xpcool.com/internal/dao/internal"
|
||||||
|
)
|
||||||
|
|
||||||
|
// userMessageDao is the data access object for the table user_message.
|
||||||
|
// You can define custom methods on it to extend its functionality as needed.
|
||||||
|
type userMessageDao struct {
|
||||||
|
*internal.UserMessageDao
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
// UserMessage is a globally accessible object for table user_message operations.
|
||||||
|
UserMessage = userMessageDao{internal.NewUserMessageDao()}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Add your custom methods and functionality below.
|
||||||
92
internal/library/jwt/jwt.go
Normal file
92
internal/library/jwt/jwt.go
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
// Package jwt implements HS256 JWT with Go standard crypto primitives.
|
||||||
|
package jwt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/base64"
|
||||||
|
"encoding/json"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Claims struct {
|
||||||
|
Subject uint64 `json:"sub"`
|
||||||
|
Scope string `json:"scope"`
|
||||||
|
Terminal string `json:"terminal,omitempty"`
|
||||||
|
Type string `json:"typ"`
|
||||||
|
ExpireAt int64 `json:"exp"`
|
||||||
|
IssuedAt int64 `json:"iat"`
|
||||||
|
JTI string `json:"jti,omitempty"` // 刷新令牌的唯一编号,用于数据库会话校验。
|
||||||
|
}
|
||||||
|
type Service struct {
|
||||||
|
secret []byte
|
||||||
|
accessTTL, refreshTTL time.Duration
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(ctx context.Context) *Service {
|
||||||
|
// 密钥和有效期由配置中心统一提供,生产环境必须通过环境变量覆盖。
|
||||||
|
return &Service{secret: []byte(g.Cfg().MustGet(ctx, "jwt.secret").String()), accessTTL: g.Cfg().MustGet(ctx, "jwt.accessExpire").Duration(), refreshTTL: g.Cfg().MustGet(ctx, "jwt.refreshExpire").Duration()}
|
||||||
|
}
|
||||||
|
func (s *Service) Issue(id uint64, scope, terminal string) (access, refresh string, expires int64, err error) {
|
||||||
|
// access token 只负责短期访问;refresh token 带唯一 JTI,用于可撤销的长期会话。
|
||||||
|
now := time.Now().Unix()
|
||||||
|
expires = now + int64(s.accessTTL.Seconds())
|
||||||
|
access, err = s.sign(Claims{Subject: id, Scope: scope, Terminal: terminal, Type: "access", ExpireAt: expires, IssuedAt: now})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
jti, err := newJTI()
|
||||||
|
if err != nil {
|
||||||
|
return "", "", 0, gerror.Wrap(err, "生成刷新令牌标识失败")
|
||||||
|
}
|
||||||
|
refresh, err = s.sign(Claims{Subject: id, Scope: scope, Terminal: terminal, Type: "refresh", ExpireAt: now + int64(s.refreshTTL.Seconds()), IssuedAt: now, JTI: jti})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
func (s *Service) Parse(token, typ, scope string) (*Claims, error) {
|
||||||
|
// 先使用常量时间比较校验签名,再解析声明,避免伪造令牌进入业务层。
|
||||||
|
parts := strings.Split(token, ".")
|
||||||
|
if len(parts) != 3 || !hmac.Equal([]byte(parts[2]), []byte(s.signature(parts[0]+"."+parts[1]))) {
|
||||||
|
return nil, gerror.New("invalid token")
|
||||||
|
}
|
||||||
|
raw, err := base64.RawURLEncoding.DecodeString(parts[1])
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "decode token")
|
||||||
|
}
|
||||||
|
var c Claims
|
||||||
|
if err = json.Unmarshal(raw, &c); err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "decode claims")
|
||||||
|
}
|
||||||
|
if c.ExpireAt < time.Now().Unix() || c.Type != typ || c.Scope != scope {
|
||||||
|
return nil, gerror.New("token expired or scope mismatch")
|
||||||
|
}
|
||||||
|
return &c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// newJTI 生成 256 位随机标识,编码后正好适配数据库 CHAR(43) 字段。
|
||||||
|
func newJTI() (string, error) {
|
||||||
|
b := make([]byte, 32)
|
||||||
|
if _, err := rand.Read(b); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return base64.RawURLEncoding.EncodeToString(b), nil
|
||||||
|
}
|
||||||
|
func (s *Service) sign(c Claims) (string, error) {
|
||||||
|
h := base64.RawURLEncoding.EncodeToString([]byte(`{"alg":"HS256","typ":"JWT"}`))
|
||||||
|
b, err := json.Marshal(c)
|
||||||
|
if err != nil {
|
||||||
|
return "", gerror.Wrap(err, "encode claims")
|
||||||
|
}
|
||||||
|
p := h + "." + base64.RawURLEncoding.EncodeToString(b)
|
||||||
|
return p + "." + s.signature(p), nil
|
||||||
|
}
|
||||||
|
func (s *Service) signature(input string) string {
|
||||||
|
mac := hmac.New(sha256.New, s.secret)
|
||||||
|
_, _ = mac.Write([]byte(input))
|
||||||
|
return base64.RawURLEncoding.EncodeToString(mac.Sum(nil))
|
||||||
|
}
|
||||||
13
internal/library/page/page.go
Normal file
13
internal/library/page/page.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package page
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultSize = 20
|
||||||
|
MaxSize = 100
|
||||||
|
)
|
||||||
|
|
||||||
|
type Input struct {
|
||||||
|
Page int `json:"page" v:"min:1#page must be >= 1"`
|
||||||
|
PageSize int `json:"pageSize" v:"min:1|max:100#pageSize must be 1-100"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (in Input) Offset() int { return (in.Page - 1) * in.PageSize }
|
||||||
11
internal/library/response/error.go
Normal file
11
internal/library/response/error.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error creates an error carrying a stable application code for global response handling.
|
||||||
|
func Error(code int, message string) error {
|
||||||
|
return gerror.NewCode(gcode.New(code, message, nil), message)
|
||||||
|
}
|
||||||
15
internal/library/response/response.go
Normal file
15
internal/library/response/response.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package response
|
||||||
|
|
||||||
|
import "github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
|
||||||
|
// Body is the only JSON envelope exposed by both API surfaces.
|
||||||
|
type Body struct {
|
||||||
|
Code int `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
Data any `json:"data,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func JSON(r *ghttp.Request, code int, message string, data any) {
|
||||||
|
r.Response.WriteJsonExit(Body{Code: code, Message: message, Data: data})
|
||||||
|
}
|
||||||
|
func OK(r *ghttp.Request, data any) { JSON(r, 0, "ok", data) }
|
||||||
71
internal/middleware/auth.go
Normal file
71
internal/middleware/auth.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"service.xpcool.com/internal/consts"
|
||||||
|
"service.xpcool.com/internal/library/jwt"
|
||||||
|
"service.xpcool.com/internal/library/response"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type contextKey string
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserIDKey contextKey = "userId"
|
||||||
|
AdminIDKey contextKey = "adminId"
|
||||||
|
PermissionKey contextKey = "permission"
|
||||||
|
)
|
||||||
|
|
||||||
|
func bearer(r *ghttp.Request) string {
|
||||||
|
// 统一从 Authorization: Bearer <token> 提取令牌。
|
||||||
|
return strings.TrimSpace(strings.TrimPrefix(r.Header.Get("Authorization"), "Bearer"))
|
||||||
|
}
|
||||||
|
func auditParam(raw string) string {
|
||||||
|
// 操作日志需要参数用于审计,但绝不记录密码、令牌和验证码等敏感字段。
|
||||||
|
lower := strings.ToLower(raw)
|
||||||
|
if strings.Contains(lower, "password") || strings.Contains(lower, "token") || strings.Contains(lower, "code") {
|
||||||
|
return "[redacted]"
|
||||||
|
}
|
||||||
|
return raw
|
||||||
|
}
|
||||||
|
func UserAuth(s *jwt.Service) ghttp.HandlerFunc {
|
||||||
|
// 用户端仅接受 scope=user 的 access token。
|
||||||
|
return func(r *ghttp.Request) {
|
||||||
|
c, err := s.Parse(bearer(r), "access", "user")
|
||||||
|
if err != nil {
|
||||||
|
response.JSON(r, consts.CodeUnauthorized, "login required", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.SetCtxVar(UserIDKey, c.Subject)
|
||||||
|
r.Middleware.Next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func AdminAuth(s *jwt.Service, permissionCheck func(context.Context, uint64, string) (bool, error), audit func(context.Context, uint64, string, string, string, string, string, int, int)) ghttp.HandlerFunc {
|
||||||
|
// 管理端在令牌通过后继续校验 X-Permission 对应的 RBAC 权限,并在请求结束后记审计日志。
|
||||||
|
return func(r *ghttp.Request) {
|
||||||
|
start := time.Now()
|
||||||
|
c, err := s.Parse(bearer(r), "access", "admin")
|
||||||
|
if err != nil {
|
||||||
|
response.JSON(r, consts.CodeUnauthorized, "admin login required", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
permission := r.Header.Get("X-Permission")
|
||||||
|
if permission == "" {
|
||||||
|
response.JSON(r, consts.CodeForbidden, "permission identifier required", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
ok, err := permissionCheck(r.Context(), c.Subject, permission)
|
||||||
|
if err != nil || !ok {
|
||||||
|
response.JSON(r, consts.CodeAdminPermissionDenied, "permission denied", nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
audit(r.Context(), c.Subject, permission, r.Method, r.URL.Path, r.GetClientIp(), auditParam(r.GetBodyString()), int(time.Since(start).Milliseconds()), r.Response.Status)
|
||||||
|
}()
|
||||||
|
r.SetCtxVar(AdminIDKey, c.Subject)
|
||||||
|
r.SetCtxVar(PermissionKey, permission)
|
||||||
|
r.Middleware.Next()
|
||||||
|
}
|
||||||
|
}
|
||||||
26
internal/middleware/common.go
Normal file
26
internal/middleware/common.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package middleware
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
|
"service.xpcool.com/internal/consts"
|
||||||
|
"service.xpcool.com/internal/library/response"
|
||||||
|
)
|
||||||
|
|
||||||
|
// CORS is deliberately mounted only on public HTTP route groups.
|
||||||
|
func CORS(r *ghttp.Request) {
|
||||||
|
r.Response.CORSDefault()
|
||||||
|
if r.Method == "OPTIONS" {
|
||||||
|
r.Response.WriteStatusExit(204)
|
||||||
|
}
|
||||||
|
r.Middleware.Next()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recover converts panics to the common envelope; server logs retain stack traces.
|
||||||
|
func Recover(r *ghttp.Request) {
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
response.JSON(r, consts.CodeInternal, "internal server error", nil)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
r.Middleware.Next()
|
||||||
|
}
|
||||||
0
internal/model/.gitkeep
Normal file
0
internal/model/.gitkeep
Normal file
0
internal/model/do/.gitkeep
Normal file
0
internal/model/do/.gitkeep
Normal file
26
internal/model/do/admin_menu.go
Normal file
26
internal/model/do/admin_menu.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMenu is the golang structure of table admin_menu for DAO operations like Where/Data.
|
||||||
|
type AdminMenu struct {
|
||||||
|
g.Meta `orm:"table:admin_menu, do:true"`
|
||||||
|
Id any //
|
||||||
|
ParentId any //
|
||||||
|
Name any //
|
||||||
|
Type any // 1 menu,2 api
|
||||||
|
Path any //
|
||||||
|
Permission any //
|
||||||
|
Sort any //
|
||||||
|
Status any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
27
internal/model/do/admin_operation_log.go
Normal file
27
internal/model/do/admin_operation_log.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOperationLog is the golang structure of table admin_operation_log for DAO operations like Where/Data.
|
||||||
|
type AdminOperationLog struct {
|
||||||
|
g.Meta `orm:"table:admin_operation_log, do:true"`
|
||||||
|
Id any //
|
||||||
|
AdminUserId any //
|
||||||
|
Permission any //
|
||||||
|
Method any //
|
||||||
|
Path any //
|
||||||
|
Ip any //
|
||||||
|
RequestParam any //
|
||||||
|
DurationMs any //
|
||||||
|
StatusCode any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
22
internal/model/do/admin_role.go
Normal file
22
internal/model/do/admin_role.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRole is the golang structure of table admin_role for DAO operations like Where/Data.
|
||||||
|
type AdminRole struct {
|
||||||
|
g.Meta `orm:"table:admin_role, do:true"`
|
||||||
|
Id any //
|
||||||
|
Code any //
|
||||||
|
Name any //
|
||||||
|
Status any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
21
internal/model/do/admin_role_menu.go
Normal file
21
internal/model/do/admin_role_menu.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleMenu is the golang structure of table admin_role_menu for DAO operations like Where/Data.
|
||||||
|
type AdminRoleMenu struct {
|
||||||
|
g.Meta `orm:"table:admin_role_menu, do:true"`
|
||||||
|
Id any //
|
||||||
|
RoleId any //
|
||||||
|
MenuId any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
24
internal/model/do/admin_user.go
Normal file
24
internal/model/do/admin_user.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUser is the golang structure of table admin_user for DAO operations like Where/Data.
|
||||||
|
type AdminUser struct {
|
||||||
|
g.Meta `orm:"table:admin_user, do:true"`
|
||||||
|
Id any //
|
||||||
|
Username any //
|
||||||
|
PasswordHash any //
|
||||||
|
Nickname any //
|
||||||
|
Status any //
|
||||||
|
LastLoginAt *gtime.Time //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
21
internal/model/do/admin_user_role.go
Normal file
21
internal/model/do/admin_user_role.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUserRole is the golang structure of table admin_user_role for DAO operations like Where/Data.
|
||||||
|
type AdminUserRole struct {
|
||||||
|
g.Meta `orm:"table:admin_user_role, do:true"`
|
||||||
|
Id any //
|
||||||
|
AdminUserId any //
|
||||||
|
RoleId any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
25
internal/model/do/auth_refresh_session.go
Normal file
25
internal/model/do/auth_refresh_session.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthRefreshSession is the golang structure of table auth_refresh_session for DAO operations like Where/Data.
|
||||||
|
type AuthRefreshSession struct {
|
||||||
|
g.Meta `orm:"table:auth_refresh_session, do:true"`
|
||||||
|
Id any //
|
||||||
|
SubjectId any // ????????? ID
|
||||||
|
Scope any // user/admin
|
||||||
|
Terminal any // mini/h5/app
|
||||||
|
Jti any // JWT ??????
|
||||||
|
ExpiredAt *gtime.Time //
|
||||||
|
RevokedAt *gtime.Time //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
22
internal/model/do/content.go
Normal file
22
internal/model/do/content.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Content is the golang structure of table content for DAO operations like Where/Data.
|
||||||
|
type Content struct {
|
||||||
|
g.Meta `orm:"table:content, do:true"`
|
||||||
|
Id any //
|
||||||
|
Title any //
|
||||||
|
Body any //
|
||||||
|
Status any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
28
internal/model/do/user.go
Normal file
28
internal/model/do/user.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// 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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User is the golang structure of table user for DAO operations like Where/Data.
|
||||||
|
type User struct {
|
||||||
|
g.Meta `orm:"table:user, do:true"`
|
||||||
|
Id any //
|
||||||
|
UnionId any //
|
||||||
|
OpenId any //
|
||||||
|
Mobile any //
|
||||||
|
Account any //
|
||||||
|
PasswordHash any //
|
||||||
|
Nickname any //
|
||||||
|
Avatar any //
|
||||||
|
Status any //
|
||||||
|
LastLoginAt *gtime.Time //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
21
internal/model/do/user_favorite.go
Normal file
21
internal/model/do/user_favorite.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserFavorite is the golang structure of table user_favorite for DAO operations like Where/Data.
|
||||||
|
type UserFavorite struct {
|
||||||
|
g.Meta `orm:"table:user_favorite, do:true"`
|
||||||
|
Id any //
|
||||||
|
UserId any //
|
||||||
|
ContentId any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
23
internal/model/do/user_message.go
Normal file
23
internal/model/do/user_message.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package do
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserMessage is the golang structure of table user_message for DAO operations like Where/Data.
|
||||||
|
type UserMessage struct {
|
||||||
|
g.Meta `orm:"table:user_message, do:true"`
|
||||||
|
Id any //
|
||||||
|
UserId any //
|
||||||
|
Title any //
|
||||||
|
Content any //
|
||||||
|
IsRead any //
|
||||||
|
CreatedAt *gtime.Time //
|
||||||
|
UpdatedAt *gtime.Time //
|
||||||
|
DeletedAt *gtime.Time //
|
||||||
|
}
|
||||||
9
internal/model/dto/auth.go
Normal file
9
internal/model/dto/auth.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
type UserLoginInput struct{ LoginType, Code, Mobile, VerifyCode, Account, Password, Terminal string }
|
||||||
|
type AdminLoginInput struct{ Username, Password string }
|
||||||
|
type TokenPair struct {
|
||||||
|
AccessToken string `json:"accessToken"`
|
||||||
|
RefreshToken string `json:"refreshToken"`
|
||||||
|
ExpiresIn int64 `json:"expiresIn"`
|
||||||
|
}
|
||||||
0
internal/model/entity/.gitkeep
Normal file
0
internal/model/entity/.gitkeep
Normal file
24
internal/model/entity/admin_menu.go
Normal file
24
internal/model/entity/admin_menu.go
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMenu is the golang structure for table admin_menu.
|
||||||
|
type AdminMenu struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
ParentId uint64 `json:"parentId" orm:"parent_id" description:""` //
|
||||||
|
Name string `json:"name" orm:"name" description:""` //
|
||||||
|
Type int `json:"type" orm:"type" description:"1 menu,2 api"` // 1 menu,2 api
|
||||||
|
Path string `json:"path" orm:"path" description:""` //
|
||||||
|
Permission string `json:"permission" orm:"permission" description:""` //
|
||||||
|
Sort int `json:"sort" orm:"sort" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
25
internal/model/entity/admin_operation_log.go
Normal file
25
internal/model/entity/admin_operation_log.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOperationLog is the golang structure for table admin_operation_log.
|
||||||
|
type AdminOperationLog struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
AdminUserId uint64 `json:"adminUserId" orm:"admin_user_id" description:""` //
|
||||||
|
Permission string `json:"permission" orm:"permission" description:""` //
|
||||||
|
Method string `json:"method" orm:"method" description:""` //
|
||||||
|
Path string `json:"path" orm:"path" description:""` //
|
||||||
|
Ip string `json:"ip" orm:"ip" description:""` //
|
||||||
|
RequestParam string `json:"requestParam" orm:"request_param" description:""` //
|
||||||
|
DurationMs uint `json:"durationMs" orm:"duration_ms" description:""` //
|
||||||
|
StatusCode int `json:"statusCode" orm:"status_code" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
20
internal/model/entity/admin_role.go
Normal file
20
internal/model/entity/admin_role.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRole is the golang structure for table admin_role.
|
||||||
|
type AdminRole struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
Code string `json:"code" orm:"code" description:""` //
|
||||||
|
Name string `json:"name" orm:"name" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
19
internal/model/entity/admin_role_menu.go
Normal file
19
internal/model/entity/admin_role_menu.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleMenu is the golang structure for table admin_role_menu.
|
||||||
|
type AdminRoleMenu struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
RoleId uint64 `json:"roleId" orm:"role_id" description:""` //
|
||||||
|
MenuId uint64 `json:"menuId" orm:"menu_id" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
22
internal/model/entity/admin_user.go
Normal file
22
internal/model/entity/admin_user.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUser is the golang structure for table admin_user.
|
||||||
|
type AdminUser struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
Username string `json:"username" orm:"username" description:""` //
|
||||||
|
PasswordHash string `json:"passwordHash" orm:"password_hash" description:""` //
|
||||||
|
Nickname string `json:"nickname" orm:"nickname" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:""` //
|
||||||
|
LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
19
internal/model/entity/admin_user_role.go
Normal file
19
internal/model/entity/admin_user_role.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUserRole is the golang structure for table admin_user_role.
|
||||||
|
type AdminUserRole struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
AdminUserId uint64 `json:"adminUserId" orm:"admin_user_id" description:""` //
|
||||||
|
RoleId uint64 `json:"roleId" orm:"role_id" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
23
internal/model/entity/auth_refresh_session.go
Normal file
23
internal/model/entity/auth_refresh_session.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthRefreshSession is the golang structure for table auth_refresh_session.
|
||||||
|
type AuthRefreshSession struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
SubjectId uint64 `json:"subjectId" orm:"subject_id" description:"????????? ID"` // ????????? ID
|
||||||
|
Scope string `json:"scope" orm:"scope" description:"user/admin"` // user/admin
|
||||||
|
Terminal string `json:"terminal" orm:"terminal" description:"mini/h5/app"` // mini/h5/app
|
||||||
|
Jti string `json:"jti" orm:"jti" description:"JWT ??????"` // JWT ??????
|
||||||
|
ExpiredAt *gtime.Time `json:"expiredAt" orm:"expired_at" description:""` //
|
||||||
|
RevokedAt *gtime.Time `json:"revokedAt" orm:"revoked_at" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
20
internal/model/entity/content.go
Normal file
20
internal/model/entity/content.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Content is the golang structure for table content.
|
||||||
|
type Content struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
Title string `json:"title" orm:"title" description:""` //
|
||||||
|
Body string `json:"body" orm:"body" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
26
internal/model/entity/user.go
Normal file
26
internal/model/entity/user.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User is the golang structure for table user.
|
||||||
|
type User struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
UnionId string `json:"unionId" orm:"union_id" description:""` //
|
||||||
|
OpenId string `json:"openId" orm:"open_id" description:""` //
|
||||||
|
Mobile string `json:"mobile" orm:"mobile" description:""` //
|
||||||
|
Account string `json:"account" orm:"account" description:""` //
|
||||||
|
PasswordHash string `json:"passwordHash" orm:"password_hash" description:""` //
|
||||||
|
Nickname string `json:"nickname" orm:"nickname" description:""` //
|
||||||
|
Avatar string `json:"avatar" orm:"avatar" description:""` //
|
||||||
|
Status int `json:"status" orm:"status" description:""` //
|
||||||
|
LastLoginAt *gtime.Time `json:"lastLoginAt" orm:"last_login_at" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
19
internal/model/entity/user_favorite.go
Normal file
19
internal/model/entity/user_favorite.go
Normal file
@ -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"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserFavorite is the golang structure for table user_favorite.
|
||||||
|
type UserFavorite struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
UserId uint64 `json:"userId" orm:"user_id" description:""` //
|
||||||
|
ContentId uint64 `json:"contentId" orm:"content_id" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
21
internal/model/entity/user_message.go
Normal file
21
internal/model/entity/user_message.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package entity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserMessage is the golang structure for table user_message.
|
||||||
|
type UserMessage struct {
|
||||||
|
Id uint64 `json:"id" orm:"id" description:""` //
|
||||||
|
UserId uint64 `json:"userId" orm:"user_id" description:""` //
|
||||||
|
Title string `json:"title" orm:"title" description:""` //
|
||||||
|
Content string `json:"content" orm:"content" description:""` //
|
||||||
|
IsRead int `json:"isRead" orm:"is_read" description:""` //
|
||||||
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:""` //
|
||||||
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:""` //
|
||||||
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:""` //
|
||||||
|
}
|
||||||
9
internal/model/vo/auth.go
Normal file
9
internal/model/vo/auth.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package vo
|
||||||
|
|
||||||
|
import "service.xpcool.com/internal/model/dto"
|
||||||
|
|
||||||
|
type Login struct {
|
||||||
|
Token dto.TokenPair `json:"token"`
|
||||||
|
UserID uint64 `json:"userId"`
|
||||||
|
Terminal string `json:"terminal,omitempty"`
|
||||||
|
}
|
||||||
0
internal/service/.gitkeep
Normal file
0
internal/service/.gitkeep
Normal file
20
internal/service/admin_audit.go
Normal file
20
internal/service/admin_audit.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/os/glog"
|
||||||
|
"service.xpcool.com/internal/dao"
|
||||||
|
"service.xpcool.com/internal/model/do"
|
||||||
|
)
|
||||||
|
|
||||||
|
type adminAudit struct{}
|
||||||
|
|
||||||
|
func NewAdminAudit() IAdminAudit { return &adminAudit{} }
|
||||||
|
|
||||||
|
// Record 采用尽力而为策略:审计落库失败会记录系统日志,但不影响原业务请求结果。
|
||||||
|
func (a *adminAudit) Record(ctx context.Context, e AuditEvent) {
|
||||||
|
_, err := dao.AdminOperationLog.Ctx(ctx).Data(do.AdminOperationLog{AdminUserId: e.AdminID, Permission: e.Permission, Method: e.Method, Path: e.Path, Ip: e.IP, RequestParam: e.Param, DurationMs: e.DurationMS, StatusCode: e.StatusCode}).Insert()
|
||||||
|
if err != nil {
|
||||||
|
glog.Error(ctx, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
44
internal/service/admin_auth.go
Normal file
44
internal/service/admin_auth.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
"service.xpcool.com/internal/consts"
|
||||||
|
"service.xpcool.com/internal/dao"
|
||||||
|
"service.xpcool.com/internal/library/jwt"
|
||||||
|
"service.xpcool.com/internal/library/response"
|
||||||
|
"service.xpcool.com/internal/model/do"
|
||||||
|
"service.xpcool.com/internal/model/dto"
|
||||||
|
"service.xpcool.com/internal/model/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
type adminAuth struct{ tokens *jwt.Service }
|
||||||
|
|
||||||
|
func NewAdminAuth(tokens *jwt.Service) IAdminAuth { return &adminAuth{tokens} }
|
||||||
|
func (s *adminAuth) Login(ctx context.Context, in dto.AdminLoginInput) (*dto.TokenPair, uint64, error) {
|
||||||
|
// 管理端只允许账号密码登录,状态异常或密码错误均返回统一错误,避免枚举账号。
|
||||||
|
var a entity.AdminUser
|
||||||
|
if err := dao.AdminUser.Ctx(ctx).Where(do.AdminUser{Username: in.Username}).Scan(&a); err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "query administrator")
|
||||||
|
}
|
||||||
|
if a.Id == 0 {
|
||||||
|
return nil, 0, response.Error(consts.CodeAdminNotFound, "administrator not found")
|
||||||
|
}
|
||||||
|
if a.Status != 1 || bcrypt.CompareHashAndPassword([]byte(a.PasswordHash), []byte(in.Password)) != nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeAdminPasswordWrong, "username or password incorrect")
|
||||||
|
}
|
||||||
|
access, refresh, exp, err := s.tokens.Issue(a.Id, "admin", "")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "issue token")
|
||||||
|
}
|
||||||
|
return &dto.TokenPair{AccessToken: access, RefreshToken: refresh, ExpiresIn: exp}, a.Id, nil
|
||||||
|
}
|
||||||
|
func (s *adminAuth) HasPermission(ctx context.Context, adminID uint64, permission string) (bool, error) {
|
||||||
|
// 多角色权限通过管理员-角色-菜单三表关联查询,菜单中的 permission 即接口权限标识。
|
||||||
|
count, err := dao.AdminUserRole.Ctx(ctx).As("ur").LeftJoin("admin_role_menu rm", "ur.role_id=rm.role_id").LeftJoin("admin_menu m", "rm.menu_id=m.id").Where("ur.admin_user_id", adminID).Where("m.permission", permission).Where("m.status", 1).Count()
|
||||||
|
if err != nil {
|
||||||
|
return false, gerror.Wrap(err, "check permission")
|
||||||
|
}
|
||||||
|
return count > 0, nil
|
||||||
|
}
|
||||||
51
internal/service/auth.go
Normal file
51
internal/service/auth.go
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"service.xpcool.com/internal/model/dto"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IUserAuth interface {
|
||||||
|
Login(context.Context, dto.UserLoginInput) (*dto.TokenPair, uint64, error)
|
||||||
|
Refresh(context.Context, string) (*dto.TokenPair, uint64, error)
|
||||||
|
}
|
||||||
|
type IAdminAuth interface {
|
||||||
|
Login(context.Context, dto.AdminLoginInput) (*dto.TokenPair, uint64, error)
|
||||||
|
HasPermission(context.Context, uint64, string) (bool, error)
|
||||||
|
}
|
||||||
|
type AuditEvent struct {
|
||||||
|
AdminID uint64
|
||||||
|
Permission, Method, Path, IP, Param string
|
||||||
|
DurationMS, StatusCode int
|
||||||
|
}
|
||||||
|
type IAdminAudit interface {
|
||||||
|
Record(context.Context, AuditEvent)
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
localUserAuth IUserAuth
|
||||||
|
localAdminAuth IAdminAuth
|
||||||
|
localAdminAudit IAdminAudit
|
||||||
|
)
|
||||||
|
|
||||||
|
func UserAuth() IUserAuth {
|
||||||
|
if localUserAuth == nil {
|
||||||
|
panic("UserAuth implementation not registered")
|
||||||
|
}
|
||||||
|
return localUserAuth
|
||||||
|
}
|
||||||
|
func RegisterUserAuth(i IUserAuth) { localUserAuth = i }
|
||||||
|
func AdminAuth() IAdminAuth {
|
||||||
|
if localAdminAuth == nil {
|
||||||
|
panic("AdminAuth implementation not registered")
|
||||||
|
}
|
||||||
|
return localAdminAuth
|
||||||
|
}
|
||||||
|
func RegisterAdminAuth(i IAdminAuth) { localAdminAuth = i }
|
||||||
|
func AdminAudit() IAdminAudit {
|
||||||
|
if localAdminAudit == nil {
|
||||||
|
panic("AdminAudit implementation not registered")
|
||||||
|
}
|
||||||
|
return localAdminAudit
|
||||||
|
}
|
||||||
|
func RegisterAdminAudit(i IAdminAudit) { localAdminAudit = i }
|
||||||
131
internal/service/user_auth.go
Normal file
131
internal/service/user_auth.go
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
|
"golang.org/x/crypto/bcrypt"
|
||||||
|
"service.xpcool.com/internal/consts"
|
||||||
|
"service.xpcool.com/internal/dao"
|
||||||
|
"service.xpcool.com/internal/library/jwt"
|
||||||
|
"service.xpcool.com/internal/library/response"
|
||||||
|
"service.xpcool.com/internal/model/do"
|
||||||
|
"service.xpcool.com/internal/model/dto"
|
||||||
|
"service.xpcool.com/internal/model/entity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WechatResolver 抽象微信 code 换 openid,避免业务层依赖具体 HTTP 实现。
|
||||||
|
type WechatResolver interface {
|
||||||
|
OpenID(context.Context, string) (string, error)
|
||||||
|
}
|
||||||
|
type SMSVerifier interface {
|
||||||
|
Verify(context.Context, string, string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// userAuth 负责用户三种登录方式及令牌签发,不承担第三方平台通信细节。
|
||||||
|
type userAuth struct {
|
||||||
|
tokens *jwt.Service
|
||||||
|
wechat WechatResolver
|
||||||
|
sms SMSVerifier
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserAuth(tokens *jwt.Service, wechat WechatResolver, sms SMSVerifier) IUserAuth {
|
||||||
|
return &userAuth{tokens, wechat, sms}
|
||||||
|
}
|
||||||
|
func (s *userAuth) Login(ctx context.Context, in dto.UserLoginInput) (*dto.TokenPair, uint64, error) {
|
||||||
|
var u entity.User
|
||||||
|
var err error
|
||||||
|
switch in.LoginType {
|
||||||
|
case "wechat":
|
||||||
|
// 微信首次授权成功后按 openid 自动创建用户。
|
||||||
|
if s.wechat == nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeInternal, "wechat provider not configured")
|
||||||
|
}
|
||||||
|
openID, e := s.wechat.OpenID(ctx, in.Code)
|
||||||
|
if e != nil {
|
||||||
|
return nil, 0, gerror.Wrap(e, "wechat login")
|
||||||
|
}
|
||||||
|
err = dao.User.Ctx(ctx).Where(do.User{OpenId: openID}).Scan(&u)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "query user")
|
||||||
|
}
|
||||||
|
if u.Id == 0 {
|
||||||
|
id, e := dao.User.Ctx(ctx).Data(do.User{OpenId: openID, Nickname: "微信用户", Status: 1}).InsertAndGetId()
|
||||||
|
if e != nil {
|
||||||
|
return nil, 0, gerror.Wrap(e, "create user")
|
||||||
|
}
|
||||||
|
u.Id = uint64(id)
|
||||||
|
}
|
||||||
|
case "mobile":
|
||||||
|
// 验证码由注入的服务校验,校验成功后按手机号自动注册。
|
||||||
|
if s.sms == nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeInternal, "sms provider not configured")
|
||||||
|
}
|
||||||
|
if err = s.sms.Verify(ctx, in.Mobile, in.VerifyCode); err != nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeInvalidParam, "invalid verification code")
|
||||||
|
}
|
||||||
|
err = dao.User.Ctx(ctx).Where(do.User{Mobile: in.Mobile}).Scan(&u)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "query user")
|
||||||
|
}
|
||||||
|
if u.Id == 0 {
|
||||||
|
id, e := dao.User.Ctx(ctx).Data(do.User{Mobile: in.Mobile, Nickname: "用户" + in.Mobile[7:], Status: 1}).InsertAndGetId()
|
||||||
|
if e != nil {
|
||||||
|
return nil, 0, gerror.Wrap(e, "create user")
|
||||||
|
}
|
||||||
|
u.Id = uint64(id)
|
||||||
|
}
|
||||||
|
case "password":
|
||||||
|
// 密码只使用 bcrypt 比对哈希值,任何场景都不回传或记录明文。
|
||||||
|
err = dao.User.Ctx(ctx).Where(do.User{Account: in.Account}).Scan(&u)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "query user")
|
||||||
|
}
|
||||||
|
if u.Id == 0 || bcrypt.CompareHashAndPassword([]byte(u.PasswordHash), []byte(in.Password)) != nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeUserPasswordWrong, "account or password incorrect")
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return nil, 0, response.Error(consts.CodeUserLoginType, "unsupported login type")
|
||||||
|
}
|
||||||
|
if u.Status != 1 {
|
||||||
|
return nil, 0, response.Error(consts.CodeForbidden, "user disabled")
|
||||||
|
}
|
||||||
|
_, err = dao.User.Ctx(ctx).Where(do.User{Id: u.Id}).Data(do.User{LastLoginAt: gtime.Now()}).Update()
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "update login time")
|
||||||
|
}
|
||||||
|
return s.issue(ctx, u.Id, in.Terminal)
|
||||||
|
}
|
||||||
|
func (s *userAuth) Refresh(ctx context.Context, refresh string) (*dto.TokenPair, uint64, error) {
|
||||||
|
// 刷新时先校验 JWT,再以 JTI 原子撤销旧会话,实现单次使用的令牌轮换。
|
||||||
|
c, err := s.tokens.Parse(refresh, "refresh", "user")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, response.Error(consts.CodeUnauthorized, "invalid refresh token")
|
||||||
|
}
|
||||||
|
result, err := dao.AuthRefreshSession.Ctx(ctx).Where(do.AuthRefreshSession{Jti: c.JTI}).WhereNull("revoked_at").Data(do.AuthRefreshSession{RevokedAt: gtime.Now()}).Update()
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "撤销旧刷新令牌失败")
|
||||||
|
}
|
||||||
|
affected, err := result.RowsAffected()
|
||||||
|
if err != nil || affected != 1 {
|
||||||
|
return nil, 0, response.Error(consts.CodeUnauthorized, "刷新令牌已失效")
|
||||||
|
}
|
||||||
|
return s.issue(ctx, c.Subject, c.Terminal)
|
||||||
|
}
|
||||||
|
|
||||||
|
// issue 签发 JWT 后把 refresh token 的 JTI 落库,确保可以撤销和追踪设备会话。
|
||||||
|
func (s *userAuth) issue(ctx context.Context, id uint64, terminal string) (*dto.TokenPair, uint64, error) {
|
||||||
|
a, r, exp, err := s.tokens.Issue(id, "user", terminal)
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "issue token")
|
||||||
|
}
|
||||||
|
claims, err := s.tokens.Parse(r, "refresh", "user")
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "解析新刷新令牌失败")
|
||||||
|
}
|
||||||
|
_, err = dao.AuthRefreshSession.Ctx(ctx).Data(do.AuthRefreshSession{SubjectId: id, Scope: "user", Terminal: terminal, Jti: claims.JTI, ExpiredAt: gtime.NewFromTimeStamp(claims.ExpireAt)}).Insert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, 0, gerror.Wrap(err, "保存刷新令牌会话失败")
|
||||||
|
}
|
||||||
|
return &dto.TokenPair{AccessToken: a, RefreshToken: r, ExpiresIn: exp}, id, nil
|
||||||
|
}
|
||||||
133
internal/table/admin_menu.go
Normal file
133
internal/table/admin_menu.go
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminMenu defines the fields of table "admin_menu" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminMenu = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"parent_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "parent_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: "0",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "name",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "type",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "1 menu,2 api",
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "path",
|
||||||
|
Type: "varchar(255)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"permission": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "permission",
|
||||||
|
Type: "varchar(128)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"sort": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "sort",
|
||||||
|
Type: "int",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "0",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "status",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "1",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 8,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 9,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 10,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminMenuTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminMenuTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_menu", AdminMenu, schema...)
|
||||||
|
}
|
||||||
143
internal/table/admin_operation_log.go
Normal file
143
internal/table/admin_operation_log.go
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminOperationLog defines the fields of table "admin_operation_log" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminOperationLog = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"admin_user_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "admin_user_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"permission": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "permission",
|
||||||
|
Type: "varchar(128)",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"method": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "method",
|
||||||
|
Type: "varchar(12)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"path": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "path",
|
||||||
|
Type: "varchar(255)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"ip": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "ip",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"request_param": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "request_param",
|
||||||
|
Type: "json",
|
||||||
|
Null: true,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"duration_ms": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "duration_ms",
|
||||||
|
Type: "int unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "0",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status_code": {
|
||||||
|
Index: 8,
|
||||||
|
Name: "status_code",
|
||||||
|
Type: "int",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "0",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 9,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 10,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 11,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminOperationLogTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminOperationLogTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_operation_log", AdminOperationLog, schema...)
|
||||||
|
}
|
||||||
93
internal/table/admin_role.go
Normal file
93
internal/table/admin_role.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRole defines the fields of table "admin_role" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminRole = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"code": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "code",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "name",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "status",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "1",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminRoleTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminRoleTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_role", AdminRole, schema...)
|
||||||
|
}
|
||||||
83
internal/table/admin_role_menu.go
Normal file
83
internal/table/admin_role_menu.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminRoleMenu defines the fields of table "admin_role_menu" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminRoleMenu = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"role_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "role_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"menu_id": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "menu_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminRoleMenuTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminRoleMenuTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_role_menu", AdminRoleMenu, schema...)
|
||||||
|
}
|
||||||
113
internal/table/admin_user.go
Normal file
113
internal/table/admin_user.go
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUser defines the fields of table "admin_user" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminUser = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"username": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "username",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"password_hash": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "password_hash",
|
||||||
|
Type: "varchar(100)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"nickname": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "nickname",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "status",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: "1",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"last_login_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "last_login_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 8,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminUserTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminUserTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_user", AdminUser, schema...)
|
||||||
|
}
|
||||||
83
internal/table/admin_user_role.go
Normal file
83
internal/table/admin_user_role.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AdminUserRole defines the fields of table "admin_user_role" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AdminUserRole = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"admin_user_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "admin_user_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"role_id": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "role_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAdminUserRoleTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAdminUserRoleTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "admin_user_role", AdminUserRole, schema...)
|
||||||
|
}
|
||||||
123
internal/table/auth_refresh_session.go
Normal file
123
internal/table/auth_refresh_session.go
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AuthRefreshSession defines the fields of table "auth_refresh_session" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var AuthRefreshSession = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"subject_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "subject_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "????????? ID",
|
||||||
|
},
|
||||||
|
"scope": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "scope",
|
||||||
|
Type: "varchar(16)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "user/admin",
|
||||||
|
},
|
||||||
|
"terminal": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "terminal",
|
||||||
|
Type: "varchar(16)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "mini/h5/app",
|
||||||
|
},
|
||||||
|
"jti": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "jti",
|
||||||
|
Type: "char(43)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "JWT ??????",
|
||||||
|
},
|
||||||
|
"expired_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "expired_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"revoked_at": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "revoked_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 8,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 9,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetAuthRefreshSessionTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetAuthRefreshSessionTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "auth_refresh_session", AuthRefreshSession, schema...)
|
||||||
|
}
|
||||||
93
internal/table/content.go
Normal file
93
internal/table/content.go
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Content defines the fields of table "content" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var Content = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "title",
|
||||||
|
Type: "varchar(200)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"body": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "body",
|
||||||
|
Type: "longtext",
|
||||||
|
Null: true,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "status",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: "1",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetContentTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetContentTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "content", Content, schema...)
|
||||||
|
}
|
||||||
153
internal/table/user.go
Normal file
153
internal/table/user.go
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// User defines the fields of table "user" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var User = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"union_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "union_id",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"open_id": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "open_id",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"mobile": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "mobile",
|
||||||
|
Type: "varchar(20)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"account": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "account",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "UNI",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"password_hash": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "password_hash",
|
||||||
|
Type: "varchar(100)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"nickname": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "nickname",
|
||||||
|
Type: "varchar(64)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"avatar": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "avatar",
|
||||||
|
Type: "varchar(512)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"status": {
|
||||||
|
Index: 8,
|
||||||
|
Name: "status",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: "1",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"last_login_at": {
|
||||||
|
Index: 9,
|
||||||
|
Name: "last_login_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 10,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 11,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 12,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetUserTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "user", User, schema...)
|
||||||
|
}
|
||||||
83
internal/table/user_favorite.go
Normal file
83
internal/table/user_favorite.go
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserFavorite defines the fields of table "user_favorite" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var UserFavorite = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "user_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"content_id": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "content_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserFavoriteTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetUserFavoriteTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "user_favorite", UserFavorite, schema...)
|
||||||
|
}
|
||||||
103
internal/table/user_message.go
Normal file
103
internal/table/user_message.go
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
// =================================================================================
|
||||||
|
// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed.
|
||||||
|
// =================================================================================
|
||||||
|
|
||||||
|
package table
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserMessage defines the fields of table "user_message" with their properties.
|
||||||
|
// This map is used internally by GoFrame ORM to understand table structure.
|
||||||
|
var UserMessage = map[string]*gdb.TableField{
|
||||||
|
"id": {
|
||||||
|
Index: 0,
|
||||||
|
Name: "id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "PRI",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "auto_increment",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"user_id": {
|
||||||
|
Index: 1,
|
||||||
|
Name: "user_id",
|
||||||
|
Type: "bigint unsigned",
|
||||||
|
Null: false,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
Index: 2,
|
||||||
|
Name: "title",
|
||||||
|
Type: "varchar(200)",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
Index: 3,
|
||||||
|
Name: "content",
|
||||||
|
Type: "text",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"is_read": {
|
||||||
|
Index: 4,
|
||||||
|
Name: "is_read",
|
||||||
|
Type: "tinyint",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: "0",
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
Index: 5,
|
||||||
|
Name: "created_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"updated_at": {
|
||||||
|
Index: 6,
|
||||||
|
Name: "updated_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: false,
|
||||||
|
Key: "",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
"deleted_at": {
|
||||||
|
Index: 7,
|
||||||
|
Name: "deleted_at",
|
||||||
|
Type: "datetime",
|
||||||
|
Null: true,
|
||||||
|
Key: "MUL",
|
||||||
|
Default: nil,
|
||||||
|
Extra: "",
|
||||||
|
Comment: "",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetUserMessageTableFields registers the table fields definition to the database instance.
|
||||||
|
// db: database instance that implements gdb.DB interface.
|
||||||
|
// schema: optional schema/namespace name, especially for databases that support schemas.
|
||||||
|
func SetUserMessageTableFields(ctx context.Context, db gdb.DB, schema ...string) error {
|
||||||
|
return db.GetCore().SetTableFields(ctx, "user_message", UserMessage, schema...)
|
||||||
|
}
|
||||||
11
main.go
Normal file
11
main.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
|
|
||||||
|
"service.xpcool.com/internal/cmd"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cmd.Main.Run(gctx.GetInitCtx())
|
||||||
|
}
|
||||||
13
manifest/config/config.dev.yaml
Normal file
13
manifest/config/config.dev.yaml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
server:
|
||||||
|
address: ":8000"
|
||||||
|
openapiPath: "/api.json"
|
||||||
|
swaggerPath: "/swagger"
|
||||||
|
logger: { level: "all", stdout: true }
|
||||||
|
database:
|
||||||
|
default:
|
||||||
|
link: "${DB_DSN}"
|
||||||
|
jwt:
|
||||||
|
# Must be overridden by JWT_SECRET in every deployed environment.
|
||||||
|
secret: "${JWT_SECRET}"
|
||||||
|
accessExpire: "2h"
|
||||||
|
refreshExpire: "720h"
|
||||||
4
manifest/config/config.prod.yaml
Normal file
4
manifest/config/config.prod.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
server: { address: ":8000", openapiPath: "/api.json", swaggerPath: "/swagger" }
|
||||||
|
logger: { level: "warning", stdout: true }
|
||||||
|
database: { default: { link: "${DB_DSN}" } }
|
||||||
|
jwt: { secret: "${JWT_SECRET}", accessExpire: "2h", refreshExpire: "720h" }
|
||||||
3
manifest/config/config.test.yaml
Normal file
3
manifest/config/config.test.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
server: { address: ":8001" }
|
||||||
|
database: { default: { link: "${TEST_DB_DSN}" } }
|
||||||
|
jwt: { secret: "${JWT_SECRET}", accessExpire: "15m", refreshExpire: "1h" }
|
||||||
21
manifest/deploy/kustomize/base/deployment.yaml
Normal file
21
manifest/deploy/kustomize/base/deployment.yaml
Normal file
@ -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
|
||||||
|
|
||||||
8
manifest/deploy/kustomize/base/kustomization.yaml
Normal file
8
manifest/deploy/kustomize/base/kustomization.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- deployment.yaml
|
||||||
|
- service.yaml
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user