Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

60 linhas
1.5KB

  1. package main
  2. import (
  3. "biukop.com/sfm/loan"
  4. log "github.com/sirupsen/logrus"
  5. "net/http"
  6. "strconv"
  7. )
  8. func apiV1PayOutExGet(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  9. strId := r.URL.Path[len(apiV1Prefix+"payout-ex/"):]
  10. ret := loan.PayOutEx{}
  11. id, e := strconv.Atoi(strId)
  12. if e != nil {
  13. log.Error("invalid id for PayOutEx", strId, e.Error())
  14. apiV1Client403Error(w, r, ss)
  15. }
  16. e = ret.Read(int64(id))
  17. if e != nil {
  18. log.Error("failed to read PayOutEx", strId, e.Error())
  19. apiV1Server500Error(w, r)
  20. }
  21. apiV1SendJson(ret, w, r, ss)
  22. return
  23. }
  24. func apiV1PayOutExListGet(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
  25. // strId := r.URL.Path[len(apiV1Prefix+"payout-ex-list/"):]
  26. input, e := decodeJsonFullLoanOverview(r)
  27. // TODO; Generalize that input, and return a list of filters and sort
  28. // Todo: do some serious query for the data in the Grid, and make it a pattern. Get it done!
  29. if e != nil {
  30. apiV1EmptyResponse(w, r, ss)
  31. } else {
  32. switch ss.GetRole() {
  33. case "broker":
  34. input.Filter.Filters = append(input.Filter.Filters, loan.FullLoanSummaryFilter{
  35. Field: "broker_ids",
  36. Operator: "contains",
  37. Value: loan.JsonString(ss.User)})
  38. break
  39. case "user":
  40. input.Filter.Filters = append(input.Filter.Filters, loan.FullLoanSummaryFilter{
  41. Field: "client_ids",
  42. Operator: "contains",
  43. Value: loan.JsonString(ss.User)})
  44. break
  45. }
  46. data := loan.QFullLLoanSummary(input)
  47. //send out
  48. apiV1SendJson(data, w, r, ss)
  49. }
  50. }