WH01243 4 年之前
父節點
當前提交
f1dc1225ba

+ 1 - 1
rpc/userlib/etc/userlib.yaml

@@ -2,7 +2,7 @@ Name: jydocs.userlib.rpc
 ListenOn: 127.0.0.1:8081
 ListenOn: 127.0.0.1:8081
 Etcd:
 Etcd:
   Hosts:
   Hosts:
-    - 192.168.3.240:2379
+    - 127.0.0.1:2379
   Key: jydocs.userlib.rpc
   Key: jydocs.userlib.rpc
 JyDocsMysqlDB:
 JyDocsMysqlDB:
   DriverName: "mysql"
   DriverName: "mysql"

+ 1 - 0
rpc/userlib/internal/logic/doccollectlogic.go

@@ -32,6 +32,7 @@ func (l *DocCollectLogic) DocCollect(in *userlib.UserCollectRequest) (*userlib.U
 		&model.UserDoc{
 		&model.UserDoc{
 			UserId:          in.UserId,
 			UserId:          in.UserId,
 			DocId:           in.DocId,
 			DocId:           in.DocId,
+
 			DocCategory:     int(in.DocCategory),
 			DocCategory:     int(in.DocCategory),
 			IsDelete:        int(userlib.UserDocStatus_Normal),
 			IsDelete:        int(userlib.UserDocStatus_Normal),
 			DocName:         in.DocName,
 			DocName:         in.DocName,

+ 49 - 0
rpc/userlib/internal/logic/docdownloadlogic.go

@@ -0,0 +1,49 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jydocs/rpc/userlib/internal/svc"
+	"app.yhyue.com/moapp/jydocs/rpc/userlib/userlib"
+	"app.yhyue.com/moapp/jydocs/services/model"
+	userLibService "app.yhyue.com/moapp/jydocs/services/userlib"
+	"context"
+	"log"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type DocDownloadLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDocDownloadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocDownloadLogic {
+	return &DocDownloadLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+//转存操作
+func (l *DocDownloadLogic) DocDownload(in *userlib.UserCollectRequest) (*userlib.UserCollectResponse, error) {
+	b := userLibService.UserDocDownload(
+		&model.UserDoc{
+			UserId:          in.UserId,
+			DocId:           in.DocId,
+			DocCategory:     int(in.DocCategory),
+			IsDelete:        int(userlib.UserDocStatus_Normal),
+			DocName:         in.DocName,
+			DocFileType:     int(in.DocFileType),
+			DocFileSuffix:   in.DocFileSuffix,
+			DocFileSize:     int(in.DocFileSize),
+			DocPageSize:     int(in.DocPageSize),
+			DocSummary:      in.DocSummary,
+			DocSourceUserId: in.SourceUserId,
+		}, int(in.Cost))
+	log.Printf("用户文档收藏,userId:[%s],docId:[%s] 是否成功:[%v]", in.UserId, in.DocId, b)
+	return &userlib.UserCollectResponse{
+		Code:    200,
+		Message: "success",
+	}, nil
+	return &userlib.UserCollectResponse{}, nil
+}

+ 30 - 0
rpc/userlib/internal/logic/docrecyclelogic.go

@@ -0,0 +1,30 @@
+package logic
+
+import (
+	"context"
+
+	"app.yhyue.com/moapp/jydocs/rpc/userlib/internal/svc"
+	"app.yhyue.com/moapp/jydocs/rpc/userlib/userlib"
+
+	"github.com/tal-tech/go-zero/core/logx"
+)
+
+type DocRecycleLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewDocRecycleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocRecycleLogic {
+	return &DocRecycleLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+func (l *DocRecycleLogic) DocRecycle(in *userlib.UserRecoveryRequest) (*userlib.UserCollectResponse, error) {
+	// todo: add your logic here and delete this line
+
+	return &userlib.UserCollectResponse{}, nil
+}

+ 10 - 0
rpc/userlib/internal/server/userlibserver.go

@@ -40,3 +40,13 @@ func (s *UserLibServer) DocRestore(ctx context.Context, in *userlib.UserRestoreR
 	l := logic.NewDocRestoreLogic(ctx, s.svcCtx)
 	l := logic.NewDocRestoreLogic(ctx, s.svcCtx)
 	return l.DocRestore(in)
 	return l.DocRestore(in)
 }
 }
+//转存
+func (s *UserLibServer) DocDownload(ctx context.Context, in *userlib.UserCollectRequest) (*userlib.UserCollectResponse, error) {
+	l := logic.NewDocDownloadLogic(ctx, s.svcCtx)
+	return l.DocDownload(in)
+}
+//回收站
+func (s *UserLibServer) DocRecycle(ctx context.Context, in *userlib.UserRecoveryRequest) (*userlib.UserCollectResponse, error) {
+	l := logic.NewDocRecycleLogic(ctx, s.svcCtx)
+	return l.DocRecycle(in)
+}

+ 27 - 1
rpc/userlib/test/userLib_test.go

@@ -24,7 +24,7 @@ func Test_UserDocCollect(t *testing.T) {
 		UserId:       "1",
 		UserId:       "1",
 		SourceUserId: "2",
 		SourceUserId: "2",
 		DocName:      "2020招标文件白皮书.docx",
 		DocName:      "2020招标文件白皮书.docx",
-		DocFileType:  userlib.UserDocFileType_Doc,
+		DocFileType:  userlib.UserDocFileType_Word,
 		DocFileSize:  1002,
 		DocFileSize:  1002,
 		DocPageSize:  20,
 		DocPageSize:  20,
 		DocCategory:  userlib.UserDocCategory_Collect,
 		DocCategory:  userlib.UserDocCategory_Collect,
@@ -36,3 +36,29 @@ func Test_UserDocCollect(t *testing.T) {
 	}
 	}
 	log.Print("UserDoc Collect call response:", resp)
 	log.Print("UserDoc Collect call response:", resp)
 }
 }
+//用户转存单元测试
+func Test_UserDocDwnload(t *testing.T) {
+	client := zrpc.MustNewClient(zrpc.RpcClientConf{
+		Etcd: discov.EtcdConf{
+			Hosts: []string{"127.0.0.1:2379"},
+			Key:   "jydocs.userlib.rpc",
+		},
+	})
+	userLib := userlibclient.NewUserLib(client)
+	resp, err := userLib.DocDownload(context.Background(), &userlibclient.UserCollectRequest{
+		DocId:        "1",
+		UserId:       "wh5",
+		SourceUserId: "2",
+		DocName:      "2020招标文件白皮书.docx",
+		DocFileType:  userlib.UserDocFileType_Word,
+		DocFileSize:  1002,
+		DocPageSize:  20,
+		DocCategory:  userlib.UserDocCategory_Collect,
+		DocFileSuffix:"docx",
+		Cost:100,
+	})
+	if err != nil {
+		log.Println("UserDoc Collect call error:", err)
+	}
+	log.Print("UserDoc Collect call response:", resp)
+}

+ 10 - 2
rpc/userlib/userlib.proto

@@ -15,7 +15,6 @@ enum UserDocFileType {
     PPT =3;
     PPT =3;
     TXT =4;
     TXT =4;
   Other =5;
   Other =5;
-}
 
 
 
 
 
 
@@ -82,10 +81,19 @@ message UserDoc {
     string docName=3;
     string docName=3;
 }
 }
 
 
-
+//回收站操作1进入回收站2永久删除3删除改为未删除
+message UserRecoveryRequest {
+    string userId=1; //用户id
+    string docId=2; //文档id
+    string id =3;   //记录标识
+    UserDocStatus   userDocStatus=4;//记录状态
+}
 service  UserLib {
 service  UserLib {
     rpc UserDocs(UserDocsRequest) returns (UserDocsResponse);//用户文档列表
     rpc UserDocs(UserDocsRequest) returns (UserDocsResponse);//用户文档列表
   	rpc DocCollect(UserCollectRequest) returns(UserCollectResponse); //文档收藏
   	rpc DocCollect(UserCollectRequest) returns(UserCollectResponse); //文档收藏
 	rpc DocDelete(UserDeleteRequest) returns(UserDeleteResponse); //文档删除
 	rpc DocDelete(UserDeleteRequest) returns(UserDeleteResponse); //文档删除
 	rpc DocRestore(UserRestoreRequest) returns(UserRestoreResponse); //文档恢复
 	rpc DocRestore(UserRestoreRequest) returns(UserRestoreResponse); //文档恢复
+	rpc DocDownload(UserCollectRequest) returns(UserCollectResponse); //文档转存
+	rpc DocRecycle(UserRecoveryRequest
+	) returns(UserCollectResponse); //回收站
 }
 }

+ 242 - 61
rpc/userlib/userlib/userlib.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
 // versions:
 // 	protoc-gen-go v1.25.0
 // 	protoc-gen-go v1.25.0
-// 	protoc        v3.15.5
+// 	protoc        v3.15.1
 // source: userlib.proto
 // source: userlib.proto
 
 
 package userlib
 package userlib
@@ -83,30 +83,30 @@ func (UserDocCategory) EnumDescriptor() ([]byte, []int) {
 type UserDocFileType int32
 type UserDocFileType int32
 
 
 const (
 const (
-	UserDocFileType_Doc   UserDocFileType = 0
-	UserDocFileType_Pdf   UserDocFileType = 1
-	UserDocFileType_Xls   UserDocFileType = 2
-	UserDocFileType_Ppt   UserDocFileType = 3
-	UserDocFileType_Txt   UserDocFileType = 4
+	UserDocFileType_Word  UserDocFileType = 0
+	UserDocFileType_PDF   UserDocFileType = 1
+	UserDocFileType_EXCEL UserDocFileType = 2
+	UserDocFileType_PPT   UserDocFileType = 3
+	UserDocFileType_TXT   UserDocFileType = 4
 	UserDocFileType_Other UserDocFileType = 5
 	UserDocFileType_Other UserDocFileType = 5
 )
 )
 
 
 // Enum value maps for UserDocFileType.
 // Enum value maps for UserDocFileType.
 var (
 var (
 	UserDocFileType_name = map[int32]string{
 	UserDocFileType_name = map[int32]string{
-		0: "Doc",
-		1: "Pdf",
-		2: "Xls",
-		3: "Ppt",
-		4: "Txt",
+		0: "Word",
+		1: "PDF",
+		2: "EXCEL",
+		3: "PPT",
+		4: "TXT",
 		5: "Other",
 		5: "Other",
 	}
 	}
 	UserDocFileType_value = map[string]int32{
 	UserDocFileType_value = map[string]int32{
-		"Doc":   0,
-		"Pdf":   1,
-		"Xls":   2,
-		"Ppt":   3,
-		"Txt":   4,
+		"Word":  0,
+		"PDF":   1,
+		"EXCEL": 2,
+		"PPT":   3,
+		"TXT":   4,
 		"Other": 5,
 		"Other": 5,
 	}
 	}
 )
 )
@@ -277,7 +277,7 @@ func (x *UserCollectRequest) GetDocFileType() UserDocFileType {
 	if x != nil {
 	if x != nil {
 		return x.DocFileType
 		return x.DocFileType
 	}
 	}
-	return UserDocFileType_Doc
+	return UserDocFileType_Word
 }
 }
 
 
 func (x *UserCollectRequest) GetDocFileSuffix() string {
 func (x *UserCollectRequest) GetDocFileSuffix() string {
@@ -758,6 +758,78 @@ func (x *UserDoc) GetDocName() string {
 	return ""
 	return ""
 }
 }
 
 
+//回收站操作1进入回收站2永久删除3删除改为未删除
+type UserRecoveryRequest struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	UserId        string        `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"`                                           //用户id
+	DocId         string        `protobuf:"bytes,2,opt,name=docId,proto3" json:"docId,omitempty"`                                             //文档id
+	Id            string        `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"`                                                   //记录标识
+	UserDocStatus UserDocStatus `protobuf:"varint,4,opt,name=userDocStatus,proto3,enum=userlib.UserDocStatus" json:"userDocStatus,omitempty"` //记录状态
+}
+
+func (x *UserRecoveryRequest) Reset() {
+	*x = UserRecoveryRequest{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_userlib_proto_msgTypes[9]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *UserRecoveryRequest) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*UserRecoveryRequest) ProtoMessage() {}
+
+func (x *UserRecoveryRequest) ProtoReflect() protoreflect.Message {
+	mi := &file_userlib_proto_msgTypes[9]
+	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 UserRecoveryRequest.ProtoReflect.Descriptor instead.
+func (*UserRecoveryRequest) Descriptor() ([]byte, []int) {
+	return file_userlib_proto_rawDescGZIP(), []int{9}
+}
+
+func (x *UserRecoveryRequest) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+func (x *UserRecoveryRequest) GetDocId() string {
+	if x != nil {
+		return x.DocId
+	}
+	return ""
+}
+
+func (x *UserRecoveryRequest) GetId() string {
+	if x != nil {
+		return x.Id
+	}
+	return ""
+}
+
+func (x *UserRecoveryRequest) GetUserDocStatus() UserDocStatus {
+	if x != nil {
+		return x.UserDocStatus
+	}
+	return UserDocStatus_Normal
+}
+
 var File_userlib_proto protoreflect.FileDescriptor
 var File_userlib_proto protoreflect.FileDescriptor
 
 
 var file_userlib_proto_rawDesc = []byte{
 var file_userlib_proto_rawDesc = []byte{
@@ -825,38 +897,57 @@ var file_userlib_proto_rawDesc = []byte{
 	0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
 	0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
 	0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x6f, 0x63, 0x4e, 0x61, 0x6d,
 	0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x64, 0x6f, 0x63, 0x4e, 0x61, 0x6d,
 	0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65,
 	0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x64, 0x6f, 0x63, 0x4e, 0x61, 0x6d, 0x65,
-	0x2a, 0x3c, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61, 0x74, 0x65, 0x67,
-	0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x65, 0x6c, 0x66, 0x55, 0x70, 0x6c, 0x6f, 0x61,
-	0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x10,
-	0x01, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x10, 0x02, 0x2a, 0x49,
-	0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x46, 0x69, 0x6c, 0x65, 0x54, 0x79, 0x70,
-	0x65, 0x12, 0x07, 0x0a, 0x03, 0x44, 0x6f, 0x63, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x64,
-	0x66, 0x10, 0x01, 0x12, 0x07, 0x0a, 0x03, 0x58, 0x6c, 0x73, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03,
-	0x50, 0x70, 0x74, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x54, 0x78, 0x74, 0x10, 0x04, 0x12, 0x09,
-	0x0a, 0x05, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x10, 0x05, 0x2a, 0x43, 0x0a, 0x0d, 0x55, 0x73, 0x65,
-	0x72, 0x44, 0x6f, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x6f,
-	0x72, 0x6d, 0x61, 0x6c, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x44,
-	0x65, 0x6c, 0x65, 0x74, 0x65, 0x10, 0x01, 0x12, 0x15, 0x0a, 0x11, 0x50, 0x65, 0x72, 0x6d, 0x61,
-	0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x10, 0x02, 0x32, 0xa2,
-	0x02, 0x0a, 0x07, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x62, 0x12, 0x3f, 0x0a, 0x08, 0x55, 0x73,
-	0x65, 0x72, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62,
-	0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
-	0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44,
-	0x6f, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x44,
-	0x6f, 0x63, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72,
+	0x22, 0x91, 0x01, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72,
+	0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72,
+	0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64,
+	0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x3c, 0x0a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f,
+	0x63, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x16, 0x2e,
+	0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x53,
+	0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x53, 0x74,
+	0x61, 0x74, 0x75, 0x73, 0x2a, 0x3c, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43,
+	0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x65, 0x6c, 0x66, 0x55,
+	0x70, 0x6c, 0x6f, 0x61, 0x64, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x44, 0x6f, 0x77, 0x6e, 0x6c,
+	0x6f, 0x61, 0x64, 0x10, 0x01, 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
+	0x10, 0x02, 0x2a, 0x4c, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x46, 0x69, 0x6c,
+	0x65, 0x54, 0x79, 0x70, 0x65, 0x12, 0x08, 0x0a, 0x04, 0x57, 0x6f, 0x72, 0x64, 0x10, 0x00, 0x12,
+	0x07, 0x0a, 0x03, 0x50, 0x44, 0x46, 0x10, 0x01, 0x12, 0x09, 0x0a, 0x05, 0x45, 0x58, 0x43, 0x45,
+	0x4c, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x50, 0x50, 0x54, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03,
+	0x54, 0x58, 0x54, 0x10, 0x04, 0x12, 0x09, 0x0a, 0x05, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x10, 0x05,
+	0x2a, 0x43, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x53, 0x74, 0x61, 0x74, 0x75,
+	0x73, 0x12, 0x0a, 0x0a, 0x06, 0x4e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x10, 0x00, 0x12, 0x0f, 0x0a,
+	0x0b, 0x4c, 0x6f, 0x67, 0x69, 0x63, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x10, 0x01, 0x12, 0x15,
+	0x0a, 0x11, 0x50, 0x65, 0x72, 0x6d, 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x6c, 0x79, 0x44, 0x65, 0x6c,
+	0x65, 0x74, 0x65, 0x10, 0x02, 0x32, 0xb6, 0x03, 0x0a, 0x07, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69,
+	0x62, 0x12, 0x3f, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73, 0x12, 0x18, 0x2e,
+	0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73,
+	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69,
+	0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x44, 0x6f, 0x63, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
+	0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43,
+	0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e,
+	0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c,
+	0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x09, 0x44,
+	0x6f, 0x63, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c,
+	0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71,
+	0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55,
+	0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
+	0x65, 0x12, 0x47, 0x0a, 0x0a, 0x44, 0x6f, 0x63, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12,
+	0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
+	0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75,
+	0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f,
+	0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0b, 0x44, 0x6f,
+	0x63, 0x44, 0x6f, 0x77, 0x6e, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72,
 	0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52,
 	0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52,
 	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62,
 	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62,
 	0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70,
 	0x2e, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70,
-	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x09, 0x44, 0x6f, 0x63, 0x44, 0x65, 0x6c, 0x65, 0x74,
-	0x65, 0x12, 0x1a, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72,
-	0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e,
-	0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65,
-	0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x47, 0x0a, 0x0a, 0x44, 0x6f,
-	0x63, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x12, 0x1b, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c,
-	0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65,
-	0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e,
-	0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
-	0x6e, 0x73, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x6f, 0x6e, 0x73, 0x65, 0x12, 0x48, 0x0a, 0x0a, 0x44, 0x6f, 0x63, 0x52, 0x65, 0x63, 0x79, 0x63,
+	0x6c, 0x65, 0x12, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65,
+	0x72, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x1a, 0x1c, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x43,
+	0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x62, 0x06,
+	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 }
 
 
 var (
 var (
@@ -872,7 +963,7 @@ func file_userlib_proto_rawDescGZIP() []byte {
 }
 }
 
 
 var file_userlib_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
 var file_userlib_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
-var file_userlib_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
+var file_userlib_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
 var file_userlib_proto_goTypes = []interface{}{
 var file_userlib_proto_goTypes = []interface{}{
 	(UserDocCategory)(0),        // 0: userlib.UserDocCategory
 	(UserDocCategory)(0),        // 0: userlib.UserDocCategory
 	(UserDocFileType)(0),        // 1: userlib.UserDocFileType
 	(UserDocFileType)(0),        // 1: userlib.UserDocFileType
@@ -886,25 +977,31 @@ var file_userlib_proto_goTypes = []interface{}{
 	(*UserDocsRequest)(nil),     // 9: userlib.UserDocsRequest
 	(*UserDocsRequest)(nil),     // 9: userlib.UserDocsRequest
 	(*UserDocsResponse)(nil),    // 10: userlib.UserDocsResponse
 	(*UserDocsResponse)(nil),    // 10: userlib.UserDocsResponse
 	(*UserDoc)(nil),             // 11: userlib.UserDoc
 	(*UserDoc)(nil),             // 11: userlib.UserDoc
+	(*UserRecoveryRequest)(nil), // 12: userlib.UserRecoveryRequest
 }
 }
 var file_userlib_proto_depIdxs = []int32{
 var file_userlib_proto_depIdxs = []int32{
 	0,  // 0: userlib.UserCollectRequest.docCategory:type_name -> userlib.UserDocCategory
 	0,  // 0: userlib.UserCollectRequest.docCategory:type_name -> userlib.UserDocCategory
 	1,  // 1: userlib.UserCollectRequest.docFileType:type_name -> userlib.UserDocFileType
 	1,  // 1: userlib.UserCollectRequest.docFileType:type_name -> userlib.UserDocFileType
 	0,  // 2: userlib.UserDocsRequest.userDocCategory:type_name -> userlib.UserDocCategory
 	0,  // 2: userlib.UserDocsRequest.userDocCategory:type_name -> userlib.UserDocCategory
 	11, // 3: userlib.UserDocsResponse.docs:type_name -> userlib.UserDoc
 	11, // 3: userlib.UserDocsResponse.docs:type_name -> userlib.UserDoc
-	9,  // 4: userlib.UserLib.UserDocs:input_type -> userlib.UserDocsRequest
-	3,  // 5: userlib.UserLib.DocCollect:input_type -> userlib.UserCollectRequest
-	5,  // 6: userlib.UserLib.DocDelete:input_type -> userlib.UserDeleteRequest
-	7,  // 7: userlib.UserLib.DocRestore:input_type -> userlib.UserRestoreRequest
-	10, // 8: userlib.UserLib.UserDocs:output_type -> userlib.UserDocsResponse
-	4,  // 9: userlib.UserLib.DocCollect:output_type -> userlib.UserCollectResponse
-	6,  // 10: userlib.UserLib.DocDelete:output_type -> userlib.UserDeleteResponse
-	8,  // 11: userlib.UserLib.DocRestore:output_type -> userlib.UserRestoreResponse
-	8,  // [8:12] is the sub-list for method output_type
-	4,  // [4:8] is the sub-list for method input_type
-	4,  // [4:4] is the sub-list for extension type_name
-	4,  // [4:4] is the sub-list for extension extendee
-	0,  // [0:4] is the sub-list for field type_name
+	2,  // 4: userlib.UserRecoveryRequest.userDocStatus:type_name -> userlib.UserDocStatus
+	9,  // 5: userlib.UserLib.UserDocs:input_type -> userlib.UserDocsRequest
+	3,  // 6: userlib.UserLib.DocCollect:input_type -> userlib.UserCollectRequest
+	5,  // 7: userlib.UserLib.DocDelete:input_type -> userlib.UserDeleteRequest
+	7,  // 8: userlib.UserLib.DocRestore:input_type -> userlib.UserRestoreRequest
+	3,  // 9: userlib.UserLib.DocDownload:input_type -> userlib.UserCollectRequest
+	12, // 10: userlib.UserLib.DocRecycle:input_type -> userlib.UserRecoveryRequest
+	10, // 11: userlib.UserLib.UserDocs:output_type -> userlib.UserDocsResponse
+	4,  // 12: userlib.UserLib.DocCollect:output_type -> userlib.UserCollectResponse
+	6,  // 13: userlib.UserLib.DocDelete:output_type -> userlib.UserDeleteResponse
+	8,  // 14: userlib.UserLib.DocRestore:output_type -> userlib.UserRestoreResponse
+	4,  // 15: userlib.UserLib.DocDownload:output_type -> userlib.UserCollectResponse
+	4,  // 16: userlib.UserLib.DocRecycle:output_type -> userlib.UserCollectResponse
+	11, // [11:17] is the sub-list for method output_type
+	5,  // [5:11] is the sub-list for method input_type
+	5,  // [5:5] is the sub-list for extension 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_userlib_proto_init() }
 func init() { file_userlib_proto_init() }
@@ -1021,6 +1118,18 @@ func file_userlib_proto_init() {
 				return nil
 				return nil
 			}
 			}
 		}
 		}
+		file_userlib_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*UserRecoveryRequest); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	}
 	type x struct{}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
 	out := protoimpl.TypeBuilder{
@@ -1028,7 +1137,7 @@ func file_userlib_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_userlib_proto_rawDesc,
 			RawDescriptor: file_userlib_proto_rawDesc,
 			NumEnums:      3,
 			NumEnums:      3,
-			NumMessages:   9,
+			NumMessages:   10,
 			NumExtensions: 0,
 			NumExtensions: 0,
 			NumServices:   1,
 			NumServices:   1,
 		},
 		},
@@ -1059,6 +1168,8 @@ type UserLibClient interface {
 	DocCollect(ctx context.Context, in *UserCollectRequest, opts ...grpc.CallOption) (*UserCollectResponse, error)
 	DocCollect(ctx context.Context, in *UserCollectRequest, opts ...grpc.CallOption) (*UserCollectResponse, error)
 	DocDelete(ctx context.Context, in *UserDeleteRequest, opts ...grpc.CallOption) (*UserDeleteResponse, error)
 	DocDelete(ctx context.Context, in *UserDeleteRequest, opts ...grpc.CallOption) (*UserDeleteResponse, error)
 	DocRestore(ctx context.Context, in *UserRestoreRequest, opts ...grpc.CallOption) (*UserRestoreResponse, error)
 	DocRestore(ctx context.Context, in *UserRestoreRequest, opts ...grpc.CallOption) (*UserRestoreResponse, error)
+	DocDownload(ctx context.Context, in *UserCollectRequest, opts ...grpc.CallOption) (*UserCollectResponse, error)
+	DocRecycle(ctx context.Context, in *UserRecoveryRequest, opts ...grpc.CallOption) (*UserCollectResponse, error)
 }
 }
 
 
 type userLibClient struct {
 type userLibClient struct {
@@ -1105,12 +1216,32 @@ func (c *userLibClient) DocRestore(ctx context.Context, in *UserRestoreRequest,
 	return out, nil
 	return out, nil
 }
 }
 
 
+func (c *userLibClient) DocDownload(ctx context.Context, in *UserCollectRequest, opts ...grpc.CallOption) (*UserCollectResponse, error) {
+	out := new(UserCollectResponse)
+	err := c.cc.Invoke(ctx, "/userlib.UserLib/DocDownload", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *userLibClient) DocRecycle(ctx context.Context, in *UserRecoveryRequest, opts ...grpc.CallOption) (*UserCollectResponse, error) {
+	out := new(UserCollectResponse)
+	err := c.cc.Invoke(ctx, "/userlib.UserLib/DocRecycle", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // UserLibServer is the server API for UserLib service.
 // UserLibServer is the server API for UserLib service.
 type UserLibServer interface {
 type UserLibServer interface {
 	UserDocs(context.Context, *UserDocsRequest) (*UserDocsResponse, error)
 	UserDocs(context.Context, *UserDocsRequest) (*UserDocsResponse, error)
 	DocCollect(context.Context, *UserCollectRequest) (*UserCollectResponse, error)
 	DocCollect(context.Context, *UserCollectRequest) (*UserCollectResponse, error)
 	DocDelete(context.Context, *UserDeleteRequest) (*UserDeleteResponse, error)
 	DocDelete(context.Context, *UserDeleteRequest) (*UserDeleteResponse, error)
 	DocRestore(context.Context, *UserRestoreRequest) (*UserRestoreResponse, error)
 	DocRestore(context.Context, *UserRestoreRequest) (*UserRestoreResponse, error)
+	DocDownload(context.Context, *UserCollectRequest) (*UserCollectResponse, error)
+	DocRecycle(context.Context, *UserRecoveryRequest) (*UserCollectResponse, error)
 }
 }
 
 
 // UnimplementedUserLibServer can be embedded to have forward compatible implementations.
 // UnimplementedUserLibServer can be embedded to have forward compatible implementations.
@@ -1129,6 +1260,12 @@ func (*UnimplementedUserLibServer) DocDelete(context.Context, *UserDeleteRequest
 func (*UnimplementedUserLibServer) DocRestore(context.Context, *UserRestoreRequest) (*UserRestoreResponse, error) {
 func (*UnimplementedUserLibServer) DocRestore(context.Context, *UserRestoreRequest) (*UserRestoreResponse, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method DocRestore not implemented")
 	return nil, status.Errorf(codes.Unimplemented, "method DocRestore not implemented")
 }
 }
+func (*UnimplementedUserLibServer) DocDownload(context.Context, *UserCollectRequest) (*UserCollectResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DocDownload not implemented")
+}
+func (*UnimplementedUserLibServer) DocRecycle(context.Context, *UserRecoveryRequest) (*UserCollectResponse, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method DocRecycle not implemented")
+}
 
 
 func RegisterUserLibServer(s *grpc.Server, srv UserLibServer) {
 func RegisterUserLibServer(s *grpc.Server, srv UserLibServer) {
 	s.RegisterService(&_UserLib_serviceDesc, srv)
 	s.RegisterService(&_UserLib_serviceDesc, srv)
@@ -1206,6 +1343,42 @@ func _UserLib_DocRestore_Handler(srv interface{}, ctx context.Context, dec func(
 	return interceptor(ctx, in, info, handler)
 	return interceptor(ctx, in, info, handler)
 }
 }
 
 
+func _UserLib_DocDownload_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(UserCollectRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(UserLibServer).DocDownload(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/userlib.UserLib/DocDownload",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(UserLibServer).DocDownload(ctx, req.(*UserCollectRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _UserLib_DocRecycle_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(UserRecoveryRequest)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(UserLibServer).DocRecycle(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/userlib.UserLib/DocRecycle",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(UserLibServer).DocRecycle(ctx, req.(*UserRecoveryRequest))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 var _UserLib_serviceDesc = grpc.ServiceDesc{
 var _UserLib_serviceDesc = grpc.ServiceDesc{
 	ServiceName: "userlib.UserLib",
 	ServiceName: "userlib.UserLib",
 	HandlerType: (*UserLibServer)(nil),
 	HandlerType: (*UserLibServer)(nil),
@@ -1226,6 +1399,14 @@ var _UserLib_serviceDesc = grpc.ServiceDesc{
 			MethodName: "DocRestore",
 			MethodName: "DocRestore",
 			Handler:    _UserLib_DocRestore_Handler,
 			Handler:    _UserLib_DocRestore_Handler,
 		},
 		},
+		{
+			MethodName: "DocDownload",
+			Handler:    _UserLib_DocDownload_Handler,
+		},
+		{
+			MethodName: "DocRecycle",
+			Handler:    _UserLib_DocRecycle_Handler,
+		},
 	},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "userlib.proto",
 	Metadata: "userlib.proto",

+ 18 - 5
rpc/userlib/userlibclient/userlib.go

@@ -14,21 +14,24 @@ import (
 )
 )
 
 
 type (
 type (
-	UserDocsRequest     = userlib.UserDocsRequest
-	UserDoc             = userlib.UserDoc
+	UserCollectRequest  = userlib.UserCollectRequest
+	UserCollectResponse = userlib.UserCollectResponse
 	UserRestoreRequest  = userlib.UserRestoreRequest
 	UserRestoreRequest  = userlib.UserRestoreRequest
 	UserRestoreResponse = userlib.UserRestoreResponse
 	UserRestoreResponse = userlib.UserRestoreResponse
+	UserDocsResponse    = userlib.UserDocsResponse
+	UserDoc             = userlib.UserDoc
 	UserDeleteRequest   = userlib.UserDeleteRequest
 	UserDeleteRequest   = userlib.UserDeleteRequest
 	UserDeleteResponse  = userlib.UserDeleteResponse
 	UserDeleteResponse  = userlib.UserDeleteResponse
-	UserDocsResponse    = userlib.UserDocsResponse
-	UserCollectRequest  = userlib.UserCollectRequest
-	UserCollectResponse = userlib.UserCollectResponse
+	UserDocsRequest     = userlib.UserDocsRequest
+	UserRecoveryRequest = userlib.UserRecoveryRequest
 
 
 	UserLib interface {
 	UserLib interface {
 		UserDocs(ctx context.Context, in *UserDocsRequest) (*UserDocsResponse, error)
 		UserDocs(ctx context.Context, in *UserDocsRequest) (*UserDocsResponse, error)
 		DocCollect(ctx context.Context, in *UserCollectRequest) (*UserCollectResponse, error)
 		DocCollect(ctx context.Context, in *UserCollectRequest) (*UserCollectResponse, error)
 		DocDelete(ctx context.Context, in *UserDeleteRequest) (*UserDeleteResponse, error)
 		DocDelete(ctx context.Context, in *UserDeleteRequest) (*UserDeleteResponse, error)
 		DocRestore(ctx context.Context, in *UserRestoreRequest) (*UserRestoreResponse, error)
 		DocRestore(ctx context.Context, in *UserRestoreRequest) (*UserRestoreResponse, error)
+		DocDownload(ctx context.Context, in *UserCollectRequest) (*UserCollectResponse, error)
+		DocRecycle(ctx context.Context, in *UserRecoveryRequest) (*UserCollectResponse, error)
 	}
 	}
 
 
 	defaultUserLib struct {
 	defaultUserLib struct {
@@ -61,3 +64,13 @@ func (m *defaultUserLib) DocRestore(ctx context.Context, in *UserRestoreRequest)
 	client := userlib.NewUserLibClient(m.cli.Conn())
 	client := userlib.NewUserLibClient(m.cli.Conn())
 	return client.DocRestore(ctx, in)
 	return client.DocRestore(ctx, in)
 }
 }
+
+func (m *defaultUserLib) DocDownload(ctx context.Context, in *UserCollectRequest) (*UserCollectResponse, error) {
+	client := userlib.NewUserLibClient(m.cli.Conn())
+	return client.DocDownload(ctx, in)
+}
+
+func (m *defaultUserLib) DocRecycle(ctx context.Context, in *UserRecoveryRequest) (*UserCollectResponse, error) {
+	client := userlib.NewUserLibClient(m.cli.Conn())
+	return client.DocRecycle(ctx, in)
+}

+ 10 - 1
services/model/base_model.go

@@ -6,8 +6,17 @@ import (
 )
 )
 
 
 type BaseModel struct {
 type BaseModel struct {
-	ID         int            `json:"id" form:"id" gorm:"primaryKey"`
+	ID        int            `json:"id" form:"id" gorm:"primaryKey"`
 	CreateAt  time.Time      `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
 	CreateAt  time.Time      `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
 	UpdateAt  time.Time      `json:"-" gorm:"autoUpdateTime"`
 	UpdateAt  time.Time      `json:"-" gorm:"autoUpdateTime"`
 	DeletedAt gorm.DeletedAt `json:"-" gorm:"column:delete_at"`
 	DeletedAt gorm.DeletedAt `json:"-" gorm:"column:delete_at"`
 }
 }
+
+const (
+	UserDocStatus_Normal            = 0 //文件正常
+	UserDocStatus_LogicDelete       = 1 //删除
+	UserDocStatus_PermanentlyDelete = 2 //永久删除
+	UserDocCategory_SelfUpload      = 0 //自己上传
+	UserDocCategory_Download        = 1 //转存(下载)
+	UserDocCategory_Collect         = 2 //收藏
+)

+ 45 - 34
services/model/stdlib.go

@@ -1,28 +1,35 @@
 package model
 package model
 
 
+import (
+	"time"
+)
+
 type UserMoneyRecord struct {
 type UserMoneyRecord struct {
-	Id               string `json:"id"`
-	UserId           string `json:"userId"`
-	DocName          string `json:"before"`
-	DocFileType      int    `json:"docFileType"`
-	DocFileSuffix    string `json:"docFileSuffix"`
-	DocFileSize      int    `json:"docFileSize"`
-	DocPageSize      int    `json:"docPageSize"`
-	DocTags          string `json:"docTags"`
-	DocClassLevelOne string `json:"docClassLevelOne"`
-	DocClassLevelTwo string `json:"docClassLevelTwo"`
-	UploadDate       string `json:"uploadDate"`
-	IsDelete         int    `json:"isDelete"`
-	OssDocId         string `json:"ossDocId"`
-	OssDocUrl        string `json:"ossDocUrl"`
-	Md5              string `json:"md5"`
-	OssPdfId         string `json:"ossPdfId"`
-	OssPdfUrl        string `json:"ossPdfUrl"`
-	OssTxtId         string `json:"ossTxtId"`
-	OssTxtUrl        string `json:"ossTxtUrl"`
-	Price            int    `json:"price"`
-	DownOrUp         int    `json:"downOrUp"`
-	DocSummary       string `json:"docSummary"`
+	Id               string    `json:"id"`
+	UserId           string    `json:"userId"`
+	DocName          string    `json:"before"`
+	DocFileType      int       `json:"docFileType"`
+	DocFileSuffix    string    `json:"docFileSuffix"`
+	DocFileSize      int       `json:"docFileSize"`
+	DocPageSize      int       `json:"docPageSize"`
+	DocTags          string    `json:"docTags"`
+	DocClassLevelOne string    `json:"docClassLevelOne"`
+	DocClassLevelTwo string    `json:"docClassLevelTwo"`
+	UploadDate       string    `json:"uploadDate"`
+	IsDelete         int       `json:"isDelete"`
+	OssDocId         string    `json:"ossDocId"`
+	OssDocUrl        string    `json:"ossDocUrl"`
+	Md5              string    `json:"md5"`
+	OssPdfId         string    `json:"ossPdfId"`
+	OssPdfUrl        string    `json:"ossPdfUrl"`
+	OssTxtId         string    `json:"ossTxtId"`
+	OssTxtUrl        string    `json:"ossTxtUrl"`
+	Price            int       `json:"price"`
+	DownOrUp         int       `json:"downOrUp"`
+	DocSummary       string    `json:"docSummary"`
+	CreateAt         time.Time `json:"-" gorm:"autoCreateTime"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
+	UpdateAt         time.Time `json:"-" gorm:"autoUpdateTime"`
+	DeletedAt        time.Time `json:"-" gorm:"column:delete_at"`
 }
 }
 
 
 func (ud *UserMoneyRecord) TableName() string {
 func (ud *UserMoneyRecord) TableName() string {
@@ -30,18 +37,22 @@ func (ud *UserMoneyRecord) TableName() string {
 }
 }
 
 
 type UserDoc struct {
 type UserDoc struct {
-	BaseModel
-	UserId          string `json:"user_id"  gorm:"column:userId"`
-	DocId           string `json:"doc_id" gorm:"column:docId"`
-	DocCategory     int    `json:"doc_category" gorm:"column:docCategory"`
-	IsDelete        int    `json:"is_delete" gorm:"column:isDelete"`
-	DocName         string `json:"doc_name" gorm:"column:docName"`
-	DocFileType     int    `json:"doc_file_type" gorm:"column:docFileType"`
-	DocFileSuffix   string `json:"doc_file_suffix" gorm:"column:docFileSuffix"`
-	DocFileSize     int    `json:"doc_file_size" gorm:"column:docFileSize"`
-	DocPageSize     int    `json:"doc_page_size" gorm:"column:docPageSize"`
-	DocSummary      string `json:"doc_summary" gorm:"column:docSummary"`
-	DocSourceUserId string `json:"doc_source_user_id" gorm:"column:docSourceUserId"`
+	ID              int       `json:"id" form:"id" gorm:"primaryKey"`
+	CreateAt        time.Time `json:"create_at" gorm:"create_at"` //标签autoCreateTime设置如果字段名字不为CreatAt时候自动插入当前时间
+	UpdateAt        time.Time `json:"update_at" gorm:"update_at"`
+	DeletedAt       time.Time `json:"delete_at" gorm:"column:delete_at"`
+	Id              string    `json:"id"  gorm:"column:id"`
+	UserId          string    `json:"user_id"  gorm:"column:userId"`
+	DocId           string    `json:"doc_id" gorm:"column:docId"`
+	DocCategory     int       `json:"doc_category" gorm:"column:docCategory"`
+	IsDelete        int       `json:"is_delete" gorm:"column:isDelete"`
+	DocName         string    `json:"doc_name" gorm:"column:docName"`
+	DocFileType     int       `json:"doc_file_type" gorm:"column:docFileType"`
+	DocFileSuffix   string    `json:"doc_file_suffix" gorm:"column:docFileSuffix"`
+	DocFileSize     int       `json:"doc_file_size" gorm:"column:docFileSize"`
+	DocPageSize     int       `json:"doc_page_size" gorm:"column:docPageSize"`
+	DocSummary      string    `json:"doc_summary" gorm:"column:docSummary"`
+	DocSourceUserId string    `json:"doc_source_user_id" gorm:"column:docSourceUserId"`
 }
 }
 
 
 func (ud *UserDoc) TableName() string {
 func (ud *UserDoc) TableName() string {

+ 78 - 0
services/userlib/userDocService.go

@@ -1,10 +1,14 @@
 package userlib
 package userlib
 
 
 import (
 import (
+	"app.yhyue.com/moapp/jyPoints/rpc/integralclient"
 	"app.yhyue.com/moapp/jydocs/services/model"
 	"app.yhyue.com/moapp/jydocs/services/model"
 	docRpcUtil "app.yhyue.com/moapp/jydocs/services/util"
 	docRpcUtil "app.yhyue.com/moapp/jydocs/services/util"
+	"context"
+	"github.com/tal-tech/go-zero/zrpc"
 	"gorm.io/gorm"
 	"gorm.io/gorm"
 	"log"
 	"log"
+	"time"
 )
 )
 
 
 func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
@@ -31,3 +35,77 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 	}
 	}
 	return true
 	return true
 }
 }
+
+//转存操作
+func UserDocDownload(userDoc *model.UserDoc, cost int) bool {
+	log.Println("UserDocCollect exec ......")
+	err := docRpcUtil.GetJyDocsDB().Transaction(func(tx *gorm.DB) error {
+		//用户文库表添加记录
+		//获取文档有关信息
+		//查询之前有无下载记录  0和1只要有一条不能下载,如果有未删除可以下载
+		userDocDownloadList := []model.UserDoc{}
+		err := docRpcUtil.GetJyDocsDB().Table("user_doc").Where(" userId=? and docId=? and docCategory=? and (isDelete=? or isDelete=?)", userDoc.UserId, userDoc.DocId, model.UserDocCategory_Download, model.UserDocStatus_Normal, model.UserDocStatus_LogicDelete).Find(&userDocDownloadList)
+		if err.Error != nil {
+			return err.Error
+		}
+		if len(userDocDownloadList) > 0 {
+			return nil
+		}
+		//先扣除积分
+		//rpc
+		ctx, _ := context.WithTimeout(context.Background(), 5*time.Second)
+		FileSystem :=integralclient.NewIntegral(zrpc.MustNewClient(c.FileSystemConf))
+		req := &integral.Req{UserId: "111111",PointType:2003,BusinessTypeId:1,BusinessType:"1", Point: 110,EndDate:"2021-03-11",AppId: 10000}
+		res, err := FileSystem.IntegralConsume(ctx, req)
+		log.Println("err ", err)
+		log.Println("req ", res)
+
+		//查询之前有无收藏记录 有收藏记录类型改为下载,状态改为未删除、有收藏记录插入一条新纪录
+		userDocCollectionList := []model.UserDoc{}
+		err = docRpcUtil.GetJyDocsDB().Table("user_doc").Where(" userId=? and docId=? and docCategory=? and (isDelete=? or isDelete=?)", userDoc.UserId, userDoc.DocId, model.UserDocCategory_Collect, model.UserDocStatus_Normal, model.UserDocStatus_LogicDelete).Find(&userDocCollectionList)
+		if  err.Error != nil {
+			return err.Error
+		}
+		if len(userDocCollectionList)>0{
+			//修改收藏为下载
+			if err := tx.Exec("update user_doc set docCategory=? , isDelete=?  ,update_at=?  where  id =?", model.UserDocCategory_Download,model.UserDocStatus_Normal,time.Now(), userDocCollectionList[0].ID).Error; err != nil {
+				return err
+			}
+			if err.Error != nil {
+				log.Println("userDocCollect error:", err)
+				tx.Rollback()
+				return err.Error
+			}
+			//用户收藏、转存记录表添加记录
+			err := docRpcUtil.GetJyDocsDB().Exec("insert into download_collection_record (docId,userId,sourceUserId,category,cost,date) values (?,?,?,?,?,?)", userDoc.DocId, userDoc.UserId, userDoc.DocSourceUserId, model.UserDocCategory_Download, cost,time.Now())
+			if err.Error != nil {
+				log.Println("userDocCollect record insert error:", err)
+				tx.Rollback()
+				return nil
+			}
+		}else{
+			//用户文库表添加记录
+			userDoc.CreateAt=time.Now()
+			userDoc.UpdateAt=time.Now()
+			userDoc.DeletedAt=time.Now()
+			err= docRpcUtil.GetJyDocsDB().Create(userDoc)
+			if err.Error != nil {
+				log.Println("userDocCollect error:", err)
+				tx.Rollback()
+				return err.Error
+			}
+			//用户收藏、转存记录表添加记录
+			err := docRpcUtil.GetJyDocsDB().Exec("insert into download_collection_record (docId,userId,sourceUserId,category,cost,date) values (?,?,?,?,?,?)", userDoc.DocId, userDoc.UserId, userDoc.DocSourceUserId, model.UserDocCategory_Download, cost,time.Now())
+			if err.Error != nil {
+				log.Println("userDocCollect record insert error:", err)
+				tx.Rollback()
+				return nil
+			}
+		}
+		return nil
+	})
+	if err != nil {
+		return false
+	}
+	return true
+}