package feedback

import (
	"context"
	"github.com/gogf/gf/v2/frame/g"
	"server/internal/model"
	"server/internal/service"

	"server/api/feedback/v1"
)

func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
	userId := g.RequestFromCtx(ctx).GetCtxVar("id").Int64()
	out, err := service.Feedback().Create(ctx, &model.FeedbackAddIn{
		Content: req.Content,
		UserId:  userId,
	})
	if err != nil {
		return nil, err
	}
	return &v1.AddRes{Success: out.Success}, nil
}
