mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 22:20:34 +07:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 305ac3dbf6 | |||
| 72569a0f75 | |||
| 0e56c3534a | |||
|
|
db5bf3bae0 | ||
| 199fe0a823 |
@@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/opbnq-q/nto-cli/model"
|
||||
"log"
|
||||
"nto_cli/model"
|
||||
"os"
|
||||
|
||||
"github.com/rivo/tview"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package generation
|
||||
|
||||
import (
|
||||
"github.com/opbnq-q/nto-cli/model"
|
||||
"github.com/opbnq-q/nto-cli/utils"
|
||||
"log"
|
||||
"nto_cli/model"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
@@ -3,9 +3,9 @@ package generation
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"github.com/opbnq-q/nto-cli/model"
|
||||
"github.com/opbnq-q/nto-cli/utils"
|
||||
"log"
|
||||
"nto_cli/model"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -15,8 +15,6 @@ import (
|
||||
//go:embed templates/scheme.tmpl
|
||||
var SchemeTemplate string
|
||||
|
||||
const GolangServicesPath = "../../bindings/app/internal/services"
|
||||
|
||||
type Dependency struct {
|
||||
ImportName string
|
||||
ServiceName string
|
||||
@@ -25,20 +23,18 @@ type Dependency struct {
|
||||
}
|
||||
|
||||
type TemplateData struct {
|
||||
StructName string
|
||||
LowerName string
|
||||
GolangServicesPath string
|
||||
Fields []model.Field
|
||||
Dependencies []Dependency
|
||||
StructName string
|
||||
LowerName string
|
||||
Fields []model.Field
|
||||
Dependencies []Dependency
|
||||
}
|
||||
|
||||
func GenerateScheme(model *model.Model, mkPath string) {
|
||||
data := TemplateData{
|
||||
StructName: model.Name,
|
||||
LowerName: strings.ToLower(model.Name),
|
||||
GolangServicesPath: GolangServicesPath,
|
||||
Fields: model.Fields,
|
||||
Dependencies: processDependencies(model.Fields),
|
||||
StructName: model.Name,
|
||||
LowerName: strings.ToLower(model.Name),
|
||||
Fields: model.Fields,
|
||||
Dependencies: processDependencies(model.Fields),
|
||||
}
|
||||
|
||||
schemeFilename := strings.ToUpper(model.Name[:1]) + strings.ToLower(model.Name[1:]) + "Scheme.vue"
|
||||
|
||||
@@ -3,9 +3,9 @@ package generation
|
||||
import (
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"github.com/opbnq-q/nto-cli/model"
|
||||
"github.com/opbnq-q/nto-cli/utils"
|
||||
"log"
|
||||
"nto_cli/model"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@@ -18,7 +18,6 @@ var ServiceTemplate string
|
||||
type ServiceTemplateContext struct {
|
||||
LowerModelName string
|
||||
ModelName string
|
||||
ServicesPath string
|
||||
}
|
||||
|
||||
func GenerateService(model *model.Model, mkPath string) {
|
||||
@@ -38,7 +37,6 @@ func GenerateService(model *model.Model, mkPath string) {
|
||||
context := ServiceTemplateContext{
|
||||
LowerModelName: strings.ToLower(model.Name),
|
||||
ModelName: model.Name,
|
||||
ServicesPath: GolangServicesPath,
|
||||
}
|
||||
|
||||
serviceTemplate, err := template.New("service").Parse(ServiceTemplate)
|
||||
|
||||
@@ -4,7 +4,7 @@ import { onMounted, reactive } from 'vue'
|
||||
import { getDefaultValues } from '../utils/structs/defaults.util'
|
||||
import Service from './{{.LowerName}}.service'
|
||||
import type { Scheme } from '../types/scheme.type'
|
||||
import { {{.StructName}} } from '{{.GolangServicesPath}}'
|
||||
import { {{.StructName}} } from '../../bindings/wails_tables/internal/services'
|
||||
import { ref } from 'vue'
|
||||
import type { Validate } from "../types/validate.type";
|
||||
import { getDefaultSortOptions } from "../utils/structs/default-sort-options.util";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { GetAll, Create, Delete, GetById, Update, Count, SortedByOrder, SearchByAllTextFields } from "../../bindings/app/internal/services/{{.LowerModelName}}service"
|
||||
import type { {{.ModelName}} } from "{{.ServicesPath}}"
|
||||
import { GetAll, Create, Delete, GetById, Update, Count, SortedByOrder, SearchByAllTextFields } from "../../bindings/wails_tables/internal/services/{{.LowerModelName}}service";
|
||||
import type { {{.ModelName}} } from "../../bindings/wails_tables/internal/models";
|
||||
import type { IService } from "../types/service.type"
|
||||
import type { SortOptions } from "../types/sort-options.type";
|
||||
|
||||
@@ -33,7 +33,16 @@ export default class {{.ModelName}}Service implements IService<{{.ModelName}}> {
|
||||
return await SearchByAllTextFields(input) as {{ .ModelName }}[]
|
||||
}
|
||||
|
||||
async sort(options: SortOptions<{{ .ModelName }}>) {
|
||||
return await SortedByOrder(Object.entries(options).map(item => ({Name: item[0], Order: item[1]}))) as {{ .ModelName }}[]
|
||||
}
|
||||
async sort(options: SortOptions<{{.ModelName}}>) {
|
||||
return (await SortedByOrder(
|
||||
Object.entries(options).map((item) => {
|
||||
if (item[1] !== 'NONE') {
|
||||
return ({
|
||||
Name: item[0],
|
||||
Order: item[1],
|
||||
})
|
||||
}
|
||||
}).filter(item => !!item)
|
||||
)) as {{.ModelName}}[];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package model
|
||||
|
||||
import "nto_cli/utils"
|
||||
import "github.com/opbnq-q/nto-cli/utils"
|
||||
|
||||
func GetNotImplementedModels(models []Model) []Model {
|
||||
var unimplementedModels []Model
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/opbnq-q/nto-cli/utils"
|
||||
"go/ast"
|
||||
"go/parser"
|
||||
"go/token"
|
||||
"log/slog"
|
||||
"nto_cli/utils"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
Reference in New Issue
Block a user