|
@ -1,106 +1,108 @@ |
|
|
package userrpc |
|
|
package userrpc |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"encoding/json" |
|
|
|
|
|
"errors" |
|
|
|
|
|
|
|
|
"encoding/json" |
|
|
|
|
|
"errors" |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取用户积分 |
|
|
* 获取用户积分 |
|
|
*/ |
|
|
*/ |
|
|
func GetUserScore(dbname,userId string, url ...string) (string, error) { |
|
|
|
|
|
|
|
|
func GetUserScore(dbname, userId string, url ...string) (string, error) { |
|
|
|
|
|
|
|
|
if dbname == "" || userId == "" { |
|
|
|
|
|
return "", errors.New("参数错误") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if dbname == "" || userId == "" { |
|
|
|
|
|
return "", errors.New("参数错误") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
|
data := GetUserReq{} |
|
|
|
|
|
data.Dbname = dbname |
|
|
|
|
|
data.UserId = userId |
|
|
|
|
|
|
|
|
data := GetUserReq{} |
|
|
|
|
|
data.Dbname = dbname |
|
|
|
|
|
data.UserId = userId |
|
|
|
|
|
|
|
|
req, err := SetReqData(data) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
req, err := SetReqData(data) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
|
err = conn.GetUserScore(req, res) |
|
|
|
|
|
|
|
|
err = conn.GetUserScore(req, res) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res_data_de, err := GetResData(res) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
if res_data_de == "" { |
|
|
|
|
|
return "", nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res_data_de, err := GetResData(res) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
if res_data_de == "" { |
|
|
|
|
|
return "", nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var score string |
|
|
|
|
|
err = json.Unmarshal([]byte(res_data_de),&score) |
|
|
|
|
|
|
|
|
var score string |
|
|
|
|
|
err = json.Unmarshal([]byte(res_data_de), &score) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return score, nil |
|
|
|
|
|
|
|
|
return score, nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 获取用户红包 |
|
|
* 获取用户红包 |
|
|
*/ |
|
|
*/ |
|
|
func GetUserRedEnvelope(dbname,userId string, url ...string) (string, error) { |
|
|
|
|
|
|
|
|
func GetUserRedEnvelope(dbname, userId string, url ...string) (string, error) { |
|
|
|
|
|
|
|
|
if dbname == "" || userId == "" { |
|
|
|
|
|
return "", errors.New("参数错误") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if dbname == "" || userId == "" { |
|
|
|
|
|
return "", errors.New("参数错误") |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
|
conn, err := rpc_server_conn(url...) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
defer conn.Close() |
|
|
|
|
|
|
|
|
data := GetUserReq{} |
|
|
|
|
|
data.Dbname = dbname |
|
|
|
|
|
data.UserId = userId |
|
|
|
|
|
|
|
|
data := GetUserReq{} |
|
|
|
|
|
data.Dbname = dbname |
|
|
|
|
|
data.UserId = userId |
|
|
|
|
|
|
|
|
req, err := SetReqData(data) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
req, err := SetReqData(data) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
|
res := &Response{} |
|
|
|
|
|
|
|
|
err = conn.GetUserRedEnvelope(req, res) |
|
|
|
|
|
|
|
|
err = conn.GetUserRedEnvelope(req, res) |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res_data_de, err := GetResData(res) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
if res_data_de == "" { |
|
|
|
|
|
return "", nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
res_data_de, err := GetResData(res) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
if res_data_de == "" { |
|
|
|
|
|
return "", nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var redEnvelope string |
|
|
|
|
|
err = json.Unmarshal([]byte(res_data_de),&redEnvelope) |
|
|
|
|
|
|
|
|
var redEnvelope string |
|
|
|
|
|
err = json.Unmarshal([]byte(res_data_de), &redEnvelope) |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return redEnvelope, nil |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return "", err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return redEnvelope, nil |
|
|
|
|
|
} |
|
|
|