sms_summary_evaluation.go 1.4 KB
package notify

import (
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/application/factory"
	"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
)

// 周期评估短信通知
// 条件:周期自评结束前4个小时,且还未完成评估填写
type NotifySummaryEvaluation struct {
}

func (notices *NotifySummaryEvaluation) Init() *NotifySummaryEvaluation {
	return &NotifySummaryEvaluation{}
}

func (notices *NotifySummaryEvaluation) From() string {
	return "SummaryEvaluation"
}

// AddTask 添加待执行的短信通知任务
func (notices *NotifySummaryEvaluation) AddTask(index string, phone string, param map[string]string) error {

	return nil
}

// RunTask 执行短信通知任务
func (notice *NotifySummaryEvaluation) RunTask() error {

	return nil
}

func (notice *NotifySummaryEvaluation) addNewSms(newSms *domain.LogSms) error {
	transactionContext, err := factory.CreateTransactionContext(nil)
	if err != nil {
		return err
	}
	if err := transactionContext.StartTransaction(); err != nil {
		return err
	}
	defer func() {
		_ = transactionContext.RollbackTransaction()
	}()
	logSmsRepo := factory.CreateLogSmsRepository(map[string]interface{}{"transactionContext": transactionContext})
	err = logSmsRepo.Save(newSms)
	if err != nil {
		return err
	}
	if err := transactionContext.CommitTransaction(); err != nil {
		return err
	}
	return nil
}