diff --git a/cloud/sysCloud/user.go b/cloud/sysCloud/user.go index d2af515..5e1c15c 100644 --- a/cloud/sysCloud/user.go +++ b/cloud/sysCloud/user.go @@ -25,7 +25,7 @@ func Login(name, pass string) (*bean.SysLogin, error) { func FindUser(xid string) *models.SysUser { e := &models.SysUser{} pars := ruisUtil.NewMap() - pars.Set("id", xid) + pars.Set("xid", xid) err := cloud.SysCloudExec.ExecObjJSON("/user/info", pars, e) if err != nil { return nil @@ -37,9 +37,23 @@ func CurrUser(c *macaron.Context) *models.SysUser { if tkm == nil { return nil } - id, ok := (*tkm)["xid"].(string) - if !ok || len(id) <= 0 { + xid, ok := (*tkm)["xid"].(string) + if !ok || len(xid) <= 0 { return nil } - return FindUser(id) + return FindUser(xid) +} + +func Register(phone, pass, nick string) (*bean.SysLogin, error) { + ret := &bean.SysLogin{} + pars := ruisUtil.NewMap() + pars.Set("phone", phone) + pars.Set("pass", pass) + pars.Set("nick", nick) + err := cloud.SysCloudExec.ExecObjJSON("/user/reg", pars, ret) + if err != nil { + return nil, err + } + + return ret, nil } diff --git a/webs/sys/controller/comm.go b/webs/sys/controller/comm.go index 5d0a627..3a10ebb 100644 --- a/webs/sys/controller/comm.go +++ b/webs/sys/controller/comm.go @@ -49,8 +49,8 @@ func (e *CommController) clearUserCache(c *macaron.Context, ch cache.Cache, ctj c.PlainText(500, []byte("param err:uid!")) return } - key := fmt.Sprintf("user-permission:%s", uid) - ch.Delete(key) + ch.Delete(fmt.Sprintf("uinfo:%s", uid)) + ch.Delete(fmt.Sprintf("user-permission:%s", uid)) c.PlainText(200, []byte("ok")) } func (e *CommController) checkPermission(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { diff --git a/webs/sys/controller/user.go b/webs/sys/controller/user.go index 6a31100..5dd3c90 100644 --- a/webs/sys/controller/user.go +++ b/webs/sys/controller/user.go @@ -35,14 +35,14 @@ func (e *UserController) Mid() []macaron.Handler { } func (UserController) info(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { - id := ctj.GetString("id") - if len(id) <= 0 { + xid := ctj.GetString("xid") + if len(xid) <= 0 { c.PlainText(500, []byte("param err")) return } e := &models.SysUser{} - key := fmt.Sprintf("uinfo:%s", id) + key := fmt.Sprintf("uinfo:%s", xid) if ch.Get(key) != nil { bts := ch.Get(key).([]byte) err := json.Unmarshal(bts, e) @@ -51,7 +51,7 @@ func (UserController) info(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJ return } } - e = userService.FindXid(id) + e = userService.FindXid(xid) bts, err := json.Marshal(e) if err == nil { ch.Put(key, bts, 3600*5)