forked from mikezss/skl-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
15,932 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
*.bak |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,27 @@ | ||
# skl-go | ||
# skl-go | ||
|
||
## Features | ||
* An enterprise api for web applications. | ||
* Written in beego | ||
* Including user,usergroup,orginazation,role and priviledge management | ||
|
||
## Environment Support | ||
* beego 1.9.0 | ||
* golang go1.9.2 | ||
|
||
## Installation | ||
* install golang by yourself | ||
* install beego by yourself | ||
* go install skl-golang | ||
|
||
|
||
## Usage | ||
|
||
## Links | ||
|
||
## Development | ||
|
||
|
||
## License | ||
* MIT | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
appname = skl-go | ||
httpport = 8088 | ||
runmode = dev | ||
autorender = false | ||
copyrequestbody = true | ||
EnableDocs = true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dbtype="sqlite3" | ||
mailhost="" | ||
mailhostaddress="" | ||
mailuser="1329565748@qq.com" | ||
mailpwd="" | ||
[sqlite3] | ||
dbname="skl-go.db" | ||
[mysql] | ||
dbname="mysqlskl6" | ||
hostname="localhost" | ||
port="3306" | ||
username="root" | ||
password="root" | ||
[postgres] | ||
dbname="pgskl6" | ||
hostname="localhost" | ||
port="5433" | ||
username="postgres" | ||
password="postgres" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package controllers | ||
|
||
import ( | ||
_ "encoding/json" | ||
"strconv" | ||
"strings" | ||
|
||
"fmt" | ||
"github.com/mikezss/skl-go/models" | ||
|
||
"github.com/astaxie/beego" | ||
"github.com/astaxie/beego/session" | ||
"github.com/beego/i18n" | ||
) | ||
|
||
//(2)建立一个全局session mananger对象 | ||
var GlobalSessions *session.Manager | ||
|
||
// Operations about Users | ||
type BASEController struct { | ||
beego.Controller | ||
i18n.Locale | ||
User models.CMN_USER_TB | ||
IsLogin bool | ||
} | ||
|
||
func init() { | ||
fmt.Println("BASEController.init()==>") | ||
var err error | ||
GlobalSessions, err = session.NewManager("memory", &session.ManagerConfig{CookieName: "gosessionid", Gclifetime: 3600}) | ||
go GlobalSessions.GC() | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
fmt.Println("GlobalSessions:") | ||
fmt.Println(GlobalSessions) | ||
fmt.Println("BASEController.init()<==") | ||
} | ||
|
||
// Prepare implemented Prepare method for baseRouter. | ||
func (this *BASEController) Prepare() { | ||
fmt.Println("BASEController.Prepare==>") | ||
rquri := this.Ctx.Request.RequestURI | ||
fmt.Println("rquest uri==>" + rquri) | ||
if this.CruSession == nil { | ||
this.StartSession() | ||
} else { | ||
PROFILE := this.CruSession.Get("PROFILE") | ||
fmt.Println(PROFILE) | ||
if PROFILE == nil && !strings.Contains(rquri, "/login/login") { | ||
status := "expired" | ||
this.Data["json"] = map[string]string{"status": status} | ||
this.ServeJSON() | ||
return | ||
|
||
} | ||
} | ||
|
||
fmt.Println("BASEController.Prepare<==") | ||
} | ||
func (this *BASEController) getUserid() string { | ||
var p models.PROFILE | ||
pr := this.CruSession.Get("PROFILE") | ||
if pr != nil { | ||
p = pr.(models.PROFILE) | ||
return p.Userid | ||
} | ||
|
||
return "" | ||
} | ||
func stringsToJson(str string) string { | ||
rs := []rune(str) | ||
jsons := "" | ||
for _, r := range rs { | ||
rint := int(r) | ||
if rint < 128 { | ||
jsons += string(r) | ||
} else { | ||
jsons += "\\u" + strconv.FormatInt(int64(rint), 16) // json | ||
} | ||
} | ||
return jsons | ||
} |
Oops, something went wrong.