Hello!
I hope that you can help me
first file
func (b *Auth) GetInfo(login string) {
var auth models.Auth
if strings.Contains(login, "@") {
auth = db.GetDb().
Table("profile").
Select("id, cell_phone, email").
Where("email = ?", login).
First(&b)
return auth
} else {
auth = db.GetDb().
Table("profile").
Select("id, cell_phone, email").
Where("phone = ?", login).
First(&b)
return auth
}
}
second file
type Auth struct {
ID int `json:"id"`
ExtID string `json:"ext_id"`
CellPhone string `json:"cell_phone"`
Email string `json:"email"`
}
func Authentication(ctx *gin.Context) {
login := ctx.Query("login")
authentication := models.Auth{}
authentication.GetDriverInfo(login)
ctx.JSON(http.StatusOK, authentication)
}
third file
func main() {
db.Initialize()
router := gin.Default()
core := router.Group("/api/private")
{
core.GET("/profile", info.Authentication)
}
}
I receive response body with empty field
create table + insert i won’t show
What i need to change?