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.
 
 
 

102 lines
2.3 KiB

package sysCloud
import (
"GoClouds/cloud"
"GoClouds/service/userService"
ruisUtil "github.com/mgr9525/go-ruisutil"
"gopkg.in/macaron.v1"
)
func ClearCache(key string) (rb bool) {
defer ruisUtil.Recovers("CheckUPermmsion", func(errs string) {
rb = false
})
pars := ruisUtil.NewMap()
pars.Set("key", key)
code, _, err := cloud.SysCloudExec.ExecJSON("/comm/clearCache", pars)
if err != nil {
return false
}
if code == 200 {
return true
}
return false
}
func ClearUserCache(uid string) (rb bool) {
defer ruisUtil.Recovers("CheckUPermmsion", func(errs string) {
rb = false
})
pars := ruisUtil.NewMap()
pars.Set("uid", uid)
code, _, err := cloud.SysCloudExec.ExecJSON("/comm/clearUserCache", pars)
if err != nil {
return false
}
if code == 200 {
return true
}
return false
}
func CheckPermission(uid, perm string) (rb bool) {
defer ruisUtil.Recovers("CheckUPermmsion", func(errs string) {
rb = false
})
pars := ruisUtil.NewMap()
pars.Set("uid", uid)
pars.Set("perm", perm)
code, cont, err := cloud.SysCloudExec.ExecJSON("/comm/checkPermission", pars)
if err != nil {
return false
}
if code != 200 {
return false
}
return cont == "true"
}
func CheckUPermission(perm string, c *macaron.Context) (rb bool) {
defer ruisUtil.Recovers("CheckUPermmsion", func(errs string) {
rb = false
})
lguser := userService.GetCurrentUser(c)
if lguser == nil {
return false
}
return CheckPermission(lguser.Uuid, perm)
}
func GetUserPerms(uid string) map[string]bool {
ret := make(map[string]bool)
pars := ruisUtil.NewMap()
pars.Set("uid", uid)
err := cloud.SysCloudExec.ExecObjJSON("/comm/getUserPerms", pars, &ret)
if err != nil {
println("getUserPerms err:" + err.Error())
return ret
}
return ret
}
func SendSms(phone, ips string) (int, string) {
pars := ruisUtil.NewMap()
pars.Set("phone", phone)
pars.Set("ips", ips)
code, conts, err := cloud.SysCloudExec.ExecJSON("/comm/sendSms", pars)
if err != nil {
println("SendSms err:" + err.Error())
}
return code, conts
}
func VaildSms(phone, codes string) (int, string) {
pars := ruisUtil.NewMap()
pars.Set("phone", phone)
pars.Set("code", codes)
code, conts, err := cloud.SysCloudExec.ExecJSON("/comm/vaildSms", pars)
if err != nil {
println("VaildSms err:" + err.Error())
}
return code, conts
}