diff --git a/apiV1PayInList.go b/apiV1PayInList.go new file mode 100644 index 0000000..f14dcda --- /dev/null +++ b/apiV1PayInList.go @@ -0,0 +1,37 @@ +package main + +import ( + "biukop.com/sfm/loan" + "encoding/json" + log "github.com/sirupsen/logrus" + "net/http" +) + +func decodePayInFilter(r *http.Request) (ret loan.PayInListFilter, e error) { + decoder := json.NewDecoder(r.Body) + //decoder.DisallowUnknownFields() + e = decoder.Decode(&ret) + if e != nil { + log.Error("failed decoding PayIn list filter", e.Error()) + return + } + return +} + +func apiV1PayInList(w http.ResponseWriter, r *http.Request, ss *loan.Session) { + filter, e := decodePayInFilter(r) + if e != nil { + log.Error("invalid pay in list filter", filter, e) + apiV1Client404Error(w, r, ss) + return + } + + ret, e := filter.RetrieveData() + if e != nil { + log.Error("failed to retrieve PayIn list", filter, e) + apiV1Server500Error(w, r) + return + } + + apiV1SendJson(ret, w, r, ss) +} diff --git a/apiV1Uploads.go b/apiV1Uploads.go index 24fae6a..4c5af11 100644 --- a/apiV1Uploads.go +++ b/apiV1Uploads.go @@ -242,7 +242,7 @@ func apiV1UploadAsImage(w http.ResponseWriter, r *http.Request, ss *loan.Session if e != nil { return } - + //time.Sleep(5* time.Second); // if this is image itself, serve it directly if strings.Contains(strings.ToLower(ul.Upload.Format), "image") { f, e := os.Open(ul.filePath()) @@ -336,7 +336,7 @@ func apiV1UploadAsPDF(w http.ResponseWriter, r *http.Request, ss *loan.Session) if forceHttpDownload(r) { w.Header().Set("Content-Disposition", "attachment; filename="+ul.Upload.FileName) } - http.ServeContent(w, r, ul.filePath(), fi.ModTime(), f) + http.ServeContent(w, r, ul.Upload.FileName, fi.ModTime(), f) return } } diff --git a/apiv1.go b/apiv1.go index cb21af1..d8c1b6d 100644 --- a/apiv1.go +++ b/apiv1.go @@ -66,8 +66,11 @@ func setupApiV1Handler() []apiV1HandlerMap { {"GET", "people-list/", apiV1PeopleList}, {"GET", "broker-list/", apiV1BrokerList}, {"POST", "sync-people/", apiV1SyncPeople}, + {"POST", "payIn/", apiV1PayInPost}, {"DELETE", "payIn/", apiV1PayInDelete}, + {"POST", "pay-in-list/", apiV1PayInList}, + {"GET", "user-reward/", apiV1UserReward}, {"GET", "login-available/", apiV1LoginAvailable}, @@ -124,8 +127,11 @@ func setupApiV1Handler() []apiV1HandlerMap { {"GET", "people-list", apiV1PeopleList}, {"GET", "broker-list/", apiV1BrokerList}, {"POST", "sync-people/", apiV1SyncPeople}, + {"POST", "payIn/", apiV1PayInPost}, {"DELETE", "payIn/", apiV1PayInDelete}, + {"POST", "pay-in-list/", apiV1PayInList}, + {"GET", "user-reward/", apiV1UserReward}, {"GET", "login-available/", apiV1LoginAvailable}, diff --git a/html/index.html b/html/index.html index 55e588c..6161a80 100644 --- a/html/index.html +++ b/html/index.html @@ -59,6 +59,11 @@
+ + + + +