xuzhiheng 2 роки тому
батько
коміт
e8b106c3ff

+ 1 - 0
README.md

@@ -1,5 +1,6 @@
 bi页面的相关服务接口
 goctl rpc proto -src biService.proto -dir .
+goctl rpc protoc biService.proto --go_out=. --go-grpc_out=. --zrpc_out=.
 goctl api go -api biService.api -dir .
 go test -v -coverprofile=coverage
 go tool cover -html=coverage -o coverage.html

+ 7 - 0
api/biService.api

@@ -29,6 +29,11 @@ type (
 	getInfoIdReq {
 		PositionId int64 `header:"userPositionId,optional"`
 	}
+
+	drawClueReq {
+		PositionId int64 `json:"positionId,optional"`
+		Count      int64 `json:"count,optional"`
+	}
 )
 
 service biService-api {
@@ -38,4 +43,6 @@ service biService-api {
 	post /biService/addProject (addProjectReq) returns (resp)
 	@handler GetInfoId
 	post /biService/getInfoId (getInfoIdReq) returns (resp)
+	@handler DrawClue
+	post /biService/drawClue (drawClueReq) returns (resp)
 }

+ 28 - 0
api/internal/handler/drawcluehandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/logic"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func DrawClueHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.DrawClueReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewDrawClueLogic(r.Context(), svcCtx)
+		resp, err := l.DrawClue(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 7 - 2
api/internal/handler/routes.go

@@ -9,8 +9,8 @@ import (
 	"github.com/zeromicro/go-zero/rest"
 )
 
-func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
-	engine.AddRoutes(
+func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
+	server.AddRoutes(
 		[]rest.Route{
 			{
 				Method:  http.MethodPost,
@@ -27,6 +27,11 @@ func RegisterHandlers(engine *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/biService/getInfoId",
 				Handler: GetInfoIdHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/biService/drawClue",
+				Handler: DrawClueHandler(serverCtx),
+			},
 		},
 	)
 }

+ 34 - 0
api/internal/logic/drawcluelogic.go

@@ -0,0 +1,34 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/svc"
+	"bp.jydev.jianyu360.cn/BaseService/biService/api/internal/types"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type DrawClueLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(req *types.DrawClueReq) (resp *types.Resp, err error) {
+	// todo: add your logic here and delete this line
+	res, err := l.svcCtx.BiServiceRpc.DrawClue(l.ctx, &biservice.DrawClueReq{
+		PositionId: req.PositionId,
+		Count:      req.Count,
+	})
+	return &types.Resp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
+}

+ 5 - 0
api/internal/types/types.go

@@ -29,3 +29,8 @@ type AddProjectReq struct {
 type GetInfoIdReq struct {
 	PositionId int64 `header:"userPositionId,optional"`
 }
+
+type DrawClueReq struct {
+	PositionId int64 `json:"positionId,optional"`
+	Count      int64 `json:"count,optional"`
+}

+ 6 - 0
rpc/biService.proto

@@ -51,8 +51,14 @@ message GetInfoIdResp {
 	repeated string data = 3;
 }
 
+message drawClueReq {
+	int64 positionId = 1;
+	int64 count = 2;
+}
+
 service BiService {
 	rpc myDataAsset (MyDataAssetReq) returns (MyDataAssetResp); //我的数据资产
 	rpc addProject (AddProjectReq) returns (AddProjectResp); //添加项目
 	rpc getInfoId (AddProjectReq) returns (GetInfoIdResp); //获取添加过项目的信息id
+	rpc drawClue (drawClueReq) returns (AddProjectResp); //领取线索
 }

+ 22 - 16
rpc/biservice/biservice.go

@@ -1,8 +1,6 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
-//go:generate mockgen -destination ./biservice_mock.go -package biservice -source $GOFILE
-
 package biservice
 
 import (
@@ -11,21 +9,24 @@ import (
 	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/pb"
 
 	"github.com/zeromicro/go-zero/zrpc"
+	"google.golang.org/grpc"
 )
 
 type (
-	MyDataAssetReq  = pb.MyDataAssetReq
-	MyDataAssetResp = pb.MyDataAssetResp
-	MyDataAsset     = pb.MyDataAsset
+	AddProject      = pb.AddProject
 	AddProjectReq   = pb.AddProjectReq
 	AddProjectResp  = pb.AddProjectResp
-	AddProject      = pb.AddProject
+	DrawClueReq     = pb.DrawClueReq
 	GetInfoIdResp   = pb.GetInfoIdResp
+	MyDataAsset     = pb.MyDataAsset
+	MyDataAssetReq  = pb.MyDataAssetReq
+	MyDataAssetResp = pb.MyDataAssetResp
 
 	BiService interface {
-		MyDataAsset(ctx context.Context, in *MyDataAssetReq) (*MyDataAssetResp, error)
-		AddProject(ctx context.Context, in *AddProjectReq) (*AddProjectResp, error)
-		GetInfoId(ctx context.Context, in *AddProjectReq) (*GetInfoIdResp, error)
+		MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
+		AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
+		GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
+		DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error)
 	}
 
 	defaultBiService struct {
@@ -39,17 +40,22 @@ func NewBiService(cli zrpc.Client) BiService {
 	}
 }
 
-func (m *defaultBiService) MyDataAsset(ctx context.Context, in *MyDataAssetReq) (*MyDataAssetResp, error) {
+func (m *defaultBiService) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
+	client := pb.NewBiServiceClient(m.cli.Conn())
+	return client.MyDataAsset(ctx, in, opts...)
+}
+
+func (m *defaultBiService) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.MyDataAsset(ctx, in)
+	return client.AddProject(ctx, in, opts...)
 }
 
-func (m *defaultBiService) AddProject(ctx context.Context, in *AddProjectReq) (*AddProjectResp, error) {
+func (m *defaultBiService) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.AddProject(ctx, in)
+	return client.GetInfoId(ctx, in, opts...)
 }
 
-func (m *defaultBiService) GetInfoId(ctx context.Context, in *AddProjectReq) (*GetInfoIdResp, error) {
+func (m *defaultBiService) DrawClue(ctx context.Context, in *DrawClueReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
 	client := pb.NewBiServiceClient(m.cli.Conn())
-	return client.GetInfoId(ctx, in)
+	return client.DrawClue(ctx, in, opts...)
 }

+ 30 - 0
rpc/internal/logic/drawcluelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"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 DrawClueLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDrawClueLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DrawClueLogic {
+	return &DrawClueLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DrawClueLogic) DrawClue(in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	// todo: add your logic here and delete this line
+
+	return service.DrawClue(in), nil
+}

+ 7 - 1
rpc/internal/server/biserviceserver.go

@@ -1,4 +1,4 @@
-// Code generated by goctl. DO NOT EDIT!
+// Code generated by goctl. DO NOT EDIT.
 // Source: biService.proto
 
 package server
@@ -13,6 +13,7 @@ import (
 
 type BiServiceServer struct {
 	svcCtx *svc.ServiceContext
+	pb.UnimplementedBiServiceServer
 }
 
 func NewBiServiceServer(svcCtx *svc.ServiceContext) *BiServiceServer {
@@ -35,3 +36,8 @@ func (s *BiServiceServer) GetInfoId(ctx context.Context, in *pb.AddProjectReq) (
 	l := logic.NewGetInfoIdLogic(ctx, s.svcCtx)
 	return l.GetInfoId(in)
 }
+
+func (s *BiServiceServer) DrawClue(ctx context.Context, in *pb.DrawClueReq) (*pb.AddProjectResp, error) {
+	l := logic.NewDrawClueLogic(ctx, s.svcCtx)
+	return l.DrawClue(in)
+}

+ 97 - 181
rpc/pb/biService.pb.go

@@ -1,17 +1,12 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.23.0
-// 	protoc        v3.11.4
+// 	protoc-gen-go v1.28.1
+// 	protoc        v3.19.4
 // source: biService.proto
 
 package pb
 
 import (
-	context "context"
-	proto "github.com/golang/protobuf/proto"
-	grpc "google.golang.org/grpc"
-	codes "google.golang.org/grpc/codes"
-	status "google.golang.org/grpc/status"
 	protoreflect "google.golang.org/protobuf/reflect/protoreflect"
 	protoimpl "google.golang.org/protobuf/runtime/protoimpl"
 	reflect "reflect"
@@ -25,10 +20,6 @@ const (
 	_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
 )
 
-// This is a compile-time assertion that a sufficiently up-to-date version
-// of the legacy proto package is being used.
-const _ = proto.ProtoPackageIsVersion4
-
 type MyDataAssetReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -526,6 +517,61 @@ func (x *GetInfoIdResp) GetData() []string {
 	return nil
 }
 
+type DrawClueReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	PositionId int64 `protobuf:"varint,1,opt,name=positionId,proto3" json:"positionId,omitempty"`
+	Count      int64 `protobuf:"varint,2,opt,name=count,proto3" json:"count,omitempty"`
+}
+
+func (x *DrawClueReq) Reset() {
+	*x = DrawClueReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_biService_proto_msgTypes[7]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *DrawClueReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*DrawClueReq) ProtoMessage() {}
+
+func (x *DrawClueReq) ProtoReflect() protoreflect.Message {
+	mi := &file_biService_proto_msgTypes[7]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use DrawClueReq.ProtoReflect.Descriptor instead.
+func (*DrawClueReq) Descriptor() ([]byte, []int) {
+	return file_biService_proto_rawDescGZIP(), []int{7}
+}
+
+func (x *DrawClueReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
+func (x *DrawClueReq) GetCount() int64 {
+	if x != nil {
+		return x.Count
+	}
+	return 0
+}
+
 var File_biService_proto protoreflect.FileDescriptor
 
 var file_biService_proto_rawDesc = []byte{
@@ -593,17 +639,24 @@ var file_biService_proto_rawDesc = []byte{
 	0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65,
 	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
 	0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61,
-	0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x99, 0x01, 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, 0x12, 0x2d, 0x0a, 0x0a,
-	0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64,
-	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64,
-	0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2b, 0x0a, 0x09, 0x67,
-	0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x12, 0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72,
-	0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x47, 0x65, 0x74, 0x49, 0x6e,
-	0x66, 0x6f, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
+	0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, 0x0a, 0x0b,
+	0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1e, 0x0a, 0x0a, 0x70,
+	0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x63,
+	0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e,
+	0x74, 0x32, 0xc4, 0x01, 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, 0x12, 0x2d, 0x0a, 0x0a, 0x61, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x12,
+	0x0e, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a,
+	0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x2b, 0x0a, 0x09, 0x67, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x12, 0x0e, 0x2e,
+	0x41, 0x64, 0x64, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e,
+	0x47, 0x65, 0x74, 0x49, 0x6e, 0x66, 0x6f, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x29, 0x0a,
+	0x08, 0x64, 0x72, 0x61, 0x77, 0x43, 0x6c, 0x75, 0x65, 0x12, 0x0c, 0x2e, 0x64, 0x72, 0x61, 0x77,
+	0x43, 0x6c, 0x75, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x41, 0x64, 0x64, 0x50, 0x72, 0x6f,
+	0x6a, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62,
 	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
@@ -619,7 +672,7 @@ func file_biService_proto_rawDescGZIP() []byte {
 	return file_biService_proto_rawDescData
 }
 
-var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
+var file_biService_proto_msgTypes = make([]protoimpl.MessageInfo, 8)
 var file_biService_proto_goTypes = []interface{}{
 	(*MyDataAssetReq)(nil),  // 0: MyDataAssetReq
 	(*MyDataAssetResp)(nil), // 1: MyDataAssetResp
@@ -628,6 +681,7 @@ var file_biService_proto_goTypes = []interface{}{
 	(*AddProjectResp)(nil),  // 4: AddProjectResp
 	(*AddProject)(nil),      // 5: AddProject
 	(*GetInfoIdResp)(nil),   // 6: GetInfoIdResp
+	(*DrawClueReq)(nil),     // 7: drawClueReq
 }
 var file_biService_proto_depIdxs = []int32{
 	2, // 0: MyDataAssetResp.data:type_name -> MyDataAsset
@@ -635,11 +689,13 @@ var file_biService_proto_depIdxs = []int32{
 	0, // 2: BiService.myDataAsset:input_type -> MyDataAssetReq
 	3, // 3: BiService.addProject:input_type -> AddProjectReq
 	3, // 4: BiService.getInfoId:input_type -> AddProjectReq
-	1, // 5: BiService.myDataAsset:output_type -> MyDataAssetResp
-	4, // 6: BiService.addProject:output_type -> AddProjectResp
-	6, // 7: BiService.getInfoId:output_type -> GetInfoIdResp
-	5, // [5:8] is the sub-list for method output_type
-	2, // [2:5] is the sub-list for method input_type
+	7, // 5: BiService.drawClue:input_type -> drawClueReq
+	1, // 6: BiService.myDataAsset:output_type -> MyDataAssetResp
+	4, // 7: BiService.addProject:output_type -> AddProjectResp
+	6, // 8: BiService.getInfoId:output_type -> GetInfoIdResp
+	4, // 9: BiService.drawClue:output_type -> AddProjectResp
+	6, // [6:10] is the sub-list for method output_type
+	2, // [2:6] is the sub-list for method input_type
 	2, // [2:2] is the sub-list for extension type_name
 	2, // [2:2] is the sub-list for extension extendee
 	0, // [0:2] is the sub-list for field type_name
@@ -735,6 +791,18 @@ func file_biService_proto_init() {
 				return nil
 			}
 		}
+		file_biService_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*DrawClueReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -742,7 +810,7 @@ func file_biService_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_biService_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   7,
+			NumMessages:   8,
 			NumExtensions: 0,
 			NumServices:   1,
 		},
@@ -755,155 +823,3 @@ func file_biService_proto_init() {
 	file_biService_proto_goTypes = nil
 	file_biService_proto_depIdxs = nil
 }
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// BiServiceClient is the client API for BiService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type BiServiceClient interface {
-	MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error)
-	AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error)
-	GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error)
-}
-
-type biServiceClient struct {
-	cc grpc.ClientConnInterface
-}
-
-func NewBiServiceClient(cc grpc.ClientConnInterface) BiServiceClient {
-	return &biServiceClient{cc}
-}
-
-func (c *biServiceClient) MyDataAsset(ctx context.Context, in *MyDataAssetReq, opts ...grpc.CallOption) (*MyDataAssetResp, error) {
-	out := new(MyDataAssetResp)
-	err := c.cc.Invoke(ctx, "/BiService/myDataAsset", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *biServiceClient) AddProject(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*AddProjectResp, error) {
-	out := new(AddProjectResp)
-	err := c.cc.Invoke(ctx, "/BiService/addProject", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-func (c *biServiceClient) GetInfoId(ctx context.Context, in *AddProjectReq, opts ...grpc.CallOption) (*GetInfoIdResp, error) {
-	out := new(GetInfoIdResp)
-	err := c.cc.Invoke(ctx, "/BiService/getInfoId", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
-// BiServiceServer is the server API for BiService service.
-type BiServiceServer interface {
-	MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error)
-	AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error)
-	GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error)
-}
-
-// UnimplementedBiServiceServer can be embedded to have forward compatible implementations.
-type UnimplementedBiServiceServer struct {
-}
-
-func (*UnimplementedBiServiceServer) MyDataAsset(context.Context, *MyDataAssetReq) (*MyDataAssetResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method MyDataAsset not implemented")
-}
-func (*UnimplementedBiServiceServer) AddProject(context.Context, *AddProjectReq) (*AddProjectResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method AddProject not implemented")
-}
-func (*UnimplementedBiServiceServer) GetInfoId(context.Context, *AddProjectReq) (*GetInfoIdResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method GetInfoId not implemented")
-}
-
-func RegisterBiServiceServer(s *grpc.Server, srv BiServiceServer) {
-	s.RegisterService(&_BiService_serviceDesc, srv)
-}
-
-func _BiService_MyDataAsset_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(MyDataAssetReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).MyDataAsset(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/MyDataAsset",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).MyDataAsset(ctx, req.(*MyDataAssetReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _BiService_AddProject_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(AddProjectReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).AddProject(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/AddProject",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).AddProject(ctx, req.(*AddProjectReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-func _BiService_GetInfoId_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(AddProjectReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(BiServiceServer).GetInfoId(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/BiService/GetInfoId",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(BiServiceServer).GetInfoId(ctx, req.(*AddProjectReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
-var _BiService_serviceDesc = grpc.ServiceDesc{
-	ServiceName: "BiService",
-	HandlerType: (*BiServiceServer)(nil),
-	Methods: []grpc.MethodDesc{
-		{
-			MethodName: "myDataAsset",
-			Handler:    _BiService_MyDataAsset_Handler,
-		},
-		{
-			MethodName: "addProject",
-			Handler:    _BiService_AddProject_Handler,
-		},
-		{
-			MethodName: "getInfoId",
-			Handler:    _BiService_GetInfoId_Handler,
-		},
-	},
-	Streams:  []grpc.StreamDesc{},
-	Metadata: "biService.proto",
-}

+ 155 - 0
service/clue.go

@@ -0,0 +1,155 @@
+package service
+
+import (
+	"math"
+	"time"
+
+	common "app.yhyue.com/moapp/jybase/common"
+	. "bp.jydev.jianyu360.cn/BaseService/biService/entity"
+	"bp.jydev.jianyu360.cn/BaseService/biService/rpc/biservice"
+)
+
+func DrawClue(this *biservice.DrawClueReq) *biservice.AddProjectResp {
+	count1 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 1})
+	count2 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 2})
+	count3 := JyBiTidb.Count("dwd_f_crm_open_sea", map[string]interface{}{"level": 3})
+	counts1 := int64(math.Floor(float64(this.Count) / float64(10) * 2))
+	counts2 := int64(math.Floor(float64(this.Count) / float64(10) * 4))
+	counts3 := this.Count - counts1 - counts2
+	if counts1 > count1 {
+		counts2 += counts1 - count1
+	}
+	if counts2 > count2 {
+		counts3 += counts2 - count2
+	}
+	DrawClues(this.PositionId, counts1, counts2, counts3)
+	return &biservice.AddProjectResp{
+		ErrorCode: 0,
+		Data: &biservice.AddProject{
+			Status: 1,
+		},
+	}
+}
+
+func DrawClues(positionId, count1, count2, count3 int64) {
+	data1 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 1}, "", "", 0, count1)
+	data2 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 2}, "", "", 0, count2)
+	data3 := JyBiTidb.Find("dwd_f_crm_open_sea", map[string]interface{}{"level": 3}, "", "", 0, count3)
+	if data1 != nil && len(*data1) > 0 {
+		for _, v := range *data1 {
+			//update postionid and update record
+			clueId := common.Int64All(v["clue_id"])
+			nowTime := time.Now().Format("2006-01-02 15:04:05")
+			seatNumber, name := getSeatNumber(positionId)
+			JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+				JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+				JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+					"clue_id":      clueId,
+					"seatNumber":   seatNumber,
+					"position_id":  positionId,
+					"comeintime":   nowTime,
+					"comeinsource": 3,
+					"is_task":      0,
+				})
+				JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+					"clue_id":      clueId,
+					"position_id":  positionId,
+					"change_field": "position_id",
+					"change_type":  "所属人变更",
+					"old_value":    "/",
+					"new_value":    name,
+					"createtime":   nowTime,
+					"BCPCID":       common.GetRandom(32),
+					"operator_id":  positionId,
+				})
+			})
+		}
+	}
+	if data2 != nil && len(*data2) > 0 {
+		for _, v := range *data2 {
+			JyBiTidb.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				clueId := common.Int64All(v["clue_id"])
+				nowTime := time.Now().Format("2006-01-02 15:04:05")
+				seatNumber, name := getSeatNumber(positionId)
+				JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+					JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      0,
+					})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+				})
+			})
+		}
+	}
+	if data3 != nil && len(*data3) > 0 {
+		for _, v := range *data3 {
+			JyBiTidb.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+				clueId := common.Int64All(v["clue_id"])
+				nowTime := time.Now().Format("2006-01-02 15:04:05")
+				seatNumber, name := getSeatNumber(positionId)
+				JyBiMysql.ExecTx("领取线索等", func(tx *sql.Tx) bool {
+					JyBiTidb.UpdateByTx(tx, "dwd_f_crm_clue_info", map[string]interface{}{"id": clue_id}, map[string]interface{}{"position_id": positionId, "seatNumber": seatNumber})
+					JyBiTidb.DeleteByTx(tx, "dwd_f_crm_open_sea", map[string]interface{}{"id": clue_id})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_private_sea", map[string]interface{}{
+						"clue_id":      clueId,
+						"seatNumber":   seatNumber,
+						"position_id":  positionId,
+						"comeintime":   nowTime,
+						"comeinsource": 3,
+						"is_task":      0,
+					})
+					JyBiTidb.InsertByTx(tx, "dwd_f_crm_clue_change_record", map[string]interface{}{
+						"clue_id":      clueId,
+						"position_id":  positionId,
+						"change_field": "position_id",
+						"change_type":  "所属人变更",
+						"old_value":    "/",
+						"new_value":    name,
+						"createtime":   nowTime,
+						"BCPCID":       common.GetRandom(32),
+						"operator_id":  positionId,
+					})
+				})
+			})
+		}
+	}
+}
+
+func getSeatNumber(positionId int64) (seatNumber, name string) {
+	positionData := JyTidb.FindOne("base_position", map[string]interface{}{"id": positionId}, "", "")
+	if positionData != nil && len(*positionData) > 0 {
+		userId := common.Int64All((*positionData)["user_id"])
+		if userId > 0 {
+			userData := Mgo.FindOne("user", map[string]interface{}{"base_user_id": userId})
+			if userData != nil && len(*userData) > 0 {
+				s_phone := common.ObjToString((*userData)["s_phone"])
+				if s_phone == "" {
+					s_phone = common.ObjToString((*userData)["s_m_phone"])
+				}
+				saleData := JyBiTidb.FindOne("jy_salesperson_info", map[string]interface{}{"phone": s_phone}, "", "")
+				if saleData != nil && len(*saleData) > 0 {
+					seatNumber = common.ObjToString((*saleData)["seatNumber"])
+					name = common.ObjToString((*saleData)["name"])
+				}
+			}
+		}
+	}
+	return
+}