| @@ -24,6 +24,21 @@ func apiV1GridLoanFullOverview(w http.ResponseWriter, r *http.Request, ss *loan. | |||
| 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) | |||
| @@ -0,0 +1,22 @@ | |||
| package main | |||
| import ( | |||
| "biukop.com/sfm/loan" | |||
| "net/http" | |||
| ) | |||
| func apiV1UserReward(w http.ResponseWriter, r *http.Request, ss *loan.Session) { | |||
| if ss.User == "" { | |||
| apiV1Client403Error(w, r, ss) | |||
| return | |||
| } | |||
| userId := ss.User | |||
| if ss.GetRole() == "admin" { //allow admin to query other user | |||
| userId = r.URL.Path[len(apiV1Prefix+"user-reward/"):] //remove prefix | |||
| } | |||
| data := loan.GetUserReward(userId) | |||
| apiV1SendJson(data, w, r, ss) | |||
| } | |||
| @@ -49,6 +49,10 @@ func apiV1Login(w http.ResponseWriter, r *http.Request, ss *loan.Session) { | |||
| //format response | |||
| res.add("login", true) | |||
| res.add("role", ss.GetRole()) | |||
| u, e := ss.GetUser() | |||
| if e == nil { | |||
| res.add("user", u.People) | |||
| } | |||
| res.add("Biukop-Session", ss.Id) | |||
| res.add("Biukop-Mid", ss.Get("Biukop-Mid")) | |||
| res.add("sessionExpire", ss.ExpireStr()) | |||
| @@ -49,6 +49,7 @@ func setupApiV1Handler() []apiV1HandlerMap { | |||
| {"POST", "sync-people/", apiV1SyncPeople}, | |||
| {"POST", "payIn/", apiV1PayInPost}, | |||
| {"DELETE", "payIn/", apiV1PayInDelete}, | |||
| {"GET", "user-reward/", apiV1UserReward}, | |||
| {"GET", "login", apiV1DumpRequest}, | |||
| } | |||
| } else { //production | |||
| @@ -74,6 +75,7 @@ func setupApiV1Handler() []apiV1HandlerMap { | |||
| {"POST", "sync-people/", apiV1SyncPeople}, | |||
| {"POST", "payIn/", apiV1PayInPost}, | |||
| {"DELETE", "payIn/", apiV1PayInDelete}, | |||
| {"GET", "user-reward/", apiV1UserReward}, | |||
| {"GET", "login", apiV1EmptyResponse}, | |||
| } | |||
| } | |||