改名
This commit is contained in:
@@ -8,23 +8,23 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func GetFunction(ctx *jxcontext.Context) (functions []*model.Function, err error) {
|
||||
return dao.GetFunction(dao.GetDB(), "", 0)
|
||||
func GetMenu(ctx *jxcontext.Context) (menus []*model.Menu, err error) {
|
||||
return dao.GetMenu(dao.GetDB(), "", 0)
|
||||
}
|
||||
|
||||
func AddFunction(ctx *jxcontext.Context, function *model.Function) (err error) {
|
||||
func AddMenu(ctx *jxcontext.Context, menu *model.Menu) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if function == nil {
|
||||
if menu == nil {
|
||||
return fmt.Errorf("添加失败!function nil")
|
||||
}
|
||||
if function.Name == "" || function.Level == 0 {
|
||||
if menu.Name == "" || menu.Level == 0 {
|
||||
return fmt.Errorf("添加失败!function 名称和等级必须有值!")
|
||||
}
|
||||
functions, err := dao.GetFunction(db, function.Name, function.Level)
|
||||
if len(functions) > 0 {
|
||||
return fmt.Errorf("添加失败!已存在相同名称的 fuction name : %v", function.Name)
|
||||
menus, err := dao.GetMenu(db, menu.Name, menu.Level)
|
||||
if len(menus) > 0 {
|
||||
return fmt.Errorf("添加失败!已存在相同名称的 fuction name : %v", menu.Name)
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
@@ -33,8 +33,8 @@ func AddFunction(ctx *jxcontext.Context, function *model.Function) (err error) {
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
dao.WrapAddIDCULDEntity(function, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, function)
|
||||
dao.WrapAddIDCULDEntity(menu, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, menu)
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user