Prechádzať zdrojové kódy

Merge branch 'dev/v1.0.18_wjh' into feature/v1.0.17

* dev/v1.0.18_wjh:
  导出数据发送邮件接口修改

# Conflicts:
#	rpc/biService.proto
#	rpc/biservice/biservice.go
#	rpc/internal/server/biserviceserver.go
#	rpc/pb/biService.pb.go
#	rpc/pb/biService_grpc.pb.go
Jianghan 1 rok pred
rodič
commit
9b58757919

+ 1 - 1
api/internal/logic/sendmaillogic.go

@@ -25,7 +25,7 @@ func NewSendMailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SendMail
 }
 
 func (l *SendMailLogic) SendMail(req *types.ExportByDbReq) (resp *types.BiResp, err error) {
-	res, err := l.svcCtx.BiServiceRpc.ExportDataByDb(l.ctx, &biservice.ExportByDbReq{
+	res, err := l.svcCtx.BiServiceRpc.SendMail(l.ctx, &biservice.ExportByDbReq{
 		Token:   req.Token,
 		Title:   req.Title,
 		Content: req.Content,

+ 1 - 1
rpc/biService.proto

@@ -211,5 +211,5 @@ service BiService {
 	rpc getCompanyType (CompanyReq) returns (CompanyResp); //判断公司类型
 	rpc distributeClueShow (DistributeClueShowReq) returns (DistributeClueShowResp); //批量分配展示
 	rpc exportDataByDb (ExportByDbReq) returns (BiReply); //数据导出(通用)
-
+	rpc sendMail (ExportByDbReq) returns (BiReply); //数据导出(通用)
 }

+ 6 - 0
rpc/biservice/biservice.go

@@ -62,6 +62,7 @@ type (
 		GetCompanyType(ctx context.Context, in *CompanyReq, opts ...grpc.CallOption) (*CompanyResp, error)
 		DistributeClueShow(ctx context.Context, in *DistributeClueShowReq, opts ...grpc.CallOption) (*DistributeClueShowResp, error)
 		ExportDataByDb(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
+		SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
 	}
 
 	defaultBiService struct {
@@ -164,3 +165,8 @@ func (m *defaultBiService) ExportDataByDb(ctx context.Context, in *ExportByDbReq
 	client := pb.NewBiServiceClient(m.cli.Conn())
 	return client.ExportDataByDb(ctx, in, opts...)
 }
+
+func (m *defaultBiService) SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.SendMail(ctx, in, opts...)
+}

+ 14 - 0
rpc/internal/logic/T_test.go

@@ -0,0 +1,14 @@
+package logic
+
+import (
+	"fmt"
+	"testing"
+)
+
+func TokenTest(t *testing.T) {
+	content := "你好老师,这是导出的数据"
+	mail := "516807046@qq.com"
+	query := "select t1.全称 as FULL_NAME,t0.CREATE_TIME as CREATE_TIME,coalesce(t0.pv_resp_person,t0.ofv_resp_person,t0.onv_resp_person) as SFZ,coalesce(t0.pv_visitor,t0.ofv_visitor,t0.onv_visitor) as BFZ,coalesce(t0.pv_visit_time,t0.ofv_visit_time,t0.onv_visit_time) as BFSJ,t0.FOLLOW_STATUS as FOLLOW_STATUS,coalesce(t0.pv_next_follow_time,t0.ofv_next_follow_time,t0.onv_next_follow_time) as XCGJSJ,coalesce(t0.pv_content,t0.ofv_content,t0.onv_content) as NR from crm.follow_record t0 left join (select t0.id as ID,t1.full_name as 全称 from crm.task t0 left join crm.custom t1 on (t0.source_id=t1.id) where (t0.source=3)) t1 on (t0.task_id=t1.ID) where (t0.CREATE_TIME>=str_to_date('2024-02-01','%Y-%m-%d') and t0.CREATE_TIME<str_to_date('2024-02-02','%Y-%m-%d') AND t0.CREATE_PERSON IN ('孙振杰','陈瑞文','朱凤超')) order by coalesce(t0.pv_visit_time,t0.ofv_visit_time,t0.onv_visit_time) desc limit 6"
+	title := "数据导出"
+	RsaEncrypt([]byte(fmt.Sprintf("%s&%s&%s&%s", content, mail, query, title)))
+}

+ 5 - 44
rpc/internal/logic/exportdatabydblogic.go

@@ -1,17 +1,12 @@
 package logic
 
 import (
-	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"context"
+
 	"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"
-	"encoding/base64"
-	"fmt"
-	"github.com/gogf/gf/v2/util/gconv"
-	"github.com/tjfoc/gmsm/sm4"
+
 	"github.com/zeromicro/go-zero/core/logx"
-	"regexp"
 )
 
 type ExportDataByDbLogic struct {
@@ -28,42 +23,8 @@ func NewExportDataByDbLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Ex
 	}
 }
 
-var reg1 = regexp.MustCompile("(?i)(insert|delete|update|master|truncate|declare|exec|alter|use)\\s")
-var reg2 = regexp.MustCompile("(?i)(select|from)\\s")
-
 func (l *ExportDataByDbLogic) ExportDataByDb(in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	// todo: add your logic here and delete this line
 
-	if reg1.MatchString(in.Query) && !reg2.MatchString(in.Query) {
-		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,
-		Query:   in.Query,
-		Stype:   in.Stype,
-	}).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 base64.StdEncoding.EncodeToString(b)
+	return &pb.BiReply{}, nil
 }

+ 77 - 0
rpc/internal/logic/sendmaillogic.go

@@ -0,0 +1,77 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jybase/common"
+	"bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/service"
+	"context"
+	"fmt"
+	"github.com/gogf/gf/v2/util/gconv"
+	"github.com/tjfoc/gmsm/sm4"
+	"regexp"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
+
+	"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),
+	}
+}
+
+var reg1 = regexp.MustCompile("(?i)(insert|delete|update|master|truncate|declare|exec|alter|use)\\s")
+var reg2 = regexp.MustCompile("(?i)(select|from)\\s")
+
+func (l *SendMailLogic) SendMail(in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	if in.Query != "" && in.Token != "" && in.Title != "" && in.Content != "" && in.Mails != "" {
+		return &pb.BiReply{
+			ErrorCode: 1,
+			ErrorMsg:  "参数不能为空",
+			Data:      nil,
+		}, nil
+	}
+	if reg1.MatchString(in.Query) && !reg2.MatchString(in.Query) {
+		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,
+		Query:   in.Query,
+		Stype:   in.Stype,
+	}).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))
+}

+ 5 - 0
rpc/internal/server/biserviceserver.go

@@ -111,3 +111,8 @@ func (s *BiServiceServer) ExportDataByDb(ctx context.Context, in *pb.ExportByDbR
 	l := logic.NewExportDataByDbLogic(ctx, s.svcCtx)
 	return l.ExportDataByDb(in)
 }
+
+func (s *BiServiceServer) SendMail(ctx context.Context, in *pb.ExportByDbReq) (*pb.BiReply, error) {
+	l := logic.NewSendMailLogic(ctx, s.svcCtx)
+	return l.SendMail(in)
+}

+ 27 - 23
rpc/pb/biService.pb.go

@@ -2209,7 +2209,7 @@ var file_biService_proto_rawDesc = []byte{
 	0x61, 0x69, 0x6c, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x18, 0x05, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x05, 0x71, 0x75, 0x65, 0x72, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74,
 	0x79, 0x70, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x74, 0x79, 0x70, 0x65,
-	0x32, 0xa5, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30,
+	0x32, 0xcb, 0x06, 0x0a, 0x09, 0x42, 0x69, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x30,
 	0x0a, 0x0b, 0x6d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x12, 0x0f, 0x2e,
 	0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x10,
 	0x2e, 0x4d, 0x79, 0x44, 0x61, 0x74, 0x61, 0x41, 0x73, 0x73, 0x65, 0x74, 0x52, 0x65, 0x73, 0x70,
@@ -2259,8 +2259,10 @@ var file_biService_proto_rawDesc = []byte{
 	0x43, 0x6c, 0x75, 0x65, 0x53, 0x68, 0x6f, 0x77, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2a, 0x0a, 0x0e,
 	0x65, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x44, 0x61, 0x74, 0x61, 0x42, 0x79, 0x44, 0x62, 0x12, 0x0e,
 	0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x44, 0x62, 0x52, 0x65, 0x71, 0x1a, 0x08,
-	0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x24, 0x0a, 0x08, 0x73, 0x65, 0x6e, 0x64,
+	0x4d, 0x61, 0x69, 0x6c, 0x12, 0x0e, 0x2e, 0x45, 0x78, 0x70, 0x6f, 0x72, 0x74, 0x42, 0x79, 0x44,
+	0x62, 0x52, 0x65, 0x71, 0x1a, 0x08, 0x2e, 0x42, 0x69, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x42, 0x06,
+	0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -2333,26 +2335,28 @@ var file_biService_proto_depIdxs = []int32{
 	22, // 22: BiService.getCompanyType:input_type -> CompanyReq
 	24, // 23: BiService.distributeClueShow:input_type -> DistributeClueShowReq
 	28, // 24: BiService.exportDataByDb:input_type -> ExportByDbReq
-	1,  // 25: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4,  // 26: BiService.addProject:output_type -> AddProjectResp
-	6,  // 27: BiService.getInfoId:output_type -> GetInfoIdResp
-	4,  // 28: BiService.drawClue:output_type -> AddProjectResp
-	9,  // 29: BiService.Call:output_type -> BiResp
-	4,  // 30: BiService.distributeClue:output_type -> AddProjectResp
-	14, // 31: BiService.clueImport:output_type -> ClueImportResp
-	4,  // 32: BiService.clueAdd:output_type -> AddProjectResp
-	14, // 33: BiService.clueImportTt:output_type -> ClueImportResp
-	14, // 34: BiService.autoFollow:output_type -> ClueImportResp
-	10, // 35: BiService.sqlManage:output_type -> BiReply
-	10, // 36: BiService.myInfo:output_type -> BiReply
-	10, // 37: BiService.allInfoExport:output_type -> BiReply
-	10, // 38: BiService.allProjectExport:output_type -> BiReply
-	10, // 39: BiService.infoOperate:output_type -> BiReply
-	23, // 40: BiService.getCompanyType:output_type -> CompanyResp
-	27, // 41: BiService.distributeClueShow:output_type -> DistributeClueShowResp
-	10, // 42: BiService.exportDataByDb:output_type -> BiReply
-	25, // [25:43] is the sub-list for method output_type
-	7,  // [7:25] is the sub-list for method input_type
+	28, // 25: BiService.sendMail:input_type -> ExportByDbReq
+	1,  // 26: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4,  // 27: BiService.addProject:output_type -> AddProjectResp
+	6,  // 28: BiService.getInfoId:output_type -> GetInfoIdResp
+	4,  // 29: BiService.drawClue:output_type -> AddProjectResp
+	9,  // 30: BiService.Call:output_type -> BiResp
+	4,  // 31: BiService.distributeClue:output_type -> AddProjectResp
+	14, // 32: BiService.clueImport:output_type -> ClueImportResp
+	4,  // 33: BiService.clueAdd:output_type -> AddProjectResp
+	14, // 34: BiService.clueImportTt:output_type -> ClueImportResp
+	14, // 35: BiService.autoFollow:output_type -> ClueImportResp
+	10, // 36: BiService.sqlManage:output_type -> BiReply
+	10, // 37: BiService.myInfo:output_type -> BiReply
+	10, // 38: BiService.allInfoExport:output_type -> BiReply
+	10, // 39: BiService.allProjectExport:output_type -> BiReply
+	10, // 40: BiService.infoOperate:output_type -> BiReply
+	23, // 41: BiService.getCompanyType:output_type -> CompanyResp
+	27, // 42: BiService.distributeClueShow:output_type -> DistributeClueShowResp
+	10, // 43: BiService.exportDataByDb:output_type -> BiReply
+	10, // 44: BiService.sendMail:output_type -> BiReply
+	26, // [26:45] is the sub-list for method output_type
+	7,  // [7:26] is the sub-list for method input_type
 	7,  // [7:7] is the sub-list for extension type_name
 	7,  // [7:7] is the sub-list for extension extendee
 	0,  // [0:7] is the sub-list for field type_name

+ 37 - 0
rpc/pb/biService_grpc.pb.go

@@ -37,6 +37,7 @@ const (
 	BiService_GetCompanyType_FullMethodName     = "/BiService/getCompanyType"
 	BiService_DistributeClueShow_FullMethodName = "/BiService/distributeClueShow"
 	BiService_ExportDataByDb_FullMethodName     = "/BiService/exportDataByDb"
+	BiService_SendMail_FullMethodName           = "/BiService/sendMail"
 )
 
 // BiServiceClient is the client API for BiService service.
@@ -61,6 +62,7 @@ type BiServiceClient interface {
 	GetCompanyType(ctx context.Context, in *CompanyReq, opts ...grpc.CallOption) (*CompanyResp, error)
 	DistributeClueShow(ctx context.Context, in *DistributeClueShowReq, opts ...grpc.CallOption) (*DistributeClueShowResp, error)
 	ExportDataByDb(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
+	SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error)
 }
 
 type biServiceClient struct {
@@ -233,6 +235,15 @@ func (c *biServiceClient) ExportDataByDb(ctx context.Context, in *ExportByDbReq,
 	return out, nil
 }
 
+func (c *biServiceClient) SendMail(ctx context.Context, in *ExportByDbReq, opts ...grpc.CallOption) (*BiReply, error) {
+	out := new(BiReply)
+	err := c.cc.Invoke(ctx, BiService_SendMail_FullMethodName, in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BiServiceServer is the server API for BiService service.
 // All implementations must embed UnimplementedBiServiceServer
 // for forward compatibility
@@ -255,6 +266,7 @@ type BiServiceServer interface {
 	GetCompanyType(context.Context, *CompanyReq) (*CompanyResp, error)
 	DistributeClueShow(context.Context, *DistributeClueShowReq) (*DistributeClueShowResp, error)
 	ExportDataByDb(context.Context, *ExportByDbReq) (*BiReply, error)
+	SendMail(context.Context, *ExportByDbReq) (*BiReply, error)
 	mustEmbedUnimplementedBiServiceServer()
 }
 
@@ -316,6 +328,9 @@ func (UnimplementedBiServiceServer) DistributeClueShow(context.Context, *Distrib
 func (UnimplementedBiServiceServer) ExportDataByDb(context.Context, *ExportByDbReq) (*BiReply, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ExportDataByDb not implemented")
 }
+func (UnimplementedBiServiceServer) SendMail(context.Context, *ExportByDbReq) (*BiReply, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SendMail not implemented")
+}
 func (UnimplementedBiServiceServer) mustEmbedUnimplementedBiServiceServer() {}
 
 // UnsafeBiServiceServer may be embedded to opt out of forward compatibility for this service.
@@ -653,6 +668,24 @@ func _BiService_ExportDataByDb_Handler(srv interface{}, ctx context.Context, dec
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BiService_SendMail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ExportByDbReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BiServiceServer).SendMail(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: BiService_SendMail_FullMethodName,
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BiServiceServer).SendMail(ctx, req.(*ExportByDbReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BiService_ServiceDesc is the grpc.ServiceDesc for BiService service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -732,6 +765,10 @@ var BiService_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "exportDataByDb",
 			Handler:    _BiService_ExportDataByDb_Handler,
 		},
+		{
+			MethodName: "sendMail",
+			Handler:    _BiService_SendMail_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "biService.proto",