baozhensong 6 rokov pred
rodič
commit
d9b19d46e9

+ 3 - 1
services/apiprovider/actions.go

@@ -321,6 +321,8 @@ func AppAuth(req *http.Request, r render.Render) {
 		AccessToken: TokenMaker(app),
 	}
 
-	r.JSON(http.StatusOK, result)
+	r.JSON(http.StatusOK, Common{
+		Result: result,
+	})
 	return
 }

+ 43 - 0
services/knowoapi/model/application_test.go

@@ -0,0 +1,43 @@
+package model
+
+import (
+	"sparrow/pkg/mysql"
+	"testing"
+
+	"github.com/jinzhu/gorm"
+)
+
+func TestGetAppCount(t *testing.T) {
+
+	key := "aab1f679672380cf8cc79816bac4256809d0820473bc958e4c4eac91fd97e27b"
+
+	app := getApplication(t)
+	a, err := app.GetAppInfo(uint(1), key)
+	if err != nil {
+		t.Fatal(err)
+	}
+	t.Log(a)
+}
+
+func getApplication(t *testing.T) *Application {
+	db, err := getAppDB()
+	if err != nil {
+		t.Fatal(err)
+	}
+	app := new(Application).Init(db)
+	return app
+}
+
+func getAppDB() (*gorm.DB, error) {
+	db, err := mysql.GetClient("192.168.175.60", "3306", "SparrowCloud", "SparrowCloud", "123456")
+	if err != nil {
+		return nil, err
+	}
+	gormdb, err := gorm.Open("mysql", db)
+	if err != nil {
+		return nil, err
+	}
+	gormdb.SingularTable(true)
+	gormdb.LogMode(true)
+	return gormdb, nil
+}