All Projects → dreamlu → gt-crud

dreamlu / gt-crud

Licence: MIT license
gin+gorm+mysql+api[两步自动crud]

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to gt-crud

Go Admin
基于Gin + Vue + Element UI的前后端分离权限管理系统脚手架(包含了:多租户的支持,基础用户管理功能,jwt鉴权,代码生成器,RBAC资源控制,表单构建,定时任务等)3分钟构建自己的中后台项目;文档:https://doc.go-admin.dev Demo: https://www.go-admin.dev Antd beta版本:https://preview.go-admin.dev
Stars: ✭ 5,439 (+36160%)
Mutual labels:  gin, gorm, casbin
Go-Gin-Api
基于golang开源框架 gin封装的api框架
Stars: ✭ 42 (+180%)
Mutual labels:  gin, gorm, casbin
iris-admin
Web admin for iris-go framwork
Stars: ✭ 602 (+3913.33%)
Mutual labels:  gin, gorm, casbin
ginadmin
基于Gin开发的后台管理系统,集成了、数据库操作、日志管理、权限分配管理、多模板页面、自动分页器、数据库迁移和填充、Docker集成部署等功能、静态资源打包
Stars: ✭ 149 (+893.33%)
Mutual labels:  gin, gorm, casbin
Cmall Go
golang写的电子商城的API接口
Stars: ✭ 167 (+1013.33%)
Mutual labels:  gin, gorm
Gosql
golang orm and sql builder
Stars: ✭ 141 (+840%)
Mutual labels:  gin, gorm
Goilerplate
Clean Boilerplate of Go, Domain-Driven Design, Clean Architecture, Gin and GORM.
Stars: ✭ 173 (+1053.33%)
Mutual labels:  gin, gorm
golang-example-app
Example application
Stars: ✭ 138 (+820%)
Mutual labels:  gorm, casbin
Ultimate Go
This repo contains my notes on working with Go and computer systems.
Stars: ✭ 1,530 (+10100%)
Mutual labels:  gin, gorm
Go init
一个用go组织项目结构,主要包括 gin, goredis, gorm, websocket, rabbitmq等。👉
Stars: ✭ 183 (+1120%)
Mutual labels:  gin, gorm
go api boilerplate
🐶Go (Golang)🚀REST / GraphQL API + Postgres boilerplate
Stars: ✭ 127 (+746.67%)
Mutual labels:  gin, gorm
Gin bbs
Gin BBS App
Stars: ✭ 123 (+720%)
Mutual labels:  gin, gorm
Zendea
A free, open-source, self-hosted forum software written in Go 官方QQ群:656868
Stars: ✭ 116 (+673.33%)
Mutual labels:  gin, gorm
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+11766.67%)
Mutual labels:  gin, gorm
iam
企业级的 Go 语言实战项目:认证和授权系统
Stars: ✭ 1,900 (+12566.67%)
Mutual labels:  gin, gorm
Goweibo
Go Weibo App
Stars: ✭ 243 (+1520%)
Mutual labels:  gin, gorm
pink-lady
a template project of gin app.
Stars: ✭ 44 (+193.33%)
Mutual labels:  gin, gorm
gin-gorm-api-example
[Article] Minimal code for Golang based API
Stars: ✭ 98 (+553.33%)
Mutual labels:  gin, gorm
Ugin
UGin is an API boilerplate written in Go (Golang) with Gin Framework.
Stars: ✭ 110 (+633.33%)
Mutual labels:  gin, gorm
Logrus
Hooks for logrus logging
Stars: ✭ 110 (+633.33%)
Mutual labels:  gin, gorm

gt-crud

  • 简单方式(两步自动crud)
// 1.定义模型,参考models/client/client.go
type Client struct {
	ID uint64 `gorm:"type:bigint(20)" json:"id"`
	Name string `gorm:"type:varchar(30);" json:"name" valid:"required,len=2-20"` // 昵称
}

// 步骤二可省略, 最新方式可通过路由直接初始化调用DB
// 如需额外定义数据库, 可建立模型初始化放入其中
// 2.初始化数据库表,参考util/db/db.go
gt.DB().AutoMigrate(client.Client{})

// 3.路由router中定义,参考routers/dreamlu/router.go
// 定制方法需要确定该结构体实现了models/models_service.go中对应的接口
// 路由定义
		Route(map[string]interface{}{
			// 客户
			"/client":       client2.Client{},
			// admin
			"/admin/applet": applet2.Applet{},
		})
// cls["/client"] = controllers.New(client.Client{}, models.Update(&client.Client{}))
  • 更新 1.增加完善casbin权限,routers/router中开启权限中间间//router.Use(authz.NewAuthorizer(authz.Enforcer)), main中//go policy.InitPolicy()开启角色权限配置
    2.增加路由封装记录所有路由api+Method

gt-crud 是一个gin + gorm + gt 的使用案例

  • 特点
    1.gin 提供核心的请求处理(了解)
    2.gorm 数据库处理(了解)
    3.gt 提供常用的操作工具类以及一些开发约定(封装了gin+gorm形成常用业务链,须知)

  • api文档参考:
    1.api.html(或者在线api.html)
    2.此处单机部署开发,单机docker化参考docker目录,微服务go参考micro-go

  • 数据库模型生成,代码

模型定义需遵循:模型定义

插件提供了一些其他常见功能

  • 开箱即用
    1.针对小程序
    2.如用到支付回调和退款回调,请修改conf/中notifyUrl为你自己本地测试域名和上线域名,并根据注释掉的代码书写自己的逻辑
    3.默认多账号小程序;单账号:注释掉models/global.go中AdminCom的adminID字段,(ps:为了方便部署, 全局搜索initApplet(),打开注释,填入单账号的appid等参数)`
    n.更多用法参考gt

  • 关于crud

var crud = gt.NewCrud(
	gt.Model(Client{}),
)

案例中使用是当前页面全局性的变量, 如果新增了方法, 修改了Model(),如: crud.Params(gt.Model(Client2{})) 这种情况下,其他使用相同变量的crud的Model都会收到影响,解决方法如下:
1.新增的方法中使用gt.NewCrud(gt.Model(Client2{}))解决
2.可将crud.Params(gt.Model(Client{}))添加至每个使用的crud变量中
3.项目使用,全局替换gt-crud,另修改conf/和docker中数据库名称和密码

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].