overflow_server_app/module/member/signup.go

56 lines
1.2 KiB
Go
Raw Permalink Normal View History

2017-08-23 09:19:21 +00:00
package member
import (
2017-11-23 08:06:44 +00:00
"context"
2017-08-23 09:19:21 +00:00
"fmt"
2017-09-05 06:37:33 +00:00
"encoding/json"
2017-08-23 09:19:21 +00:00
2017-11-23 08:06:44 +00:00
"git.loafle.net/overflow/overflow_server_app/external/grpc"
2017-08-23 09:19:21 +00:00
"github.com/valyala/fasthttp"
)
2017-08-24 06:06:09 +00:00
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"`
}
2017-09-05 06:37:33 +00:00
func SignUp(ctx *fasthttp.RequestCtx) {
var err error
2017-09-05 04:03:24 +00:00
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{})
2017-08-24 06:06:09 +00:00
m := &Member{}
2017-09-05 04:03:24 +00:00
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)
2017-08-24 06:06:09 +00:00
2017-09-05 06:37:33 +00:00
mm, _ := json.Marshal(m)
2017-08-24 06:06:09 +00:00
params := []string{string(mm), string(m.Pw)}
2017-08-23 09:19:21 +00:00
2017-11-23 08:06:44 +00:00
gRPCCtx := context.Background()
r, err := grpc.Exec(gRPCCtx, "MemberService.signup", params)
2017-08-23 09:19:21 +00:00
2017-08-24 06:06:09 +00:00
fmt.Fprintf(ctx, "Welcome!!!!: %s\n", r)
2017-08-23 09:19:21 +00:00
}