Esempio n. 1
0
func testRegister() {
	m := member.ValueMember{
		Usr:      "******",
		Pwd:      "test",
		Name:     "测试员",
		Sex:      1,
		Avatar:   "",
		Birthday: "1988-11-09",
		Phone:    "18616999822",
		Address:  "",
		Qq:       "",
		Email:    "",
		RegIp:    "127.0.0.1",
	}
	b, err := goclient.Member.Register(&m, 101, 0, "")
	if err != nil {
		jsv.LogErr(err)

	} else {
		jsv.Println("注册成功")
	}
	b, _, _ = goclient.Member.Login(m.Usr, m.Pwd)
	if b {
		jsv.Println("登录成功")
	} else {

		jsv.Printf("登录失败:Usr:%s,Pwd:%s\n", m.Usr, m.Pwd)
	}
}
Esempio n. 2
0
func Verify(m *jsv.Args) (memberId int, err error) {
	member_id, token := (*m)["member_id"].(string), (*m)["token"].(string)

	if memberId, err = strconv.Atoi(member_id); err != nil || token == "" {

		jsv.Println(err)
		return memberId, errors.New("invalid parameter")
	} else {
		//todo:  用户令牌更改,需修改。
		return memberId, nil
	}

	rds := Redis().Get()
	defer rds.Close()

	sessKey := fmt.Sprintf("dps:session:m%d", memberId)
	servToken, err := redis.String(rds.Do("GET", sessKey))
	if err != nil {
		return memberId, member.ErrInvalidSession
	}

	//	if jsv.Context.Debug() {
	//		jsv.Println("[Member][Verify]", memberId, token, servToken)
	//	}

	if servToken != token {
		return memberId, member.ErrSessionTimeout
	} else {
		rds.Do("SETEX", sessKey, 3600*3, token) //更新回话并延长时间
	}
	return memberId, nil
}
Esempio n. 3
0
func testPartner() {
	p, err := goclient.Partner.GetPartner(101, "d435a520e50e960b")
	if err != nil {
		jsv.LogErr(err)
	} else {
		jsv.Println(p)
	}
}
Esempio n. 4
0
func testSubmitOrder() {
	items := "2*1|3*2|4*1"
	orderNo, err := goclient.Partner.SubmitOrder(101, "d435a520e50e960b",
		1, 0, 1, items, "")
	if err != nil {
		jsv.LogErr(err)
	} else {
		jsv.Println("[OrderNo]", orderNo)
	}
}
Esempio n. 5
0
func testMemberLogin() {
	b, t, err := goclient.Member.Login("jarryliu", "123000")
	if b {
		jsv.Println("[Login]:Sucessfull.", t)
		arr := strings.Split(t, "$")
		id, _ := strconv.Atoi(arr[0])
		token := arr[1]
		r := goclient.Member.Verify(id, token)
		if r.Result {
			jsv.Println("成功\n")
		} else {
			jsv.Println("验证失败:", r.Message)
		}

		acc, _ := goclient.Member.GetMemberRelation(id, token)
		if acc != nil {
			jsv.Println(*acc)
		}
	} else {
		jsv.Println("[Login]:Failed.", err)
	}

}