1
0
mirror of https://github.com/ManyakRus/crud_generator.git synced 2024-11-27 08:40:53 +02:00
Go to file
2023-11-20 17:08:58 +03:00
bin сделал готовый микросервис 2023-11-20 17:08:58 +03:00
cmd/crud_generator сделал готовый микросервис 2023-11-20 17:08:58 +03:00
internal сделал готовый микросервис 2023-11-20 17:08:58 +03:00
pkg сделал readme 2023-11-14 17:07:41 +03:00
scripts сделал CopyAllFiles_Exclude_() 2023-11-15 17:59:21 +03:00
vendor сделал ReplacePackageName() 2023-11-17 13:23:15 +03:00
.gitignore сделал CopyAllFiles_Exclude_() 2023-11-15 17:59:21 +03:00
go.mod сделал ReplacePackageName() 2023-11-17 13:23:15 +03:00
go.sum сделал ReplacePackageName() 2023-11-17 13:23:15 +03:00
Makefile сделал CopyAllFiles_Exclude_() 2023-11-15 17:59:21 +03:00
README.md сделал settings.txt 2023-11-17 15:08:31 +03:00
readme.rus сделал settings.txt 2023-11-17 15:08:31 +03:00

The crud_generator application is designed to automatically generate source code files in golang language to perform CRUD operations.

For each table in the Postgres SQL database, files will be created to perform crud operations: create, read, update, save, delete (or delete + restore) files are generated:

  1. model - struct structure with all fields from the database, and gorm + db + json annotations Tables with fields in the database must be created manually in advance. The code generator will find all the tables and their fields in the database and use them.
  2. db - files for performing crud operations, exchange with the database, as well as files with tests
  3. grpc server - files for performing crud operations over the network, using the GRPC protocol, as well as files with tests
  4. grpc client - client files for using GRPC by third-party services, as well as files with tests
  5. nrpc server - files for performing crud operations over the network, using the NRPC protocol (via the NATS message broker), as well as files with tests
  6. nrpc client - client files for use by NRPC third-party services, as well as files with tests
  7. crud_starter - a file with functions for switching to the desired protocol db or grpc or nrpc

Code templates are stored in the bin/templates folder. The code template is a .go file copied from the real project - so it’s easy to make a template (change it to your own) - just copy your file. The code generator replaces part of the code in the template with another code:

  • name of the database table
  • model name
  • adding and removing imports

Installation procedure:

  1. Compile this repository make build the crud_generator file will appear in the bin folder

  2. Fill settings in the bin/templates/configs_/settings.txt file

  • connections to your database
  • name of your new service
  • URL of your new service
  • and etc.
  1. Launch crud_generator A new folder with the name of your service will appear in the bin folder, with subfolders and finished files inside.

  2. Copy the finished files to your service. (TODO: later I’ll generate a completely ready-made microservice launched with 1 line of code)

P.S. I generated myself 170,000 lines of code, from 70 tables in the database, for my service.

Source code in Golang language. Tested on Linux Ubuntu Readme from 11/14/2023

Made by Alexander Nikitin https://github.com/ManyakRus/crud_generator