overflow_server_app/module/member/signup.go
2017-09-05 15:37:33 +09:00

54 lines
1.1 KiB
Go

package member
import (
"fmt"
"encoding/json"
"git.loafle.net/overflow/overflow_server_app/grpc"
"github.com/valyala/fasthttp"
)
type Member struct {
Id string `json:"id"`
Email string `json:"email"`
Pw string `json:"pw"`
Name string `json:"name"`
CompanyName string `json:"companyName"`
Phone string `json:"phone"`
}
func SignUp(ctx *fasthttp.RequestCtx) {
var err error
var webParams []interface{}
webBytes := ctx.PostBody()
err = json.Unmarshal(webBytes, &webParams)
if err != nil {
fmt.Fprintf(ctx, "Err!!!!: %s\n", err)
}
length := len(webParams)
if length < 0 {
fmt.Println("eeee")
}
jsonMap := webParams[0].(map[string]interface{})
memberMap := jsonMap["member"].(map[string]interface{})
m := &Member{}
m.Email = memberMap["email"].(string)
m.Name = memberMap["name"].(string)
m.CompanyName = memberMap["companyName"].(string)
m.Phone = memberMap["phone"].(string)
m.Pw = memberMap["pw"].(string)
mm, _ := json.Marshal(m)
params := []string{string(mm), string(m.Pw)}
r, err := grpc.Exec("MemberService", "signup", params)
fmt.Fprintf(ctx, "Welcome!!!!: %s\n", r)
}