feat: template for service

This commit is contained in:
2025-03-08 19:27:18 +07:00
parent 7395354ae2
commit 5d3584f6bf
4 changed files with 47 additions and 57 deletions

View File

@@ -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()
}
}
}