Пример #1
0
func picTest() {
	jingwei.ReadConfig("./conf/default.json")
	handler := &jingwei.RpcServiceImpl{}
	var apiErr *api.Exception
	var err error
	apiErr, err = handler.AddUser(&api.UserPost{"user24", "passwd", "*****@*****.**", "User16", "Intro",
		"Picture", "Birth", "Addr", "PhoneNumber", "Man"})
	if apiErr != nil || err != nil {
		panic(apiErr)
	}
	user, _, _ := handler.GetUserByEmail("*****@*****.**")
	if user == nil {
		panic("error")
	}
	path := "/Users/kang/Desktop/golang.jpg"
	content, ok := ioutil.ReadFile(path)
	if ok != nil {
		panic(ok)
	}
	apiErr, err = handler.AddUserAvatar(&api.UserAvatarPost{user.ID.Hex(), "jpg", string(content)})
	if !(apiErr == nil && err == nil) {
		panic(err)
	}
	fmt.Println("now ID:", user.ID.Hex())
	user, _, _ = handler.GetUserByEmail("*****@*****.**")
	fmt.Println("expectURL:", user.Picture)
	fmt.Println("finished")
}
Пример #2
0
func modelTest() {
	jingwei.ReadConfig("./conf/default.json")
	hos := models.NewHospital()
	hos.Name = "xiaokang"
	hos.Save()

	id := hos.ID.Hex()
	fmt.Println("hos.ID:", id)
	hos, _ = models.HospitalFindByID(id)
	fmt.Println(hos)
	fmt.Println("now.ID:", hos.ID.Hex())
}