{"id":16909091,"url":"https://github.com/linkinstars/baileys","last_synced_at":"2025-03-20T17:45:33.929Z","repository":{"id":53020407,"uuid":"209240291","full_name":"LinkinStars/baileys","owner":"LinkinStars","description":"🤔 golang 代码的自动生成工具","archived":false,"fork":false,"pushed_at":"2023-10-11T22:43:40.000Z","size":4558,"stargazers_count":39,"open_issues_count":1,"forks_count":17,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-25T16:28:16.404Z","etag":null,"topics":["autocode","tpl"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LinkinStars.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-18T07:00:01.000Z","updated_at":"2025-01-06T07:56:59.000Z","dependencies_parsed_at":"2024-06-20T05:44:23.591Z","dependency_job_id":null,"html_url":"https://github.com/LinkinStars/baileys","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinkinStars%2Fbaileys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinkinStars%2Fbaileys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinkinStars%2Fbaileys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LinkinStars%2Fbaileys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LinkinStars","download_url":"https://codeload.github.com/LinkinStars/baileys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244665788,"owners_count":20490275,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["autocode","tpl"],"created_at":"2024-10-13T18:54:22.602Z","updated_at":"2025-03-20T17:45:33.893Z","avatar_url":"https://github.com/LinkinStars.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Baileys 代码自动生成工具\n\u003cimg align=\"right\" width=\"159px\" src=\"https://raw.githubusercontent.com/LinkinStars/baileys/master/docs/logo.png\"\u003e\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/LinkinStars/baileys)](https://goreportcard.com/report/github.com/LinkinStars/baileys)\n\n## Feature\n- 读取数据库结构生成代码 (无法在线使用，因需要连接本地数据库)\n- 将 golang struct 转换为 Protocol Buffers \n- 将 json 转换为 golang struct\n\n[在线使用](https://baileys.linkinstars.com/)\n  \n### 读取数据库结构生成代码\n\u003e 修改配置文件，修改模板，点击生成，从数据库到代码的一键生成完成！从此 golang 的 web 开发也可以非常简单~   正所谓，只有更快的拧螺丝，才有时间造火箭。\n\n![](./docs/show.gif)\n\n#### 使用过程\n1. 下载 release 版本，或者 clone 下来你自己编译也可以   \nhttps://github.com/LinkinStars/baileys/releases\n2. 解压后，修改 conf 文件夹下的配置文件conf.yml，主要是数据库配置和模板生成路径\n3. 修改 tpl 下的模板为你自己想要的样子，你可以先往后走，回来再修改\n4. ./baileys 启动\n5. 选择你需要的模板和表格，点击生成即可\n\nPS: 修改配置文件，模板，数据库之后，只需要刷新页面即可重新加载，不需要重新启动\n\n下面是默认模板最终生成的样子  \nhttps://github.com/LinkinStars/golang-web-template\n\n#### 命令行参数\n-c 可以指定配置文件的目录 默认目录为 \"./conf/conf.yml\"  \n-p 可以指定端口号 默认端口为 \"5272\"  \n\n#### 导入问题\n生成文件的位置和 gopath 的设置会影响包的导入\n\n#### 模板问题\n- 模板文件夹 tpl 中 every 文件夹下的模板表示所有选中数据库的表均会一一去生成，比如一个表生成一个实体类等。  \n- one 表示选中的表都会遍历一遍生成一个文件，比如遍历所有的表生成一个路由配置。\n- 模板中可以使用的引用字段如下\n\n```go\n// TableData 表的数模型\ntype TableData struct {\n    UpperCamelName string // 大驼峰名称\n    LowerCamelName string // 小驼峰名称\n    UnderlineName  string // 下划线名称\n    Comment        string // 注释\n    Fields         []FieldData\n}\n\n// FieldData 字段的数据模型\ntype FieldData struct {\n    UpperCamelName string // 大驼峰名称\n    LowerCamelName string // 小驼峰名称\n    UnderlineName  string // 下划线名称\n    Type           string // 对应go的类型\n    Comment        string // 字段注释\n    ORMTag         string // orm框架的标签\n    ValTag         string // 验证框架的标签\n}\n```  \n\n#### 命名问题\n数据库中字段最好以下划线分割进行命名，这样能最正常的保证输出结果，如果以小驼峰命名可能出现奇怪的命名\n\n#### 自定义\n主要数据库中拿到的参数这边都已经提供，如果需要可以直接从模板中引用。    \n如果参数不够用，比如你需要自定义标签等，那就只能fork过去自己改了。  \n如果你有写好的目标想要共享也可以提issue。\n\n#### UPDATE\n- 1.0.0 支持生成XORM的标签，validate.v9的标签 [release]\n- 1.0.1 支持生成GORM的标签 [test]\n\n### 将 golang struct 转换为 Protocol Buffers\n![](./docs/struct2pb.png)\n使用很简单，只需要将 struct 复制到左边，然后点击转换即可\n\n## TODO\n- [x] go struct 转 json\n    - [x] 支持嵌套结构体转换\n    - [x] 支持无 json tag 结构体自动生成 tag 后转换\n    - [x] 忽略 json tag 为 '-' 的情况\n    - [ ] 忽略 json tag 中的 omitempty\n- [x] json 转 go struct (使用 https://github.com/mholt/json-to-go 实现)\n- [x] 首页页面展示优化\n- [x] 自动生成 golang struct 和 pb 对象的转换 function\n- [x] yaml 转 go struct (https://zhwt.github.io/yaml-to-go/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkinstars%2Fbaileys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinkinstars%2Fbaileys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinkinstars%2Fbaileys/lists"}