You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
907 B
45 lines
907 B
package sysCloud
|
|
|
|
import (
|
|
"GoClouds/cloud"
|
|
"GoClouds/core/bean"
|
|
"GoClouds/models"
|
|
gocloud "github.com/mgr9525/go-cloud"
|
|
ruisUtil "github.com/mgr9525/go-ruisutil"
|
|
"gopkg.in/macaron.v1"
|
|
)
|
|
|
|
func Login(name, pass string) (*bean.SysLogin, error) {
|
|
ret := &bean.SysLogin{}
|
|
pars := ruisUtil.NewMap()
|
|
pars.Set("name", name)
|
|
pars.Set("pass", pass)
|
|
err := cloud.SysCloudExec.ExecObjJSON("/user/login", pars, ret)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ret, nil
|
|
}
|
|
|
|
func FindUser(id string) *models.SysUser {
|
|
e := &models.SysUser{}
|
|
pars := ruisUtil.NewMap()
|
|
pars.Set("id", id)
|
|
err := cloud.SysCloudExec.ExecObjJSON("/user/info", pars, e)
|
|
if err != nil {
|
|
return nil
|
|
}
|
|
return e
|
|
}
|
|
func CurrUser(c *macaron.Context) *models.SysUser {
|
|
tkm := gocloud.GetToken(c)
|
|
if tkm == nil {
|
|
return nil
|
|
}
|
|
id, ok := (*tkm)["xid"].(string)
|
|
if !ok || len(id) <= 0 {
|
|
return nil
|
|
}
|
|
return FindUser(id)
|
|
}
|