开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:代码生成工具集

简介: GoWind Admin|风行是一套企业级前后端一体中后台框架,配套代码生成工具集,支持配置导出、数据库转ORM/Proto/Kratos服务代码,提升开发效率,开箱即用。

开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:代码生成工具集

我们为go-wind-admin这个项目打造了一个代码生成工具集。

  • cfgexp 用于将服务本地配置导入到远程配置系统,支持:Etd、Consul、Nacos……
  • sql2orm 用于把数据库的表结构导入,并且生成为ORM代码,支持:ENT、GORM……
  • sql2proto 用于把数据的表结构导入,并且生成gRPC、REST的Protobuf代码。
  • sql2kratos 用于把数据的表结构导入,并且生成一整套的Kratos服务代码。

项目代码地址:

cfgexp

该工具将本地配置文件导出到Consul或Etcd等远程配置系统,从而更轻松地管理分布式系统中的配置。

现在已经支持的远程配置系统有:

  • Etcd
  • Consul
  • Nacos

如何安装

go install github.com/tx7do/kratos-cli/config-exporter/cmd/cfgexp@latest

如何使用

Config Exporter is a tool to export configuration from remote services like Consul or Etcd to local files.

Usage:
  cfgexp [flags]

Flags:
  -a, --addr string    remote config service address (default "127.0.0.1:8500")
  -e, --env string     environment name, like dev, test, prod, etc. (default "dev")
  -g, --group string   group name, this name is used to key prefix in remote config service (default "DEFAULT_GROUP")
  -h, --help           help for cfgexp
  -n, --ns string      namespace ID, used for Nacos (default "public")
  -p, --proj string    project name, this name is used to key prefix in remote config service
  -r, --root string    project root dir (default "./")
  -t, --type string    remote config service name (consul, etcd, etc.) (default "consul")

示例

Etcd

cfgexp \
    -t "etcd" \
    -a "localhost:2379" \
    -p "go_wind_admin"

consul

cfgexp \
    -t "consul" \
    -a "localhost:8500" \
    -p "go_wind_admin"

Nacos

cfgexp \
    -t "nacos" \
    -a "localhost:8848" \
    -p "go_wind_admin" \
    -n "public" \
    -e "dev" \
    -g "DEFAULT_GROUP"

sql2orm

该工具导入 SQL 数据库的表结构,并生成用于 Kratos 微服务的 ORM代码。

支持的ORM:

  • ent
  • GORM

如何安装

go install github.com/tx7do/kratos-cli/sql-orm/cmd/sql2orm@latest

如何使用

sql2orm is a tool to generate ORM code from SQL database schemas.

Usage:
  sql2orm [flags]

Flags:
  -d, --dao-path string          output path for DAO code (for gorm) (default "./daos/")
  -v, --drv string               Database driver name to use (mysql, postgres, sqlite...) (default "mysql")
  -n, --dsn string               Data source name (connection information), for example:
                                 "mysql://user:pass@tcp(localhost:3306)/dbname"
                                 "postgres://user:pass@host:port/dbname"
  -e, --exclude-tables strings   comma-separated list of tables to exclude
  -h, --help                     help for sql2orm
  -o, --orm string               ORM type to use (ent, gorm) (default "ent")
  -s, --schema-path string       output path for schema (default "./ent/schema/")
  -t, --tables strings           comma-separated list of tables to inspect (all if empty)

示例

Ent

sql2orm \
  --orm "ent" \
  --dsn "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  --schema-path "./ent/schema"

GORM

sql2orm \
  --orm "gorm" \
  --drv "postgres" \
  --dsn "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  --schema-path "./daos/models" \
  --dao-path "./daos/"

sql2proto

该工具导入 SQL 数据库的表结构,并生成用于 Kratos 微服务的 Protobuf 代码。

如何安装

go install github.com/tx7do/kratos-cli/sql-proto/cmd/sql2proto@latest

如何使用

sql2proto is a tool to import SQL database schema and generate Protobuf code.

Usage:
  sql2proto [flags]

Flags:
  -n, --dsn string          Data source name (connection information), for example:
                            "mysql://user:pass@tcp(localhost:3306)/dbname"
                            "postgres://user:pass@host:port/dbname"
  -e, --excludes strings    comma-separated list of tables to exclude
  -h, --help                help for sql2proto
  -i, --includes strings    comma-separated list of tables to inspect (all if empty)
  -m, --module string       module name for the generated code, e.g., 'admin' (default "admin")
  -o, --output string       output path for protobuf schema files (default "./api/protos/")
  -s, --src-module string   Source module name, for REST service generate, e.g., "admin" (default "user")
  -t, --type string         generate RPC service type, "rest" for REST service, "grpc" for gRPC service (default "grpc")
  -v, --version string      Version of the module, e.g., 'v1' (default "v1")

示例

生成gRPC服务的Proto:

sql2proto \
  -n "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  -o "./api/protos" \
  -t "grpc" \
  -m "user"

生成REST服务的Proto:

sql2proto \
  -n "mysql://root:pass@localhost:3306/test" \
  -o "./api/protos" \
  -t "rest" \
  -m "admin" \
  -s "user"

sql2kratos

该工具导入 SQL 数据库的表结构,并生成 Kratos 微服务代码。

如何安装

go install github.com/tx7do/kratos-cli/sql-kratos/cmd/sql2kratos@latest

如何使用

sql2kratos imports the SQL database schemas and generates Kratos microservice code.

Usage:
  sql2kratos [flags]

Flags:
  -n, --dsn string          Data source name (connection information), for example:
                            "mysql://user:pass@tcp(localhost:3306)/dbname"
                            "postgres://user:pass@host:port/dbname"
  -e, --excludes strings    comma-separated list of tables to exclude
  -l, --gen-data            enable generate data package code (default true)
  -k, --gen-main            enable generate main package code (default true)
  -z, --gen-orm             enable generate ORM code (default true)
  -q, --gen-proto           enable generate protobuf schema files (default true)
  -w, --gen-srv             enable generate server package code (default true)
  -a, --gen-svc             enable generate service package code (default true)
  -h, --help                help for sql2kratos
  -i, --includes strings    comma-separated list of tables to inspect (all if empty)
  -m, --module string       Target module name for the generated code, e.g., 'admin' (default "admin")
  -r, --orm string          ORM type to use (ent, gorm) (default "ent")
  -o, --output string       output path for protobuf schema files (default "./api/protos/")
  -p, --project string      Project name for the generated code, e.g., 'go-wind-admin' (default "go-wind-admin")
  -x, --repo                use repository pattern (default true)
  -g, --servers strings     comma-separated list of servers to generate, e.g., "grpc,rest" (default [grpc])
  -c, --service string      Service name for the generated code, e.g., 'user' (default "user")
  -s, --src-module string   Source module name, for REST service generate, e.g., "admin" (default "user")
  -v, --version string      Version of the module, e.g., 'v1' (default "v1")

示例

gRPC服务代码:

sql2kratos \
  -p "go-wind-admin" \
  -n "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  -r "ent" \
  -o "." \
  -m "user" \
  -c "user" \
  -g "grpc"

REST服务代码:

sql2kratos \
  -p "go-wind-admin" \
  -n "postgres://postgres:pass@localhost:5432/test?sslmode=disable" \
  -r "ent" \
  -o "." \
  -s "user" \
  -m "admin" \
  -c "admin" \
  -g "rest" \
  -x=false \
  -z=false \
  -l=false

项目代码

目录
相关文章
|
前端开发 JavaScript Go
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:介绍
风行(GoWind Admin)是一款开箱即用的企业级Golang全栈中后台框架,基于go-kratos与Vben Admin,支持单体/微服务架构。功能完备,涵盖用户、租户、角色、权限、日志等管理模块,助力开发者高效构建管理系统。
1650 0
|
10月前
|
Java 中间件 Nacos
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:kratos-bootstrap 入门教程(类比 Spring Boot)
kratos-bootstrap 是 GoWind Admin 的核心引导框架,类比 Spring Boot,提供应用初始化、配置管理、组件集成等一站式解决方案。通过标准化流程与多源配置支持,开发者可快速构建企业级中后台服务,专注业务开发,降低微服务复杂度。
858 2
|
SQL API 容器
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:后端项目结构说明
GoWind Admin|风行是一款企业级前后端一体中后台框架,后端采用Go语言,基于Protobuf定义API,支持Buf代码生成与Docker部署。项目结构清晰,含API定义、服务实现、数据库ORM、配置管理及自动化脚本,开箱即用,助力高效开发。
739 0
|
10月前
|
关系型数据库 API Go
初学者友好:Go-Kratos 集成 go-crud,Ent ORM CRUD 无需重复编码,轻松上手
本文介绍如何基于 `kratos-ent-example` 项目,集成 `go-curd` 工具简化 Go-Kratos 微服务中 Ent ORM 的 CRUD 操作。通过封装重复逻辑,实现增删改查代码的极简编写,帮助初学者快速上手微服务开发,提升效率,降低学习成本。
439 3
|
10月前
|
存储 缓存 关系型数据库
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:分层设计的取舍之道(从 “简单粗暴” 到依赖倒置)
GoWind Admin 是企业级前后端一体中后台框架,深入探讨分层设计的取舍:从“Service直连Data”到依赖倒置与biz层演进,平衡开发效率与架构韧性,适配轻量到超大型项目,实现开箱即用与长期扩展的统一。
443 4
|
前端开发 Go API
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:数据脱敏和隐私保护
GoWind Admin基于Protobuf生态,集成protoc-gen-redact插件,实现开箱即用的数据脱敏与隐私保护。通过注解定义规则,自动生成脱敏代码,支持多语言、灵活配置,零侵入业务逻辑,适用于微服务、日志、前端等场景,保障数据安全合规。
433 0
|
前端开发 安全 API
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:自动化解放双手,初学者快速搭建系统并自动生成前端接口
GoWind Admin 是基于 Go-Kratos 与 Vue3 的企业级中后台框架,开箱即用,集成用户、权限、租户等核心模块。搭配 protoc-gen-typescript-http,可从 Protobuf 自动生成类型安全的前端接口,大幅降低联调成本,提升开发效率,助力初学者快速搭建系统,实现前后端高效协作。
814 0
|
10月前
|
前端开发 JavaScript Go
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:为什么选 Golang+Vue3 这套组合?
go-wind-admin 采用 Golang + Vue3 技术栈,融合高性能后端与高效前端生态。后端基于 go-kratos、ent/gorm 灵活适配复杂业务,前端结合 Vue3、TypeScript 与 Vben Admin,提升开发效率与可维护性,兼顾性能、扩展性与企业级需求,是中后台系统的理想选择。(239字)
969 6
|
10月前
|
Go API 数据库
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:基于 GORM 从零实现新服务
GoWind Admin 是基于 GORM 的企业级中后台框架,支持 gRPC 与 REST 双协议。本文详解如何从零构建服务:设计表结构、编写 GORM 模型、定义 Proto 接口、实现数据访问与业务逻辑,并注册服务。分层架构清晰,开箱即用,助力高效开发。
349 4
|
10月前
|
监控 NoSQL 开发者
开箱即用的 GoWind Admin|风行,企业级前后端一体中后台框架:极速搭建微服务应用
GoWind Admin(风行)是基于Go语言的企业级前后端一体中后台框架,集成kratos生态,支持一键生成微服务、多协议(gRPC/REST)、多数据层(gorm/ent/redis),开箱即用,大幅降低架构成本,助力快速构建高可用微服务应用。
804 2