Add a resource for getting service requests
This commit is contained in:
parent
28ec1c3d67
commit
4a440e3022
18 changed files with 387 additions and 51 deletions
34
resource/service_request.go
Normal file
34
resource/service_request.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
nhttp "github.com/Gleipnir-Technology/nidus-sync/http"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
//"github.com/aarondl/opt/null"
|
||||
//"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
type serviceRequestR struct {
|
||||
router *router
|
||||
}
|
||||
|
||||
func ServiceRequest(r *router) *serviceRequestR {
|
||||
return &serviceRequestR{
|
||||
router: r,
|
||||
}
|
||||
}
|
||||
|
||||
func (res *serviceRequestR) List(ctx context.Context, r *http.Request, user platform.User, query QueryParams) ([]*types.ServiceRequest, *nhttp.ErrorWithStatus) {
|
||||
limit := 20
|
||||
if query.Limit != nil {
|
||||
limit = *query.Limit
|
||||
}
|
||||
serviceRequests, err := platform.ServiceRequestList(ctx, user, limit)
|
||||
if err != nil {
|
||||
return nil, nhttp.NewError("list signals: %w", err)
|
||||
}
|
||||
return serviceRequests, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue