update getting file recipe
This commit is contained in:
parent
ea506b8128
commit
3bfbbd778a
10 changed files with 243 additions and 152 deletions
|
|
@ -26,7 +26,8 @@ func (mr *MaterialRouter) Route(r chi.Router) {
|
|||
r.Get("/code", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
version := r.URL.Query().Get("version")
|
||||
filename := r.URL.Query().Get("filename")
|
||||
country := r.URL.Query().Get("country")
|
||||
|
||||
matIDs := r.URL.Query().Get("mat_ids")
|
||||
|
||||
|
|
@ -41,7 +42,14 @@ func (mr *MaterialRouter) Route(r chi.Router) {
|
|||
matIDsUint = append(matIDsUint, matIDUint)
|
||||
}
|
||||
|
||||
material := mr.data.GetMaterialCode(matIDsUint, version)
|
||||
countryID, err := mr.data.GetCountryIDByName(country)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, "Country not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
material := mr.data.GetMaterialCode(matIDsUint, countryID, filename)
|
||||
|
||||
json.NewEncoder(w).Encode(material)
|
||||
})
|
||||
|
|
@ -49,9 +57,17 @@ func (mr *MaterialRouter) Route(r chi.Router) {
|
|||
r.Get("/setting/{mat_id}", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
version := r.URL.Query().Get("version")
|
||||
filename := r.URL.Query().Get("filename")
|
||||
country := r.URL.Query().Get("country")
|
||||
|
||||
material := mr.data.GetMaterialSetting(version)
|
||||
countryID, err := mr.data.GetCountryIDByName(country)
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, "Country not found", http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
material := mr.data.GetMaterialSetting(countryID, filename)
|
||||
|
||||
matID := chi.URLParam(r, "mat_id")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue