| @@ -47,9 +47,11 @@ func apiV1LoanSinglePostBasic(w http.ResponseWriter, r *http.Request, ss *loan.S | |||
| l.Amount = input.Amount | |||
| l.Item = input.Item | |||
| l.Rating = input.Rating | |||
| l.Settlement = input.Settlement | |||
| l.Description = input.Description | |||
| e = l.WriteBasic() | |||
| if e != nil { | |||
| log.Error("cannot save basic loan", e.Error()) | |||
| apiV1Client404Error(w, r, ss) | |||
| } else { | |||
| apiV1SendJson(l, w, r, ss) | |||
| @@ -58,3 +60,17 @@ func apiV1LoanSinglePostBasic(w http.ResponseWriter, r *http.Request, ss *loan.S | |||
| } | |||
| } | |||
| func apiV1LoanSingleDelete(w http.ResponseWriter, r *http.Request, ss *loan.Session) { | |||
| loanId := r.URL.Path[len(apiV1Prefix+"loan/"):] //remove prefix | |||
| e := loan.Delete(loanId) | |||
| if e != nil { | |||
| log.Error("cannot delete loan by id ", loanId, e.Error()) | |||
| apiV1Client404Error(w, r, ss) | |||
| return | |||
| } | |||
| apiV1SendJson(loanId, w, r, ss) | |||
| } | |||
| @@ -37,6 +37,7 @@ func setupApiV1Handler() []apiV1HandlerMap { | |||
| {"GET", "chart/top-broker", apiV1ChartTopBroker}, | |||
| {"POST", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview}, | |||
| {"GET", "loan/", apiV1LoanSingleGet}, | |||
| {"DELETE", "loan/", apiV1LoanSingleDelete}, | |||
| {"GET", "people/", apiV1PeopleGet}, | |||
| {"GET", "broker/", apiV1BrokerGet}, | |||
| {"POST", "loan/basic/", apiV1LoanSinglePostBasic}, | |||
| @@ -59,6 +60,7 @@ func setupApiV1Handler() []apiV1HandlerMap { | |||
| {"GET", "chart/top-broker", apiV1ChartTopBroker}, | |||
| {"POST", "grid/loan/full-loan-overview", apiV1GridLoanFullOverview}, | |||
| {"GET", "loan/", apiV1LoanSingleGet}, | |||
| {"DELETE", "loan/", apiV1LoanSingleDelete}, | |||
| {"GET", "people/", apiV1PeopleGet}, | |||
| {"GET", "broker/", apiV1BrokerGet}, | |||
| {"POST", "loan/basic/", apiV1LoanSinglePostBasic}, | |||