diff --git a/models/container.go b/models/container.go index cb3fb0d..71feb90 100644 --- a/models/container.go +++ b/models/container.go @@ -113,20 +113,18 @@ func initContainer() { func (c *Container) write(cks []JdCookie) error { switch c.Type { case "ql": - if c.Version == "2.8" { if len(c.Delete) > 0 { c.request("/api/envs", DELETE, fmt.Sprintf(`[%s]`, strings.Join(c.Delete, ","))) } - d := "" + hh := []string{} if len(cks) != 0 { for _, ck := range cks { if ck.Available == True { - d += fmt.Sprintf("pt_key=%s;pt_pin=%s;\\n", ck.PtKey, ck.PtPin) + hh = append(hh, fmt.Sprintf(`{"name":"JD_COOKIE","value":"pt_key=%s;pt_pin=%s;","remarks":"%s"}`, ck.PtKey, ck.PtPin, ck.Note)) } } - c.request("/api/envs", POST, `{"name":"JD_COOKIE","value":"`+d+`"}`) - + c.request("/api/envs", POST, fmt.Sprintf(`[%s]`, strings.Join(hh, ","))) type AutoGenerated struct { Code int `json:"code"` Data []struct { @@ -165,7 +163,7 @@ func (c *Container) write(cks []JdCookie) error { "value": v, } d, _ := json.Marshal(r) - c.request("/api/envs", POST, string(d)) + c.request("/api/envs", POST, fmt.Sprintf(`[%s]`, string(d))) } }