func GetPhotosByUserId(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) userId, _ := strconv.Atoi(vars["userId"]) user := repository.GetUserById(userId) if user.Id == 0 { w.Write([]byte(`{"Error":"Khong co user"}`)) return } photos := repository.GetPhotosByUserId(userId) json.NewEncoder(w).Encode(photos) }
func GetPhotosByUserId(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) userId, _ := strconv.Atoi(vars["userId"]) photos := repository.GetPhotosByUserId(userId) json.NewEncoder(w).Encode(photos) }