M sdbapi/handlers/userinfo.go => sdbapi/handlers/userinfo.go +2 -2
@@ 18,10 18,10 @@ import (
)
func UserInfo(c *gin.Context) {
- username := c.Param("username")
+ id := c.Param("id")
var user models.User
- record := db.DbConn.Where("username = ?", username).First(&user)
+ record := db.DbConn.Where("id = ?", id).First(&user)
if record.Error != nil {
c.JSON(http.StatusNotFound, gin.H{"error": errors.UserNotFound})
c.Abort()
M sdbapi/main.go => sdbapi/main.go +2 -2
@@ 39,10 39,10 @@ func createRouter() *gin.Engine {
{
user.POST("/register", handlers.CreateUser)
user.POST("/token", handlers.GenerateToken)
- user.GET("/info/:username", handlers.UserInfo)
+ user.GET("/:id", handlers.UserInfo)
userp := user.Group("/_").Use(middlewares.Auth())
{
- userp.GET("/info/:id", handlers.UserInfoP)
+ userp.GET("/:id", handlers.UserInfoP)
}
}
}