Categorygithub.com/chenxiao1990/GenMysqlProject
modulepackage
1.2.2
Repository: https://github.com/chenxiao1990/genmysqlproject.git
Documentation: pkg.go.dev

# README

ui

Image1

Image2

Image3

GenMysqlProject

介绍

json 转 go struct mysql 数据库表 转 go struct

生成mysql数据表的 gorm查询go代码

通过mysql数据表初始化各个表的curd功能,包含api、service、dao、model模块 。

api使用gin框架提供对外http接口

mysql数据库访问使用gorm框架

安装教程

  • 下载源码编译
git clone [email protected]:chenxiao1990/GenMysqlProject.git
cd GenMysqlProject
go build 
./GenMysqlProject

使用说明

编译成可执行程序后直接运行,然后浏览器打开 http://localhost:8008/vue

  • 生成工程
    输入工程名,点击生成,会在运行目录下生成工程
  • 生成查询代码
    进行一些点击操作生成查询数据库的代码

注意事项

  • 表中如果无id字段,那么要删掉dao层中相关使用id的操作
  • 如果有两个表,表名是 something, somethings 那么需要手动处理一下,会有两个Something结构生成
  • 主流的字段格式已解析,可能会有漏掉的,后边会根据反馈进行修改

web端工程的 静态资源打包 go-bindata工具

本工程中已打包,所以你不想做更改的话 可以不用管这个

go-bindata -fs -prefix "webui/dist/" webui/dist/...

-fs 表示生成 func AssetFile() http.FileSystem

-prefix  去掉生成包的访问前缀 webui/dist

成功生成bindata.go文件 里面就是一堆静态文件的字符串
GRouter = gin.Default()
GRouter.StaticFS("/vue", AssetFile())
这样 gin就添加了 dist里的静态文件访问  
例如 webui/dist/css/app.xxx.css 访问路径为 http://ip:port/vue/css/app.xxx.css

# Packages

No description provided by the author

# Functions

Asset loads and returns the asset for the given name.
AssetDir returns the file names below a certain directory embedded in the file by go-bindata.
AssetFile return a http.FileSystem instance that data backend by asset.
AssetInfo loads and returns the asset info for the given name.
AssetNames returns the names of the assets.
No description provided by the author
Cors 跨域配置.
fmtFieldName formats a string as a struct key Example: fmtFieldName("foo_id") Output: FooID.
GenerateStruct generates a struct for the given table.
No description provided by the author
GinInit ...
MustAsset is like Asset but panics when Asset would return an error.
NewReplyError 默认的错误回复.
NewReplyOk 默认的正确回复.
RestoreAsset restores an asset under the given directory.
RestoreAssets restores an asset under the given directory recursively.

# Variables

GRouter 全局Router 全局调用的函数会在模块的init()之前执行.

# Structs

No description provided by the author
No description provided by the author
Reply api的回复结构.