123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- package logic
- import (
- "app.yhyue.com/moapp/jybase/common"
- "bp.jydev.jianyu360.cn/BaseService/biService/entity"
- "bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
- "bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
- "bp.jydev.jianyu360.cn/BaseService/biService/service"
- "context"
- "github.com/tjfoc/gmsm/sm4"
- "github.com/zeromicro/go-zero/core/logx"
- )
- type SendMailLogic struct {
- ctx context.Context
- svcCtx *svc.ServiceContext
- logx.Logger
- }
- func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMailLogic {
- return &SendMailLogic{
- ctx: ctx,
- svcCtx: svcCtx,
- Logger: logx.WithContext(ctx),
- }
- }
- func (l *SendMailLogic) SendMail(in *pb.ExportByDbReq) (*pb.BiReply, error) {
- if in.Token == "" || in.Title == "" || in.Content == "" || in.Mails == "" {
- return &pb.BiReply{
- ErrorCode: 1,
- ErrorMsg: "参数不能为空",
- Data: nil,
- }, nil
- }
- //if RsaEncrypt([]byte(fmt.Sprintf("%s&%s&%s&%s", gconv.String(in.Content), gconv.String(in.Mails), gconv.String(in.Query), gconv.String(in.Title)))) == in.Token {
- // return &pb.BiReply{
- // ErrorCode: 1,
- // ErrorMsg: "token验证不通过",
- // Data: nil,
- // }, nil
- //}
- res := (&service.ExportByDbReq{
- Token: in.Token,
- Title: in.Title,
- Content: in.Content,
- Mails: in.Mails,
- FileName: in.FileName,
- Datas: in.Datas,
- }).ExportDataByDb()
- return &pb.BiReply{
- ErrorCode: 0,
- ErrorMsg: "",
- Data: res,
- }, nil
- }
- func RsaEncrypt(data []byte) string {
- key := []byte(entity.PublicKey)
- b, _ := sm4.Sm4Ecb(key, data, true)
- return common.GetMd5String(string(b))
- }
|