Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove all and will push source code
- Loading branch information
1 parent
19a009d
commit 8b9ef95
Showing
15 changed files
with
872 additions
and
49 deletions.
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
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,17 +1,23 @@ | ||
title = "SST运维作业平台" | ||
title = "SST运维作业平台" | ||
culture = "-- 简单 . 高效 . 自动化 --" | ||
|
||
appname = SST | ||
appname = SST | ||
httpport = 8080 | ||
runmode = dev | ||
runmode = dev | ||
|
||
sessionon = true | ||
|
||
loginuser = duliang | ||
loginpasswd = Duliangduliang | ||
loginuser = duliang123 | ||
loginpasswd = 123456 | ||
|
||
mysqluser = | ||
mysqlpass = | ||
mysqlurls = 127.0.0.1 | ||
mysqldb = | ||
mysqltbpre = | ||
|
||
|
||
salt_url = https://127.0.0.1:8000/login | ||
salt_username = salt_u_duliang | ||
salt_password = DL@@#124132-_@ | ||
salt_password = DL@!(*$abc | ||
salt_api_url = https://127.0.0.1:8000 |
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,88 @@ | ||
package admin | ||
|
||
import ( | ||
"fmt" | ||
"time" | ||
. "SST/models/admin" | ||
"SST/controllers" | ||
"github.com/astaxie/beego" | ||
) | ||
|
||
type MainController struct { | ||
beego.Controller | ||
} | ||
|
||
func (c *MainController) Get() { | ||
c.Data["Website"] = "github.com/duliang123/SST" | ||
c.Data["Email"] = "" | ||
c.Layout = "admin/layout.tpl" | ||
c.TplName = "index.tpl" | ||
} | ||
|
||
//登录 | ||
type LoginUserController struct { | ||
controllers.BaseController | ||
} | ||
|
||
func (this *LoginUserController) Get() { | ||
check := this.BaseController.IsLogin | ||
if check { | ||
//this.Abort("401") | ||
this.Redirect("/index", 302) | ||
} else { | ||
this.Data["title"] = beego.AppConfig.String("title") | ||
this.Data["culture"] = beego.AppConfig.String("culture") | ||
this.TplName = "admin/login.tpl" | ||
} | ||
} | ||
|
||
func (this *LoginUserController) Post() { | ||
username := this.GetString("username") | ||
password := this.GetString("password") | ||
|
||
if "" == username { | ||
this.Data["json"] = map[string]interface{}{"code": 0, "message": "请填写用户名"} | ||
this.ServeJSON() | ||
} | ||
|
||
if "" == password { | ||
this.Data["json"] = map[string]interface{}{"code": 0, "message": "请填写密码"} | ||
this.ServeJSON() | ||
} | ||
err, users := LoginUser(username, password) | ||
|
||
if err == nil { | ||
this.SetSession("userLogin", fmt.Sprintf("%d", users.Id)+"||"+users.Username+"||"+users.Avatar) | ||
//this.SetSession("userPermission", GetPermissions(users.Id)) | ||
this.Data["json"] = map[string]interface{}{"code": 1, "message": "贺喜你,登录成功"} | ||
} else { | ||
this.Data["json"] = map[string]interface{}{"code": 0, "message": "登录失败"} | ||
} | ||
this.ServeJSON() | ||
} | ||
|
||
//退出 | ||
type LogoutUserController struct { | ||
controllers.BaseController | ||
} | ||
|
||
func (this *LogoutUserController) Get() { | ||
this.DelSession("userLogin") | ||
//this.Ctx.WriteString("you have logout") | ||
this.Redirect("/login", 302) | ||
|
||
} | ||
|
||
//首页 | ||
type AdminController struct { | ||
controllers.BaseController | ||
} | ||
|
||
func (this *AdminController) Get() { | ||
this.Data["title"] = beego.AppConfig.String("title") | ||
this.Data["culture"] = beego.AppConfig.String("culture") | ||
this.Data["navtitle"] = "欢迎页" | ||
this.Data["datetime"] = time.Now().Format("2006-01-02 15:04:05") | ||
this.Layout = "admin/layout.tpl" | ||
this.TplName = "admin/index.tpl" | ||
} |
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,43 @@ | ||
package controllers | ||
|
||
import ( | ||
//"opms/initial" | ||
|
||
"strconv" | ||
"strings" | ||
//"fmt" | ||
|
||
"github.com/astaxie/beego" | ||
) | ||
|
||
type BaseController struct { | ||
beego.Controller | ||
IsLogin bool | ||
//UserInfo string | ||
UserUserId int64 | ||
UserUsername string | ||
UserAvatar string | ||
} | ||
|
||
func (this *BaseController) Prepare() { | ||
userLogin := this.GetSession("userLogin") | ||
if userLogin == nil { | ||
this.IsLogin = false | ||
//this.Redirect("/login", 302) | ||
} else { | ||
this.IsLogin = true | ||
tmp := strings.Split((this.GetSession("userLogin")).(string), "||") | ||
|
||
//id, _ := strconv.Atoi(tmp[0]) | ||
userid, _ := strconv.Atoi(tmp[0]) | ||
longid := int64(userid) | ||
this.Data["LoginUserid"] = longid | ||
this.Data["LoginUsername"] = tmp[1] | ||
this.Data["LoginAvatar"] = tmp[2] | ||
|
||
this.UserUserId = longid | ||
this.UserUsername = tmp[1] | ||
this.UserAvatar = tmp[2] | ||
} | ||
this.Data["IsLogin"] = this.IsLogin | ||
} |
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,15 @@ | ||
package controllers | ||
|
||
import ( | ||
"github.com/astaxie/beego" | ||
) | ||
|
||
type MainController struct { | ||
beego.Controller | ||
} | ||
|
||
func (c *MainController) Get() { | ||
c.Data["Website"] = "beego.me" | ||
c.Data["Email"] = "astaxie@gmail.com" | ||
c.TplName = "index.tpl" | ||
} |
Oops, something went wrong.