feat(csms): 充电桩添加 deviceName 字段,区别于 identifier 用于区分设备
This commit is contained in:
@@ -71,6 +71,7 @@ app.post("/", async (c) => {
|
||||
registrationStatus?: "Accepted" | "Pending" | "Rejected";
|
||||
feePerKwh?: number;
|
||||
pricingMode?: "fixed" | "tou";
|
||||
deviceName?: string;
|
||||
}>();
|
||||
|
||||
if (!body.chargePointIdentifier?.trim()) {
|
||||
@@ -93,6 +94,7 @@ app.post("/", async (c) => {
|
||||
registrationStatus: body.registrationStatus ?? "Pending",
|
||||
feePerKwh: body.feePerKwh ?? 0,
|
||||
pricingMode: body.pricingMode ?? "fixed",
|
||||
deviceName: body.deviceName?.trim() || null,
|
||||
})
|
||||
.returning()
|
||||
.catch((err: Error) => {
|
||||
@@ -142,6 +144,7 @@ app.patch("/:id", async (c) => {
|
||||
registrationStatus?: string;
|
||||
chargePointVendor?: string;
|
||||
chargePointModel?: string;
|
||||
deviceName?: string | null;
|
||||
}>();
|
||||
|
||||
const set: {
|
||||
@@ -150,6 +153,7 @@ app.patch("/:id", async (c) => {
|
||||
registrationStatus?: "Accepted" | "Pending" | "Rejected";
|
||||
chargePointVendor?: string;
|
||||
chargePointModel?: string;
|
||||
deviceName?: string | null;
|
||||
updatedAt: Date;
|
||||
} = { updatedAt: dayjs().toDate() };
|
||||
|
||||
@@ -167,6 +171,7 @@ app.patch("/:id", async (c) => {
|
||||
}
|
||||
if (body.chargePointVendor !== undefined) set.chargePointVendor = body.chargePointVendor.trim() || "Unknown";
|
||||
if (body.chargePointModel !== undefined) set.chargePointModel = body.chargePointModel.trim() || "Unknown";
|
||||
if ("deviceName" in body) set.deviceName = body.deviceName?.trim() || null;
|
||||
if (body.pricingMode !== undefined) {
|
||||
if (!['fixed', 'tou'].includes(body.pricingMode)) {
|
||||
return c.json({ error: "pricingMode must be 'fixed' or 'tou'" }, 400);
|
||||
|
||||
Reference in New Issue
Block a user