添加tool工具,添加用户权限
This commit is contained in:
parent
cd3c9a30ce
commit
ee478c105f
|
|
@ -14,6 +14,8 @@ type User struct {
|
||||||
Password string `gorm:"column:password"`
|
Password string `gorm:"column:password"`
|
||||||
Gender string `gorm:"column:gender"`
|
Gender string `gorm:"column:gender"`
|
||||||
Role string `gorm:"column:role"`
|
Role string `gorm:"column:role"`
|
||||||
|
Redis bool `gorm:"column:redis"`
|
||||||
|
Run bool `gorm:"column:run"`
|
||||||
CreateTime string `gorm:"column:create_time"`
|
CreateTime string `gorm:"column:create_time"`
|
||||||
UpdateTime string `gorm:"column:update_time"`
|
UpdateTime string `gorm:"column:update_time"`
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
package handler
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"net/http"
|
||||||
|
"videoplayer/dao"
|
||||||
|
"videoplayer/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
type SetRedisReq struct {
|
||||||
|
Option string `json:"option" form:"option"`
|
||||||
|
Key string `json:"key" form:"key"`
|
||||||
|
Value string `json:"value" form:"value"`
|
||||||
|
Expire int `json:"expire" form:"expire"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetUpToolGroup(router *gin.Engine) {
|
||||||
|
toolGroup := router.Group("/tool")
|
||||||
|
toolGroup.POST("/set_redis", SetRedis)
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetRedis(c *gin.Context) {
|
||||||
|
//先查看是否有权限
|
||||||
|
id, _ := c.Get("id")
|
||||||
|
id1 := int(id.(float64))
|
||||||
|
user := dao.FindUserByUserID(id1)
|
||||||
|
if user.Redis == false {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "no redis Permissions", "code": proto.NoRedisPermissions, "message": "failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//解析请求参数
|
||||||
|
var req SetRedisReq
|
||||||
|
if err := c.ShouldBind(&req); err == nil {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"error": "parameter error", "code": proto.ParameterError, "message": "failed"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,4 +41,7 @@ const (
|
||||||
|
|
||||||
// UUID相关错误码
|
// UUID相关错误码
|
||||||
UUIDNotFound = 18 // uuid不存在
|
UUIDNotFound = 18 // uuid不存在
|
||||||
|
|
||||||
|
//Tool
|
||||||
|
NoRedisPermissions = 51
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue