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