WH01243 4 年之前
父节点
当前提交
feed22b297

+ 1 - 1
rpc/userlib/internal/logic/docdeletelogic.go

@@ -27,7 +27,7 @@ func NewDocDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocDele
 func (l *DocDeleteLogic) DocDelete(in *userlib.UserRecoveryRequest) (*userlib.UserDeleteResponse, error) {
 	// todo: add your logic here and delete this line
 	result := &userlib.UserDeleteResponse{}
-	code,msg:= userLibService.UserDocDelete(in.UserDocId)
+	code,msg:= userLibService.UserDocDelete(in.UserDocId,in.AppId)
 	if code {
 		result.Code = 1
 		result.Message = msg

+ 3 - 2
rpc/userlib/internal/logic/docdownloadlogic.go

@@ -30,8 +30,9 @@ func NewDocDownloadLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocDo
 func (l *DocDownloadLogic) DocDownload(in *userlib.UserCollectRequest) (*userlib.UserCollectResponse, error) {
 	b, msg := userLibService.UserDocDownload(
 		&model.UserDoc{
-			UserId:          in.UserId,
-			DocId:           in.DocId,
+			UserId: in.UserId,
+			DocId:  in.DocId,
+			AppId:  in.AppId,
 		}, int(in.Cost), config.Configs.FileSystemConf.Etcd.Hosts, config.Configs.FileSystemConf.Etcd.Key)
 	log.Printf("用户文档收藏,userId:[%s],docId:[%s] 是否成功:[%v]", in.UserId, in.DocId, b)
 	if b {

+ 1 - 1
rpc/userlib/internal/logic/docpermanentdeletelogic.go

@@ -26,7 +26,7 @@ func NewDocPermanentDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext)
 func (l *DocPermanentDeleteLogic) DocPermanentDelete(in *userlib.UserRecoveryRequest) (*userlib.UserCollectResponse, error) {
 	// todo: add your logic here and delete this line
 	result := &userlib.UserCollectResponse{}
-	code,msg:= userLibService.UserDocPermanentDelete(in.UserDocId)
+	code,msg:= userLibService.UserDocPermanentDelete(in.UserDocId,in.AppId)
 	if code {
 		result.Code = 1
 		result.Message = msg

+ 1 - 1
rpc/userlib/internal/logic/docrestorelogic.go

@@ -26,7 +26,7 @@ func NewDocRestoreLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocRes
 func (l *DocRestoreLogic) DocRestore(in *userlib.UserRecoveryRequest) (*userlib.UserRestoreResponse, error) {
 	// todo: add your logic here and delete this line
 	result := &userlib.UserRestoreResponse{}
-	code,msg:= userLibService.UserDocRestore(in.UserDocId)
+	code,msg:= userLibService.UserDocRestore(in.UserDocId,in.AppId)
 	if code {
 		result.Code = 1
 		result.Message =msg

+ 4 - 0
rpc/userlib/test/userLib_test.go

@@ -57,6 +57,7 @@ func Test_UserDocDelete(t *testing.T)  {
 	userLib := userlibclient.NewUserLib(client)
 	resp, err := userLib.DocDelete(context.Background(), &userlibclient.UserRecoveryRequest{
 		UserDocId: int32(10),
+		AppId:int64(10000),
 	})
 	if err != nil {
 		log.Println("UserDoc Collect call error:", err)
@@ -74,6 +75,7 @@ func Test_UserDocRestore(t *testing.T)  {
 	userLib := userlibclient.NewUserLib(client)
 	resp, err := userLib.DocRestore(context.Background(), &userlibclient.UserRecoveryRequest{
 		UserDocId: int32(10),
+		AppId:int64(10000),
 	})
 	if err != nil {
 		log.Println("UserDoc Collect call error:", err)
@@ -91,6 +93,7 @@ func Test_UserDocPermanentDelete(t *testing.T)  {
 	userLib := userlibclient.NewUserLib(client)
 	resp, err := userLib.DocPermanentDelete(context.Background(), &userlibclient.UserRecoveryRequest{
 		UserDocId: int32(10),
+		AppId:int64(10000),
 	})
 	if err != nil {
 		log.Println("UserDoc Collect call error:", err)
@@ -110,6 +113,7 @@ func Test_UserDocDwnload(t *testing.T) {
 		DocId:        "123",
 		UserId:       "wh5",
 		Cost:1000,
+		AppId:int64(10000),
 	})
 	if err != nil {
 		log.Println("UserDoc Collect call error:", err)

+ 5 - 1
rpc/userlib/userlib.proto

@@ -22,6 +22,7 @@ message UserCollectRequest {
     string userId=1; //用户id
     string docId=2; //文档id
     int32 cost=3;//收藏|转存费用
+    int64 appId=4;//剑鱼标识
 }
 
 message UserCollectResponse {
@@ -32,6 +33,7 @@ message UserCollectResponse {
 //用户删除
 message UserDeleteRequest {
     string docId=1;//文档id
+    int64 appId=2;//剑鱼标识
 }
 message UserDeleteResponse {
     int32 code =1;    //响应代码
@@ -50,7 +52,8 @@ message UserRestoreResponse {
 //用户文档列表
 message UserDocsRequest {
     string userId=1;//用户id
-    UserDocCategory userDocCategory=2;//用户文档分类
+    int64 appId=2;//剑鱼标识
+    UserDocCategory userDocCategory=3;//用户文档分类
 }
 
 message UserDocsResponse {
@@ -59,6 +62,7 @@ message UserDocsResponse {
 }
 message UserRecoveryRequest {
     int32 userDocId =1;   //记录标识
+    int64 appId=2;//剑鱼标识
 }
 enum UserDocStatus {
     Normal =0;//文件正常

+ 117 - 80
rpc/userlib/userlib/userlib.pb.go

@@ -196,6 +196,7 @@ type UserCollectRequest struct {
 	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
 	Cost   int32  `protobuf:"varint,3,opt,name=cost,proto3" json:"cost,omitempty"`    //收藏|转存费用
+	AppId  int64  `protobuf:"varint,4,opt,name=appId,proto3" json:"appId,omitempty"`  //剑鱼标识
 }
 
 func (x *UserCollectRequest) Reset() {
@@ -251,6 +252,13 @@ func (x *UserCollectRequest) GetCost() int32 {
 	return 0
 }
 
+func (x *UserCollectRequest) GetAppId() int64 {
+	if x != nil {
+		return x.AppId
+	}
+	return 0
+}
+
 type UserCollectResponse struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -312,7 +320,8 @@ type UserDeleteRequest struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	DocId string `protobuf:"bytes,1,opt,name=docId,proto3" json:"docId,omitempty"` //文档id
+	DocId string `protobuf:"bytes,1,opt,name=docId,proto3" json:"docId,omitempty"`  //文档id
+	AppId int64  `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"` //剑鱼标识
 }
 
 func (x *UserDeleteRequest) Reset() {
@@ -354,6 +363,13 @@ func (x *UserDeleteRequest) GetDocId() string {
 	return ""
 }
 
+func (x *UserDeleteRequest) GetAppId() int64 {
+	if x != nil {
+		return x.AppId
+	}
+	return 0
+}
+
 type UserDeleteResponse struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -519,7 +535,8 @@ type UserDocsRequest struct {
 	unknownFields protoimpl.UnknownFields
 
 	UserId          string          `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"`                                                 //用户id
-	UserDocCategory UserDocCategory `protobuf:"varint,2,opt,name=userDocCategory,proto3,enum=userlib.UserDocCategory" json:"userDocCategory,omitempty"` //用户文档分类
+	AppId           int64           `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"`                                                  //剑鱼标识
+	UserDocCategory UserDocCategory `protobuf:"varint,3,opt,name=userDocCategory,proto3,enum=userlib.UserDocCategory" json:"userDocCategory,omitempty"` //用户文档分类
 }
 
 func (x *UserDocsRequest) Reset() {
@@ -561,6 +578,13 @@ func (x *UserDocsRequest) GetUserId() string {
 	return ""
 }
 
+func (x *UserDocsRequest) GetAppId() int64 {
+	if x != nil {
+		return x.AppId
+	}
+	return 0
+}
+
 func (x *UserDocsRequest) GetUserDocCategory() UserDocCategory {
 	if x != nil {
 		return x.UserDocCategory
@@ -629,6 +653,7 @@ type UserRecoveryRequest struct {
 	unknownFields protoimpl.UnknownFields
 
 	UserDocId int32 `protobuf:"varint,1,opt,name=userDocId,proto3" json:"userDocId,omitempty"` //记录标识
+	AppId     int64 `protobuf:"varint,2,opt,name=appId,proto3" json:"appId,omitempty"`         //剑鱼标识
 }
 
 func (x *UserRecoveryRequest) Reset() {
@@ -670,96 +695,108 @@ func (x *UserRecoveryRequest) GetUserDocId() int32 {
 	return 0
 }
 
+func (x *UserRecoveryRequest) GetAppId() int64 {
+	if x != nil {
+		return x.AppId
+	}
+	return 0
+}
+
 var File_userlib_proto protoreflect.FileDescriptor
 
 var file_userlib_proto_rawDesc = []byte{
 	0x0a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12,
-	0x07, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x22, 0x56, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72,
+	0x07, 0x75, 0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x22, 0x6c, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72,
 	0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 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, 0x12, 0x0a, 0x04,
 	0x63, 0x6f, 0x73, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x73, 0x74,
-	0x22, 0x43, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52,
-	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65,
-	0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x29, 0x0a, 0x11, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x6c,
-	0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f,
-	0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64,
-	0x22, 0x42, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65,
-	0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01,
-	0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65,
-	0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73,
-	0x73, 0x61, 0x67, 0x65, 0x22, 0x2a, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74,
-	0x6f, 0x72, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f,
-	0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64,
-	0x22, 0x43, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52,
-	0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18,
-	0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65,
-	0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x6d, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63,
-	0x73, 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, 0x42, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61, 0x74, 0x65, 0x67,
-	0x6f, 0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x75, 0x73, 0x65, 0x72,
-	0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61, 0x74, 0x65, 0x67,
-	0x6f, 0x72, 0x79, 0x52, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61, 0x74, 0x65,
-	0x67, 0x6f, 0x72, 0x79, 0x22, 0x40, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73,
-	0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65,
-	0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07,
-	0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d,
-	0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x33, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65,
-	0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a,
-	0x09, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
-	0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x49, 0x64, 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, 0x8e, 0x04, 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, 0x4b, 0x0a, 0x10, 0x44, 0x6f, 0x63, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x43,
-	0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 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,
-	0x46, 0x0a, 0x09, 0x44, 0x6f, 0x63, 0x44, 0x65, 0x6c, 0x65, 0x74, 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, 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, 0x48, 0x0a, 0x0a, 0x44, 0x6f, 0x63, 0x52, 0x65,
-	0x73, 0x74, 0x6f, 0x72, 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, 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, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x43, 0x6f,
+	0x6c, 0x6c, 0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
+	0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64,
+	0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01,
+	0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x3f, 0x0a, 0x11, 0x55,
+	0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18,
+	0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x12,
+	0x55, 0x73, 0x65, 0x72, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
+	0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
+	0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+	0x22, 0x2a, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52,
+	0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x18,
+	0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x6f, 0x63, 0x49, 0x64, 0x22, 0x43, 0x0a, 0x13,
+	0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f,
+	0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
+	0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61,
+	0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
+	0x65, 0x22, 0x83, 0x01, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x73, 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, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x61, 0x70,
+	0x70, 0x49, 0x64, 0x12, 0x42, 0x0a, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61,
+	0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x18, 0x2e, 0x75,
+	0x73, 0x65, 0x72, 0x6c, 0x69, 0x62, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43, 0x61,
+	0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x52, 0x0f, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x43,
+	0x61, 0x74, 0x65, 0x67, 0x6f, 0x72, 0x79, 0x22, 0x40, 0x0a, 0x10, 0x55, 0x73, 0x65, 0x72, 0x44,
+	0x6f, 0x63, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x63,
+	0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12,
+	0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x49, 0x0a, 0x13, 0x55, 0x73, 0x65,
+	0x72, 0x52, 0x65, 0x63, 0x6f, 0x76, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
+	0x12, 0x1c, 0x0a, 0x09, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20,
+	0x01, 0x28, 0x05, 0x52, 0x09, 0x75, 0x73, 0x65, 0x72, 0x44, 0x6f, 0x63, 0x49, 0x64, 0x12, 0x14,
+	0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x61,
+	0x70, 0x70, 0x49, 0x64, 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, 0x8e, 0x04, 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, 0x50, 0x0a, 0x12, 0x44,
-	0x6f, 0x63, 0x50, 0x65, 0x72, 0x6d, 0x61, 0x6e, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x6c, 0x65, 0x74,
-	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,
+	0x65, 0x63, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4b, 0x0a, 0x10, 0x44,
+	0x6f, 0x63, 0x43, 0x61, 0x6e, 0x63, 0x65, 0x6c, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 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, 0x46, 0x0a, 0x09, 0x44, 0x6f, 0x63, 0x44,
+	0x65, 0x6c, 0x65, 0x74, 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, 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, 0x48, 0x0a, 0x0a, 0x44, 0x6f, 0x63, 0x52, 0x65, 0x73, 0x74, 0x6f, 0x72, 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, 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,
+	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, 0x50, 0x0a, 0x12, 0x44, 0x6f, 0x63, 0x50, 0x65, 0x72, 0x6d, 0x61,
+	0x6e, 0x65, 0x6e, 0x74, 0x44, 0x65, 0x6c, 0x65, 0x74, 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 (

+ 4 - 4
rpc/userlib/userlibclient/userlib.go

@@ -14,14 +14,14 @@ import (
 )
 
 type (
-	UserCollectRequest  = userlib.UserCollectRequest
 	UserCollectResponse = userlib.UserCollectResponse
 	UserDeleteRequest   = userlib.UserDeleteRequest
-	UserDeleteResponse  = userlib.UserDeleteResponse
-	UserDocsRequest     = userlib.UserDocsRequest
-	UserRestoreRequest  = userlib.UserRestoreRequest
 	UserRestoreResponse = userlib.UserRestoreResponse
+	UserDocsRequest     = userlib.UserDocsRequest
 	UserDocsResponse    = userlib.UserDocsResponse
+	UserCollectRequest  = userlib.UserCollectRequest
+	UserDeleteResponse  = userlib.UserDeleteResponse
+	UserRestoreRequest  = userlib.UserRestoreRequest
 	UserRecoveryRequest = userlib.UserRecoveryRequest
 
 	UserLib interface {

+ 27 - 26
services/model/stdlib.go

@@ -5,29 +5,30 @@ import (
 )
 
 type Doc struct {
-	Id               string    `json:"id" gorm:"id"`
-	UserId           string    `json:"userId" gorm:"column:userId"`
-	DocName          string    `json:"docName" gorm:"column:docName"`
-	DocFileType      int       `json:"docFileType" gorm:"column:docFileType"`
-	DocFileSuffix    string    `json:"docFileSuffix" gorm:"column:docFileSuffix"`
-	DocFileSize      int       `json:"docFileSize" gorm:"column:docFileSize"`
-	DocPageSize      int       `json:"docPageSize" gorm:"column:docPageSize"`
-	DocTags          string    `json:"docTags" gorm:"column:docTags"`
-	DocClassLevelOne string    `json:"docClassLevelOne" gorm:"column:docClassLevelOne"`
-	DocClassLevelTwo string    `json:"docClassLevelTwo" gorm:"column:docClassLevelTwo"`
-	UploadDate       string    `json:"uploadDate" gorm:"column:uploadDate"`
-	IsDelete         int       `json:"isDelete" gorm:"column:isDelete"`
-	OssDocId         string    `json:"ossDocId" gorm:"column:ossDocId"`
-	OssDocUrl        string    `json:"ossDocUrl" gorm:"column:ossDocUrl"`
-	Md5              string    `json:"md5" gorm:"column:md5"`
-	OssPdfId         string    `json:"ossPdfId" gorm:"column:ossPdfId"`
-	OssPdfUrl        string    `json:"ossPdfUrl" gorm:"column:ossPdfUrl"`
-	OssTxtId         string    `json:"ossTxtId" gorm:"column:ossTxtId"`
-	OssTxtUrl        string    `json:"ossTxtUrl" gorm:"column:ossTxtUrl"`
-	Price            int       `json:"price" gorm:"column:price"`
-	DownOrUp         int       `json:"downOrUp" gorm:"column:downOrUp"`
-	DocSummary       string    `json:"docSummary" gorm:"column:docSummary"`
+	Id               string `json:"id" gorm:"id"`
+	UserId           string `json:"userId" gorm:"column:userId"`
+	DocName          string `json:"docName" gorm:"column:docName"`
+	DocFileType      int    `json:"docFileType" gorm:"column:docFileType"`
+	DocFileSuffix    string `json:"docFileSuffix" gorm:"column:docFileSuffix"`
+	DocFileSize      int    `json:"docFileSize" gorm:"column:docFileSize"`
+	DocPageSize      int    `json:"docPageSize" gorm:"column:docPageSize"`
+	DocTags          string `json:"docTags" gorm:"column:docTags"`
+	DocClassLevelOne string `json:"docClassLevelOne" gorm:"column:docClassLevelOne"`
+	DocClassLevelTwo string `json:"docClassLevelTwo" gorm:"column:docClassLevelTwo"`
+	UploadDate       string `json:"uploadDate" gorm:"column:uploadDate"`
+	IsDelete         int    `json:"isDelete" gorm:"column:isDelete"`
+	OssDocId         string `json:"ossDocId" gorm:"column:ossDocId"`
+	OssDocUrl        string `json:"ossDocUrl" gorm:"column:ossDocUrl"`
+	Md5              string `json:"md5" gorm:"column:md5"`
+	OssPdfId         string `json:"ossPdfId" gorm:"column:ossPdfId"`
+	OssPdfUrl        string `json:"ossPdfUrl" gorm:"column:ossPdfUrl"`
+	OssTxtId         string `json:"ossTxtId" gorm:"column:ossTxtId"`
+	OssTxtUrl        string `json:"ossTxtUrl" gorm:"column:ossTxtUrl"`
+	Price            int    `json:"price" gorm:"column:price"`
+	DownOrUp         int    `json:"downOrUp" gorm:"column:downOrUp"`
+	DocSummary       string `json:"docSummary" gorm:"column:docSummary"`
 }
+
 func (ud *Doc) TableName() string {
 	return "doc"
 }
@@ -37,6 +38,7 @@ type UserDoc struct {
 	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"`
+	AppId           int64    `json:"app_id"  gorm:"column:appId"`
 	UserId          string    `json:"user_id"  gorm:"column:userId"`
 	DocId           string    `json:"doc_id" gorm:"column:docId"`
 	DocCategory     int       `json:"doc_category" gorm:"column:docCategory"`
@@ -48,9 +50,8 @@ type UserDoc struct {
 	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"`
-	IsDownload     int       `json:"is_download" gorm:"column:isDownload"`
-	IsCollection     int       `json:"is_collection" gorm:"column:isCollection"`
-
+	IsDownload      int       `json:"is_download" gorm:"column:isDownload"`
+	IsCollection    int       `json:"is_collection" gorm:"column:isCollection"`
 }
 
 func (ud *UserDoc) TableName() string {
@@ -82,4 +83,4 @@ type UserDocData struct {
 
 func (ud *UserDocData) TableName() string {
 	return "user_doc"
-}
+}

+ 96 - 68
services/userlib/userDocService.go

@@ -22,7 +22,7 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 	docData := model.UserDocData{}
 	err := orm.Transaction(func(tx *gorm.DB) error {
 		err0 := orm.Select("id,userId,docId,docCategory,isDelete").
-			Where("userId = ? AND docId = ? AND (isDelete = 0 OR isDelete = 1)",userDoc.UserId,userDoc.DocId).
+			Where("userId = ? AND docId = ? AND (isDelete = 0 OR isDelete = 1)", userDoc.UserId, userDoc.DocId).
 			Find(&docData).Error
 		if err0 != nil {
 			log.Println("查询已存在收藏记录失败")
@@ -31,7 +31,7 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 		//已下载数据处理
 		if docData.DocCategory == 1 {
 			log.Println("该文档已下载,无法收藏")
-			return  err0
+			return err0
 		}
 
 		//已收藏数据处理
@@ -41,14 +41,14 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 		}
 		//已取消收藏,再次进行收藏
 		if docData.IsDelete == 1 && docData.UserId != "" {
-			err := orm.Exec("UPDATE user_doc SET isDelete = 0 WHERE id = ?",docData.Id).Error
+			err := orm.Exec("UPDATE user_doc SET isDelete = 0 WHERE id = ?", docData.Id).Error
 			if err != nil {
 				log.Println("文档再次收藏失败")
 				tx.Rollback()
 				return err
 			}
 			//无收藏记录,新增收藏
-		}else{
+		} else {
 			//用户文库表添加记录(需要检查是否重复)
 			timeData := time.Now()
 			userDoc.CreateAt = timeData
@@ -56,10 +56,10 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 			userDoc.DeletedAt = timeData
 			//查询文档基础信息
 			doc := model.Doc{}
-			err0 := orm.Where("id = ?",userDoc.DocId).
+			err0 := orm.Where("id = ?", userDoc.DocId).
 				Find(&doc).Error
 			if err0 != nil || doc.Id == "" {
-				log.Println("文档不存在",err0)
+				log.Println("文档不存在", err0)
 				return err0
 			}
 			userDoc.DocSourceUserId = doc.UserId
@@ -78,7 +78,7 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 				return err
 			}
 		}
-		//用户收藏、转存记录表添加记录
+		//用户收藏、兑换记录表添加记录
 		err := orm.Exec("insert into download_collection_record (docId,userId,sourceUserId,category,cost) values (?,?,?,?,?)", userDoc.DocId, userDoc.UserId, userDoc.DocSourceUserId, userDoc.DocCategory, cost).Error
 		if err != nil {
 			log.Println("userDocCollect record insert error:", err)
@@ -97,7 +97,7 @@ func UserDocCollect(userDoc *model.UserDoc, cost int) bool {
 func UserDocCancelCollect(userDocId string) bool {
 	orm := docRpcUtil.GetJyDocsDB()
 	err := orm.Transaction(func(tx *gorm.DB) error {
-		err := orm.Exec("UPDATE user_doc SET isDelete = 1 WHERE id = ? AND docCategory = 2 AND isDelete = 0",userDocId).Error
+		err := orm.Exec("UPDATE user_doc SET isDelete = 1 WHERE id = ? AND docCategory = 2 AND isDelete = 0", userDocId).Error
 		if err != nil {
 			log.Println("文档取消收藏失败")
 			tx.Rollback()
@@ -111,30 +111,31 @@ func UserDocCancelCollect(userDocId string) bool {
 	return true
 }
 
-//转存操作
-func UserDocDownload(userDoc *model.UserDoc, cost int,hosts []string,key string) (bool,string) {
+//兑换操作
+func UserDocDownload(userDoc *model.UserDoc, cost int, hosts []string, key string) (bool, string) {
 	log.Println("UserDocCollect exec ......")
-	msg:="转存成功"
+	msg := "兑换成功"
 	err := docRpcUtil.GetJyDocsDB().Transaction(func(tx *gorm.DB) error {
 		//用户文库表添加记录
 		//获取文档有关信息
-		//查询之前有无下载记录  0和1只要有一条不能下载,如果有未删除可以下载
+		//查询之前有无兑换记录  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)
+		err := docRpcUtil.GetJyDocsDB().Table("user_doc").Where(" userId=? and docId=? and isDownload=1 and (isDelete=? or isDelete=?)  and  appId=?", userDoc.UserId, userDoc.DocId, model.UserDocStatus_Normal, model.UserDocStatus_LogicDelete,userDoc.AppId).Find(&userDocDownloadList)
 		if err.Error != nil {
-			log.Println("查询转存记录失败:",err)
-			msg="查询转存记录失败"
+			log.Println("查询兑换记录失败:", err)
+			msg = "查询兑换记录失败"
 			return err.Error
 		}
 		if len(userDocDownloadList) > 0 {
-			msg="之前已经下载不能再次下载"
-			return errors.New("之前已经下载不能再次下载")}
+			msg = "之前已经兑换不能再次兑换"
+			return errors.New("之前已经兑换不能再次兑换")
+		}
 		//先扣除积分
 		//rpc
 		client := zrpc.MustNewClient(zrpc.RpcClientConf{
 			Etcd: discov.EtcdConf{
 				Hosts: hosts,
-				Key:  key,
+				Key:   key,
 			},
 		})
 		integralLib := integralclient.NewIntegral(client)
@@ -143,47 +144,47 @@ func UserDocDownload(userDoc *model.UserDoc, cost int,hosts []string,key string)
 			BusinessTypeId: 1,
 			BusinessType:   "1",
 			Point:          int64(cost),
-			AppId:          10000}
+			AppId:          userDoc.AppId}
 		res, pointsErr := integralLib.IntegralConsume(context.Background(), req)
 		log.Println("err ", pointsErr)
 		log.Println("req ", res)
-		if (pointsErr != nil ) {
-			log.Println("扣除积分失败:",pointsErr)
-			msg="扣除积分失败"
+		if (pointsErr != nil) {
+			log.Println("扣除积分失败:", pointsErr)
+			msg = "扣除积分失败"
 			return pointsErr
 		}
 		if (res.Code == 0) {
-			log.Println("扣除积分失败:",pointsErr)
-			msg=res.Message
-			return  errors.New(res.Message)
+			log.Println("扣除积分失败:", pointsErr)
+			msg = res.Message
+			return errors.New(res.Message)
 		}
-		//查询之前有无收藏记录 有收藏记录类型改为下载,状态改为未删除、有收藏记录插入一条新纪录
+		//查询之前有无收藏记录 有收藏记录类型改为兑换,状态改为未删除、有收藏记录插入一条新纪录
 		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)
+		err = docRpcUtil.GetJyDocsDB().Table("user_doc").Where(" userId=? and docId=? and  appId=? ", userDoc.UserId, userDoc.DocId, userDoc.AppId).Find(&userDocCollectionList)
 		if err.Error != nil {
-			log.Println("收藏记录查询:",err)
-			msg="收藏记录查询"
+			log.Println("收藏记录查询:", err)
+			msg = "收藏记录查询"
 			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 {
-				log.Println("收藏记录更改为转存记录失败:",err)
-				msg="收藏记录更改为转存记录失败"
+			//兑换记录修改
+			if err := tx.Exec("update user_doc set isDownload=? , isDelete=?  ,update_at=?  where  id =?", 1, model.UserDocStatus_Normal, time.Now(), userDocCollectionList[0].ID).Error; err != nil {
+				log.Println("兑换记录修改失败:", err)
+				msg = "兑换记录修改失败"
 				tx.Rollback()
 				return err
 			}
 			if err.Error != nil {
-				log.Println("转存操作流水添加失败:", err)
-				msg="收藏记录更改为转存记录失败"
+				log.Println("兑换操作流水添加失败:", err)
+				msg = "收藏记录更改为兑换记录失败"
 				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("转存操作流水添加失败:", err)
-				msg="转存操作流水添加失败"
+				log.Println("兑换操作流水添加失败:", err)
+				msg = "兑换操作流水添加失败"
 				tx.Rollback()
 				return err.Error
 			}
@@ -197,11 +198,11 @@ func UserDocDownload(userDoc *model.UserDoc, cost int,hosts []string,key string)
 			//查询文档基础信息
 			doc := model.Doc{}
 			err0 := docRpcUtil.GetJyDocsDB().
-				Where("id = ?",userDoc.DocId).
+				Where("id = ?", userDoc.DocId).
 				Find(&doc)
 			if err0.Error != nil {
 				log.Println("文档不存在")
-				msg="文档不存在"
+				msg = "文档不存在"
 				return errors.New("文档不存在")
 			}
 			userDoc.DocSourceUserId = doc.UserId
@@ -215,16 +216,16 @@ func UserDocDownload(userDoc *model.UserDoc, cost int,hosts []string,key string)
 			userDoc.DocSummary = doc.DocSummary
 			err = docRpcUtil.GetJyDocsDB().Create(userDoc)
 			if err.Error != nil {
-				log.Println("转存操作添加失败:", err)
-				msg="转存操作添加失败"
+				log.Println("兑换操作添加失败:", err)
+				msg = "兑换操作添加失败"
 				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("转存操作流水添加失败:", err)
-				msg="转存操作流水添加失败"
+				log.Println("兑换操作流水添加失败:", err)
+				msg = "兑换操作流水添加失败"
 				tx.Rollback()
 				return err.Error
 			}
@@ -232,59 +233,86 @@ func UserDocDownload(userDoc *model.UserDoc, cost int,hosts []string,key string)
 		return nil
 	})
 	if err != nil {
-		return false,msg
+		return false, msg
 	}
-	return true,msg
+	return true, msg
 }
+
 //文档删除
-func UserDocDelete(userDocId int32)  (bool,string){
-	msg:="文档删除成功"
+func UserDocDelete(userDocId int32,appId int64 ) (bool, string) {
+	msg := "文档删除成功"
 	err := docRpcUtil.GetJyDocsDB().Transaction(func(tx *gorm.DB) error {
 		//逻辑删除
-		err := docRpcUtil.GetJyDocsDB().Exec("UPDATE user_doc SET isDelete = ? WHERE id = ?", model.UserDocStatus_LogicDelete,userDocId).Error
+		err := docRpcUtil.GetJyDocsDB().Exec("UPDATE user_doc SET isDelete = ? WHERE id = ?", model.UserDocStatus_LogicDelete, userDocId).Error
 		if err != nil {
-			msg="文档删除失败"
+			msg = "文档删除失败"
 			log.Println("文档删除失败:", err)
 			tx.Rollback()
 			return err
 		}
-		//删除记录新增
 
+		docData := model.UserDoc{}
+		//查询用户文档详情
+		docRpcUtil.GetJyDocsDB().Select("userId,docId").First(&docData, userDocId)
+		log.Println(docData.UserId)
+		log.Println(docData.DocId)
+		//删除记录新增
+		err = docRpcUtil.GetJyDocsDB().Exec("insert into del_record (docId, userId, date, operate, appId) values (?,?,?,?,?)",  docData.DocId,docData.UserId, time.Now(),  1, appId).Error
+		if err != nil {
+			tx.Rollback()
+			msg = "删除记录新增失败"
+			log.Println("删除记录新增失败:", err)
+			return err
+		}
 		return nil
 	})
 	if err != nil {
-		return false,msg
+		return false, msg
 	}
-	return true,msg
+	return true, msg
 
 }
+
 //文档回收
-func UserDocRestore(userDocId int32) (bool,string) {
-	msg:="文档找回成功"
+func UserDocRestore(userDocId int32,appId int64) (bool, string) {
+	msg := "文档找回成功"
 	err := docRpcUtil.GetJyDocsDB().Transaction(func(tx *gorm.DB) error {
 		//逻辑删除
-		err := docRpcUtil.GetJyDocsDB().Exec("UPDATE user_doc SET isDelete = ? WHERE id = ?",model.UserDocStatus_Normal, userDocId).Error
+		err := docRpcUtil.GetJyDocsDB().Exec("UPDATE user_doc SET isDelete = ? WHERE id = ?", model.UserDocStatus_Normal, userDocId).Error
 		if err != nil {
-			msg="文档找回失败"
+			msg = "文档找回失败"
 			log.Println("文档找回失败:", err)
 			tx.Rollback()
 			return err
 		}
+		docData := model.UserDoc{}
+		//查询用户文档详情
+		docRpcUtil.GetJyDocsDB().Select("userId,docId").First(&docData, userDocId)
+		log.Println(docData.UserId)
+		log.Println(docData.DocId)
+		//删除记录新增
+		err = docRpcUtil.GetJyDocsDB().Exec("insert into del_record (docId, userId, date, operate, appId) values (?,?,?,?,?)",  docData.DocId,docData.UserId, time.Now(),  1, appId).Error
+		if err != nil {
+			tx.Rollback()
+			msg = "删除记录新增失败"
+			log.Println("删除记录新增失败:", err)
+			return err
+		}
 		return nil
 	})
 	if err != nil {
-		return false,msg
+		return false, msg
 	}
-	return true,msg
+	return true, msg
 
-}//永久删除
-func UserDocPermanentDelete(userDocId int32) (bool,string) {
-	msg:="永久删除成功"
+} //永久删除
+func UserDocPermanentDelete(userDocId int32,appId int64) (bool, string) {
+	msg := "永久删除成功"
 	err := docRpcUtil.GetJyDocsDB().Transaction(func(tx *gorm.DB) error {
 		//逻辑删除
-		err := docRpcUtil.GetJyDocsDB().up("UPDATE user_doc SET isDelete = ? WHERE id = ?",model.UserDocStatus_PermanentlyDelete, userDocId).Error
+		err := docRpcUtil.GetJyDocsDB().Exec("UPDATE user_doc SET isDelete = ? WHERE id = ?", model.UserDocStatus_PermanentlyDelete, userDocId).Error
 		if err != nil {
-			msg="永久删除失败"
+			msg = "永久删除失败"
 			log.Println("永久删除失败:", err)
 			tx.Rollback()
 			return err
@@ -292,8 +320,8 @@ func UserDocPermanentDelete(userDocId int32) (bool,string) {
 		return nil
 	})
 	if err != nil {
-		return false,msg
+		return false, msg
 	}
-	return true,msg
+	return true, msg
 
-}
+}