admin: new interface to manage claims

This commit is contained in:
nemunaire 2018-01-17 01:21:32 +01:00
commit 1eef71923a
10 changed files with 791 additions and 0 deletions

View file

@ -248,6 +248,30 @@ func eventHandler(f func(fic.Event,[]byte) (interface{}, error)) func (httproute
}
}
func claimHandler(f func(fic.Claim,[]byte) (interface{}, error)) func (httprouter.Params,[]byte) (interface{}, error) {
return func (ps httprouter.Params, body []byte) (interface{}, error) {
if cid, err := strconv.Atoi(string(ps.ByName("cid"))); err != nil {
return nil, err
} else if claim, err := fic.GetClaim(cid); err != nil {
return nil, err
} else {
return f(claim, body)
}
}
}
func claimAssigneeHandler(f func(fic.ClaimAssignee,[]byte) (interface{}, error)) func (httprouter.Params,[]byte) (interface{}, error) {
return func (ps httprouter.Params, body []byte) (interface{}, error) {
if aid, err := strconv.Atoi(string(ps.ByName("aid"))); err != nil {
return nil, err
} else if assignee, err := fic.GetAssignee(int64(aid)); err != nil {
return nil, err
} else {
return f(assignee, body)
}
}
}
func fileHandler(f func(fic.EFile,[]byte) (interface{}, error)) func (httprouter.Params,[]byte) (interface{}, error) {
return func (ps httprouter.Params, body []byte) (interface{}, error) {
if fileid, err := strconv.Atoi(string(ps.ByName("fileid"))); err != nil {