Explorar o código

Merge branch 'develop' of 192.168.3.17:zhanghongbo/qfw into develop

renzheng %!s(int64=9) %!d(string=hai) anos
pai
achega
7c26004a21

+ 2 - 2
common/src/qfw/util/rpc/credit.go

@@ -24,7 +24,7 @@ func (rc *RpcCall) InCreadit(param *CreditData, replay *int) error {
 	if err != nil {
 		return err
 	}
-	err = client.Call("CreditRpc.InCreadit", param, replay)
+	err = client.Call("CreditRpc.InCreadit", &param, &replay)
 	return err
 }
 
@@ -35,6 +35,6 @@ func (rc *RpcCall) OutCreadit(param *CreditData, replay *int) error {
 	if err != nil {
 		return err
 	}
-	err = client.Call("CreditRpc.OutCreadit", param, replay)
+	err = client.Call("CreditRpc.OutCreadit", &param, &replay)
 	return err
 }

+ 1 - 1
core/src/main.go

@@ -6,12 +6,12 @@ import (
 	"github.com/go-xweb/xweb"
 	_ "qfw/chat"
 	. "qfw/coreconfig"
-	_ "qfw/credit"
 	"qfw/filemanage"
 	_ "qfw/filter"
 	_ "qfw/front"
 	_ "qfw/manage"
 	_ "qfw/member"
+	_ "qfw/member/credit"
 	_ "qfw/member/message"
 	_ "qfw/microwebsite"
 	_ "qfw/mobile"

+ 0 - 38
core/src/qfw/credit/credit.go

@@ -1,38 +0,0 @@
-// credit
-package credit
-
-import (
-	"github.com/go-xweb/xweb"
-	"log"
-	. "qfw/coreconfig"
-	"qfw/util"
-	"qfw/util/rpc"
-)
-
-var Rc *rpc.RpcCall
-
-func init() {
-	util.ReadConfig(&SysConfig)
-	Rc = new(rpc.RpcCall)
-	Rc.Addr = SysConfig.CreditRpc
-	//添加模块解析
-	xweb.AddAction(&Credit{})
-}
-
-type Credit struct {
-	*xweb.Action
-	increditAjaxRqe xweb.Mapper `xweb:"/incredit"` //增加积分
-}
-
-//增加积分
-func (c *Credit) IncreditAjaxRqe() error {
-	otherParam := make(map[string]interface{})
-	otherParam["name"] = "zhangsan"
-	otherParam["age"] = 18
-	replay := 0
-	err := Rc.InCreadit(&rpc.CreditData{Code: "1", Uid: "2", Num: 3, OtherParam: otherParam}, &replay)
-	if err == nil {
-		log.Println("加分成功")
-	}
-	return nil
-}

+ 40 - 0
core/src/qfw/member/credit/credit.go

@@ -0,0 +1,40 @@
+// credit
+package credit
+
+import (
+	"github.com/go-xweb/xweb"
+	. "gopkg.in/mgo.v2/bson"
+	. "qfw/coreconfig"
+	"qfw/util"
+	"qfw/util/rpc"
+)
+
+var rc rpc.RpcCall
+var replay *int
+
+func init() {
+	util.ReadConfig(&SysConfig)
+	rc = rpc.RpcCall{Addr: SysConfig.CreditRpc}
+	//添加模块解析
+	xweb.AddAction(&Credit{})
+}
+
+type Credit struct {
+	*xweb.Action
+	increditAjaxRqe xweb.Mapper `xweb:"/member/incredit"` //增加积分
+}
+
+//增加积分
+func (c *Credit) IncreditAjaxRqe() error {
+	userId := c.GetSession("userId").(string)
+	code := c.GetString("code")
+	num, _ := c.GetInt("num")
+	param := make(map[string]interface{})
+	err := rc.InCreadit(&rpc.CreditData{Code: code, Uid: userId, Num: int(num), OtherParam: param}, replay)
+	result := false
+	if err == nil {
+		result = true
+	}
+	c.ServeJson(M{"result": result})
+	return nil
+}