forked from suyuan32/simple-admin-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_email_log_by_id_logic.go
57 lines (49 loc) · 1.43 KB
/
get_email_log_by_id_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
package emaillog
import (
"context"
"github.com/huuhoait/simple-admin-common/i18n"
"github.com/zeromicro/go-zero/core/errorx"
"github.com/huuhoait/simple-admin-core/api/internal/svc"
"github.com/huuhoait/simple-admin-core/api/internal/types"
"github.com/huuhoait/simple-admin-message-center/types/mcms"
"github.com/zeromicro/go-zero/core/logx"
)
type GetEmailLogByIdLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewGetEmailLogByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetEmailLogByIdLogic {
return &GetEmailLogByIdLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetEmailLogByIdLogic) GetEmailLogById(req *types.UUIDReq) (resp *types.EmailLogInfoResp, err error) {
if !l.svcCtx.Config.McmsRpc.Enabled {
return nil, errorx.NewCodeUnavailableError(i18n.ServiceUnavailable)
}
data, err := l.svcCtx.McmsRpc.GetEmailLogById(l.ctx, &mcms.UUIDReq{Id: req.Id})
if err != nil {
return nil, err
}
return &types.EmailLogInfoResp{
BaseDataInfo: types.BaseDataInfo{
Code: 0,
Msg: l.svcCtx.Trans.Trans(l.ctx, i18n.Success),
},
Data: types.EmailLogInfo{
BaseUUIDInfo: types.BaseUUIDInfo{
Id: data.Id,
CreatedAt: data.CreatedAt,
UpdatedAt: data.UpdatedAt,
},
Target: data.Target,
Subject: data.Subject,
Content: data.Content,
SendStatus: data.SendStatus,
Provider: data.Provider,
},
}, nil
}