Documentation
¶
Index ¶
- Constants
- Variables
- func CapitalizeFirst(s string) string
- func CreateServiceFileIfNotExists(filePath string) error
- func GenerateCrudMethodCode(methodName string, context CrudTemplatesContext) string
- func GetStructNames(modelsDir string) ([]string, error)
- func ImplementCrudMethods(modelName string, serviceName string, file *dst.File, reimplement bool) error
- func ImplementMethod(file *dst.File, methodDecl *dst.FuncDecl, reimplement bool) error
- func ImplementModelAlias(modelName string, file *dst.File)
- func ImplementService(mainPkgPath string, modelName string, reimplement bool) error
- func ImplementServiceStruct(modelName string, file *dst.File, reimplement bool)
- func MaintainImports(file *dst.File) error
- func MethodCodeToDeclaration(methodCode string) (*dst.FuncDecl, error)
- func ToPlural(entityName string) string
- type CrudTemplatesContext
Constants ¶
View Source
const CountMethod = "Count"
View Source
const CountRawTemplate = `` /* 129-byte string literal not displayed */
View Source
const CreateMethod = "Create"
View Source
const CreateRawTemplate = `` /* 184-byte string literal not displayed */
View Source
const DeleteMethod = "Delete"
View Source
const DeleteRawTemplate = `` /* 198-byte string literal not displayed */
View Source
const GetAllMethod = "GetAll"
View Source
const GetAllRawTemplate = `` /* 237-byte string literal not displayed */
View Source
const GetByIdMethod = "GetById"
View Source
const GetByIdRawTemplate = `` /* 371-byte string literal not displayed */
View Source
const UpdateMethod = "Update"
View Source
const UpdateRawTemplate = `` /* 182-byte string literal not displayed */
Variables ¶
View Source
var RawTemplates = map[string]string{ CreateMethod: CreateRawTemplate, GetAllMethod: GetAllRawTemplate, GetByIdMethod: GetByIdRawTemplate, UpdateMethod: UpdateRawTemplate, DeleteMethod: DeleteRawTemplate, CountMethod: CountRawTemplate, }
View Source
var ServiceImports = []string{
"app/internal/dal",
"app/internal/models",
"errors",
"gorm.io/gen/field",
"gorm.io/gorm",
}
Functions ¶
func CapitalizeFirst ¶
func GenerateCrudMethodCode ¶
func GenerateCrudMethodCode(methodName string, context CrudTemplatesContext) string
func GetStructNames ¶
GetStructNames reads all .go files from modelsDir and returns the names of all top-level struct types found, using the DST (dave/dst) library.
func ImplementCrudMethods ¶
func ImplementMethod ¶
func ImplementModelAlias ¶
func ImplementService ¶
func ImplementServiceStruct ¶
func MaintainImports ¶
func MethodCodeToDeclaration ¶
Types ¶
type CrudTemplatesContext ¶
Click to show internal directories.
Click to hide internal directories.