作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev

... ... @@ -39,17 +39,21 @@ func (c *RbacController) RoleAdd() {
return
}
n := []rune(param.Name)
if len(n) > 10 || len(n) <= 0 {
if len(n) > 10 {
msg = protocol.BadRequestParam("10008")
return
}
if len(n) <= 0 {
msg = protocol.BadRequestParam("10009")
return
}
r, err := serverbac.RoleAdd(param)
msg = protocol.NewReturnResponse(r, err)
return
}
// RoleUpdate 编辑部门
// @router /role [put]
// @router /role/edit [post]
func (c *RbacController) RoleUpdate() {
var msg *protocol.ResponseMessage
defer func() {
... ... @@ -68,10 +72,14 @@ func (c *RbacController) RoleUpdate() {
return
}
n := []rune(param.Name)
if len(n) > 10 || len(n) <= 0 {
if len(n) > 10 {
msg = protocol.BadRequestParam("10008")
return
}
if len(n) <= 0 {
msg = protocol.BadRequestParam("10009")
return
}
param.Types = models.ROLETYPES_ROLE
r, err := serverbac.RoleEdit(param)
msg = protocol.NewReturnResponse(r, err)
... ... @@ -124,10 +132,14 @@ func (c *RbacController) RoleGroupAdd() {
return
}
n := []rune(param.Name)
if len(n) > 10 || len(n) <= 0 {
if len(n) > 10 {
msg = protocol.BadRequestParam("10007")
return
}
if len(n) <= 0 {
msg = protocol.BadRequestParam("10081")
return
}
param.Pid = 0
param.Types = models.ROLETYPES_GROUP
roleinfo, err := serverbac.RoleAdd(param)
... ... @@ -155,10 +167,14 @@ func (c *RbacController) RoleGroupUpdate() {
return
}
n := []rune(param.Name)
if len(n) > 10 || len(n) <= 0 {
if len(n) > 10 {
msg = protocol.BadRequestParam("10007")
return
}
if len(n) <= 0 {
msg = protocol.BadRequestParam("10081")
return
}
param.Pid = 0
param.Types = models.ROLETYPES_GROUP
roleinfo, err := serverbac.RoleEdit(param)
... ...
... ... @@ -13,6 +13,8 @@ var errmessge ErrorMap = map[string]string{
"10006": "默认角色不能修改",
"10007": "角色组名称最多10个字符",
"10008": "角色名称最多10个字符",
"10009": "角色名称必填",
"10081": "角色组名称必填",
//职位相关
"10011": "该职位已被使用无法删除",
"10012": "超过10级的职位限制,请重新选择",
... ...
package filesave
import (
"fmt"
"github.com/sony/sonyflake"
)
var sf = sonyflake.NewSonyflake(sonyflake.Settings{})
func GenerateIDBySonyflake() int64 {
num, _ := sf.NextID()
return int64(num)
}
func GenerateNewName() string {
id := GenerateIDBySonyflake()
return fmt.Sprint(id)
}
... ... @@ -42,10 +42,23 @@ type PermissionContentObject interface {
ObjectMarshal() (string, error)
}
type UserObject struct {
UserId int64 `json:"user_id"`
CompanyId int64 `json:"company_id"`
UserCompanyId int64 `json:"user_company_id"`
}
type PermissionContentBase struct {
Check int8 `json:"check"`
}
func (p *PermissionContentBase) ValidDefault(obj UserObject) bool {
if p.Check == 1 {
return true
}
return false
}
func NewPermissionContentBase() PermissionContentObject {
return &PermissionContentBase{}
}
... ...