改名
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
|
||||
}
|
||||
|
||||
@@ -5,10 +5,10 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
)
|
||||
|
||||
func GetFunction(db *DaoDB, name string, level int) (functions []*model.Function, err error) {
|
||||
func GetMenu(db *DaoDB, name string, level int) (menus []*model.Menu, err error) {
|
||||
sql := `
|
||||
SELECT *
|
||||
FROM function
|
||||
FROM menu
|
||||
WHERE deleted_at = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
@@ -22,6 +22,6 @@ func GetFunction(db *DaoDB, name string, level int) (functions []*model.Function
|
||||
sql += " AND level = ?"
|
||||
sqlParams = append(sqlParams, level)
|
||||
}
|
||||
err = GetRows(db, &functions, sql, sqlParams)
|
||||
return functions, err
|
||||
err = GetRows(db, &menus, sql, sqlParams)
|
||||
return menus, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user