Compare commits

..

2 Commits

Author SHA1 Message Date
a7a9b207e2 계정 대량 조회 추가 2024-07-31 16:49:06 +09:00
f7e3da51ae RegisterHandlers 시그니쳐 수정 (ServerMuxInterface) 2024-07-31 16:48:54 +09:00
3 changed files with 53 additions and 34 deletions

View File

@ -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

View File

@ -431,7 +431,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
var portptr = flagx.Int("port", 80, "")
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error {
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) error {
var allServices []*serviceDescription
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
return logger.ErrorWithCallStack(err)

View File

@ -3,13 +3,13 @@ package core
import (
"context"
"encoding/hex"
"net/http"
"os"
"path"
"sync/atomic"
"time"
"unsafe"
"repositories.action2quare.com/ayo/gocommon"
"repositories.action2quare.com/ayo/gocommon/logger"
"go.mongodb.org/mongo-driver/bson"
@ -34,7 +34,7 @@ type filePipelineDocument struct {
File *FileDocumentDesc `bson:"fullDocument"`
}
func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux *http.ServeMux, prefix string) {
func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) {
defer func() {
s := recover()
if s != nil {
@ -119,7 +119,7 @@ func (mg *Maingate) watchFileCollection(parentctx context.Context, serveMux *htt
}
}
func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux *http.ServeMux, prefix string) {
func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux gocommon.ServerMuxInterface, prefix string) {
defer func() {
s := recover()
if s != nil {