功能(菜单)接口
This commit is contained in:
@@ -1,10 +1,40 @@
|
||||
package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||
)
|
||||
|
||||
func GetFunction(ctx *jxcontext.Context) (functions []*model.Function, err error) {
|
||||
return functions, err
|
||||
return dao.GetFunction(dao.GetDB(), "", 0)
|
||||
}
|
||||
|
||||
func AddFunction(ctx *jxcontext.Context, function *model.Function) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
if function == nil {
|
||||
return fmt.Errorf("添加失败!function nil")
|
||||
}
|
||||
if function.Name == "" || function.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)
|
||||
}
|
||||
dao.Begin(db)
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
dao.Rollback(db)
|
||||
panic(r)
|
||||
}
|
||||
}()
|
||||
dao.WrapAddIDCULDEntity(&function, ctx.GetUserName())
|
||||
err = dao.CreateEntity(db, function)
|
||||
dao.Commit(db)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user