This commit is contained in:
@@ -57,7 +57,7 @@ message GetMailingListByIDRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message GetMailingListByIDResponse {
|
message GetMailingListByIDResponse {
|
||||||
MailingItem item = 1;
|
MailingDetail detail = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
message MailingItem {
|
message MailingItem {
|
||||||
@@ -68,3 +68,10 @@ message MailingItem {
|
|||||||
google.protobuf.Timestamp created_at = 5;
|
google.protobuf.Timestamp created_at = 5;
|
||||||
int32 suppliers_found = 6;
|
int32 suppliers_found = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message MailingDetail {
|
||||||
|
string request_id = 1;
|
||||||
|
string title = 2;
|
||||||
|
string mail_text = 3;
|
||||||
|
repeated Supplier suppliers = 4;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.techease.ru/Smart-search/smart-search-back/pkg/errors"
|
"git.techease.ru/Smart-search/smart-search-back/pkg/errors"
|
||||||
pb "git.techease.ru/Smart-search/smart-search-back/pkg/pb/request"
|
pb "git.techease.ru/Smart-search/smart-search-back/pkg/pb/request"
|
||||||
@@ -91,14 +90,23 @@ func (h *RequestHandler) GetMailingListByID(ctx context.Context, req *pb.GetMail
|
|||||||
return nil, errors.ToGRPCError(err, h.logger, "RequestService.GetMailingListByID")
|
return nil, errors.ToGRPCError(err, h.logger, "RequestService.GetMailingListByID")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suppliers := make([]*pb.Supplier, 0, len(detail.Suppliers))
|
||||||
|
for _, s := range detail.Suppliers {
|
||||||
|
suppliers = append(suppliers, &pb.Supplier{
|
||||||
|
Id: strconv.Itoa(s.CompanyID),
|
||||||
|
Name: s.CompanyName,
|
||||||
|
Email: s.Email,
|
||||||
|
Phone: s.Phone,
|
||||||
|
Url: s.URL,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return &pb.GetMailingListByIDResponse{
|
return &pb.GetMailingListByIDResponse{
|
||||||
Item: &pb.MailingItem{
|
Detail: &pb.MailingDetail{
|
||||||
RequestId: detail.RequestID.String(),
|
RequestId: detail.RequestID.String(),
|
||||||
RequestTxt: detail.Title,
|
Title: detail.Title,
|
||||||
FinalTz: detail.MailText,
|
MailText: detail.MailText,
|
||||||
MailingStatus: "sent",
|
Suppliers: suppliers,
|
||||||
CreatedAt: timestamppb.New(time.Now()),
|
|
||||||
SuppliersFound: int32(len(detail.Suppliers)),
|
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ func (x *GetMailingListByIDRequest) GetUserId() int64 {
|
|||||||
|
|
||||||
type GetMailingListByIDResponse struct {
|
type GetMailingListByIDResponse struct {
|
||||||
state protoimpl.MessageState `protogen:"open.v1"`
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
Item *MailingItem `protobuf:"bytes,1,opt,name=item,proto3" json:"item,omitempty"`
|
Detail *MailingDetail `protobuf:"bytes,1,opt,name=detail,proto3" json:"detail,omitempty"`
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
}
|
}
|
||||||
@@ -515,9 +515,9 @@ func (*GetMailingListByIDResponse) Descriptor() ([]byte, []int) {
|
|||||||
return file_request_request_proto_rawDescGZIP(), []int{8}
|
return file_request_request_proto_rawDescGZIP(), []int{8}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *GetMailingListByIDResponse) GetItem() *MailingItem {
|
func (x *GetMailingListByIDResponse) GetDetail() *MailingDetail {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Item
|
return x.Detail
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -606,6 +606,74 @@ func (x *MailingItem) GetSuppliersFound() int32 {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MailingDetail struct {
|
||||||
|
state protoimpl.MessageState `protogen:"open.v1"`
|
||||||
|
RequestId string `protobuf:"bytes,1,opt,name=request_id,json=requestId,proto3" json:"request_id,omitempty"`
|
||||||
|
Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title,omitempty"`
|
||||||
|
MailText string `protobuf:"bytes,3,opt,name=mail_text,json=mailText,proto3" json:"mail_text,omitempty"`
|
||||||
|
Suppliers []*Supplier `protobuf:"bytes,4,rep,name=suppliers,proto3" json:"suppliers,omitempty"`
|
||||||
|
unknownFields protoimpl.UnknownFields
|
||||||
|
sizeCache protoimpl.SizeCache
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) Reset() {
|
||||||
|
*x = MailingDetail{}
|
||||||
|
mi := &file_request_request_proto_msgTypes[10]
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) String() string {
|
||||||
|
return protoimpl.X.MessageStringOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*MailingDetail) ProtoMessage() {}
|
||||||
|
|
||||||
|
func (x *MailingDetail) ProtoReflect() protoreflect.Message {
|
||||||
|
mi := &file_request_request_proto_msgTypes[10]
|
||||||
|
if x != nil {
|
||||||
|
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||||
|
if ms.LoadMessageInfo() == nil {
|
||||||
|
ms.StoreMessageInfo(mi)
|
||||||
|
}
|
||||||
|
return ms
|
||||||
|
}
|
||||||
|
return mi.MessageOf(x)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deprecated: Use MailingDetail.ProtoReflect.Descriptor instead.
|
||||||
|
func (*MailingDetail) Descriptor() ([]byte, []int) {
|
||||||
|
return file_request_request_proto_rawDescGZIP(), []int{10}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) GetRequestId() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.RequestId
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) GetTitle() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Title
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) GetMailText() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.MailText
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *MailingDetail) GetSuppliers() []*Supplier {
|
||||||
|
if x != nil {
|
||||||
|
return x.Suppliers
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var File_request_request_proto protoreflect.FileDescriptor
|
var File_request_request_proto protoreflect.FileDescriptor
|
||||||
|
|
||||||
const file_request_request_proto_rawDesc = "" +
|
const file_request_request_proto_rawDesc = "" +
|
||||||
@@ -644,9 +712,9 @@ const file_request_request_proto_rawDesc = "" +
|
|||||||
"\x19GetMailingListByIDRequest\x12\x1d\n" +
|
"\x19GetMailingListByIDRequest\x12\x1d\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" +
|
"request_id\x18\x01 \x01(\tR\trequestId\x12\x17\n" +
|
||||||
"\auser_id\x18\x02 \x01(\x03R\x06userId\"F\n" +
|
"\auser_id\x18\x02 \x01(\x03R\x06userId\"L\n" +
|
||||||
"\x1aGetMailingListByIDResponse\x12(\n" +
|
"\x1aGetMailingListByIDResponse\x12.\n" +
|
||||||
"\x04item\x18\x01 \x01(\v2\x14.request.MailingItemR\x04item\"\xf3\x01\n" +
|
"\x06detail\x18\x01 \x01(\v2\x16.request.MailingDetailR\x06detail\"\xf3\x01\n" +
|
||||||
"\vMailingItem\x12\x1d\n" +
|
"\vMailingItem\x12\x1d\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"request_id\x18\x01 \x01(\tR\trequestId\x12\x1f\n" +
|
"request_id\x18\x01 \x01(\tR\trequestId\x12\x1f\n" +
|
||||||
@@ -656,7 +724,13 @@ const file_request_request_proto_rawDesc = "" +
|
|||||||
"\x0emailing_status\x18\x04 \x01(\tR\rmailingStatus\x129\n" +
|
"\x0emailing_status\x18\x04 \x01(\tR\rmailingStatus\x129\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12'\n" +
|
"created_at\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x12'\n" +
|
||||||
"\x0fsuppliers_found\x18\x06 \x01(\x05R\x0esuppliersFound2\xc7\x02\n" +
|
"\x0fsuppliers_found\x18\x06 \x01(\x05R\x0esuppliersFound\"\x92\x01\n" +
|
||||||
|
"\rMailingDetail\x12\x1d\n" +
|
||||||
|
"\n" +
|
||||||
|
"request_id\x18\x01 \x01(\tR\trequestId\x12\x14\n" +
|
||||||
|
"\x05title\x18\x02 \x01(\tR\x05title\x12\x1b\n" +
|
||||||
|
"\tmail_text\x18\x03 \x01(\tR\bmailText\x12/\n" +
|
||||||
|
"\tsuppliers\x18\x04 \x03(\v2\x11.request.SupplierR\tsuppliers2\xc7\x02\n" +
|
||||||
"\x0eRequestService\x12?\n" +
|
"\x0eRequestService\x12?\n" +
|
||||||
"\bCreateTZ\x12\x18.request.CreateTZRequest\x1a\x19.request.CreateTZResponse\x12B\n" +
|
"\bCreateTZ\x12\x18.request.CreateTZRequest\x1a\x19.request.CreateTZResponse\x12B\n" +
|
||||||
"\tApproveTZ\x12\x19.request.ApproveTZRequest\x1a\x1a.request.ApproveTZResponse\x12Q\n" +
|
"\tApproveTZ\x12\x19.request.ApproveTZRequest\x1a\x1a.request.ApproveTZResponse\x12Q\n" +
|
||||||
@@ -675,7 +749,7 @@ func file_request_request_proto_rawDescGZIP() []byte {
|
|||||||
return file_request_request_proto_rawDescData
|
return file_request_request_proto_rawDescData
|
||||||
}
|
}
|
||||||
|
|
||||||
var file_request_request_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
var file_request_request_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
|
||||||
var file_request_request_proto_goTypes = []any{
|
var file_request_request_proto_goTypes = []any{
|
||||||
(*CreateTZRequest)(nil), // 0: request.CreateTZRequest
|
(*CreateTZRequest)(nil), // 0: request.CreateTZRequest
|
||||||
(*CreateTZResponse)(nil), // 1: request.CreateTZResponse
|
(*CreateTZResponse)(nil), // 1: request.CreateTZResponse
|
||||||
@@ -687,26 +761,28 @@ var file_request_request_proto_goTypes = []any{
|
|||||||
(*GetMailingListByIDRequest)(nil), // 7: request.GetMailingListByIDRequest
|
(*GetMailingListByIDRequest)(nil), // 7: request.GetMailingListByIDRequest
|
||||||
(*GetMailingListByIDResponse)(nil), // 8: request.GetMailingListByIDResponse
|
(*GetMailingListByIDResponse)(nil), // 8: request.GetMailingListByIDResponse
|
||||||
(*MailingItem)(nil), // 9: request.MailingItem
|
(*MailingItem)(nil), // 9: request.MailingItem
|
||||||
(*timestamppb.Timestamp)(nil), // 10: google.protobuf.Timestamp
|
(*MailingDetail)(nil), // 10: request.MailingDetail
|
||||||
|
(*timestamppb.Timestamp)(nil), // 11: google.protobuf.Timestamp
|
||||||
}
|
}
|
||||||
var file_request_request_proto_depIdxs = []int32{
|
var file_request_request_proto_depIdxs = []int32{
|
||||||
4, // 0: request.ApproveTZResponse.suppliers:type_name -> request.Supplier
|
4, // 0: request.ApproveTZResponse.suppliers:type_name -> request.Supplier
|
||||||
9, // 1: request.GetMailingListResponse.items:type_name -> request.MailingItem
|
9, // 1: request.GetMailingListResponse.items:type_name -> request.MailingItem
|
||||||
9, // 2: request.GetMailingListByIDResponse.item:type_name -> request.MailingItem
|
10, // 2: request.GetMailingListByIDResponse.detail:type_name -> request.MailingDetail
|
||||||
10, // 3: request.MailingItem.created_at:type_name -> google.protobuf.Timestamp
|
11, // 3: request.MailingItem.created_at:type_name -> google.protobuf.Timestamp
|
||||||
0, // 4: request.RequestService.CreateTZ:input_type -> request.CreateTZRequest
|
4, // 4: request.MailingDetail.suppliers:type_name -> request.Supplier
|
||||||
2, // 5: request.RequestService.ApproveTZ:input_type -> request.ApproveTZRequest
|
0, // 5: request.RequestService.CreateTZ:input_type -> request.CreateTZRequest
|
||||||
5, // 6: request.RequestService.GetMailingList:input_type -> request.GetMailingListRequest
|
2, // 6: request.RequestService.ApproveTZ:input_type -> request.ApproveTZRequest
|
||||||
7, // 7: request.RequestService.GetMailingListByID:input_type -> request.GetMailingListByIDRequest
|
5, // 7: request.RequestService.GetMailingList:input_type -> request.GetMailingListRequest
|
||||||
1, // 8: request.RequestService.CreateTZ:output_type -> request.CreateTZResponse
|
7, // 8: request.RequestService.GetMailingListByID:input_type -> request.GetMailingListByIDRequest
|
||||||
3, // 9: request.RequestService.ApproveTZ:output_type -> request.ApproveTZResponse
|
1, // 9: request.RequestService.CreateTZ:output_type -> request.CreateTZResponse
|
||||||
6, // 10: request.RequestService.GetMailingList:output_type -> request.GetMailingListResponse
|
3, // 10: request.RequestService.ApproveTZ:output_type -> request.ApproveTZResponse
|
||||||
8, // 11: request.RequestService.GetMailingListByID:output_type -> request.GetMailingListByIDResponse
|
6, // 11: request.RequestService.GetMailingList:output_type -> request.GetMailingListResponse
|
||||||
8, // [8:12] is the sub-list for method output_type
|
8, // 12: request.RequestService.GetMailingListByID:output_type -> request.GetMailingListByIDResponse
|
||||||
4, // [4:8] is the sub-list for method input_type
|
9, // [9:13] is the sub-list for method output_type
|
||||||
4, // [4:4] is the sub-list for extension type_name
|
5, // [5:9] is the sub-list for method input_type
|
||||||
4, // [4:4] is the sub-list for extension extendee
|
5, // [5:5] is the sub-list for extension type_name
|
||||||
0, // [0:4] is the sub-list for field type_name
|
5, // [5:5] is the sub-list for extension extendee
|
||||||
|
0, // [0:5] is the sub-list for field type_name
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { file_request_request_proto_init() }
|
func init() { file_request_request_proto_init() }
|
||||||
@@ -720,7 +796,7 @@ func file_request_request_proto_init() {
|
|||||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_request_request_proto_rawDesc), len(file_request_request_proto_rawDesc)),
|
RawDescriptor: unsafe.Slice(unsafe.StringData(file_request_request_proto_rawDesc), len(file_request_request_proto_rawDesc)),
|
||||||
NumEnums: 0,
|
NumEnums: 0,
|
||||||
NumMessages: 10,
|
NumMessages: 11,
|
||||||
NumExtensions: 0,
|
NumExtensions: 0,
|
||||||
NumServices: 1,
|
NumServices: 1,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -97,8 +97,8 @@ func (s *IntegrationSuite) TestFullFlow_CompleteRequestLifecycle() {
|
|||||||
s.T().Logf("GetMailingListByID failed: %v", err)
|
s.T().Logf("GetMailingListByID failed: %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.NotNil(mailingListByIDResp.Item)
|
s.NotNil(mailingListByIDResp.Detail)
|
||||||
s.Equal(requestID, mailingListByIDResp.Item.RequestId)
|
s.Equal(requestID, mailingListByIDResp.Detail.RequestId)
|
||||||
|
|
||||||
exportExcelReq := &supplierpb.ExportExcelRequest{
|
exportExcelReq := &supplierpb.ExportExcelRequest{
|
||||||
RequestId: requestID,
|
RequestId: requestID,
|
||||||
@@ -232,9 +232,9 @@ func (s *IntegrationSuite) TestFullFlow_CreateTZ_ApproveTZ_GetMailingListByID_Ex
|
|||||||
|
|
||||||
mailingListByIDResp, err := s.requestClient.GetMailingListByID(ctx, getMailingListByIDReq)
|
mailingListByIDResp, err := s.requestClient.GetMailingListByID(ctx, getMailingListByIDReq)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
s.NotNil(mailingListByIDResp.Item)
|
s.NotNil(mailingListByIDResp.Detail)
|
||||||
s.Equal(requestID, mailingListByIDResp.Item.RequestId)
|
s.Equal(requestID, mailingListByIDResp.Detail.RequestId)
|
||||||
s.Greater(mailingListByIDResp.Item.SuppliersFound, int32(0))
|
s.Greater(len(mailingListByIDResp.Detail.Suppliers), 0)
|
||||||
|
|
||||||
exportExcelReq := &supplierpb.ExportExcelRequest{
|
exportExcelReq := &supplierpb.ExportExcelRequest{
|
||||||
RequestId: requestID,
|
RequestId: requestID,
|
||||||
|
|||||||
@@ -209,6 +209,6 @@ func (s *IntegrationSuite) TestOwnership_GetMailingListByID_OwnRequest_Success()
|
|||||||
resp, err := s.requestClient.GetMailingListByID(ctx, getMailingByIDReq)
|
resp, err := s.requestClient.GetMailingListByID(ctx, getMailingByIDReq)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
s.NotNil(resp)
|
s.NotNil(resp)
|
||||||
s.NotNil(resp.Item)
|
s.NotNil(resp.Detail)
|
||||||
s.Equal(requestID, resp.Item.RequestId)
|
s.Equal(requestID, resp.Detail.RequestId)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ func (s *IntegrationSuite) TestRequestHandler_GetMailingListByIDSuccess() {
|
|||||||
getByIDResp, err := s.requestClient.GetMailingListByID(ctx, getByIDReq)
|
getByIDResp, err := s.requestClient.GetMailingListByID(ctx, getByIDReq)
|
||||||
s.NoError(err)
|
s.NoError(err)
|
||||||
s.NotNil(getByIDResp)
|
s.NotNil(getByIDResp)
|
||||||
s.NotNil(getByIDResp.Item)
|
s.NotNil(getByIDResp.Detail)
|
||||||
s.Equal(requestID, getByIDResp.Item.RequestId)
|
s.Equal(requestID, getByIDResp.Detail.RequestId)
|
||||||
s.Greater(getByIDResp.Item.SuppliersFound, int32(0))
|
s.Greater(len(getByIDResp.Detail.Suppliers), 0)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user