feat: 设备编号从 00000001 顺序分配

This commit is contained in:
Nixevol
2026-10-12 08:54:17 +08:00
parent 775599174b
commit c334dbc040
8 changed files with 119 additions and 29 deletions
+5 -5
View File
@@ -40,9 +40,9 @@ func TestClientCreatesAndReadsEndpoint(t *testing.T) {
}
mu.Lock()
sawCSRF = true
online["e_abc"] = true
online["00000001"] = true
mu.Unlock()
_ = json.NewEncoder(w).Encode(map[string]any{"ok": true, "data": map[string]any{"id": "e_abc", "login_password": "OnceFromNix12345"}})
_ = json.NewEncoder(w).Encode(map[string]any{"ok": true, "data": map[string]any{"id": "00000001", "login_password": "OnceFromNix12345"}})
})
mux.HandleFunc("GET /api/admin/endpoints/{id}", func(w http.ResponseWriter, r *http.Request) {
mu.Lock()
@@ -63,14 +63,14 @@ func TestClientCreatesAndReadsEndpoint(t *testing.T) {
if err != nil {
t.Fatal(err)
}
ep, err := client.CreateEndpoint(context.Background(), "客厅")
ep, err := client.CreateEndpoint(context.Background(), "00000001", "客厅")
if err != nil {
t.Fatal(err)
}
if ep.ID != "e_abc" || ep.LoginPassword != "OnceFromNix12345" {
if ep.ID != "00000001" || ep.LoginPassword != "OnceFromNix12345" {
t.Fatalf("endpoint %+v", ep)
}
got, err := client.Lookup(context.Background(), "e_abc")
got, err := client.Lookup(context.Background(), "00000001")
if err != nil || !got.Found || !got.Online {
t.Fatalf("lookup %+v %v", got, err)
}