1 Star 0 Fork 7

午夜的阳光 / modeltools

forked from longzongqin / modeltools 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Modeltools

GO语言连接Mysql生成对应的model,包括对应字段类型、注释等。生成基础的结构体,不局限于某一个ORM。

源码码地址---------

github:https://github.com/longzongqin/modeltools
码云:https://gitee.com/longzongqin/modeltools

生成示例---------

  package models

  // 管理员表
  type AdminInfo struct {
  	Id int `json:"id"` 
  	Name string `json:"name"` // 姓名
  	Username string `json:"username"` // 用户名 
  	Password string `json:"password"` // 密码
  	RoleInfoId int `json:"role_info_id"` // 角色ID
  	Status int8 `json:"status"` // -1删除,0正常,1禁用
  }

参数配置--------conf.go

  package conf
  
  // model保存路径
  const ModelPath = "./models/"
  // 是否覆盖已存在model
  const ModelReplace = true
  // 数据库驱动
  const DriverName = "mysql"
  
  type DbConf struct {
  	Host   string
  	Port   string
  	User   string
  	Pwd    string
  	DbName string
  }
  // 数据库链接配置
  var MasterDbConfig DbConf = DbConf{
  	Host:   "127.0.0.1",
  	Port:   "3306",
  	User:   "root",
  	Pwd:    "long",
  	DbName: "mvideo",
  }

生成model--------

package main

import (
	"modeltools/dbtools"
	"modeltools/generate"
)


func main() {
	//初始化数据库
	dbtools.Init()
	//generate.Genertate() //生成所有表信息
	generate.Genertate("admin_info","video_info") //生成指定表信息,可变参数可传入多个表名
}

空文件

简介

GO语言连接Mysql生成对应的model,包括对应字段类型、注释等。生成基础的结构体,不局限于某一个ORM。 展开 收起
Go
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/xierui921326/modeltools.git
git@gitee.com:xierui921326/modeltools.git
xierui921326
modeltools
modeltools
master

搜索帮助