Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

66 lignes
1.5KB

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. log "github.com/sirupsen/logrus"
  5. "net/http"
  6. "strconv"
  7. "time"
  8. )
  9. func apiV1UploadAnalysis(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  10. strId := r.URL.Path[len(apiV1Prefix+"upload-analysis/"):] //remove prefix
  11. Id, e := strconv.Atoi(strId)
  12. if e != nil {
  13. log.Error("Invalid uploads Id cannot convert to integer", Id, e)
  14. apiV1Client403Error(w, r, ss)
  15. return
  16. }
  17. ul := loan.Uploads{}
  18. e = ul.Read(int64(Id))
  19. if e != nil {
  20. log.Error("Upload not found or read error from db", Id, e)
  21. apiV1Client404Error(w, r, ss)
  22. return
  23. }
  24. ai := AiDecodeIncome{}
  25. e = ai.decodeUploadToPayIn(ul)
  26. if e != nil {
  27. log.Error("Invalid uploads Id cannot conver to integer", Id, e)
  28. apiV1Server500Error(w, r)
  29. return
  30. }
  31. apiV1SendJson(ai, w, r, ss)
  32. }
  33. func apiV1UploadCreateAnalysis(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  34. time.Sleep(1 * time.Second)
  35. strId := r.URL.Path[len(apiV1Prefix+"upload-analysis/"):] //remove prefix
  36. Id, e := strconv.Atoi(strId)
  37. if e != nil {
  38. log.Error("Invalid uploads Id cannot convert to integer", Id, e)
  39. apiV1Client403Error(w, r, ss)
  40. return
  41. }
  42. ul := loan.Uploads{}
  43. e = ul.Read(int64(Id))
  44. if e != nil {
  45. log.Error("Upload not found or read error from db", Id, e)
  46. apiV1Client404Error(w, r, ss)
  47. return
  48. }
  49. ai := AiDecodeIncome{}
  50. e = ai.decodeUploadToPayIn(ul)
  51. if e != nil {
  52. log.Error("Cannot decode upload", Id, e)
  53. apiV1Server500Error(w, r)
  54. return
  55. }
  56. apiV1SendJson(ai, w, r, ss)
  57. }