app-cloudep-notification-se.../internal/logic/senderservice/get_static_template_logic.go

43 lines
1.1 KiB
Go

package senderservicelogic
import (
"code.30cm.net/digimon/app-cloudep-notification-service/pkg/domain/template"
"context"
"code.30cm.net/digimon/app-cloudep-notification-service/gen_result/pb/notification"
"code.30cm.net/digimon/app-cloudep-notification-service/internal/svc"
"github.com/zeromicro/go-zero/core/logx"
)
type GetStaticTemplateLogic struct {
ctx context.Context
svcCtx *svc.ServiceContext
logx.Logger
}
func NewGetStaticTemplateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetStaticTemplateLogic {
return &GetStaticTemplateLogic{
ctx: ctx,
svcCtx: svcCtx,
Logger: logx.WithContext(ctx),
}
}
// GetStaticTemplate 取得 Template
func (l *GetStaticTemplateLogic) GetStaticTemplate(in *notification.TemplateReq) (*notification.TemplateResp, error) {
tmp, err := l.svcCtx.TemplateUseCase.GetEmailTemplateByStatic(
l.ctx,
template.Language(in.GetLanguage()),
template.Type(in.GetTemplateId()),
)
if err != nil {
return nil, err
}
return &notification.TemplateResp{
Title: tmp.Title,
Body: tmp.Body,
}, nil
}