Skip to content

Commit

Permalink
1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mikezss committed Dec 26, 2018
1 parent e2bd5ee commit 4306986
Show file tree
Hide file tree
Showing 36 changed files with 15,932 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.bak
28 changes: 27 additions & 1 deletion README.md
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

7 changes: 7 additions & 0 deletions conf/app.conf
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

19 changes: 19 additions & 0 deletions conf/myconf.ini
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"
83 changes: 83 additions & 0 deletions controllers/basecontrol.go
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
}
Loading

0 comments on commit 4306986

Please sign in to comment.