修正數據集圖像列表

This commit is contained in:
2023-05-27 12:29:10 +08:00
parent c5277021ac
commit d847933337
2 changed files with 10 additions and 1 deletions

View File

@@ -119,6 +119,15 @@ func DatasetsItemPatch(w http.ResponseWriter, r *http.Request) {
if info, ok := form["info"].(string); ok {
dataset.Info = info
}
if images, ok := form["images"].([]interface{}); ok {
var image_list ImageList
for _, image := range images {
if image, ok := image.(string); ok {
image_list = append(image_list, image)
}
}
dataset.Images = image_list
}
if err := configs.ORMDB().Save(&dataset).Error; err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte("500 - Internal Server Error"))

View File

@@ -46,7 +46,7 @@ echo "dataset_id: $dataset_id"
# 修改數據集, images 中增加 url (PATCH /api/datasets/:id)
response=$(curl -X PATCH -H "Content-Type: application/json" -d '{"images":[{"url":"https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"}]}' -b "session_id=$session_id" -s -w "%{http_code}" http://localhost:8080/api/datasets/$dataset_id)
response=$(curl -X PATCH -H "Content-Type: application/json" -d '{"images":["https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"]}' -b "session_id=$session_id" -s -w "%{http_code}" http://localhost:8080/api/datasets/$dataset_id)
[[ ${response: -3} -eq 200 ]] && { echo "修改數據集成功: ${response%???}"; } || exit_service "修改數據集失敗: ${response%???}"