改名
This commit is contained in:
@@ -8,23 +8,23 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model/dao"
|
"git.rosy.net.cn/jx-callback/business/model/dao"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetFunction(ctx *jxcontext.Context) (functions []*model.Function, err error) {
|
func GetMenu(ctx *jxcontext.Context) (menus []*model.Menu, err error) {
|
||||||
return dao.GetFunction(dao.GetDB(), "", 0)
|
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 (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
)
|
)
|
||||||
if function == nil {
|
if menu == nil {
|
||||||
return fmt.Errorf("添加失败!function nil")
|
return fmt.Errorf("添加失败!function nil")
|
||||||
}
|
}
|
||||||
if function.Name == "" || function.Level == 0 {
|
if menu.Name == "" || menu.Level == 0 {
|
||||||
return fmt.Errorf("添加失败!function 名称和等级必须有值!")
|
return fmt.Errorf("添加失败!function 名称和等级必须有值!")
|
||||||
}
|
}
|
||||||
functions, err := dao.GetFunction(db, function.Name, function.Level)
|
menus, err := dao.GetMenu(db, menu.Name, menu.Level)
|
||||||
if len(functions) > 0 {
|
if len(menus) > 0 {
|
||||||
return fmt.Errorf("添加失败!已存在相同名称的 fuction name : %v", function.Name)
|
return fmt.Errorf("添加失败!已存在相同名称的 fuction name : %v", menu.Name)
|
||||||
}
|
}
|
||||||
dao.Begin(db)
|
dao.Begin(db)
|
||||||
defer func() {
|
defer func() {
|
||||||
@@ -33,8 +33,8 @@ func AddFunction(ctx *jxcontext.Context, function *model.Function) (err error) {
|
|||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
dao.WrapAddIDCULDEntity(function, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(menu, ctx.GetUserName())
|
||||||
err = dao.CreateEntity(db, function)
|
err = dao.CreateEntity(db, menu)
|
||||||
dao.Commit(db)
|
dao.Commit(db)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"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 := `
|
sql := `
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM function
|
FROM menu
|
||||||
WHERE deleted_at = ?
|
WHERE deleted_at = ?
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
@@ -22,6 +22,6 @@ func GetFunction(db *DaoDB, name string, level int) (functions []*model.Function
|
|||||||
sql += " AND level = ?"
|
sql += " AND level = ?"
|
||||||
sqlParams = append(sqlParams, level)
|
sqlParams = append(sqlParams, level)
|
||||||
}
|
}
|
||||||
err = GetRows(db, &functions, sql, sqlParams)
|
err = GetRows(db, &menus, sql, sqlParams)
|
||||||
return functions, err
|
return menus, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,15 +14,15 @@ type PowerController struct {
|
|||||||
// @Title 添加功能(菜单)
|
// @Title 添加功能(菜单)
|
||||||
// @Description 添加功能(菜单)
|
// @Description 添加功能(菜单)
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param payload formData string true "Function json实体"
|
// @Param payload formData string true "Menu json实体"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /AddFunction [post]
|
// @router /AddMenu [post]
|
||||||
func (c *PowerController) AddFunction() {
|
func (c *PowerController) AddMenu() {
|
||||||
c.callAddFunction(func(params *tPowerAddFunctionParams) (retVal interface{}, errCode string, err error) {
|
c.callAddMenu(func(params *tPowerAddMenuParams) (retVal interface{}, errCode string, err error) {
|
||||||
function := &model.Function{}
|
menu := &model.Menu{}
|
||||||
if err = utils.UnmarshalUseNumber([]byte(params.Payload), function); err == nil {
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), menu); err == nil {
|
||||||
err = cms.AddFunction(params.Ctx, function)
|
err = cms.AddMenu(params.Ctx, menu)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
@@ -33,10 +33,10 @@ func (c *PowerController) AddFunction() {
|
|||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /GetFunction [post]
|
// @router /GetMenu [post]
|
||||||
func (c *PowerController) GetFunction() {
|
func (c *PowerController) GetMenu() {
|
||||||
c.callGetFunction(func(params *tPowerGetFunctionParams) (retVal interface{}, errCode string, err error) {
|
c.callGetMenu(func(params *tPowerGetMenuParams) (retVal interface{}, errCode string, err error) {
|
||||||
retVal, err = cms.GetFunction(params.Ctx)
|
retVal, err = cms.GetMenu(params.Ctx)
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1433,8 +1433,8 @@ func init() {
|
|||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "AddFunction",
|
Method: "AddMenu",
|
||||||
Router: `/AddFunction`,
|
Router: `/AddMenu`,
|
||||||
AllowHTTPMethods: []string{"post"},
|
AllowHTTPMethods: []string{"post"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
@@ -1442,8 +1442,8 @@ func init() {
|
|||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:PowerController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetFunction",
|
Method: "GetMenu",
|
||||||
Router: `/GetFunction`,
|
Router: `/GetMenu`,
|
||||||
AllowHTTPMethods: []string{"post"},
|
AllowHTTPMethods: []string{"post"},
|
||||||
MethodParams: param.Make(),
|
MethodParams: param.Make(),
|
||||||
Filters: nil,
|
Filters: nil,
|
||||||
|
|||||||
Reference in New Issue
Block a user