feat: implement helloworld API with CRUD operations and test cases
This commit is contained in:
44
03_source/cms_backend/src/app/services/helloworld.service.ts
Normal file
44
03_source/cms_backend/src/app/services/helloworld.service.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// src/app/services/helloworld.service.ts
|
||||
//
|
||||
// REQ0047/T.B.A.
|
||||
//
|
||||
// PURPOSE:
|
||||
// - helloworld example for handling helloworld Record
|
||||
//
|
||||
// RULES:
|
||||
// - T.B.A.
|
||||
//
|
||||
|
||||
import type { Helloworld } from '@prisma/client';
|
||||
|
||||
import prisma from '../lib/prisma';
|
||||
|
||||
type CreateHelloworld = {
|
||||
hello: string;
|
||||
};
|
||||
|
||||
type UpdateHelloworld = {
|
||||
hello: string;
|
||||
};
|
||||
|
||||
async function listHelloworlds(): Promise<Helloworld[]> {
|
||||
return prisma.helloworld.findMany();
|
||||
}
|
||||
|
||||
async function getHelloworld(helloworldId: number) {
|
||||
return prisma.helloworld.findFirst({ where: { id: helloworldId } });
|
||||
}
|
||||
|
||||
async function createNewHelloworld(createForm: CreateHelloworld) {
|
||||
return prisma.helloworld.create({ data: createForm });
|
||||
}
|
||||
|
||||
async function updateHelloworld(helloworldId: number, updateForm: UpdateHelloworld) {
|
||||
return prisma.helloworld.update({ where: { id: helloworldId }, data: updateForm });
|
||||
}
|
||||
|
||||
async function deleteHelloworld(helloworldId: number) {
|
||||
return prisma.helloworld.delete({ where: { id: helloworldId } });
|
||||
}
|
||||
|
||||
export { getHelloworld, listHelloworlds, updateHelloworld, deleteHelloworld, createNewHelloworld };
|
Reference in New Issue
Block a user