English | 中文
A high performance admin project framework with Hertz
and Ent
- High productivity: An enterprise management system can be built in a short time.
- High performance: Uses the Hertz framework, the most powerful in Go. ByteDance has deployed tens of thousands of services using it.
- Modularity: Referring to the DDD design concept, the module design is more concise and convenient.
- Routing interfaces: Refer to the Google Open Platform and use Protobuf to define interface specifications.
- Interface development, better expansion and Unit Test.
- address: https://formulago.com
- account: admin/formulago
- Frontend project address: https://formulago-ui.com
- Use
Hertz
as HTTP framework - Use
Protobuf
IDL to defineHTTP
interface - Use
hz
to generate code - Use
Ent
andMySQL
(you also can use PostgresSQL) - Use
Memory Cache
andRedis
(Config file configuration enabled)
- User management: The user is the system operator, and this function mainly completes the system user configuration.
- Menu management: Configure system menus, operation permissions, button permission identification, etc.
- Role management: Assign permissions in the role menu and set the permission division of roles.
- Dictionary management: Maintain some relatively fixed data that is often used in the system.
- Operation log: System normal operation log records and queries; System exception information logging and querying.
- Online users: Active user token status monitoring in the current system.
- File management: File upload, S3 (Aliyun OSS) multiple upload methods adapted.
- OAuth2.0 login: Support Google, Github, Wecom, etc.
- Common tools: Integrate common toolkits in pkg package.
- Develop tools: Provide convenient Struct to Protobuf conversion tools, Struct to Protobuf, Delete Struct Tag, etc.
This project use Protobuf
IDL to define HTTP
interface. The specific admin interface define in admin.proto.
This project use hz
to generate code. The use of hz
refers
to hz.
- hz install.
go install github.com/cloudwego/hertz/cmd/hz@latest
- hz new: Create a new Hertz project.
hz new -I api -idl api/admin/admin.proto -model_dir api/model -module formulago --unset_omitempty
- hz update: Update an existing project, while you update the IDL file.
- The api.proto and base.proto are no need to update,because they generated by the proto file which has import them.
hz update -I api -idl api/admin/admin.proto -model_dir api/model --unset_omitempty
The use of binding and Validate refers to Binding and Validate.
ent - An Entity Framework For Go.
This project use Ent
to operate MySQL
(you also can use PostgresSQL) and refers to Ent.
- Update the Database DSN to your own in Database config file.
- Go to the root directory of your project, and run following command, will generate the schema for User under data/ent/schema/ directory:
cd data
go run -mod=mod entgo.io/ent/cmd/ent init User
- Add fields to the User schema, run go generate to produce the ent operation files
go generate ./ent
- For more Ent usage, please refer to Ent Guides.
- Modify Prod configuration file and Dev configuration file to your own.
- Note that the structure of Yaml should be consistent with the config struct definition.
- While the running environment variable "IS_PROD" is true, the prod configuration file will be used, otherwise the dev configuration file will be used.
cd formulago && docker-compose up
cd formulago
go build -o formulago &&./formulago
# init Database Table data by http request
# Administrator account: admin/formulago
@router yourHost/api/initDatabase [GET]
enjoy it!