mirror of
https://github.com/jiangrui1994/CloudSaver.git
synced 2026-01-12 16:18:45 +08:00
feat:版本迭代
This commit is contained in:
17
backend/src/utils/response.ts
Normal file
17
backend/src/utils/response.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Response } from "express";
|
||||
|
||||
interface ResponseData {
|
||||
code?: number; // 业务状态码
|
||||
message?: string;
|
||||
data?: any;
|
||||
}
|
||||
|
||||
export const sendSuccess = (res: Response, response: ResponseData, businessCode: number = 0) => {
|
||||
response.code = businessCode;
|
||||
res.status(200).json(response);
|
||||
};
|
||||
|
||||
export const sendError = (res: Response, response: ResponseData, businessCode: number = 10000) => {
|
||||
response.code = businessCode;
|
||||
res.status(200).json(response);
|
||||
};
|
||||
Reference in New Issue
Block a user