upvote and feedback list
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/promote/production Build is passing

This commit is contained in:
2024-04-22 19:39:41 +03:00
parent 8fb0c0f056
commit 16a03ca5a1
17 changed files with 983 additions and 12 deletions

View File

@@ -0,0 +1,58 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
)
// GetFeedbacksForProjectHandlerFunc turns a function with the right signature into a get feedbacks for project handler
type GetFeedbacksForProjectHandlerFunc func(GetFeedbacksForProjectParams) middleware.Responder
// Handle executing the request and returning a response
func (fn GetFeedbacksForProjectHandlerFunc) Handle(params GetFeedbacksForProjectParams) middleware.Responder {
return fn(params)
}
// GetFeedbacksForProjectHandler interface for that can handle valid get feedbacks for project params
type GetFeedbacksForProjectHandler interface {
Handle(GetFeedbacksForProjectParams) middleware.Responder
}
// NewGetFeedbacksForProject creates a new http.Handler for the get feedbacks for project operation
func NewGetFeedbacksForProject(ctx *middleware.Context, handler GetFeedbacksForProjectHandler) *GetFeedbacksForProject {
return &GetFeedbacksForProject{Context: ctx, Handler: handler}
}
/*
GetFeedbacksForProject swagger:route GET /feedbacks/{project_id} feedback getFeedbacksForProject
# Get all feedbacks for a project
Get all feedbacks for a project
*/
type GetFeedbacksForProject struct {
Context *middleware.Context
Handler GetFeedbacksForProjectHandler
}
func (o *GetFeedbacksForProject) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewGetFeedbacksForProjectParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,71 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
)
// NewGetFeedbacksForProjectParams creates a new GetFeedbacksForProjectParams object
//
// There are no default values defined in the spec.
func NewGetFeedbacksForProjectParams() GetFeedbacksForProjectParams {
return GetFeedbacksForProjectParams{}
}
// GetFeedbacksForProjectParams contains all the bound params for the get feedbacks for project operation
// typically these are obtained from a http.Request
//
// swagger:parameters getFeedbacksForProject
type GetFeedbacksForProjectParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*Project id
Required: true
In: path
*/
ProjectID string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewGetFeedbacksForProjectParams() beforehand.
func (o *GetFeedbacksForProjectParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
rProjectID, rhkProjectID, _ := route.Params.GetOK("project_id")
if err := o.bindProjectID(rProjectID, rhkProjectID, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindProjectID binds and validates parameter ProjectID from path.
func (o *GetFeedbacksForProjectParams) bindProjectID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.ProjectID = raw
return nil
}

View File

@@ -0,0 +1,87 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
"gerald/internal/interfaces/rest/models"
)
// GetFeedbacksForProjectOKCode is the HTTP code returned for type GetFeedbacksForProjectOK
const GetFeedbacksForProjectOKCode int = 200
/*
GetFeedbacksForProjectOK successful operation
swagger:response getFeedbacksForProjectOK
*/
type GetFeedbacksForProjectOK struct {
/*
In: Body
*/
Payload []*models.Feedback `json:"body,omitempty"`
}
// NewGetFeedbacksForProjectOK creates GetFeedbacksForProjectOK with default headers values
func NewGetFeedbacksForProjectOK() *GetFeedbacksForProjectOK {
return &GetFeedbacksForProjectOK{}
}
// WithPayload adds the payload to the get feedbacks for project o k response
func (o *GetFeedbacksForProjectOK) WithPayload(payload []*models.Feedback) *GetFeedbacksForProjectOK {
o.Payload = payload
return o
}
// SetPayload sets the payload to the get feedbacks for project o k response
func (o *GetFeedbacksForProjectOK) SetPayload(payload []*models.Feedback) {
o.Payload = payload
}
// WriteResponse to the client
func (o *GetFeedbacksForProjectOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.WriteHeader(200)
payload := o.Payload
if payload == nil {
// return empty array
payload = make([]*models.Feedback, 0, 50)
}
if err := producer.Produce(rw, payload); err != nil {
panic(err) // let the recovery middleware deal with this
}
}
// GetFeedbacksForProjectForbiddenCode is the HTTP code returned for type GetFeedbacksForProjectForbidden
const GetFeedbacksForProjectForbiddenCode int = 403
/*
GetFeedbacksForProjectForbidden Forbidden
swagger:response getFeedbacksForProjectForbidden
*/
type GetFeedbacksForProjectForbidden struct {
}
// NewGetFeedbacksForProjectForbidden creates GetFeedbacksForProjectForbidden with default headers values
func NewGetFeedbacksForProjectForbidden() *GetFeedbacksForProjectForbidden {
return &GetFeedbacksForProjectForbidden{}
}
// WriteResponse to the client
func (o *GetFeedbacksForProjectForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(403)
}

View File

@@ -0,0 +1,99 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
)
// GetFeedbacksForProjectURL generates an URL for the get feedbacks for project operation
type GetFeedbacksForProjectURL struct {
ProjectID string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetFeedbacksForProjectURL) WithBasePath(bp string) *GetFeedbacksForProjectURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *GetFeedbacksForProjectURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *GetFeedbacksForProjectURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/feedbacks/{project_id}"
projectID := o.ProjectID
if projectID != "" {
_path = strings.Replace(_path, "{project_id}", projectID, -1)
} else {
return nil, errors.New("projectId is required on GetFeedbacksForProjectURL")
}
_basePath := o._basePath
if _basePath == "" {
_basePath = "/"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *GetFeedbacksForProjectURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *GetFeedbacksForProjectURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *GetFeedbacksForProjectURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on GetFeedbacksForProjectURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on GetFeedbacksForProjectURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *GetFeedbacksForProjectURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -0,0 +1,58 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"net/http"
"github.com/go-openapi/runtime/middleware"
)
// UpvoteFeedbackHandlerFunc turns a function with the right signature into a upvote feedback handler
type UpvoteFeedbackHandlerFunc func(UpvoteFeedbackParams) middleware.Responder
// Handle executing the request and returning a response
func (fn UpvoteFeedbackHandlerFunc) Handle(params UpvoteFeedbackParams) middleware.Responder {
return fn(params)
}
// UpvoteFeedbackHandler interface for that can handle valid upvote feedback params
type UpvoteFeedbackHandler interface {
Handle(UpvoteFeedbackParams) middleware.Responder
}
// NewUpvoteFeedback creates a new http.Handler for the upvote feedback operation
func NewUpvoteFeedback(ctx *middleware.Context, handler UpvoteFeedbackHandler) *UpvoteFeedback {
return &UpvoteFeedback{Context: ctx, Handler: handler}
}
/*
UpvoteFeedback swagger:route POST /feedback/{feedback_uuid}/upvote feedback upvoteFeedback
# Upvote a feedback
Upvote a feedback
*/
type UpvoteFeedback struct {
Context *middleware.Context
Handler UpvoteFeedbackHandler
}
func (o *UpvoteFeedback) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
route, rCtx, _ := o.Context.RouteInfo(r)
if rCtx != nil {
*r = *rCtx
}
var Params = NewUpvoteFeedbackParams()
if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
o.Context.Respond(rw, r, route.Produces, route, err)
return
}
res := o.Handler.Handle(Params) // actually handle the request
o.Context.Respond(rw, r, route.Produces, route, res)
}

View File

@@ -0,0 +1,106 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/validate"
)
// NewUpvoteFeedbackParams creates a new UpvoteFeedbackParams object
//
// There are no default values defined in the spec.
func NewUpvoteFeedbackParams() UpvoteFeedbackParams {
return UpvoteFeedbackParams{}
}
// UpvoteFeedbackParams contains all the bound params for the upvote feedback operation
// typically these are obtained from a http.Request
//
// swagger:parameters upvoteFeedback
type UpvoteFeedbackParams struct {
// HTTP Request Object
HTTPRequest *http.Request `json:"-"`
/*Feedback UUID
Required: true
In: path
*/
FeedbackUUID string
/*Session UUID
Required: true
In: query
*/
SessionUUID string
}
// BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
// for simple values it will use straight method calls.
//
// To ensure default values, the struct must have been initialized with NewUpvoteFeedbackParams() beforehand.
func (o *UpvoteFeedbackParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
var res []error
o.HTTPRequest = r
qs := runtime.Values(r.URL.Query())
rFeedbackUUID, rhkFeedbackUUID, _ := route.Params.GetOK("feedback_uuid")
if err := o.bindFeedbackUUID(rFeedbackUUID, rhkFeedbackUUID, route.Formats); err != nil {
res = append(res, err)
}
qSessionUUID, qhkSessionUUID, _ := qs.GetOK("session_uuid")
if err := o.bindSessionUUID(qSessionUUID, qhkSessionUUID, route.Formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
// bindFeedbackUUID binds and validates parameter FeedbackUUID from path.
func (o *UpvoteFeedbackParams) bindFeedbackUUID(rawData []string, hasKey bool, formats strfmt.Registry) error {
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// Parameter is provided by construction from the route
o.FeedbackUUID = raw
return nil
}
// bindSessionUUID binds and validates parameter SessionUUID from query.
func (o *UpvoteFeedbackParams) bindSessionUUID(rawData []string, hasKey bool, formats strfmt.Registry) error {
if !hasKey {
return errors.Required("session_uuid", "query", rawData)
}
var raw string
if len(rawData) > 0 {
raw = rawData[len(rawData)-1]
}
// Required: true
// AllowEmptyValue: false
if err := validate.RequiredString("session_uuid", "query", raw); err != nil {
return err
}
o.SessionUUID = raw
return nil
}

View File

@@ -0,0 +1,62 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"net/http"
"github.com/go-openapi/runtime"
)
// UpvoteFeedbackOKCode is the HTTP code returned for type UpvoteFeedbackOK
const UpvoteFeedbackOKCode int = 200
/*
UpvoteFeedbackOK successful operation
swagger:response upvoteFeedbackOK
*/
type UpvoteFeedbackOK struct {
}
// NewUpvoteFeedbackOK creates UpvoteFeedbackOK with default headers values
func NewUpvoteFeedbackOK() *UpvoteFeedbackOK {
return &UpvoteFeedbackOK{}
}
// WriteResponse to the client
func (o *UpvoteFeedbackOK) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(200)
}
// UpvoteFeedbackForbiddenCode is the HTTP code returned for type UpvoteFeedbackForbidden
const UpvoteFeedbackForbiddenCode int = 403
/*
UpvoteFeedbackForbidden Forbidden
swagger:response upvoteFeedbackForbidden
*/
type UpvoteFeedbackForbidden struct {
}
// NewUpvoteFeedbackForbidden creates UpvoteFeedbackForbidden with default headers values
func NewUpvoteFeedbackForbidden() *UpvoteFeedbackForbidden {
return &UpvoteFeedbackForbidden{}
}
// WriteResponse to the client
func (o *UpvoteFeedbackForbidden) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
rw.Header().Del(runtime.HeaderContentType) //Remove Content-Type on empty responses
rw.WriteHeader(403)
}

View File

@@ -0,0 +1,110 @@
// Code generated by go-swagger; DO NOT EDIT.
package feedback
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
import (
"errors"
"net/url"
golangswaggerpaths "path"
"strings"
)
// UpvoteFeedbackURL generates an URL for the upvote feedback operation
type UpvoteFeedbackURL struct {
FeedbackUUID string
SessionUUID string
_basePath string
// avoid unkeyed usage
_ struct{}
}
// WithBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *UpvoteFeedbackURL) WithBasePath(bp string) *UpvoteFeedbackURL {
o.SetBasePath(bp)
return o
}
// SetBasePath sets the base path for this url builder, only required when it's different from the
// base path specified in the swagger spec.
// When the value of the base path is an empty string
func (o *UpvoteFeedbackURL) SetBasePath(bp string) {
o._basePath = bp
}
// Build a url path and query string
func (o *UpvoteFeedbackURL) Build() (*url.URL, error) {
var _result url.URL
var _path = "/feedback/{feedback_uuid}/upvote"
feedbackUUID := o.FeedbackUUID
if feedbackUUID != "" {
_path = strings.Replace(_path, "{feedback_uuid}", feedbackUUID, -1)
} else {
return nil, errors.New("feedbackUuid is required on UpvoteFeedbackURL")
}
_basePath := o._basePath
if _basePath == "" {
_basePath = "/"
}
_result.Path = golangswaggerpaths.Join(_basePath, _path)
qs := make(url.Values)
sessionUUIDQ := o.SessionUUID
if sessionUUIDQ != "" {
qs.Set("session_uuid", sessionUUIDQ)
}
_result.RawQuery = qs.Encode()
return &_result, nil
}
// Must is a helper function to panic when the url builder returns an error
func (o *UpvoteFeedbackURL) Must(u *url.URL, err error) *url.URL {
if err != nil {
panic(err)
}
if u == nil {
panic("url can't be nil")
}
return u
}
// String returns the string representation of the path with query string
func (o *UpvoteFeedbackURL) String() string {
return o.Must(o.Build()).String()
}
// BuildFull builds a full url with scheme, host, path and query string
func (o *UpvoteFeedbackURL) BuildFull(scheme, host string) (*url.URL, error) {
if scheme == "" {
return nil, errors.New("scheme is required for a full url on UpvoteFeedbackURL")
}
if host == "" {
return nil, errors.New("host is required for a full url on UpvoteFeedbackURL")
}
base, err := o.Build()
if err != nil {
return nil, err
}
base.Scheme = scheme
base.Host = host
return base, nil
}
// StringFull returns the string representation of a complete url
func (o *UpvoteFeedbackURL) StringFull(scheme, host string) string {
return o.Must(o.BuildFull(scheme, host)).String()
}

View File

@@ -50,6 +50,12 @@ func NewGeraldAPI(spec *loads.Document) *GeraldAPI {
FeedbackGetFeedbacksHandler: feedback.GetFeedbacksHandlerFunc(func(params feedback.GetFeedbacksParams) middleware.Responder {
return middleware.NotImplemented("operation feedback.GetFeedbacks has not yet been implemented")
}),
FeedbackGetFeedbacksForProjectHandler: feedback.GetFeedbacksForProjectHandlerFunc(func(params feedback.GetFeedbacksForProjectParams) middleware.Responder {
return middleware.NotImplemented("operation feedback.GetFeedbacksForProject has not yet been implemented")
}),
FeedbackUpvoteFeedbackHandler: feedback.UpvoteFeedbackHandlerFunc(func(params feedback.UpvoteFeedbackParams) middleware.Responder {
return middleware.NotImplemented("operation feedback.UpvoteFeedback has not yet been implemented")
}),
}
}
@@ -90,6 +96,10 @@ type GeraldAPI struct {
FeedbackCreateFeedbackHandler feedback.CreateFeedbackHandler
// FeedbackGetFeedbacksHandler sets the operation handler for the get feedbacks operation
FeedbackGetFeedbacksHandler feedback.GetFeedbacksHandler
// FeedbackGetFeedbacksForProjectHandler sets the operation handler for the get feedbacks for project operation
FeedbackGetFeedbacksForProjectHandler feedback.GetFeedbacksForProjectHandler
// FeedbackUpvoteFeedbackHandler sets the operation handler for the upvote feedback operation
FeedbackUpvoteFeedbackHandler feedback.UpvoteFeedbackHandler
// ServeError is called when an error is received, there is a default handler
// but you can set your own with this
@@ -173,6 +183,12 @@ func (o *GeraldAPI) Validate() error {
if o.FeedbackGetFeedbacksHandler == nil {
unregistered = append(unregistered, "feedback.GetFeedbacksHandler")
}
if o.FeedbackGetFeedbacksForProjectHandler == nil {
unregistered = append(unregistered, "feedback.GetFeedbacksForProjectHandler")
}
if o.FeedbackUpvoteFeedbackHandler == nil {
unregistered = append(unregistered, "feedback.UpvoteFeedbackHandler")
}
if len(unregistered) > 0 {
return fmt.Errorf("missing registration: %s", strings.Join(unregistered, ", "))
@@ -269,6 +285,14 @@ func (o *GeraldAPI) initHandlerCache() {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/feedbacks"] = feedback.NewGetFeedbacks(o.context, o.FeedbackGetFeedbacksHandler)
if o.handlers["GET"] == nil {
o.handlers["GET"] = make(map[string]http.Handler)
}
o.handlers["GET"]["/feedbacks/{project_id}"] = feedback.NewGetFeedbacksForProject(o.context, o.FeedbackGetFeedbacksForProjectHandler)
if o.handlers["POST"] == nil {
o.handlers["POST"] = make(map[string]http.Handler)
}
o.handlers["POST"]["/feedback/{feedback_uuid}/upvote"] = feedback.NewUpvoteFeedback(o.context, o.FeedbackUpvoteFeedbackHandler)
}
// Serve creates a http handler to serve the API over HTTP