105 lines
3.6 KiB
Go
105 lines
3.6 KiB
Go
package controllers
|
|
|
|
import (
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
"git.rosy.net.cn/jx-callback/business/jxstore/cms"
|
|
"git.rosy.net.cn/jx-callback/business/model"
|
|
"github.com/astaxie/beego"
|
|
)
|
|
|
|
type PowerController struct {
|
|
beego.Controller
|
|
}
|
|
|
|
// @Title 添加功能(菜单)
|
|
// @Description 添加功能(菜单)
|
|
// @Param token header string true "认证token"
|
|
// @Param payload formData string true "Menu json实体"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /AddMenu [post]
|
|
func (c *PowerController) AddMenu() {
|
|
c.callAddMenu(func(params *tPowerAddMenuParams) (retVal interface{}, errCode string, err error) {
|
|
menu := &model.Menu{}
|
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), menu); err == nil {
|
|
err = cms.AddMenu(params.Ctx, menu)
|
|
}
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 查询功能(菜单)
|
|
// @Description 查询功能(菜单)
|
|
// @Param token header string true "认证token"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /GetMenu [post]
|
|
func (c *PowerController) GetMenu() {
|
|
c.callGetMenu(func(params *tPowerGetMenuParams) (retVal interface{}, errCode string, err error) {
|
|
retVal, err = cms.GetMenu(params.Ctx)
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 修改功能(菜单)
|
|
// @Description 修改功能(菜单)
|
|
// @Param token header string true "认证token"
|
|
// @Param payload formData string true "Menu json实体"
|
|
// @Param menuID formData int true "菜单ID"
|
|
// @Param isDelete formData bool true "是否是删除"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /UpdateMenu [put]
|
|
func (c *PowerController) UpdateMenu() {
|
|
c.callUpdateMenu(func(params *tPowerUpdateMenuParams) (retVal interface{}, errCode string, err error) {
|
|
payload := make(map[string]interface{})
|
|
if err = utils.UnmarshalUseNumber([]byte(params.Payload), &payload); err == nil {
|
|
retVal, err = cms.UpdateMenu(params.Ctx, params.MenuID, payload, params.IsDelete)
|
|
}
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 添加角色
|
|
// @Description 添加角色
|
|
// @Param token header string true "认证token"
|
|
// @Param name formData string true "角色名"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /AddRole [post]
|
|
func (c *PowerController) AddRole() {
|
|
c.callAddRole(func(params *tPowerAddRoleParams) (retVal interface{}, errCode string, err error) {
|
|
err = cms.AddRole(params.Ctx, params.Name)
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 查询角色
|
|
// @Description 查询角色
|
|
// @Param token header string true "认证token"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /GetRole [get]
|
|
func (c *PowerController) GetRole() {
|
|
c.callGetRole(func(params *tPowerGetRoleParams) (retVal interface{}, errCode string, err error) {
|
|
retVal, err = cms.GetRole(params.Ctx)
|
|
return retVal, "", err
|
|
})
|
|
}
|
|
|
|
// @Title 修改角色
|
|
// @Description 修改角色
|
|
// @Param token header string true "认证token"
|
|
// @Param name formData string true "角色名"
|
|
// @Param roleID formData int true "角色ID"
|
|
// @Param isDelete formData bool true "是否是删除"
|
|
// @Success 200 {object} controllers.CallResult
|
|
// @Failure 200 {object} controllers.CallResult
|
|
// @router /UpdateRole [put]
|
|
func (c *PowerController) UpdateRole() {
|
|
c.callUpdateRole(func(params *tPowerUpdateRoleParams) (retVal interface{}, errCode string, err error) {
|
|
retVal, err = cms.UpdateRole(params.Ctx, params.RoleID, params.Name, params.IsDelete)
|
|
return retVal, "", err
|
|
})
|
|
}
|