-
-
Notifications
You must be signed in to change notification settings - Fork 263
/
get_email_log_list_logic.go
65 lines (58 loc) · 1.66 KB
/
get_email_log_list_logic.go
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
54
55
56
57
58
59
60
61
62
63
64
65
package emaillog
import (
"context"
"github.com/suyuan32/simple-admin-common/i18n"
"github.com/zeromicro/go-zero/core/errorx"
"github.com/suyuan32/simple-admin-core/api/internal/svc"
"github.com/suyuan32/simple-admin-core/api/internal/types"
"github.com/suyuan32/simple-admin-message-center/types/mcms"
"github.com/zeromicro/go-zero/core/logx"
)
type GetEmailLogListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetEmailLogListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEmailLogListLogic {
return &GetEmailLogListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetEmailLogListLogic) GetEmailLogList(req *types.EmailLogListReq) (resp *types.EmailLogListResp, err error) {
if !l.svcCtx.Config.McmsRpc.Enabled {
return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable)
}
data, err := l.svcCtx.McmsRpc.GetEmailLogList(l.ctx,
&mcms.EmailLogListReq{
Page: req.Page,
PageSize: req.PageSize,
Target: req.Target,
Subject: req.Subject,
Provider: req.Provider,
SendStatus: req.SendStatus,
})
if err != nil {
return nil, err
}
resp = &types.EmailLogListResp{}
resp.Msg = l.svcCtx.Trans.Trans(l.ctx, i18n.Success)
resp.Data.Total = data.GetTotal()
for _, v := range data.Data {
resp.Data.Data = append(resp.Data.Data,
types.EmailLogInfo{
BaseUUIDInfo: types.BaseUUIDInfo{
Id: v.Id,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
},
Target: v.Target,
Subject: v.Subject,
Content: v.Content,
SendStatus: v.SendStatus,
Provider: v.Provider,
})
}
return resp, nil
}