계정 대량 조회 추가
This commit is contained in:
31
core/api.go
31
core/api.go
@ -396,12 +396,7 @@ func (caller apiCaller) userinfoAPI(w http.ResponseWriter, r *http.Request) erro
|
||||
if r.Method == "GET" {
|
||||
// 계정 조회
|
||||
accid, _ := gocommon.ReadObjectIDFormValue(r.Form, "accid")
|
||||
if len(accid) == 0 {
|
||||
logger.Println("[userinfoAPI] accid is empty")
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(accid) > 0 {
|
||||
all, err := mg.mongoClient.FindAll(CollectionAccount, bson.M{
|
||||
"accid": accid,
|
||||
}, options.Find().SetProjection(bson.M{"_id": 1, "accid": 1}))
|
||||
@ -432,7 +427,31 @@ func (caller apiCaller) userinfoAPI(w http.ResponseWriter, r *http.Request) erro
|
||||
|
||||
enc := json.NewEncoder(w)
|
||||
enc.Encode(linkinfos)
|
||||
}
|
||||
} else if r.Method == "POST" {
|
||||
r.ParseMultipartForm(32 << 20)
|
||||
var body struct {
|
||||
Platform string
|
||||
Uid []string
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(body.Platform) > 0 && len(body.Uid) > 0 {
|
||||
output := make(map[string]any)
|
||||
for _, uid := range body.Uid {
|
||||
link, err := mg.mongoClient.FindOne(CollectionLink, bson.M{
|
||||
"platform": body.Platform,
|
||||
"uid": uid,
|
||||
}, options.FindOne().SetProjection(bson.M{"_id": 1}))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
output[uid] = link["_id"]
|
||||
}
|
||||
json.NewEncoder(w).Encode(output)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user