[agent-pipeline] pipe-20260403004704-gib0 round-1

This commit is contained in:
kjs
2026-04-03 09:48:39 +09:00
parent 1de5c24dc9
commit d0b8ab02b3
3 changed files with 156 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
import { Request, Response } from "express";
import { SampleService } from "../services/sampleService";
const sampleService = SampleService.getInstance();
/**
* 목록 조회
* GET /api/sample/list?page=1&limit=20
*/
export const getList = async (req: Request, res: Response): Promise<void> => {
const page = Math.max(1, parseInt(req.query.page as string) || 1);
const limit = Math.min(100, Math.max(1, parseInt(req.query.limit as string) || 20));
const result = await sampleService.getList(page, limit);
res.status(200).json({
success: true,
data: result.items,
total: result.total,
page,
limit,
});
};
/**
* 등록
* POST /api/sample
*/
export const create = async (req: Request, res: Response): Promise<void> => {
const { name, description } = req.body;
if (!name || !description) {
res.status(400).json({ success: false, message: "name, description은 필수입니다." });
return;
}
const item = await sampleService.create(name, description);
res.status(201).json({ success: true, data: item });
};
/**
* 수정
* PUT /api/sample/:id
*/
export const update = async (req: Request, res: Response): Promise<void> => {
const { id } = req.params;
const { name, description } = req.body;
const item = await sampleService.update(id, name, description);
res.status(200).json({ success: true, data: item });
};
/**
* 삭제 (soft delete)
* DELETE /api/sample/:id
*/
export const remove = async (req: Request, res: Response): Promise<void> => {
const { id } = req.params;
await sampleService.softDelete(id);
res.status(200).json({ success: true, message: "삭제되었습니다." });
};