This commit is contained in:
2023-12-06 00:09:34 +08:00
parent ec727bbf6b
commit ff0696b55b
7 changed files with 140 additions and 33 deletions

View File

@@ -3,6 +3,7 @@ package api
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"time"
)
@@ -16,6 +17,20 @@ func (ids IDS) ToString() (str string) {
type ImageList []Image
// 按照ID排序
func (image *ImageList) SortByIDList(id_list []string) {
var sortedImageList ImageList
for _, id := range id_list {
id_number, _ := strconv.Atoi(id)
for _, image := range *image {
if image.ID == id_number {
sortedImageList = append(sortedImageList, image)
}
}
}
*image = sortedImageList
}
// 取到所有的文章ID, 去除重复
func (images *ImageList) ToAllArticleID() (uniqueIds IDS) {
article_ids := make(map[int]bool)