package task

import (
	"context"

	v1 "server/api/task/v1"
	"server/internal/model"
	"server/internal/service"
)

func (c *ControllerV1) Add(ctx context.Context, req *v1.AddReq) (res *v1.AddRes, err error) {
	out, err := service.Task().Add(ctx, &model.TaskAddIn{
		TaskType:     req.TaskType,
		Title:        req.Title,
		Description:  req.Description,
		RewardPoints: req.RewardPoints,
		Status:       req.Status,
	})
	if err != nil {
		return nil, err
	}
	return &v1.AddRes{Success: out.Success}, nil
}
