@@ -0,0 +1,50 @@
|
||||
package rolectrl
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"91porn-server/common"
|
||||
"91porn-server/common/constant"
|
||||
"91porn-server/common/stderr"
|
||||
"91porn-server/models/l/operatorlgmod"
|
||||
"91porn-server/models/v/rolemod"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 权限接口 doc
|
||||
// @Summary 新增权限
|
||||
// @Description 新增权限
|
||||
// @Tags 权限-配置
|
||||
// @Accept mpfd,json
|
||||
// @Produce json,html
|
||||
// @Param host formData string false "域名 可以为空"
|
||||
// @Param path formData string true "路由路径"
|
||||
// @Param method formData string false "方法 可为空"
|
||||
// @Param authorized_roles formData string true "允许的角色"
|
||||
// @Param allow_anyone formData string false "是否允许任何角色都可以访问"
|
||||
// @Success 200 {string} json "{"msg": "操作成功"}"
|
||||
// @Failure 400 {string} json "{"msg": "操作失败"}"
|
||||
// @Router /role/edit [post]
|
||||
func Edit(c *gin.Context) {
|
||||
manager, err := common.GetAdminAct(c)
|
||||
if err != nil {
|
||||
common.ServeJSON(c, stderr.AdminIDErr, err.Error())
|
||||
return
|
||||
}
|
||||
var args struct {
|
||||
Incr []rolemod.Incr `form:"roles" json:"roles" binding:"required"`
|
||||
}
|
||||
incr := rolemod.Incr{}
|
||||
if err = c.ShouldBind(&args); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrParamError, err)
|
||||
return
|
||||
}
|
||||
if err = rolemod.UpdateRole(args.Incr); err != nil {
|
||||
common.ServeJSON(c, stderr.ErrDbInsertError, err)
|
||||
return
|
||||
}
|
||||
log, _ := json.Marshal(&incr)
|
||||
_ = operatorlgmod.RecordOperation(manager, constant.RoleConfig, constant.Modify, string(log), c.Request.URL.RequestURI())
|
||||
common.ServeJSON(c, stderr.Success, nil)
|
||||
}
|
||||
Reference in New Issue
Block a user