mirror of
https://github.com/opbnq-q/nto-cli.git
synced 2025-12-06 19:20:34 +07:00
feat: template for service
This commit is contained in:
@@ -1,27 +1,29 @@
|
||||
import { GetAll, Create, Delete, GetById, Update, Count } from "../../bindings/app/internal/services/authorservice.ts"
|
||||
import type { Author } from "../../bindings/app/internal/services/models.ts"
|
||||
import { GetAll, Create, Delete, GetById, Update, Count } from "../../bindings/app/internal/services/{{.LowerModelName}}service.ts"
|
||||
import type { {{.ModelName}} } from "{{.ServicesPath}}"
|
||||
import type { IService } from "../types/service.type.ts"
|
||||
|
||||
export default class AuthorService implements IService<Author> {
|
||||
export default class {{.ModelName}}Service implements IService<{{.ModelName}}> {
|
||||
async read(id: number) {
|
||||
return await GetById(id)
|
||||
return await GetById(id) as {{.ModelName}}
|
||||
}
|
||||
|
||||
async readAll() {
|
||||
return await GetAll() as Author[]
|
||||
return await GetAll() as {{.ModelName}}[]
|
||||
}
|
||||
|
||||
async create(item: Author) {
|
||||
async create(item: {{.ModelName}}) {
|
||||
await Create(item)
|
||||
}
|
||||
|
||||
async delete(id: number) {
|
||||
return await Delete(id)
|
||||
}
|
||||
async update(item: Author) {
|
||||
|
||||
async update(item: {{.ModelName}}) {
|
||||
await Update(item)
|
||||
}
|
||||
|
||||
async count() {
|
||||
return await Count()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user