|
- package main
-
- import (
- "biukop.com/sfm/loan"
- "encoding/json"
- log "github.com/sirupsen/logrus"
- "net/http"
- )
-
- func decodeJsonFullLoanOverview(r *http.Request) (ret loan.FullLoanSummaryQueryInput, e error) {
- decoder := json.NewDecoder(r.Body)
- //decoder.DisallowUnknownFields()
- e = decoder.Decode(&ret)
- if e != nil {
- log.Error("failed decoding json for Filtering full_loan_summary ", e.Error())
- return
- }
- return
- }
- func apiV1GridLoanFullOverview(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
-
- input, e := decodeJsonFullLoanOverview(r)
-
- if e != nil {
- apiV1EmptyResponse(w, r, ss)
- } else {
- switch ss.GetRole() {
- case "broker":
- input.Filter.Filters = append(input.Filter.Filters, loan.FullLoanSummaryFilter{
- Field: "broker_ids",
- Operator: "contains",
- Value: loan.JsonString(ss.User)})
- break
- case "user":
- input.Filter.Filters = append(input.Filter.Filters, loan.FullLoanSummaryFilter{
- Field: "client_ids",
- Operator: "contains",
- Value: loan.JsonString(ss.User)})
- break
- }
-
- data := loan.QFullLLoanSummary(input)
- //send out
- apiV1SendJson(data, w, r, ss)
- }
- }
-
- func apiV1GridListLoanOverview(w http.ResponseWriter, r *http.Request, ss *loan.Session) {
- input := loan.KdQueryInput{}
- e := input.ReadFromHttpRequest(r)
- if e != nil {
- apiV1Client404Error(w, r, ss)
- return
- }
- filter := loan.OverViewListFilter{KdQueryInput: input}
- ret := filter.Retrieve()
- apiV1SendJson(ret, w, r, ss)
-
- }
|