From fe662c5355fe4fb6c4df9a4a071894ce518ddb3f Mon Sep 17 00:00:00 2001 From: mklee Date: Wed, 6 Sep 2023 11:22:54 +0900 Subject: [PATCH] =?UTF-8?q?[=EC=9D=B4=EB=AF=BC=EC=9A=B0]=20=EC=BA=90?= =?UTF-8?q?=EB=A6=AD=ED=84=B0=20=EC=83=9D=EC=84=B1=20=EC=A0=9C=ED=95=9C=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20(=EB=8C=80=EC=8B=A0=20=EC=BB=A4=EB=B0=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/api.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/core/api.go b/core/api.go index 5039810..f7ac026 100644 --- a/core/api.go +++ b/core/api.go @@ -397,6 +397,30 @@ func (caller apiCaller) configAPI(w http.ResponseWriter, r *http.Request) error return nil } +func (caller apicaller) lockcreatecharAPI(w http.ResponseWriter, r *http.Request) error { + mg, err := caller.mg.mongoClient.FindAll(CollectionService, bson.M{}) + if err != nil { + return err + } + + curregion, _ := gocommon.ReadStringFormValue(r.Form, "region") + + for _, regioninfo := range mg { + region := regioninfo["divisions"].(primitive.M) + for idx, rl := range region { + if idx == curregion { + if rl.(primitive.M)["lockcreatechar"].(bool) { + w.Write([]byte(fmt.Sprintf(`{"create":"%t"}`, true))) + } else { + w.Write([]byte(fmt.Sprintf(`{"create":"%t"}`, false))) + } + } + } + } + + return nil +} + type apiCaller struct { userinfo map[string]any globalAdmins map[string]bool @@ -503,6 +527,8 @@ func (mg *Maingate) api(w http.ResponseWriter, r *http.Request) { err = caller.blockAPI(w, r) } else if strings.HasSuffix(r.URL.Path, "/coupon") { err = caller.couponAPI(w, r) + } else if strings.HasSuffix(r.URL.Path, "/lockcreatechar") { + err = caller.lockcreatecharAPI(w, r) } if err != nil {