package handler import ( "errors" "github.com/gin-gonic/gin" "gorm.io/gorm" "health-go/config" "health-go/model" "health-go/util" "net/http" ) func FirstUser(c *gin.Context) { var user model.User result := config.DB.Where("user_name = ?", "Biid").First(&user) if result.Error != nil { if errors.Is(result.Error, gorm.ErrRecordNotFound) { util.ReturnJson(c, 404, "用户未找到", nil) } else { c.JSON(http.StatusInternalServerError, gin.H{ "code": 500, "msg": "内部服务器错误", "data": nil, }) } return } c.JSON(http.StatusOK, gin.H{ "code": 200, "msg": "ok", "data": map[string]interface{}{ "first_user": user, }, }) }