fix: gofmt && little fixes

This commit is contained in:
2025-03-07 22:27:13 +07:00
parent e6f21d1bb2
commit d522bd3841
7 changed files with 25 additions and 22 deletions

View File

@@ -12,7 +12,7 @@ type Field struct {
Medatada []Metadata
}
var PRIMITIVE_TYPES = map[string]string{
var PrimitiveTypes = map[string]string{
"date": "date",
"number": "number",
"string": "string",
@@ -38,15 +38,15 @@ var PRIMITIVE_TYPES = map[string]string{
func (f *Field) GenerateType() string {
result := " type: {\n"
keys := make([]string, 0, len(PRIMITIVE_TYPES))
for k := range PRIMITIVE_TYPES {
keys := make([]string, 0, len(PrimitiveTypes))
for k := range PrimitiveTypes {
keys = append(keys, k)
}
if slices.Contains(keys, strings.ToLower(f.Type)) {
result += fmt.Sprintf(` primitive: "%s",`, PRIMITIVE_TYPES[strings.ToLower(f.Type)])
result += fmt.Sprintf(` primitive: "%s",`, PrimitiveTypes[strings.ToLower(f.Type)])
} else {
var field string = "[]"
var field = "[]"
for _, meta := range f.Medatada {
if meta.Name == "field" {
if len(meta.Values) > 0 {

View File

@@ -2,6 +2,7 @@ package generation
import (
"fmt"
"log"
"nto_cli/utils"
"os"
"strings"
@@ -20,11 +21,11 @@ import type { IService } from "%s"
export default class %sService implements IService<%s> {
async read(id: number) {
return await GetById(id)
return await GetById(id) as %s
}
async readAll() {
return await GetAll() as %s
return await GetAll() as %s[]
}
async create(item: %s) {
@@ -34,15 +35,17 @@ export default class %sService implements IService<%s> {
async delete(id: number) {
return await Delete(id)
}
async update(item: %s) {
await Update(item)
}
async count() {
return await Count()
}
}
`, utils.GetServiceBindPath(structName), structName, utils.GetServiceStructType(structName), utils.GetServiceType(), structName, structName, structName, structName))
`, utils.GetServiceBindPath(structName), structName, utils.GetServiceStructType(structName), utils.GetServiceType(), structName, structName, structName, structName, structName, structName))
if err != nil {
panic(err)
log.Fatalf("Failed to write to file: %s", err)
}
}

BIN
nto_cli

Binary file not shown.

View File

@@ -9,7 +9,7 @@ import (
func FindFrontendPath() string {
currentPath, err := os.Getwd()
if err != nil {
panic(err)
log.Fatalf("Failed to find path for frontend: %s", err)
}
var dirs []string

View File

@@ -29,7 +29,7 @@ func GetStructList(filePath string) []string {
}
if s.Err() != nil {
log.Fatalf("")
log.Fatalf("Unexpected scanner error: %s", err)
}
return structNames