package activity

import (
	"context"
	"server/internal/model"
	"server/internal/service"

	v1 "server/api/activity/v1"
)

func (c *ControllerV1) RuleAdd(ctx context.Context, req *v1.RuleAddReq) (res *v1.RuleAddRes, err error) {
	out, err := service.SignInRewardRules().Create(ctx, &model.SignInRewardRulesCreateIn{
		RuleName:  req.RuleName,
		StartDate: req.StartDate,
		EndDate:   req.EndDate,
		CycleDays: req.CycleDays,
		Status:    req.Status,
	})
	if err != nil {
		return nil, err
	}
	return &v1.RuleAddRes{Success: out.Success}, nil
}
