package activity

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

	"server/api/activity/v1"
)

func (c *ControllerV1) RuleEdit(ctx context.Context, req *v1.RuleEditReq) (res *v1.RuleEditRes, err error) {
	out, err := service.SignInRewardRules().Update(ctx, &model.SignInRewardRulesUpdateIn{
		Id:        req.Id,
		RuleName:  req.RuleName,
		CycleDays: req.CycleDays,
		StartDate: req.StartDate,
		EndDate:   req.EndDate,
		Status:    req.Status,
	})
	if err != nil {
		return nil, err
	}
	return &v1.RuleEditRes{Success: out.Success}, nil
}
