修正數據集圖像列表
This commit is contained in:
@@ -119,6 +119,15 @@ func DatasetsItemPatch(w http.ResponseWriter, r *http.Request) {
|
|||||||
if info, ok := form["info"].(string); ok {
|
if info, ok := form["info"].(string); ok {
|
||||||
dataset.Info = info
|
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 {
|
if err := configs.ORMDB().Save(&dataset).Error; err != nil {
|
||||||
w.WriteHeader(http.StatusInternalServerError)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
w.Write([]byte("500 - Internal Server Error"))
|
w.Write([]byte("500 - Internal Server Error"))
|
||||||
|
2
test.sh
2
test.sh
@@ -46,7 +46,7 @@ echo "dataset_id: $dataset_id"
|
|||||||
|
|
||||||
|
|
||||||
# 修改數據集, images 中增加 url (PATCH /api/datasets/: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%???}"
|
[[ ${response: -3} -eq 200 ]] && { echo "修改數據集成功: ${response%???}"; } || exit_service "修改數據集失敗: ${response%???}"
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user