矿产资源查询系统后端-go
go mod init LGIS
https://github.com/go-gorm/gen
基于 GORM, 更安全更友好的ORM工具。
- 自动生成 CRUD 和 DIY 方法
- 自动根据表结构生成模型(model)代码
- 事务、嵌套事务、保存点、回滚事务点
- 完全兼容 GORM
- 更安全、更友好
- 多种生成代码模式
gentool -dsn "xx:xx@tcp(xx:xx)/xx" -tables "kcdj,kqdz,kttz,mctz,kcmc,kcql,kccl,xksy,kcjs,kckc,kcjj" -outPath "./dao"
go mod tidy
将"数据"字段改为Shuju
type Kcdj struct {
KCAAA string `gorm:"column:KCAAA" json:"KCAAA"`
KCC string `gorm:"column:KCC" json:"KCC"`
JJDAJ string `gorm:"column:JJDAJ" json:"JJDAJ"`
JJGLA string `gorm:"column:JJGLA" json:"JJGLA"`
DWAAC string `gorm:"column:DWAAC" json:"DWAAC"`
DWAAD string `gorm:"column:DWAAD" json:"DWAAD"`
KCBA string `gorm:"column:KCBA" json:"KCBA"`
KCCA string `gorm:"column:KCCA" json:"KCCA"`
KCCB string `gorm:"column:KCCB" json:"KCCB"`
PKGKB string `gorm:"column:PKGKB" json:"PKGKB"`
KCAOC string `gorm:"column:KCAOC" json:"KCAOC"`
KCAOAE string `gorm:"column:KCAOAE" json:"KCAOAE"`
KCAOAF string `gorm:"column:KCAOAF" json:"KCAOAF"`
PKD string `gorm:"column:PKD" json:"PKD"`
JJDCBF string `gorm:"column:JJDCBF" json:"JJDCBF"`
Shuju string `gorm:"column:数据" json:"数据"`
}ctx := context.Background()
db, _ := gorm.Open(mysql.Open("xxx:xxx@Jxn@tcp(xxx:xxx)/xxx?charset=utf8mb4&parseTime=True&loc=Local"))go install github.com/zeromicro/go-zero/tools/goctl@latest
goctl completion bash > /etc/bash_completion.d/goctl
goctl api new api
goctl api go -api api.api -dir .
goctl api doc -dir .
go install github.com/zeromicro/goctl-swagger@latest
生成文档, 需要删除"requestBody": {},
goctl api plugin -plugin goctl-swagger="swagger -filename MGIS.json" -api *.api -dir .
//go:embed dist
var content embed.FSGOOS=windows GOARCH=amd64 go build