internal

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

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 ServiceImports = []string{
	"app/internal/dal",
	"app/internal/models",
	"errors",
	"gorm.io/gen/field",
	"gorm.io/gorm",
}

Functions

func CapitalizeFirst

func CapitalizeFirst(s string) string

func CreateServiceFileIfNotExists

func CreateServiceFileIfNotExists(filePath string) error

func GenerateCrudMethodCode

func GenerateCrudMethodCode(methodName string, context CrudTemplatesContext) string

func GetStructNames

func GetStructNames(modelsDir string) ([]string, error)

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 ImplementCrudMethods(modelName string, serviceName string, file *dst.File, reimplement bool) error

func ImplementMethod

func ImplementMethod(file *dst.File, methodDecl *dst.FuncDecl, reimplement bool) error

func ImplementModelAlias

func ImplementModelAlias(modelName string, file *dst.File)

func ImplementService

func ImplementService(mainPkgPath string, modelName string, reimplement bool) error

func ImplementServiceStruct

func ImplementServiceStruct(modelName string, file *dst.File, reimplement bool)

func MaintainImports

func MaintainImports(file *dst.File) error

func MethodCodeToDeclaration

func MethodCodeToDeclaration(methodCode string) (*dst.FuncDecl, error)

func ToPlural

func ToPlural(entityName string) string

Types

type CrudTemplatesContext

type CrudTemplatesContext struct {
	ServiceName  string
	EntityType   string
	EntityPlural string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳