go-common/app/admin/main/macross/http/mng_role.go
2019-04-22 18:49:16 +08:00

58 lines
1.1 KiB
Go

package http
import (
"strconv"
"go-common/library/ecode"
bm "go-common/library/net/http/blademaster"
)
// role get role by sysid.
func role(c *bm.Context) {
var (
params = c.Request.Form
system string
)
if system = params.Get("system"); system == "" {
c.JSON(nil, ecode.RequestErr)
return
}
c.JSON(svr.Role(c, system), nil)
}
// saveRole save role.
func saveRole(c *bm.Context) {
var (
params = c.Request.Form
roleID int64
roleName string
)
if roleName = params.Get("role_name"); roleName == "" {
c.JSON(nil, ecode.RequestErr)
return
}
roleIDStr := params.Get("role_id")
roleID, _ = strconv.ParseInt(roleIDStr, 10, 64)
system := params.Get("system")
if roleID == 0 && system == "" {
c.JSON(nil, ecode.RequestErr)
return
}
c.JSON(nil, svr.SaveRole(c, roleID, system, roleName))
}
// DelRole del role.
func DelRole(c *bm.Context) {
var (
params = c.Request.Form
roleID int64
err error
)
roleIDStr := params.Get("role_id")
if roleID, err = strconv.ParseInt(roleIDStr, 10, 64); err != nil {
c.JSON(nil, ecode.RequestErr)
return
}
c.JSON(nil, svr.DelRole(c, roleID))
}