feat: field gen

This commit is contained in:
2025-02-15 22:10:46 +07:00
parent 011249d3e3
commit 08166e75d3
6 changed files with 97 additions and 28 deletions

View File

@@ -9,7 +9,7 @@ import (
)
func Generate(structName string, fields []entities.Field) {
mkPath := strings.ToLower(fmt.Sprintf("%s/frontend/src/%s", utils.FindFrontendPath() , structName))
mkPath := fmt.Sprintf("%s/frontend/src/%s", utils.FindFrontendPath() , strings.ToLower(structName))
if err := os.Mkdir(mkPath, 0755); err != nil {
panic(err)
}

View File

@@ -27,12 +27,12 @@ func GenerateService(structName, mkPath string) {
panic(err)
}
defer serviceFile.Close()
_, err = serviceFile.WriteString(
fmt.Sprintf(`import { GetAll, Create, Delete, ExportToExcel, GetById, Update, Count } from "%s"
_, err = serviceFile.WriteString(fmt.Sprintf(
`import { GetAll, Create, Delete, ExportToExcel, GetById, Update, Count } from "%s"
import type { %s } from "%s"
import type { Service } from "%s"
import type { IService } from "%s"
export class %sService implements Service<%s> {
export class %sService implements IService<%s> {
async read(id: number) {
return await GetById(id)
}