há 7 anos atrás
pai
commit
3833598106

+ 0 - 0
src/jy/admin/admin.go


+ 0 - 0
src/jy/buyermanager/buyermanage.go


+ 0 - 0
src/jy/cluster/cluster.go


+ 0 - 0
src/jy/extract/extract.go


+ 18 - 15
src/jy/front/front.go

@@ -1,25 +1,28 @@
 package front
 
 import (
-	"net/http"
+	"fmt"
+	. "jy/router"
+
+	. "jy/mongodbutil"
 
 	"github.com/gin-contrib/sessions"
-	"github.com/gin-contrib/sessions/memstore"
 	"github.com/gin-gonic/gin"
 )
 
-var Router = gin.Default()
-
-func Server() {
-	store := memstore.NewStore([]byte("jy_data_extract"))
-	Router.Use(sessions.Sessions("mysession", store))
-	Router.Run(":9090")
-}
-
-func Login() {
-	Router.GET("/login", func(c *gin.Context) {
-		c.JSON(http.StatusOK, gin.H{
-			"checked": true,
-		})
+func init() {
+	//登录
+	Router.POST("/login", func(c *gin.Context) {
+		name := c.GetString("name")
+		pwd := c.GetString("pwd")
+		res, b := Mgo.FindOne("user", fmt.Sprintf(`{"name":"%s","pwd":"%s"}`, name, pwd))
+		if b && res != nil {
+			session := sessions.Default(c)
+			session.Set("name", name)
+			session.Save()
+			c.JSON(200, gin.H{"checked": true})
+		} else {
+			c.JSON(200, gin.H{"checked": false})
+		}
 	})
 }

+ 15 - 0
src/jy/router/router.go

@@ -0,0 +1,15 @@
+package router
+
+import (
+	"github.com/gin-contrib/sessions"
+	"github.com/gin-contrib/sessions/memstore"
+	"github.com/gin-gonic/gin"
+)
+
+var Router = gin.Default()
+
+func init() {
+	store := memstore.NewStore([]byte("jy_data_extract"))
+	Router.Use(sessions.Sessions("mysession", store))
+	Router.Run(":9090")
+}

+ 0 - 0
src/jy/statistics/statistics.go


+ 0 - 0
src/jy/winnermanager/winnermanager.go