Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
hzwy23 committed Apr 29, 2017
1 parent fb77f49 commit 54a3d4f
Show file tree
Hide file tree
Showing 19 changed files with 257 additions and 486 deletions.
6 changes: 3 additions & 3 deletions hauth/controllers/domainController.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"encoding/json"

"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/hrpc"
"github.com/hzwy23/asofdate/hauth/models"
"github.com/hzwy23/utils/hret"
Expand Down Expand Up @@ -47,7 +47,7 @@ func (this *domainController) Page(ctx *context.Context) {
return
}

rst, err := hcache.GetStaticFile("DomainPage")
rst, err := groupcache.GetStaticFile("DomainPage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.Get(ctx.Request, "as_of_date_page_not_exist"))
return
Expand Down Expand Up @@ -379,5 +379,5 @@ func (this *domainController) GetId(ctx *context.Context) {
}

func init() {
hcache.RegisterStaticFile("DomainPage", "./views/hauth/domain_info.tpl")
groupcache.RegisterStaticFile("DomainPage", "./views/hauth/domain_info.tpl")
}
6 changes: 3 additions & 3 deletions hauth/controllers/handleLogController.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"

"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/hrpc"
"github.com/hzwy23/asofdate/hauth/models"
"github.com/hzwy23/utils/hret"
Expand Down Expand Up @@ -47,7 +47,7 @@ func (this *handleLogsController) Page(ctx *context.Context) {
return
}

rst, err := hcache.GetStaticFile("AsofdateHandleLogPage")
rst, err := groupcache.GetStaticFile("AsofdateHandleLogPage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
return
Expand Down Expand Up @@ -292,5 +292,5 @@ func (this handleLogsController) SerachLogs(ctx *context.Context) {
}

func init() {
hcache.RegisterStaticFile("AsofdateHandleLogPage", "./views/hauth/handle_logs_page.tpl")
groupcache.RegisterStaticFile("AsofdateHandleLogPage", "./views/hauth/handle_logs_page.tpl")
}
6 changes: 3 additions & 3 deletions hauth/controllers/helpController.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import (
"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/hrpc"
"github.com/hzwy23/utils/hret"
"github.com/hzwy23/utils/i18n"
Expand Down Expand Up @@ -36,7 +36,7 @@ func (this helpController) Page(ctx *context.Context) {
return
}

rst, err := hcache.GetStaticFile("AsofdateHelpPage")
rst, err := groupcache.GetStaticFile("AsofdateHelpPage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
return
Expand All @@ -45,5 +45,5 @@ func (this helpController) Page(ctx *context.Context) {
}

func init() {
hcache.RegisterStaticFile("AsofdateHelpPage", "./views/help/auth_help.tpl")
groupcache.RegisterStaticFile("AsofdateHelpPage", "./views/help/auth_help.tpl")
}
6 changes: 3 additions & 3 deletions hauth/controllers/indexController.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import (
"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/utils/hret"
"github.com/hzwy23/utils/i18n"
)
Expand All @@ -23,7 +23,7 @@ import (
// '200':
// description: all domain information
func IndexPage(ctx *context.Context) {
rst, err := hcache.GetStaticFile("AsofdateIndexPage")
rst, err := groupcache.GetStaticFile("AsofdateIndexPage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
return
Expand All @@ -32,5 +32,5 @@ func IndexPage(ctx *context.Context) {
}

func init() {
hcache.RegisterStaticFile("AsofdateIndexPage", "./views/login.tpl")
groupcache.RegisterStaticFile("AsofdateIndexPage", "./views/login.tpl")
}
10 changes: 5 additions & 5 deletions hauth/controllers/mainMenuController.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package controllers

import (
"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/models"
"github.com/hzwy23/utils/hret"
"github.com/hzwy23/utils/i18n"
Expand Down Expand Up @@ -62,13 +62,13 @@ func SubSystemEntry(ctx *context.Context) {
return
}

key := hcache.GenSha1Key(id, jclaim.User_id, url)
key := groupcache.GenSha1Key(id, jclaim.User_id, url)

if !hcache.FileIsExist(key) {
hcache.RegisterStaticFile(key, url)
if !groupcache.FileIsExist(key) {
groupcache.RegisterStaticFile(key, url)
}

tpl, err := hcache.GetStaticFile(key)
tpl, err := groupcache.GetStaticFile(key)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
Expand Down
6 changes: 3 additions & 3 deletions hauth/controllers/orgController.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"path/filepath"

"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/hrpc"
"github.com/hzwy23/asofdate/hauth/models"
"github.com/hzwy23/utils"
Expand Down Expand Up @@ -51,7 +51,7 @@ func (orgController) Page(ctx *context.Context) {
return
}

rst, err := hcache.GetStaticFile("AsofdateOrgPage")
rst, err := groupcache.GetStaticFile("AsofdateOrgPage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
return
Expand Down Expand Up @@ -604,5 +604,5 @@ func (this orgController) Upload(ctx *context.Context) {
}

func init() {
hcache.RegisterStaticFile("AsofdateOrgPage", "./views/hauth/org_page.tpl")
groupcache.RegisterStaticFile("AsofdateOrgPage", "./views/hauth/org_page.tpl")
}
203 changes: 12 additions & 191 deletions hauth/controllers/resourceController.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@ package controllers

import (
"github.com/astaxie/beego/context"
"github.com/hzwy23/asofdate/hauth/hcache"
"github.com/hzwy23/asofdate/hauth/groupcache"
"github.com/hzwy23/asofdate/hauth/hrpc"
"github.com/hzwy23/asofdate/hauth/models"
"github.com/hzwy23/utils/hret"
"github.com/hzwy23/utils/i18n"
"github.com/hzwy23/utils/logs"
"github.com/hzwy23/validator"
)

type resourceController struct {
Expand Down Expand Up @@ -41,7 +40,7 @@ func (resourceController) Page(ctx *context.Context) {
return
}

rst, err := hcache.GetStaticFile("AsofdateResourcePage")
rst, err := groupcache.GetStaticFile("AsofdateResourcePage")
if err != nil {
hret.Error(ctx.ResponseWriter, 404, i18n.PageNotFound(ctx.Request))
return
Expand Down Expand Up @@ -143,188 +142,15 @@ func (this resourceController) Post(ctx *context.Context) {
return
}

theme_id := ctx.Request.FormValue("theme_id")
res_type := ctx.Request.FormValue("res_type")
res_id := ctx.Request.FormValue("res_id")
res_name := ctx.Request.FormValue("res_name")
res_up_id := ctx.Request.FormValue("res_up_id")
res_url := ctx.Request.FormValue("res_url")
res_class := ctx.Request.FormValue("res_class")
res_img := ctx.Request.FormValue("res_img")
res_bg_color := ctx.Request.FormValue("res_bg_color")
group_id := ctx.Request.FormValue("group_id")
sort_id := ctx.Request.FormValue("sort_id")
res_open_type := ctx.Request.FormValue("res_open_type")

res_attr := "1"
if res_type == "0" || res_type == "4" {
res_attr = "0"
}
if res_type == "0" {
res_up_id = "-1"
}

if !validator.IsWord(res_id) {
logs.Error("资源编码必须由1,30位字母或数字组成")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_res_id"))
return
}

if validator.IsEmpty(res_name) {
logs.Error("菜单名称不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_desc_empty"))
return
}

if validator.IsEmpty(res_type) {
logs.Error("菜单类别不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_type"))
return
}

switch res_type {
case "0":
// 首页主菜单信息
if !validator.IsURI(res_url) {
logs.Error("菜单路由地址不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_route_uri"))
return
}

if validator.IsEmpty(res_class) {
logs.Error("菜单样式类型不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_class_style"))
return
}

if !validator.IsURI(res_img) {
logs.Error("菜单图标不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_icon"))
return
}

if !validator.IsNumeric(group_id) {
logs.Error("菜单分组信息必须是数字")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_group"))
return
}

if !validator.IsNumeric(sort_id) {
logs.Error("菜单排序号必须是数字")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_sort"))
return
}
form := ctx.Request.Form

if validator.IsEmpty(res_open_type) {
logs.Error("打开方式不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_open_type"))
return
}

err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id, res_open_type)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 419, i18n.Get(ctx.Request, "error_resource_exec"), err)
return
}
case "1":
// 子系统菜单信息
if !validator.IsURI(res_url) {
logs.Error("菜单路由地址不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_route_uri"))
return
}

if !validator.IsWord(res_up_id) {
logs.Error("菜单上级编码不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_up_id"))
return
}

if validator.IsEmpty(res_class) {
logs.Error("菜单样式类型不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_class_style"))
return
}

if !validator.IsURI(res_img) {
logs.Error("菜单图标不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_icon"))
return
}

if !validator.IsNumeric(group_id) {
logs.Error("菜单分组信息必须是数字")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_group"))
return
}

if !validator.IsNumeric(sort_id) {
logs.Error("菜单排序号必须是数字")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_sort"))
return
}

if validator.IsEmpty(res_open_type) {
logs.Error("打开方式不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_open_type"))
return
}

err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id, res_open_type)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_exec"), err)
return
}

case "2":
// 功能按钮信息
if !validator.IsWord(res_up_id) {
logs.Error("菜单上级编码不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_up_id"))
return
}

if !validator.IsURI(res_url) {
logs.Error("菜单路由地址不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_route_uri"))
return
}
sort_id = "0"
res_img = ""
group_id = ""
res_class = ""
res_bg_color = ""
res_open_type = ""
res_open_type = ""
err := this.models.Post(res_id, res_name, res_attr, res_up_id, res_type, theme_id, res_url, res_bg_color, res_class, group_id, res_img, sort_id, res_open_type)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 419, i18n.Get(ctx.Request, "error_resource_exec"), err)
return
}

case "4":
// 虚拟节点信息
// 功能按钮信息
if !validator.IsWord(res_up_id) {
logs.Error("菜单上级编码不能为空")
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_up_id"))
return
}

err := this.models.PostButton(res_id, res_name, res_attr, res_up_id, res_type)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 419, i18n.Get(ctx.Request, "error_resource_exec"), err)
return
}
default:
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_type"))
msg, err := this.models.Post(form)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, msg), err)
return
}
hret.Success(ctx.ResponseWriter, "success")
hret.Success(ctx.ResponseWriter, i18n.Success(ctx.Request))

}

Expand Down Expand Up @@ -407,20 +233,15 @@ func (this resourceController) Update(ctx *context.Context) {
res_id := ctx.Request.FormValue("res_id")
res_name := ctx.Request.FormValue("res_name")

if validator.IsEmpty(res_name) {
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_desc_empty"))
return
}

err := this.models.Update(res_id, res_name)
msg, err := this.models.Update(res_id, res_name)
if err != nil {
logs.Error(err)
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, "error_resource_update"), err)
hret.Error(ctx.ResponseWriter, 421, i18n.Get(ctx.Request, msg), err)
return
}
hret.Success(ctx.ResponseWriter, "success")
hret.Success(ctx.ResponseWriter, i18n.Success(ctx.Request))
}

func init() {
hcache.RegisterStaticFile("AsofdateResourcePage", "./views/hauth/res_info_page.tpl")
groupcache.RegisterStaticFile("AsofdateResourcePage", "./views/hauth/res_info_page.tpl")
}

0 comments on commit 54a3d4f

Please sign in to comment.