Browse Source

delete loan is ready. with basic info validation

master
sp 4 years ago
parent
commit
cfc16b975f
2 changed files with 18 additions and 0 deletions
  1. +16
    -0
      apiV1LoanSingle.go
  2. +2
    -0
      apiv1.go

+ 16
- 0
apiV1LoanSingle.go View File

@@ -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)

}

+ 2
- 0
apiv1.go View File

@@ -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},

Loading…
Cancel
Save