This commit is contained in:
2026-06-09 15:34:54 +03:30
parent 7d8aeea90f
commit 43c52dfec8
6 changed files with 256 additions and 11 deletions

View File

@@ -9,9 +9,21 @@ class UserControllerClass extends Controller {
super();
this.#service = UserService;
}
async create(req: any, res: ServerResponse, next: NextFunction) {
try {
await this.#service.create(req.body || {});
res.status(201).json({
status: 201,
data: {},
message: "ساخته شد",
});
} catch (error) {
next(error);
}
}
async getAll(req: any, res: ServerResponse, next: NextFunction) {
try {
const data = await this.#service.getAll();
const data = await this.#service.getAll(req);
return res.status(200).json({
status: 200,
@@ -23,6 +35,62 @@ class UserControllerClass extends Controller {
next(error);
}
}
async getList(req: any, res: ServerResponse, next: NextFunction) {
try {
const data = await this.#service.getList();
return res.status(200).json({
status: 200,
data,
message: "Ok",
});
} catch (error) {
console.log(error);
next(error);
}
}
async update(req: any, res: ServerResponse, next: NextFunction) {
try {
const id = req?.params?.id;
await this.#service.update(id, req.body);
return res.status(200).json({
status: 200,
data: {},
message: "ويرايش شد",
});
} catch (error) {
next(error);
}
}
async delete(req: any, res: ServerResponse, next: NextFunction) {
try {
const id = req?.params?.id;
await this.#service.delete(id);
return res.status(200).json({
status: 200,
data: {},
message: "حذف شد",
});
} catch (error) {
next(error);
}
}
async getById(req: any, res: ServerResponse, next: NextFunction) {
try {
const id = req?.params?.id;
const data = await this.#service.getById(id);
res.status(201).json({
status: 201,
data,
message: "ساخته شد",
});
} catch (error) {
next(error);
}
}
}
const UserController = new UserControllerClass();