LCW IMPORTER GOSHULDY2
This commit is contained in:
parent
11f5bf96fe
commit
fa9ed72c3d
|
|
@ -5,6 +5,7 @@ import (
|
|||
helper "db_service/pkg"
|
||||
"db_service/repositories"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
|
@ -29,7 +30,7 @@ func ParseLink(w http.ResponseWriter, route *http.Request) {
|
|||
|
||||
func ParseLinkLCW(link string,w http.ResponseWriter) {
|
||||
start := time.Now()
|
||||
|
||||
fmt.Println(link)
|
||||
linkParser := repositories.NewLCWScraper(link)
|
||||
|
||||
product, err := linkParser.InitProductDetailParsing()
|
||||
|
|
@ -39,7 +40,7 @@ func ParseLinkLCW(link string,w http.ResponseWriter) {
|
|||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"msg": err.Error(),
|
||||
})
|
||||
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +49,7 @@ func ParseLinkLCW(link string,w http.ResponseWriter) {
|
|||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
//wait until initialization data is loaded to memory
|
||||
|
|
@ -55,6 +57,7 @@ func ParseLinkLCW(link string,w http.ResponseWriter) {
|
|||
|
||||
if err = importRepo.UpdateOrCreate(product).Error; err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
|
@ -80,7 +83,7 @@ func ParseLinkTY(link string,w http.ResponseWriter) {
|
|||
json.NewEncoder(w).Encode(map[string]string{
|
||||
"msg": err.Error(),
|
||||
})
|
||||
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue