sms_summary_evaluation.go
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
}