mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 23:20:34 +07:00
39 lines
1.0 KiB
Cheetah
39 lines
1.0 KiB
Cheetah
import { GetAll, Create, Delete, GetById, Update, Count, SortedByOrder, SearchByAllTextFields } from "../../bindings/app/internal/services/{{.LowerModelName}}service"
|
|
import type { {{.ModelName}} } from "{{.ServicesPath}}"
|
|
import type { IService } from "../types/service.type"
|
|
import type { SortOptions } from "../types/sort-options.type";
|
|
|
|
|
|
export default class {{.ModelName}}Service implements IService<{{.ModelName}}> {
|
|
async read(id: number) {
|
|
return await GetById(id) as {{.ModelName}}
|
|
}
|
|
|
|
async readAll() {
|
|
return await GetAll() as {{.ModelName}}[]
|
|
}
|
|
|
|
async create(item: {{.ModelName}}) {
|
|
await Create(item)
|
|
}
|
|
|
|
async delete(id: number) {
|
|
return await Delete(id)
|
|
}
|
|
|
|
async update(item: {{.ModelName}}) {
|
|
await Update(item)
|
|
}
|
|
|
|
async count() {
|
|
return await Count()
|
|
}
|
|
|
|
async search(input: string) {
|
|
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 }}[]
|
|
}
|
|
} |