29 changed files with 1381 additions and 0 deletions
-
5cloud/sysCloud/cloud.go
-
102cloud/sysCloud/comm.go
-
17cloud/sysCloud/user.go
-
62core/comm/db.go
-
20core/utils/code.go
-
193go.sum
-
22models/sys_file.go
-
14models/sys_param.go
-
14models/sys_permssion.go
-
13models/sys_role.go
-
17models/sys_user.go
-
7models/sys_user_role.go
-
15modeluis/sys_permssion.go
-
28modeluis/sys_role.go
-
16modeluis/sys_user.go
-
17modeluis/tree_permission.go
-
18service/sysService/file.go
-
70service/sysService/param.go
-
51service/sysService/role.go
-
224service/userService/role.go
-
51service/userService/user.go
-
41webs/sys/app.yml
-
8webs/sys/app/config.go
-
3webs/sys/buildExc.bat
-
165webs/sys/controller/comm.go
-
54webs/sys/controller/user.go
-
2webs/sys/custom.yml
-
41webs/sys/main.go
-
91webs/sys/start.sh
@ -0,0 +1,5 @@ |
|||
package sysCloud |
|||
|
|||
import gocloud "github.com/mgr9525/go-cloud" |
|||
|
|||
var SysCloudExec = &gocloud.CloudExec{Serv: "go-cloud-sys"} |
@ -0,0 +1,102 @@ |
|||
package sysCloud |
|||
|
|||
import ( |
|||
"GoBanpen/service/userService" |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
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 |
|||
}) |
|||
|
|||
pers := gocloud.GetNewMaps() |
|||
pers["key"] = key |
|||
code, _, err := SysCloudExec.ExecJSON("/comm/clearCache", &pers) |
|||
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 |
|||
}) |
|||
|
|||
pers := gocloud.GetNewMaps() |
|||
pers["uid"] = uid |
|||
code, _, err := SysCloudExec.ExecJSON("/comm/clearUserCache", &pers) |
|||
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 |
|||
}) |
|||
|
|||
pers := gocloud.GetNewMaps() |
|||
pers["uid"] = uid |
|||
pers["perm"] = perm |
|||
code, cont, err := SysCloudExec.ExecJSON("/comm/checkPermission", &pers) |
|||
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) |
|||
pers := gocloud.GetNewMaps() |
|||
pers["uid"] = uid |
|||
err := SysCloudExec.ExecObjJSON("/comm/getUserPerms", &pers, &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 := 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 := SysCloudExec.ExecJSON("/comm/vaildSms", pars) |
|||
if err != nil { |
|||
println("VaildSms err:" + err.Error()) |
|||
} |
|||
return code, conts |
|||
} |
@ -0,0 +1,17 @@ |
|||
package sysCloud |
|||
|
|||
import ( |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
) |
|||
|
|||
func Login(name, pass string) (int, string) { |
|||
pers := gocloud.GetNewMaps() |
|||
pers["name"] = name |
|||
pers["pass"] = pass |
|||
code, uid, err := SysCloudExec.ExecJSON("/user/login", &pers) |
|||
if err != nil { |
|||
return 0, "网络错误" |
|||
} |
|||
|
|||
return code, uid |
|||
} |
@ -0,0 +1,62 @@ |
|||
package comm |
|||
|
|||
import ( |
|||
_ "github.com/go-sql-driver/mysql" |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
"github.com/xormplus/xorm" |
|||
"gopkg.in/mgo.v2" |
|||
) |
|||
|
|||
var ( |
|||
DbMain *xorm.Engine |
|||
DbMongo *mgo.Session |
|||
) |
|||
|
|||
func InitDb() error { |
|||
err := initDbMain() |
|||
if err != nil { |
|||
return err |
|||
} |
|||
err = initDbMongo() |
|||
if err != nil { |
|||
return err |
|||
} |
|||
return nil |
|||
} |
|||
func initDbMain() error { |
|||
cnf := gocloud.CloudConf.Datasorce["main"] |
|||
if !cnf.Enable { |
|||
return nil |
|||
} |
|||
if len(cnf.Driver) <= 0 || len(cnf.Url) <= 0 { |
|||
return nil |
|||
} |
|||
db, err := xorm.NewEngine(cnf.Driver, cnf.Url) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
|
|||
err = db.RegisterSqlTemplate(xorm.Pongo2("./../sqltpls", ".stpl")) |
|||
if err != nil { |
|||
println("db RegisterSqlTemplate error : " + err.Error()) |
|||
} |
|||
|
|||
DbMain = db |
|||
return nil |
|||
} |
|||
|
|||
func initDbMongo() error { |
|||
cnf := gocloud.CloudConf.Datasorce["mongo"] |
|||
if !cnf.Enable { |
|||
return nil |
|||
} |
|||
if len(cnf.Driver) <= 0 || len(cnf.Url) <= 0 { |
|||
return nil |
|||
} |
|||
db, err := mgo.Dial(cnf.Url) |
|||
if err != nil { |
|||
return err |
|||
} |
|||
DbMongo = db |
|||
return nil |
|||
} |
@ -0,0 +1,20 @@ |
|||
package utils |
|||
|
|||
import ( |
|||
"fmt" |
|||
"math/rand" |
|||
"strings" |
|||
"time" |
|||
) |
|||
|
|||
func GenValidateCode(width int) string { |
|||
numeric := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} |
|||
r := len(numeric) |
|||
rand.Seed(time.Now().UnixNano()) |
|||
|
|||
var sb strings.Builder |
|||
for i := 0; i < width; i++ { |
|||
fmt.Fprintf(&sb, "%d", numeric[rand.Intn(r)]) |
|||
} |
|||
return sb.String() |
|||
} |
@ -0,0 +1,193 @@ |
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= |
|||
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6 h1:Etfj2lhXyrYemgmWzEtEQQb1kezeEXc8jVjkQUyJnWI= |
|||
github.com/Chronokeeper/anyxml v0.0.0-20160530174208-54457d8e98c6/go.mod h1:YzuYAe2hrrwKXkM9kqjbkTLlkbA+/xw2MA46f1+ENxc= |
|||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a h1:3SgJcK9l5uPdBC/X17wanyJAMxM33+4ZhEIV96MIH8U= |
|||
github.com/CloudyKit/fastprinter v0.0.0-20170127035650-74b38d55f37a/go.mod h1:EFZQ978U7x8IRnstaskI3IysnWY5Ao3QgZUKOXlsAdw= |
|||
github.com/CloudyKit/jet v2.1.2+incompatible h1:ybZoYzMBdoijK6I+Ke3vg9GZsmlKo/ZhKdNMWz0P26c= |
|||
github.com/CloudyKit/jet v2.1.2+incompatible/go.mod h1:HPYO+50pSWkPoj9Q/eq0aRGByCL6ScRlUmiEX5Zgm+w= |
|||
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee h1:0RklYSvekYaIFI9JUx7TFPQvo++TdILmZiV17QI4nXk= |
|||
github.com/agrison/go-tablib v0.0.0-20160310143025-4930582c22ee/go.mod h1:M9nmO4lBRWR/bBv7UCOmDJ1MB2DVoqz19B4JchDA+K0= |
|||
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4 h1:XBNSe5eibe5Fh131ah+xnO6s4A97U1T3tKZKLQQvqu0= |
|||
github.com/agrison/mxj v0.0.0-20160310142625-1269f8afb3b4/go.mod h1:n7qJAqL9BKqGqiJyjPbWtxpdswTL5wX0IVP2Uw4vVhQ= |
|||
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= |
|||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= |
|||
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= |
|||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= |
|||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= |
|||
github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= |
|||
github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= |
|||
github.com/bradfitz/gomemcache v0.0.0-20190329173943-551aad21a668/go.mod h1:H0wQNHz2YrLsuXOZozoeDmnHXkNCRmMW0gwFWDfEZDA= |
|||
github.com/cupcake/rdb v0.0.0-20161107195141-43ba34106c76/go.mod h1:vYwsqCOLxGiisLwp9rITslkFNpZD5rz43tf41QFkTWY= |
|||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= |
|||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= |
|||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= |
|||
github.com/donnie4w/go-logger v0.0.0-20170827050443-4740c51383f4 h1:T9PR91sjTtrA1HmZB4G+M7OLCelch0f6rIEY7Mm1T4U= |
|||
github.com/donnie4w/go-logger v0.0.0-20170827050443-4740c51383f4/go.mod h1:L7S4x0R7vv3xoOhGuyAJyCO2MYzWOpccM4Isn8jIUgY= |
|||
github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= |
|||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= |
|||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= |
|||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= |
|||
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4 h1:GY1+t5Dr9OKADM64SYnQjw/w99HMYvQ0A8/JoUkxVmc= |
|||
github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= |
|||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= |
|||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= |
|||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520 h1:NRUJuo3v3WGC/g5YiyF790gut6oQr5f3FBI88Wv0dx4= |
|||
github.com/getlantern/context v0.0.0-20190109183933-c447772a6520/go.mod h1:L+mq6/vvYHKjCX2oez0CgEAJmbq1fbb/oNJIWQkBybY= |
|||
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7 h1:6uJ+sZ/e03gkbqZ0kUG6mfKoqDb4XMAzMIwlajq19So= |
|||
github.com/getlantern/errors v0.0.0-20190325191628-abdb3e3e36f7/go.mod h1:l+xpFBrCtDLpK9qNjxs+cHU6+BAdlBaxHqikB6Lku3A= |
|||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 h1:micT5vkcr9tOVk1FiH8SWKID8ultN44Z+yzd2y/Vyb0= |
|||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7/go.mod h1:dD3CgOrwlzca8ed61CsZouQS5h5jIzkK9ZWrTcf0s+o= |
|||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 h1:XYzSdCbkzOC0FDNrgJqGRo8PCMFOBFL9py72DRs7bmc= |
|||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55/go.mod h1:6mmzY2kW1TOOrVy+r41Za2MxXM+hhqTtY3oBKd2AgFA= |
|||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSlsrcuKazukx/xqO/PpLZzZXsF+EA= |
|||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA= |
|||
github.com/go-check/check v0.0.0-20180628173108-788fd7840127/go.mod h1:9ES+weclKsC9YodN5RgxqK/VD9HM9JsCSh7rNhMZE98= |
|||
github.com/go-macaron/cache v0.0.0-20190810181446-10f7c57e2196 h1:fqWZxyMLF6RVGmjvsZ9FijiU9UlAjuE6nu9RfNBZ+iE= |
|||
github.com/go-macaron/cache v0.0.0-20190810181446-10f7c57e2196/go.mod h1:O6fSdaYZbGh4clVMGMGO5k2KbMO0Cz8YdBnPrD0I8dM= |
|||
github.com/go-macaron/gzip v0.0.0-20160222043647-cad1c6580a07 h1:YSIA98PevNf1NtCa/J6cz7gjzpz99WVAOa9Eg0klKps= |
|||
github.com/go-macaron/gzip v0.0.0-20160222043647-cad1c6580a07/go.mod h1://cJFfDp/70L0oTNAMB+M8Jd0rpuIx/55iARuJ6StwE= |
|||
github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191 h1:NjHlg70DuOkcAMqgt0+XA+NHwtu66MkTVVgR4fFWbcI= |
|||
github.com/go-macaron/inject v0.0.0-20160627170012-d8a0b8677191/go.mod h1:VFI2o2q9kYsC4o7VP1HrEVosiZZTd+MVT3YZx4gqvJw= |
|||
github.com/go-macaron/pongo2 v0.0.0-20180906102555-6074d2551820 h1:BQw86zZNNZ6KOi6BHZtRQSMKMb6FrNVRXeDmnMHCZmE= |
|||
github.com/go-macaron/pongo2 v0.0.0-20180906102555-6074d2551820/go.mod h1:oz+8Lk9U8hDD4ohs3aUMZzTs+1PwmfYai9GXQR6MfNM= |
|||
github.com/go-sql-driver/mysql v1.4.1 h1:g24URVg0OFbNUTx9qqY1IRZ9D9z3iPyi5zKhQZpNwpA= |
|||
github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= |
|||
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= |
|||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= |
|||
github.com/go-xorm/sqlfiddle v0.0.0-20180821085327-62ce714f951a/go.mod h1:56xuuqnHyryaerycW3BfssRdxQstACi0Epw/yC5E2xM= |
|||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= |
|||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= |
|||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= |
|||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= |
|||
github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= |
|||
github.com/gopherjs/gopherjs v0.0.0-20190430165422-3e4dfb77656c/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= |
|||
github.com/hashicorp/consul/api v1.1.0 h1:BNQPM9ytxj6jbjjdRPioQ94T6YXriSopn0i8COv6SRA= |
|||
github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= |
|||
github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= |
|||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= |
|||
github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= |
|||
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= |
|||
github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= |
|||
github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= |
|||
github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= |
|||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= |
|||
github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82kpwzSwCI= |
|||
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= |
|||
github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= |
|||
github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= |
|||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= |
|||
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= |
|||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= |
|||
github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= |
|||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= |
|||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= |
|||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= |
|||
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= |
|||
github.com/hashicorp/serf v0.8.2 h1:YZ7UKsJv+hKjqGVUUbtE3HNj79Eln2oQ75tniF6iPt0= |
|||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= |
|||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= |
|||
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= |
|||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= |
|||
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5 h1:rhqTjzJlm7EbkELJDKMTU7udov+Se0xZkWmugr6zGok= |
|||
github.com/juju/errors v0.0.0-20181118221551-089d3ea4e4d5/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= |
|||
github.com/juju/loggo v0.0.0-20180524022052-584905176618/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= |
|||
github.com/juju/testing v0.0.0-20180920084828-472a3e8b2073/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= |
|||
github.com/klauspost/compress v1.7.5 h1:NMapGoDIKPKpk2hpcgAU6XHfsREHG2p8PIg7C3f/jpI= |
|||
github.com/klauspost/compress v1.7.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= |
|||
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= |
|||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= |
|||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= |
|||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= |
|||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= |
|||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= |
|||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= |
|||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= |
|||
github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= |
|||
github.com/mgr9525/go-cloud v1.0.6-0.20191107091222-524f1218fb4e h1:A2GUbaNotiiQNMZ+1DnOByNbLaoGId1rvBhXIzOuPfk= |
|||
github.com/mgr9525/go-cloud v1.0.6-0.20191107091222-524f1218fb4e/go.mod h1:Wc25es8QefcN6HXFUroKShVuzvfjjkkaZDNVAc5q2sA= |
|||
github.com/mgr9525/go-ruisutil v1.0.8-0.20191105071958-41a4e7d87b4f h1:OkBmLGM6QfRasXO2qR46H4rvIcDb6sfowY5mS0rePM4= |
|||
github.com/mgr9525/go-ruisutil v1.0.8-0.20191105071958-41a4e7d87b4f/go.mod h1:qXUWVKpHdwoxR0KERCkvL1JH2DETY6b5TMG9t6g9Pls= |
|||
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= |
|||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= |
|||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= |
|||
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= |
|||
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= |
|||
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= |
|||
github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= |
|||
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= |
|||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= |
|||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
|||
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= |
|||
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= |
|||
github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= |
|||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= |
|||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= |
|||
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= |
|||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= |
|||
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww= |
|||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= |
|||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= |
|||
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= |
|||
github.com/siddontang/ledisdb v0.0.0-20190202134119-8ceb77e66a92/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= |
|||
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= |
|||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= |
|||
github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= |
|||
github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM= |
|||
github.com/smartystreets/goconvey v0.0.0-20181108003508-044398e4856c/go.mod h1:XDJAKZRPZ1CvBcN2aX5YOUTYGHki24fSF0Iv48Ibg0s= |
|||
github.com/smartystreets/goconvey v0.0.0-20190731233626-505e41936337/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= |
|||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= |
|||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= |
|||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
|||
github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpPAyBWyWuQ= |
|||
github.com/tealeg/xlsx v1.0.3 h1:BXsDIQYBPq2HgbwUxrsVXIrnO0BDxmsdUfHSfvwfBuQ= |
|||
github.com/tealeg/xlsx v1.0.3/go.mod h1:uxu5UY2ovkuRPWKQ8Q7JG0JbSivrISjdPzZQKeo74mA= |
|||
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e h1:GSGeB9EAKY2spCABz6xOX5DbxZEXolK+nBSvmsQwRjM= |
|||
github.com/unknwon/com v0.0.0-20190804042917-757f69c95f3e/go.mod h1:tOOxU81rwgoCLoOVVPHb6T/wt8HZygqH5id+GNnlCXM= |
|||
github.com/xormplus/builder v0.0.0-20190724032102-0ee351fedce9 h1:h7b9aRnem5U6YuCWZlAnRWyowAR8hIIyyqUkbuAn0ms= |
|||
github.com/xormplus/builder v0.0.0-20190724032102-0ee351fedce9/go.mod h1:DR+4rxdyeR2G5yyiNx6j3/0TLjG5g+CICZfXmL2AHBg= |
|||
github.com/xormplus/core v0.0.0-20190724072625-00f5a85ad6e0 h1:vqleyrxQwTNEr+jlW3VuOYlTRtoyDp/h6C6b0R9Ewro= |
|||
github.com/xormplus/core v0.0.0-20190724072625-00f5a85ad6e0/go.mod h1:V3p6iAR/MaICgU6GJqxGQxspfljTyfOTv4Czz0B5atU= |
|||
github.com/xormplus/xorm v0.0.0-20190815102311-3995c60c8bb6 h1:LiYC4AwitnpxxRj0/knyqZIlPs14EWFc2fN1T9Q0Jho= |
|||
github.com/xormplus/xorm v0.0.0-20190815102311-3995c60c8bb6/go.mod h1:+v6b10b4x5IcQmp1/Cbo9IqaknxVeuhQng+fhya6bdI= |
|||
golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= |
|||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= |
|||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= |
|||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= |
|||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
|||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= |
|||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
|||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= |
|||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
|||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/sys v0.0.0-20190804053845-51ab0e2deafa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
|||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
|||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
|||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20181221001348-537d06c36207/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= |
|||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= |
|||
golang.org/x/tools v0.0.0-20190802220118-1d1727260058/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= |
|||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= |
|||
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4 h1:eyQQg/uGuZ3ndaBhqteakHpVW+dSOPalilfC9RpM2TA= |
|||
gopkg.in/flosch/pongo2.v3 v3.0.0-20141028000813-5e81b817a0c4/go.mod h1:bJkYqV5pg6+Z7MsSu/hSb1zsPT955hBW2QHLE1jm4wA= |
|||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= |
|||
gopkg.in/ini.v1 v1.46.0 h1:VeDZbLYGaupuvIrsYCEOe/L/2Pcs5n7hdO1ZTjporag= |
|||
gopkg.in/ini.v1 v1.46.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= |
|||
gopkg.in/macaron.v1 v1.3.4 h1:HvIscOwxhFhx3swWM/979wh2QMYyuXrNmrF9l+j3HZs= |
|||
gopkg.in/macaron.v1 v1.3.4/go.mod h1:/RoHTdC8ALpyJ3+QR36mKjwnT1F1dyYtsGM9Ate6ZFI= |
|||
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce h1:xcEWjVhvbDy+nHP67nPDDpbYrY+ILlfndk4bRioVHaU= |
|||
gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= |
|||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= |
|||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
|||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= |
|||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
@ -0,0 +1,22 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysFile struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Types string `xorm:"comment('类型') VARCHAR(50)"` |
|||
Uid string `xorm:"VARCHAR(64)"` |
|||
Toid string `xorm:"VARCHAR(64)"` |
|||
Extion string `xorm:"VARCHAR(50)"` |
|||
Name string `xorm:"not null pk VARCHAR(50)"` |
|||
Size int64 `xorm:"BIGINT(20)"` |
|||
Filename string `xorm:"VARCHAR(255)"` |
|||
Descpt string `xorm:"VARCHAR(500)"` |
|||
Status int `xorm:"INT(2)"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
Downtm time.Time `xorm:"comment('最近下载时间') TIMESTAMP"` |
|||
Downs int64 `xorm:"default 0 BIGINT(20)"` |
|||
} |
@ -0,0 +1,14 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysParam struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Name string `xorm:"not null pk comment('key') VARCHAR(50)"` |
|||
Title string `xorm:"comment('名称') VARCHAR(100)"` |
|||
Value []byte `xorm:"BLOB"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
} |
@ -0,0 +1,14 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysPermssion struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Parent string `xorm:"VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Value string `xorm:"VARCHAR(100)"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
} |
@ -0,0 +1,13 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysRole struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Perms string `xorm:"TEXT"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
} |
@ -0,0 +1,17 @@ |
|||
package models |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysUser struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Name string `xorm:"not null pk VARCHAR(50)"` |
|||
Pass string `xorm:"VARCHAR(100)"` |
|||
Nick string `xorm:"VARCHAR(100)"` |
|||
Phone string `xorm:"comment('备用电话') VARCHAR(50)"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"` |
|||
Logintm time.Time `xorm:"comment('登陆时间') TIMESTAMP"` |
|||
Fwtm time.Time `xorm:"comment('访问时间') TIMESTAMP"` |
|||
} |
@ -0,0 +1,7 @@ |
|||
package models |
|||
|
|||
type SysUserRole struct { |
|||
UserCode string `xorm:"not null pk VARCHAR(64)"` |
|||
RoleCodes string `xorm:"TEXT"` |
|||
Limits string `xorm:"TEXT"` |
|||
} |
@ -0,0 +1,15 @@ |
|||
package modeluis |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysPermssion struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Parent string `xorm:"VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Value string `xorm:"VARCHAR(100)"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
Had bool `xorm:"-"` |
|||
} |
@ -0,0 +1,28 @@ |
|||
package modeluis |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysRole struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Perms string `xorm:"TEXT"` |
|||
Times time.Time `xorm:"TIMESTAMP"` |
|||
Timeds string |
|||
Permls string |
|||
} |
|||
type SysURole struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Perms string `xorm:"TEXT" json:"-"` |
|||
Times time.Time `xorm:"TIMESTAMP"` |
|||
Had bool `xorm:"-"` |
|||
Permls string `xorm:"-"` |
|||
} |
|||
|
|||
func (SysURole) TableName() string { |
|||
return "sys_role" |
|||
} |
@ -0,0 +1,16 @@ |
|||
package modeluis |
|||
|
|||
import ( |
|||
"time" |
|||
) |
|||
|
|||
type SysUser struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Name string `xorm:"not null pk VARCHAR(50)"` |
|||
Nick string `xorm:"VARCHAR(100)"` |
|||
Phone string `xorm:"comment('备用电话') VARCHAR(50)"` |
|||
Times time.Time `xorm:"comment('创建时间') TIMESTAMP"` |
|||
Logintm time.Time `xorm:"comment('登陆时间') TIMESTAMP"` |
|||
Fwtm time.Time `xorm:"comment('访问时间') TIMESTAMP"` |
|||
} |
@ -0,0 +1,17 @@ |
|||
package modeluis |
|||
|
|||
import "time" |
|||
|
|||
type TreePermssion struct { |
|||
Id int64 `xorm:"pk autoincr BIGINT(20)"` |
|||
Uuid string `xorm:"not null pk VARCHAR(64)"` |
|||
Parent string `xorm:"VARCHAR(64)"` |
|||
Title string `xorm:"VARCHAR(100)"` |
|||
Value string `xorm:"VARCHAR(100)"` |
|||
Times time.Time `xorm:"default 'CURRENT_TIMESTAMP' TIMESTAMP"` |
|||
Childs []*TreePermssion `xorm:"extends"` |
|||
} |
|||
|
|||
func (TreePermssion) TableName() string { |
|||
return "sys_permssion" |
|||
} |
@ -0,0 +1,18 @@ |
|||
package sysService |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/models" |
|||
) |
|||
|
|||
func FindFile(uuid string) *models.SysFile { |
|||
e := new(models.SysFile) |
|||
ok, err := comm.DbMain.Where("uuid=?", uuid).Get(e) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
@ -0,0 +1,70 @@ |
|||
package sysService |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/models" |
|||
"encoding/json" |
|||
uuid "github.com/satori/go.uuid" |
|||
"time" |
|||
) |
|||
|
|||
func FindParam(key string) *models.SysParam { |
|||
e := new(models.SysParam) |
|||
ok, err := comm.DbMain.Where("name=?", key).Get(e) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
|||
|
|||
func GetParam(key string) map[string]interface{} { |
|||
e := new(models.SysParam) |
|||
ok, err := comm.DbMain.Where("name=?", key).Get(e) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
if !ok { |
|||
/*e.Uuid=uuid.NewV4().String() |
|||
e.Name=key |
|||
e.*/ |
|||
return nil |
|||
} |
|||
|
|||
rt := make(map[string]interface{}) |
|||
err = json.Unmarshal(e.Value, &rt) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
return rt |
|||
} |
|||
|
|||
func SetParam(key string, val *map[string]interface{}, tits ...string) bool { |
|||
e := new(models.SysParam) |
|||
ok, err := comm.DbMain.Where("name=?", key).Get(e) |
|||
if err != nil { |
|||
return false |
|||
} |
|||
bts, err := json.Marshal(val) |
|||
if err != nil { |
|||
return false |
|||
} |
|||
|
|||
e.Value = bts |
|||
if len(tits) > 0 { |
|||
e.Title = tits[0] |
|||
} |
|||
|
|||
if ok { |
|||
comm.DbMain.Where("uuid=?", e.Uuid).Update(e) |
|||
} else { |
|||
e.Uuid = uuid.NewV4().String() |
|||
e.Name = key |
|||
e.Times = time.Now() |
|||
comm.DbMain.Insert(e) |
|||
} |
|||
|
|||
return true |
|||
} |
@ -0,0 +1,51 @@ |
|||
package sysService |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/models" |
|||
"github.com/xormplus/builder" |
|||
"strings" |
|||
) |
|||
|
|||
func FindRole(uuid string) *models.SysRole { |
|||
e := new(models.SysRole) |
|||
ok, err := comm.DbMain.Where("uuid=?", uuid).Get(e) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
|||
func FindPermission(uuid string) *models.SysPermssion { |
|||
e := new(models.SysPermssion) |
|||
ok, err := comm.DbMain.Where("uuid=?", uuid).Get(e) |
|||
if err != nil { |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
|||
func FindPermissions(uuids string) string { |
|||
if len(uuids) <= 0 { |
|||
return "" |
|||
} |
|||
|
|||
rets := "" |
|||
permssions := make([]*models.SysPermssion, 0) |
|||
err := comm.DbMain.Where(builder.In("uuid", strings.Split(uuids, ","))).Find(&permssions) |
|||
if err == nil { |
|||
ln := len(permssions) |
|||
for i, o := range permssions { |
|||
if i < ln-1 { |
|||
rets += o.Title + "," |
|||
} else { |
|||
rets += o.Title |
|||
} |
|||
} |
|||
} |
|||
return rets |
|||
} |
@ -0,0 +1,224 @@ |
|||
package userService |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/models" |
|||
"GoBanpen/modeluis" |
|||
"encoding/json" |
|||
"fmt" |
|||
"github.com/go-macaron/cache" |
|||
ruisUtil "github.com/mgr9525/go-ruisutil" |
|||
"github.com/xormplus/builder" |
|||
"gopkg.in/macaron.v1" |
|||
"strings" |
|||
) |
|||
|
|||
func FindTreePermission() []*modeluis.TreePermssion { |
|||
rets := make([]*modeluis.TreePermssion, 0) |
|||
err := comm.DbMain.Where("parent is null or parent=''").OrderBy("sort ASC,id ASC").Find(&rets) |
|||
if err != nil { |
|||
println("findPermChilds err:" + err.Error()) |
|||
return nil |
|||
} |
|||
|
|||
for _, v := range rets { |
|||
findPermChilds(v, nil) |
|||
} |
|||
|
|||
return rets |
|||
} |
|||
func findPermChilds(parent *modeluis.TreePermssion, upms map[string]bool) { |
|||
if parent == nil { |
|||
return |
|||
} |
|||
childs := make([]*modeluis.TreePermssion, 0) |
|||
err := comm.DbMain.Where("parent=?", parent.Uuid).OrderBy("sort ASC,id ASC").Find(&childs) |
|||
if err != nil { |
|||
println("findPermChilds err:" + err.Error()) |
|||
return |
|||
} |
|||
|
|||
for _, v := range childs { |
|||
findPermChilds(v, upms) |
|||
} |
|||
|
|||
if len(childs) > 0 && len(parent.Value) > 0 { |
|||
t := *parent |
|||
ts := []*modeluis.TreePermssion{&t} |
|||
childs = append(ts, childs...) |
|||
parent.Uuid = "" |
|||
} |
|||
parent.Childs = childs |
|||
} |
|||
func FindUPermissions(uid string) []*modeluis.SysPermssion { |
|||
if len(uid) <= 0 { |
|||
return nil |
|||
} |
|||
perms := make(map[string]*modeluis.SysPermssion) |
|||
userRole := FindUserRole(uid) |
|||
//comm.DbMain.SqlTemplateClient("role.stpl")
|
|||
//rids:=strings.Split(userRole.RoleCodes,",")
|
|||
ses := comm.DbMain.Where("uuid='common'") |
|||
if len(userRole.RoleCodes) > 0 { |
|||
rcds := strings.Split(userRole.RoleCodes, ",") |
|||
ses.Or(builder.In("uuid", rcds)) |
|||
} |
|||
roles := make([]*models.SysRole, 0) |
|||
err := ses.Find(&roles) |
|||
if err != nil { |
|||
println("FindUserPermission err:" + err.Error()) |
|||
return nil |
|||
} |
|||
for _, role := range roles { |
|||
if len(role.Perms) <= 0 { |
|||
continue |
|||
} |
|||
permssions := make([]*modeluis.SysPermssion, 0) |
|||
ses := comm.DbMain.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|||
err := ses.Find(&permssions) |
|||
if err != nil { |
|||
println("FindUserPermission err:" + err.Error()) |
|||
continue |
|||
} |
|||
|
|||
limids := map[string]bool{} |
|||
if len(userRole.Limits) > 0 { |
|||
rcds := strings.Split(userRole.Limits, ",") |
|||
for _, v := range rcds { |
|||
limids[v] = true |
|||
} |
|||
} |
|||
|
|||
for _, perm := range permssions { |
|||
if len(perm.Value) > 0 { |
|||
if limids[perm.Uuid] == true { |
|||
perm.Had = true |
|||
} |
|||
perms[perm.Value] = perm |
|||
} |
|||
} |
|||
} |
|||
|
|||
rets := make([]*modeluis.SysPermssion, 0) |
|||
for _, v := range perms { |
|||
rets = append(rets, v) |
|||
} |
|||
|
|||
return rets |
|||
} |
|||
func FindUserRole(uid string) *models.SysUserRole { |
|||
userRole := new(models.SysUserRole) |
|||
ok, err := comm.DbMain.Where("user_code=?", uid).Get(userRole) |
|||
if err != nil { |
|||
println("FindUserPermission err:" + err.Error()) |
|||
} else if !ok { |
|||
userRole.UserCode = uid |
|||
comm.DbMain.Insert(userRole) |
|||
} |
|||
return userRole |
|||
} |
|||
func FindUserRoles(uid string) []*modeluis.SysURole { |
|||
userRole := FindUserRole(uid) |
|||
rcds := make(map[string]bool) |
|||
if len(userRole.RoleCodes) > 0 { |
|||
rids := strings.Split(userRole.RoleCodes, ",") |
|||
for _, v := range rids { |
|||
rcds[v] = true |
|||
} |
|||
} |
|||
roles := make([]*modeluis.SysURole, 0) |
|||
err := comm.DbMain.Where("uuid!='common'").Find(&roles) |
|||
if err != nil { |
|||
println("FindUserRoles:" + err.Error()) |
|||
} |
|||
for _, v := range roles { |
|||
v.Had = rcds[v.Uuid] == true |
|||
v.Permls = sysService.FindPermissions(v.Perms) |
|||
} |
|||
return roles |
|||
} |
|||
func FindUserPermission(uid string) map[string]bool { |
|||
perms := make(map[string]bool) |
|||
userRole := FindUserRole(uid) |
|||
//comm.DbMain.SqlTemplateClient("role.stpl")
|
|||
//rids:=strings.Split(userRole.RoleCodes,",")
|
|||
ses := comm.DbMain.Where("uuid='common'") |
|||
if len(userRole.RoleCodes) > 0 { |
|||
rcds := strings.Split(userRole.RoleCodes, ",") |
|||
ses.Or(builder.In("uuid", rcds)) |
|||
} |
|||
roles := make([]*models.SysRole, 0) |
|||
err := ses.Find(&roles) |
|||
if err != nil { |
|||
println("FindUserPermission err:" + err.Error()) |
|||
return perms |
|||
} |
|||
for _, role := range roles { |
|||
if len(role.Perms) <= 0 { |
|||
continue |
|||
} |
|||
permssions := make([]*models.SysPermssion, 0) |
|||
ses := comm.DbMain.Where(builder.In("uuid", strings.Split(role.Perms, ","))) |
|||
if len(userRole.Limits) > 0 { |
|||
rcds := strings.Split(userRole.Limits, ",") |
|||
ses.And(builder.NotIn("uuid", rcds)) |
|||
} |
|||
err := ses.Find(&permssions) |
|||
if err != nil { |
|||
println("FindUserPermission err:" + err.Error()) |
|||
continue |
|||
} |
|||
|
|||
for _, perm := range permssions { |
|||
if len(perm.Value) > 0 { |
|||
perms[perm.Value] = true |
|||
} |
|||
} |
|||
} |
|||
|
|||
return perms |
|||
} |
|||
|
|||
func FindUserPermissionCache(uid string, ch cache.Cache) map[string]bool { |
|||
key := fmt.Sprintf("user-permission:%s", uid) |
|||
perms := make(map[string]bool) |
|||
if ch.IsExist(key) { |
|||
bts := ch.Get(key).([]byte) |
|||
json.Unmarshal(bts, &perms) |
|||
} else { |
|||
perms = FindUserPermission(uid) |
|||
bts, err := json.Marshal(perms) |
|||
if err == nil { |
|||
err = ch.Put(key, bts, 3600*10) |
|||
if err != nil { |
|||
println("cache put err:" + err.Error()) |
|||
} |
|||
} |
|||
} |
|||
return perms |
|||
} |
|||
|
|||
func CheckPermission(uid, perm string, ch cache.Cache) (rb bool) { |
|||
key := fmt.Sprintf("user-permission:%s", uid) |
|||
defer ruisUtil.Recovers("CheckPermmsion", func(errs string) { |
|||
rb = false |
|||
ch.Delete(key) |
|||
}) |
|||
if len(perm) <= 0 { |
|||
return false |
|||
} |
|||
|
|||
perms := FindUserPermissionCache(uid, ch) |
|||
return perms[perm] |
|||
} |
|||
func CheckUPermission(perm string, c *macaron.Context, ch cache.Cache) (rb bool) { |
|||
defer ruisUtil.Recovers("CheckUPermmsion", func(errs string) { |
|||
rb = false |
|||
}) |
|||
lguser := GetCurrentUser(c) |
|||
if lguser == nil { |
|||
return false |
|||
} |
|||
|
|||
return CheckPermission(lguser.Uuid, perm, ch) |
|||
} |
@ -0,0 +1,51 @@ |
|||
package userService |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/models" |
|||
"github.com/donnie4w/go-logger/logger" |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
ruisUtil "github.com/mgr9525/go-ruisutil" |
|||
"gopkg.in/macaron.v1" |
|||
) |
|||
|
|||
func FindUUID(id string) *models.SysUser { |
|||
if len(id) <= 0 { |
|||
return nil |
|||
} |
|||
e := new(models.SysUser) |
|||
ok, err := comm.DbMain.Where("uuid=?", id).Get(e) |
|||
if err != nil { |
|||
logger.Info("FindUserUUID err:", err.Error()) |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
|||
func FindName(name string) *models.SysUser { |
|||
e := new(models.SysUser) |
|||
ok, err := comm.DbMain.Where("name=?", name).Get(e) |
|||
if err != nil { |
|||
logger.Info("FindName err:", err.Error()) |
|||
return nil |
|||
} |
|||
if ok { |
|||
return e |
|||
} |
|||
return nil |
|||
} |
|||
|
|||
func GetCurrentUser(c *macaron.Context) *models.SysUser { |
|||
defer ruisUtil.Recovers("GetCurrentUser", nil) |
|||
tkm := gocloud.GetToken(c) |
|||
if tkm == nil { |
|||
return nil |
|||
} |
|||
id := (*tkm)["id"].(string) |
|||
if len(id) <= 0 { |
|||
return nil |
|||
} |
|||
return FindUUID(id) |
|||
} |
@ -0,0 +1,41 @@ |
|||
server: |
|||
name: main |
|||
#host: localhost |
|||
port: 8081 |
|||
web: |
|||
gzip: false |
|||
template: renderer #pongo2,renderer |
|||
cache: |
|||
enable: false |
|||
interval: 3600 |
|||
adapter: file #memory,redis,memcache |
|||
configs: data/caches #addr=127.0.0.1:6379,password=macaron |
|||
logger: |
|||
enable: true |
|||
path: run.log |
|||
filesize: 5 |
|||
filenum: 5 |
|||
token: |
|||
enable: true |
|||
httponly: false |
|||
name: ks |
|||
key: LQ6A4Y1R3KOB9D4JX593MGW44QMJ1LNC |
|||
path: / |
|||
#domain: |
|||
consul: |
|||
enable: true |
|||
#host: localhost |
|||
#port: 8500 |
|||
id: go-cloud-sys |
|||
name: go-cloud |
|||
reghost: localhost |
|||
#tags: [123,345,654] |
|||
datasorce: |
|||
main: |
|||
enable: true |
|||
driver: mysql |
|||
url: root:root@tcp(localhost:3306)/test?charset=utf8 |
|||
mongo: |
|||
enable: true |
|||
driver: mongo |
|||
url: mongodb://root:123456@localhost/test |
@ -0,0 +1,8 @@ |
|||
package app |
|||
|
|||
var Conf = new(conf) |
|||
|
|||
type conf struct { |
|||
Smskey string |
|||
Codetmpid string |
|||
} |
@ -0,0 +1,3 @@ |
|||
set GOOS=linux |
|||
set GOARCH=amd64 |
|||
go build -o ../bin/main main.go |
@ -0,0 +1,165 @@ |
|||
package controller |
|||
|
|||
import ( |
|||
"GoBanpen/core/utils" |
|||
"GoBanpen/service/userService" |
|||
"GoBanpen/webs/sys/app" |
|||
"fmt" |
|||
"github.com/donnie4w/go-logger/logger" |
|||
"github.com/go-macaron/cache" |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
ruisUtil "github.com/mgr9525/go-ruisutil" |
|||
"gopkg.in/macaron.v1" |
|||
"io/ioutil" |
|||
"net/http" |
|||
"net/url" |
|||
"strings" |
|||
"time" |
|||
) |
|||
|
|||
type CommController struct{} |
|||
|
|||
func (e *CommController) GetPath() string { |
|||
return "/comm" |
|||
} |
|||
func (e *CommController) Routes() { |
|||
gocloud.Web.Any("/clearCache", e.clearCache) |
|||
gocloud.Web.Any("/clearUserCache", e.clearUserCache) |
|||
gocloud.Web.Any("/getUserPerms", e.getUserPerms) |
|||
gocloud.Web.Any("/checkPermission", e.checkPermission) |
|||
gocloud.Web.Any("/sendSms", e.sendSms) |
|||
gocloud.Web.Any("/vaildSms", e.vaildSms) |
|||
} |
|||
func (e *CommController) Mid() []macaron.Handler { |
|||
return []macaron.Handler{gocloud.AccessAllowFun} |
|||
} |
|||
|
|||
func (e *CommController) clearCache(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
key := ctj.GetString("key") |
|||
if len(key) > 0 { |
|||
ch.Delete(key) |
|||
} else { |
|||
ch.Flush() |
|||
} |
|||
c.PlainText(200, []byte("ok")) |
|||
} |
|||
func (e *CommController) clearUserCache(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
uid := ctj.GetString("uid") |
|||
if len(uid) <= 0 { |
|||
c.PlainText(500, []byte("param err:uid!")) |
|||
return |
|||
} |
|||
key := fmt.Sprintf("user-permission:%s", uid) |
|||
ch.Delete(key) |
|||
c.PlainText(200, []byte("ok")) |
|||
} |
|||
func (e *CommController) checkPermission(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
uid := ctj.GetString("uid") |
|||
perm := ctj.GetString("perm") |
|||
|
|||
if len(uid) <= 0 { |
|||
c.PlainText(500, []byte("param err:uid!")) |
|||
return |
|||
} |
|||
if len(perm) <= 0 { |
|||
c.PlainText(500, []byte("param err:perm!")) |
|||
return |
|||
} |
|||
|
|||
c.PlainText(200, []byte(fmt.Sprintf("%t", userService.CheckPermission(uid, perm, ch)))) |
|||
} |
|||
func (e *CommController) getUserPerms(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
uid := ctj.GetString("uid") |
|||
|
|||
if len(uid) <= 0 { |
|||
c.PlainText(500, []byte("param err:uid!")) |
|||
return |
|||
} |
|||
|
|||
c.JSON(200, userService.FindUserPermissionCache(uid, ch)) |
|||
} |
|||
func (e *CommController) sendSms(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
phone := ctj.GetString("phone") |
|||
ips := ctj.GetString("ips") |
|||
if len(phone) <= 0 { |
|||
c.PlainText(500, []byte("param err:phone!")) |
|||
return |
|||
} |
|||
if len(ips) <= 0 { |
|||
c.PlainText(500, []byte("param err:ips!")) |
|||
return |
|||
} |
|||
|
|||
key1 := fmt.Sprintf("smsSend:%s", phone) |
|||
key2 := fmt.Sprintf("smsCode:%s", phone) |
|||
//key3 := fmt.Sprintf("smsSendIP:%s", ips)
|
|||
if ch.Get(key1) != nil /*||ch.Get(key3) != nil*/ { |
|||
c.PlainText(511, []byte("1分钟后重试!")) |
|||
return |
|||
} |
|||
|
|||
code := utils.GenValidateCode(6) |
|||
|
|||
parm := url.Values{} |
|||
parm.Set("mobile", phone) |
|||
parm.Set("param", "code:"+code) |
|||
parm.Set("tpl_id", app.Conf.Codetmpid) |
|||
req, err := http.NewRequest("POST", "http://dingxin.market.alicloudapi.com/dx/sendSms", strings.NewReader(parm.Encode())) |
|||
if err != nil { |
|||
c.PlainText(512, []byte("服务器错误!")) |
|||
return |
|||
} |
|||
cli := http.Client{Timeout: time.Second * 3} |
|||
req.Header.Set("Authorization", "APPCODE "+app.Conf.Smskey) |
|||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") |
|||
ch.Put(key1, []byte(fmt.Sprintf("%d", time.Now().Unix())), 60) |
|||
//ch.Put(key3, []byte(fmt.Sprintf("%d", time.Now().Unix())), 60)
|
|||
res, err := cli.Do(req) |
|||
if err != nil { |
|||
logger.Info("sendSms http err:" + err.Error()) |
|||
c.PlainText(513, []byte("服务器错误!")) |
|||
return |
|||
} |
|||
defer res.Body.Close() |
|||
bts, err := ioutil.ReadAll(res.Body) |
|||
if err != nil { |
|||
c.PlainText(514, []byte("服务器错误!")) |
|||
return |
|||
} |
|||
mp := ruisUtil.NewMapo(bts) |
|||
if mp.GetString("return_code") != "00000" { |
|||
logger.Info("return_code err(", res.StatusCode, ":'", parm.Encode(), "'):", string(bts)) |
|||
c.PlainText(521, []byte("发送失败:"+mp.GetString("return_code"))) |
|||
return |
|||
} |
|||
|
|||
logger.Info("发送短信:", phone, ",IP:", ips, "!!:", string(bts)) |
|||
ch.Put(key2, []byte(code), 60*5) |
|||
c.PlainText(200, []byte("ok")) |
|||
} |
|||
func (e *CommController) vaildSms(c *macaron.Context, ch cache.Cache, ctj gocloud.ContJSON) { |
|||
phone := ctj.GetString("phone") |
|||
code := ctj.GetString("code") |
|||
if len(phone) <= 0 { |
|||
c.PlainText(500, []byte("param err:phone!")) |
|||
return |
|||
} |
|||
if len(code) <= 0 { |
|||
c.PlainText(500, []byte("param err:code!")) |
|||
return |
|||
} |
|||
|
|||
key := fmt.Sprintf("smsCode:%s", phone) |
|||
btscode := ch.Get(key) |
|||
if btscode == nil { |
|||
c.PlainText(511, []byte("未找到验证码!")) |
|||
return |
|||
} |
|||
if code != string(btscode.([]byte)) { |
|||
c.PlainText(512, []byte("验证码错误!")) |
|||
return |
|||
} |
|||
|
|||
ch.Delete(key) |
|||
c.PlainText(200, []byte("ok")) |
|||
} |
@ -0,0 +1,54 @@ |
|||
package controller |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/service/userService" |
|||
gocloud "github.com/mgr9525/go-cloud" |
|||
ruisUtil "github.com/mgr9525/go-ruisutil" |
|||
"gopkg.in/macaron.v1" |
|||
"time" |
|||
) |
|||
|
|||
type UserController struct{} |
|||
|
|||
func (e *UserController) GetPath() string { |
|||
return "/user" |
|||
} |
|||
func (e *UserController) Routes() { |
|||
gocloud.Web.Any("/login", e.login) |
|||
} |
|||
func (e *UserController) Mid() []macaron.Handler { |
|||
return []macaron.Handler{gocloud.AccessAllowFun} |
|||
} |
|||
|
|||
func (e *UserController) login(c *macaron.Context, ctj gocloud.ContJSON) { |
|||
name := ctj.GetString("name") |
|||
pass := ctj.GetString("pass") |
|||
if len(name) <= 0 { |
|||
c.PlainText(511, []byte("param err:name!")) |
|||
return |
|||
} |
|||
if len(pass) <= 0 { |
|||
c.PlainText(511, []byte("param err:pass!")) |
|||
return |
|||
} |
|||
|
|||
usr := userService.FindName(name) |
|||
if usr == nil { |
|||
c.PlainText(512, []byte("未找到用户")) |
|||
return |
|||
} |
|||
if usr.Pass != ruisUtil.Md5String(pass) { |
|||
c.PlainText(513, []byte("密码错误")) |
|||
return |
|||
} |
|||
if !sysCloud.CheckPermission(usr.Uuid, "login") { |
|||
c.PlainText(514, []byte("帐号禁止登录")) |
|||
return |
|||
} |
|||
|
|||
usr.Logintm = time.Now() |
|||
comm.DbMain.Cols("logintm").Where("uuid=?", usr.Uuid).Update(usr) |
|||
|
|||
c.PlainText(200, []byte(usr.Uuid)) |
|||
} |
@ -0,0 +1,2 @@ |
|||
smskey: xxxxxxxxxxxxxxx |
|||
codetmpid: TP1711063 |
@ -0,0 +1,41 @@ |
|||
package main |
|||
|
|||
import ( |
|||
"GoBanpen/core/comm" |
|||
"GoBanpen/webs/sys/app" |
|||
"GoBanpen/webs/sys/controller" |
|||
"github.com/mgr9525/go-cloud" |
|||
"html/template" |
|||
"os" |
|||
) |
|||
|
|||
func main() { |
|||
/*ymlpath:="" |
|||
if len(os.Args)>1 { |
|||
ymlpath=os.Args[1] |
|||
}*/ |
|||
|
|||
gocloud.RunApp("", constomRoute, customFun) |
|||
} |
|||
|
|||
func customFun() []template.FuncMap { |
|||
println("constomFun") |
|||
err := comm.InitDb() |
|||
if err != nil { |
|||
println("db err:" + err.Error()) |
|||
os.Exit(1) |
|||
} |
|||
gocloud.GetCustomConf("", app.Conf) |
|||
return []template.FuncMap{map[string]interface{}{ |
|||
"AppName": func() string { |
|||
return "GoCloud" |
|||
}, |
|||
"AppVer": func() string { |
|||
return "1.0.0" |
|||
}, |
|||
}} |
|||
} |
|||
func constomRoute() { |
|||
gocloud.RegController(new(controller.CommController)) |
|||
gocloud.RegController(new(controller.UserController)) |
|||
} |
@ -0,0 +1,91 @@ |
|||
#!/bin/bash |
|||
|
|||
#这里可替换为你自己的执行程序,其他代码无需更改 |
|||
|
|||
APP_PATH=/home/user/go/bin |
|||
APP_NAME="$APP_PATH/main" |
|||
|
|||
cd $APP_PATH |
|||
|
|||
#使用说明,用来提示输入参数 |
|||
usage() { |
|||
echo "Usage: sh [start|stop|restart|status]" |
|||
exit 1 |
|||
} |
|||
|
|||
#检查程序是否在运行 |
|||
is_exist(){ |
|||
pid=`ps -ef|grep $APP_NAME|grep -v grep|awk '{print $2}'` |
|||
#如果不存在返回1,存在返回0 |
|||
if [ -z "${pid}" ]; then |
|||
return 1 |
|||
else |
|||
return 0 |
|||
fi |
|||
} |
|||
|
|||
#启动方法 |
|||
start(){ |
|||
is_exist |
|||
if [ $? -eq 0 ]; then |
|||
echo "${APP_NAME} is running. Pid=${pid}" |
|||
else |
|||
nohup ${APP_NAME} > /dev/null 2>&1 & |
|||
echo "run ${APP_NAME}." |
|||
fi |
|||
} |
|||
|
|||
#停止方法 |
|||
stop(){ |
|||
is_exist |
|||
if [ $? -eq "0" ]; then |
|||
kill $pid |
|||
echo "try kill ${APP_NAME}. pid=${pid}" |
|||
sleep 1s |
|||
is_exist |
|||
if [ $? -eq "0" ]; then |
|||
kill -9 $pid |
|||
echo "Skill kill ${APP_NAME}. pid=${pid}" |
|||
else |
|||
echo "${APP_NAME} is killed" |
|||
fi |
|||
else |
|||
echo "${APP_NAME} is not running" |
|||
fi |
|||
} |
|||
|
|||
#输出运行状态 |
|||
status(){ |
|||
is_exist |
|||
if [ $? -eq "0" ]; then |
|||
echo "${APP_NAME} is running. Pid=${pid}" |
|||
else |
|||
echo "${APP_NAME} is not running." |
|||
fi |
|||
} |
|||
|
|||
#重启 |
|||
restart(){ |
|||
stop |
|||
sleep 1s |
|||
start |
|||
} |
|||
|
|||
#根据输入参数,选择执行对应方法,不输入则执行使用说明 |
|||
case "$1" in |
|||
"start") |
|||
start |
|||
;; |
|||
"stop") |
|||
stop |
|||
;; |
|||
"status") |
|||
status |
|||
;; |
|||
"restart") |
|||
restart |
|||
;; |
|||
*) |
|||
usage |
|||
;; |
|||
esac |
Write
Preview
Loading…
Cancel
Save
Reference in new issue