Compare commits
2 Commits
4212d3ed59
...
a7a9b207e2
| Author | SHA1 | Date | |
|---|---|---|---|
| a7a9b207e2 | |||
| f7e3da51ae |
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" {
|
if r.Method == "GET" {
|
||||||
// 계정 조회
|
// 계정 조회
|
||||||
accid, _ := gocommon.ReadObjectIDFormValue(r.Form, "accid")
|
accid, _ := gocommon.ReadObjectIDFormValue(r.Form, "accid")
|
||||||
if len(accid) == 0 {
|
if len(accid) > 0 {
|
||||||
logger.Println("[userinfoAPI] accid is empty")
|
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
all, err := mg.mongoClient.FindAll(CollectionAccount, bson.M{
|
all, err := mg.mongoClient.FindAll(CollectionAccount, bson.M{
|
||||||
"accid": accid,
|
"accid": accid,
|
||||||
}, options.Find().SetProjection(bson.M{"_id": 1, "accid": 1}))
|
}, 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 := json.NewEncoder(w)
|
||||||
enc.Encode(linkinfos)
|
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
|
return nil
|
||||||
|
|||||||
@ -431,7 +431,7 @@ func (mg *Maingate) prepare(context context.Context) (err error) {
|
|||||||
|
|
||||||
var portptr = flagx.Int("port", 80, "")
|
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
|
var allServices []*serviceDescription
|
||||||
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
if err := mg.mongoClient.AllAs(CollectionService, &allServices, options.Find().SetReturnKey(false)); err != nil {
|
||||||
return logger.ErrorWithCallStack(err)
|
return logger.ErrorWithCallStack(err)
|
||||||
|
|||||||
@ -3,13 +3,13 @@ package core
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
"repositories.action2quare.com/ayo/gocommon"
|
||||||
"repositories.action2quare.com/ayo/gocommon/logger"
|
"repositories.action2quare.com/ayo/gocommon/logger"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
@ -34,7 +34,7 @@ type filePipelineDocument struct {
|
|||||||
File *FileDocumentDesc `bson:"fullDocument"`
|
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() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
if s != nil {
|
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() {
|
defer func() {
|
||||||
s := recover()
|
s := recover()
|
||||||
if s != nil {
|
if s != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user