feat: Most of Item and Order controllers
This commit is contained in:
@@ -18,30 +18,24 @@ func SetUserName(pool *pgxpool.Pool) gin.HandlerFunc {
|
||||
conn, err := pool.Acquire(ctx)
|
||||
defer conn.Release()
|
||||
if err != nil {
|
||||
// TODO: Log this error
|
||||
ctx.String(http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
user_profile, _ := ctx.Get("user_profile")
|
||||
|
||||
user_name := ctx.Query("user_name")
|
||||
|
||||
if user_name == "" {
|
||||
log.Println("CreateUser(): ERROR: user name not supplied")
|
||||
ctx.String(http.StatusBadRequest, "CreateUser(): ERROR: user name not supplied")
|
||||
return
|
||||
}
|
||||
|
||||
updateCommandTag, update_err := conn.Exec(context.Background(), queries.USER_UPDATE_QUERY, user_name, user_profile.(dto.UserProfileResponse).Sub)
|
||||
_, update_err := conn.Exec(context.Background(), queries.USER_UPDATE_QUERY, user_name, user_profile.(dto.UserProfileResponse).Sub)
|
||||
if update_err != nil {
|
||||
log.Printf("%s", update_err.Error())
|
||||
ctx.AbortWithStatus(http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if updateCommandTag.RowsAffected() == 0 {
|
||||
_, query_err := conn.Exec(context.Background(), queries.USER_CREATE_QUERY, user_profile.(dto.UserProfileResponse).Sub, user_name)
|
||||
if query_err != nil {
|
||||
log.Printf("%s", query_err.Error())
|
||||
ctx.String(http.StatusInternalServerError, query_err.Error())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user