503c2ba5ec
member service code refactoring
83 lines
1.5 KiB
Go
83 lines
1.5 KiB
Go
package proxy
|
|
|
|
import (
|
|
"log"
|
|
"encoding/json"
|
|
)
|
|
|
|
type MemberService struct {
|
|
Email string `json:"email"`
|
|
PwSalt string `json:"pwSalt"`
|
|
Digest string `json:"digest"`
|
|
Name string `json:"name"`
|
|
Company string `json:"company"`
|
|
Phone string `json:"phone"`
|
|
}
|
|
|
|
var TARGET_DAO = "member"
|
|
|
|
func NewMember() *MemberService {
|
|
m := MemberService{}
|
|
return &m
|
|
}
|
|
|
|
func (m *MemberService) getMemberMap() (map[string]string) {
|
|
memMap := make(map[string]string)
|
|
|
|
str, err := json.Marshal(m)
|
|
|
|
if err != nil {
|
|
log.Fatal("Json Marshal Error: ", err)
|
|
}
|
|
|
|
memMap["com.loafle.overflow.member.model.Member"] = string(str)
|
|
|
|
return memMap
|
|
}
|
|
|
|
func (m *MemberService) Regist() (string){
|
|
log.Println("Call Regist", m.Email, m.PwSalt)
|
|
// Todo Call DB Gateway
|
|
|
|
m.Digest = "dddddddd"
|
|
|
|
memMap := m.getMemberMap()
|
|
|
|
re := invokeDB(TARGET_DAO, "create", memMap)
|
|
|
|
return re
|
|
}
|
|
|
|
func (m *MemberService) Read() (string){
|
|
log.Println("Call Read", m.Email)
|
|
// Todo Call DB Gateway
|
|
m.Digest = "read"
|
|
memMap := m.getMemberMap()
|
|
|
|
re := invokeDB(TARGET_DAO, "find", memMap)
|
|
|
|
return re
|
|
}
|
|
|
|
func (m *MemberService) Modify() (string){
|
|
log.Println("Call Modify", m.Email, "::", m.PwSalt)
|
|
// Todo Call DB Gateway
|
|
m.Digest = "read"
|
|
memMap := m.getMemberMap()
|
|
|
|
re := invokeDB(TARGET_DAO, "update", memMap)
|
|
|
|
return re
|
|
}
|
|
|
|
func (m *MemberService) Remove() (string){
|
|
log.Println("Call Remove", m.Email)
|
|
// Todo Call DB Gateway
|
|
m.Digest = "read"
|
|
memMap := m.getMemberMap()
|
|
|
|
re := invokeDB(TARGET_DAO, "delete", memMap)
|
|
|
|
return re
|
|
}
|