Browse Source

完善接口

xuzhiheng 4 years ago
parent
commit
9866b358a9

+ 4 - 0
rpc/stdlib/etc/stdlib.yaml

@@ -15,5 +15,9 @@ Etcd:
   Hosts:
     - 192.168.3.240:2379
   Key: jydocs.stdlib.rpc
+FileSystemConf:
+  Hosts:
+    - 192.168.3.240:2379
+  Key: moapp.filesystem.rpc
 DocBucketName: "jydoc-stdlib"
 PreviewBucketName: "jydoc-preview"

+ 6 - 2
rpc/stdlib/internal/config/config.go

@@ -1,10 +1,14 @@
 package config
 
-import "github.com/tal-tech/go-zero/zrpc"
-import jyDocRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
+import (
+	jyDocRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
+	"github.com/tal-tech/go-zero/core/discov"
+	"github.com/tal-tech/go-zero/zrpc"
+)
 
 type Config struct {
 	zrpc.RpcServerConf
+	FileSystemConf    discov.EtcdConf
 	JyDocsMysqlDB     jyDocRpcUtil.MysqlDBConfig
 	EsConfig          jyDocRpcUtil.EsConfig
 	DocBucketName     string

+ 1 - 13
rpc/stdlib/internal/logic/docactivitylogic.go

@@ -32,19 +32,7 @@ func (l *DocActivityLogic) DocActivity(in *stdlib.DocActivityReq) (*stdlib.DocAc
 		pageNum = 0
 	}
 	res, count := stdlibService.DocActivityList(int(in.PageSize), pageNum, int(in.ActivityId), in.AppId)
-	docActivityResp := &stdlib.DocActivityResp{Code: 1, Msg: "ok", Total: int32(count)}
 	log.Println("res ", res)
 	log.Println("count ", count)
-	for _, v := range res {
-		docActivityResp.Docs = append(docActivityResp.Docs, &stdlib.DocActivity{
-			DocId:      v.DocId,
-			DocImg:     v.DocImg,
-			DocTitle:   v.DocTitle,
-			DocSummary: v.DocSummary,
-			ActivityId: int32(v.ActivityId),
-			Price:      int32(v.Price),
-			CostPrice:  int32(v.CostPrice),
-		})
-	}
-	return docActivityResp, nil
+	return res, nil
 }

+ 1 - 1
rpc/stdlib/stdlib.go

@@ -23,7 +23,7 @@ func main() {
 	if c.JyDocsMysqlDB.DataSourceName != "" && c.EsConfig.Addr != "" {
 		jyDocsRpcUtil.InitDB(c.JyDocsMysqlDB.DataSourceName, c.JyDocsMysqlDB.DriverName, c.JyDocsMysqlDB.MaxOpenConn, c.JyDocsMysqlDB.MaxIdleConn)
 		jyDocsRpcUtil.InitEs(c.EsConfig.Addr, c.EsConfig.Pool, c.EsConfig.UserName, c.EsConfig.Password)
-		// jyDocsRpcUtil.InitOss(c.Etcd)
+		jyDocsRpcUtil.InitOss(c.FileSystemConf)
 		ctx := svc.NewServiceContext(c)
 		srv := server.NewStdlibServer(ctx)
 		s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {

+ 10 - 6
rpc/stdlib/stdlib.proto

@@ -85,20 +85,24 @@ message DocGetContentResp {
 }
 
 message DocActivityReq {
-  int32 pageNum = 1; //页码 
-  int32 pageSize = 2; //每页数量
+  int64 pageNum = 1; //页码 
+  int64 pageSize = 2; //每页数量
   string appId = 3; //appId
-  int32 activityId = 4; //活动id
+  int64 activityId = 4; //活动id
 }
 
 message DocActivity {
   string docId = 1; //文档id
-  int32 activityId = 2; //活动id
+  int64 activityId = 2; //活动id
   string docTitle = 3; //文档标题
   string docSummary = 4; //文档摘要
   string docImg = 5; //文档配图
-  int32 price = 6; //活动价
-  int32 costPrice = 7; //成本价
+  int64 price = 6; //活动价
+  int64 costPrice = 7; //成本价
+  int64 downTimes = 8; //下载次数
+  string sourceUserId = 9; //贡献人
+  int64 docFileSize = 10; //文件大小
+  int64 docPageSize = 11; //页码数
 }
 
 message DocActivityResp {

+ 102 - 62
rpc/stdlib/stdlib/stdlib.pb.go

@@ -1,7 +1,7 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.25.0
-// 	protoc        v3.15.6
+// 	protoc-gen-go v1.23.0
+// 	protoc        v3.11.4
 // source: stdlib.proto
 
 package stdlib
@@ -840,10 +840,10 @@ type DocActivityReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	PageNum    int32  `protobuf:"varint,1,opt,name=pageNum,proto3" json:"pageNum,omitempty"`       //页码
-	PageSize   int32  `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"`     //每页数量
+	PageNum    int64  `protobuf:"varint,1,opt,name=pageNum,proto3" json:"pageNum,omitempty"`       //页码
+	PageSize   int64  `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"`     //每页数量
 	AppId      string `protobuf:"bytes,3,opt,name=appId,proto3" json:"appId,omitempty"`            //appId
-	ActivityId int32  `protobuf:"varint,4,opt,name=activityId,proto3" json:"activityId,omitempty"` //活动id
+	ActivityId int64  `protobuf:"varint,4,opt,name=activityId,proto3" json:"activityId,omitempty"` //活动id
 }
 
 func (x *DocActivityReq) Reset() {
@@ -878,14 +878,14 @@ func (*DocActivityReq) Descriptor() ([]byte, []int) {
 	return file_stdlib_proto_rawDescGZIP(), []int{10}
 }
 
-func (x *DocActivityReq) GetPageNum() int32 {
+func (x *DocActivityReq) GetPageNum() int64 {
 	if x != nil {
 		return x.PageNum
 	}
 	return 0
 }
 
-func (x *DocActivityReq) GetPageSize() int32 {
+func (x *DocActivityReq) GetPageSize() int64 {
 	if x != nil {
 		return x.PageSize
 	}
@@ -899,7 +899,7 @@ func (x *DocActivityReq) GetAppId() string {
 	return ""
 }
 
-func (x *DocActivityReq) GetActivityId() int32 {
+func (x *DocActivityReq) GetActivityId() int64 {
 	if x != nil {
 		return x.ActivityId
 	}
@@ -911,13 +911,17 @@ type DocActivity struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	DocId      string `protobuf:"bytes,1,opt,name=docId,proto3" json:"docId,omitempty"`            //文档id
-	ActivityId int32  `protobuf:"varint,2,opt,name=activityId,proto3" json:"activityId,omitempty"` //活动id
-	DocTitle   string `protobuf:"bytes,3,opt,name=docTitle,proto3" json:"docTitle,omitempty"`      //文档标题
-	DocSummary string `protobuf:"bytes,4,opt,name=docSummary,proto3" json:"docSummary,omitempty"`  //文档摘要
-	DocImg     string `protobuf:"bytes,5,opt,name=docImg,proto3" json:"docImg,omitempty"`          //文档配图
-	Price      int32  `protobuf:"varint,6,opt,name=price,proto3" json:"price,omitempty"`           //活动价
-	CostPrice  int32  `protobuf:"varint,7,opt,name=costPrice,proto3" json:"costPrice,omitempty"`   //成本价
+	DocId        string `protobuf:"bytes,1,opt,name=docId,proto3" json:"docId,omitempty"`               //文档id
+	ActivityId   int64  `protobuf:"varint,2,opt,name=activityId,proto3" json:"activityId,omitempty"`    //活动id
+	DocTitle     string `protobuf:"bytes,3,opt,name=docTitle,proto3" json:"docTitle,omitempty"`         //文档标题
+	DocSummary   string `protobuf:"bytes,4,opt,name=docSummary,proto3" json:"docSummary,omitempty"`     //文档摘要
+	DocImg       string `protobuf:"bytes,5,opt,name=docImg,proto3" json:"docImg,omitempty"`             //文档配图
+	Price        int64  `protobuf:"varint,6,opt,name=price,proto3" json:"price,omitempty"`              //活动价
+	CostPrice    int64  `protobuf:"varint,7,opt,name=costPrice,proto3" json:"costPrice,omitempty"`      //成本价
+	DownTimes    int64  `protobuf:"varint,8,opt,name=downTimes,proto3" json:"downTimes,omitempty"`      //下载次数
+	SourceUserId string `protobuf:"bytes,9,opt,name=sourceUserId,proto3" json:"sourceUserId,omitempty"` //贡献人
+	DocFileSize  int64  `protobuf:"varint,10,opt,name=docFileSize,proto3" json:"docFileSize,omitempty"` //文件大小
+	DocPageSize  int64  `protobuf:"varint,11,opt,name=docPageSize,proto3" json:"docPageSize,omitempty"` //页码数
 }
 
 func (x *DocActivity) Reset() {
@@ -959,7 +963,7 @@ func (x *DocActivity) GetDocId() string {
 	return ""
 }
 
-func (x *DocActivity) GetActivityId() int32 {
+func (x *DocActivity) GetActivityId() int64 {
 	if x != nil {
 		return x.ActivityId
 	}
@@ -987,20 +991,48 @@ func (x *DocActivity) GetDocImg() string {
 	return ""
 }
 
-func (x *DocActivity) GetPrice() int32 {
+func (x *DocActivity) GetPrice() int64 {
 	if x != nil {
 		return x.Price
 	}
 	return 0
 }
 
-func (x *DocActivity) GetCostPrice() int32 {
+func (x *DocActivity) GetCostPrice() int64 {
 	if x != nil {
 		return x.CostPrice
 	}
 	return 0
 }
 
+func (x *DocActivity) GetDownTimes() int64 {
+	if x != nil {
+		return x.DownTimes
+	}
+	return 0
+}
+
+func (x *DocActivity) GetSourceUserId() string {
+	if x != nil {
+		return x.SourceUserId
+	}
+	return ""
+}
+
+func (x *DocActivity) GetDocFileSize() int64 {
+	if x != nil {
+		return x.DocFileSize
+	}
+	return 0
+}
+
+func (x *DocActivity) GetDocPageSize() int64 {
+	if x != nil {
+		return x.DocPageSize
+	}
+	return 0
+}
+
 type DocActivityResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1175,62 +1207,70 @@ var file_stdlib_proto_rawDesc = []byte{
 	0x0a, 0x64, 0x6f, 0x63, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28,
 	0x0c, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x22, 0x7c, 0x0a,
 	0x0e, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x12,
-	0x18, 0x0a, 0x07, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
+	0x18, 0x0a, 0x07, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
 	0x52, 0x07, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x12, 0x1a, 0x0a, 0x08, 0x70, 0x61, 0x67,
-	0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x70, 0x61, 0x67,
+	0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x70, 0x61, 0x67,
 	0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x18, 0x03,
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61,
-	0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52,
-	0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x64, 0x22, 0xcb, 0x01, 0x0a, 0x0b,
+	0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52,
+	0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x64, 0x22, 0xd1, 0x02, 0x0a, 0x0b,
 	0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x64,
 	0x6f, 0x63, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x6f, 0x63, 0x49,
 	0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49, 0x64, 0x18,
-	0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49,
+	0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x61, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x49,
 	0x64, 0x12, 0x1a, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x08, 0x64, 0x6f, 0x63, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x1e, 0x0a,
 	0x0a, 0x64, 0x6f, 0x63, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28,
 	0x09, 0x52, 0x0a, 0x64, 0x6f, 0x63, 0x53, 0x75, 0x6d, 0x6d, 0x61, 0x72, 0x79, 0x12, 0x16, 0x0a,
 	0x06, 0x64, 0x6f, 0x63, 0x49, 0x6d, 0x67, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x64,
 	0x6f, 0x63, 0x49, 0x6d, 0x67, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x18, 0x06,
-	0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63,
-	0x6f, 0x73, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09,
-	0x63, 0x6f, 0x73, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x22, 0x76, 0x0a, 0x0f, 0x44, 0x6f, 0x63,
-	0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x12, 0x0a, 0x04,
-	0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65,
-	0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6d,
-	0x73, 0x67, 0x12, 0x27, 0x0a, 0x04, 0x64, 0x6f, 0x63, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b,
-	0x32, 0x13, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74,
-	0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x04, 0x64, 0x6f, 0x63, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x74,
-	0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61,
-	0x6c, 0x32, 0xba, 0x03, 0x0a, 0x06, 0x53, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x12, 0x3d, 0x0a, 0x08,
-	0x44, 0x6f, 0x63, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x17, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69,
-	0x62, 0x2e, 0x44, 0x6f, 0x63, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
-	0x74, 0x1a, 0x18, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x51, 0x75,
-	0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x34, 0x0a, 0x05, 0x44,
-	0x6f, 0x63, 0x4f, 0x6e, 0x12, 0x14, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f,
-	0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64,
-	0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73,
-	0x70, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x6f, 0x63, 0x4f, 0x66, 0x66, 0x12, 0x14, 0x2e, 0x73, 0x74,
-	0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65,
-	0x71, 0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68,
-	0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x40, 0x0a, 0x0d, 0x44, 0x6f, 0x63, 0x53,
-	0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12, 0x18, 0x2e, 0x73, 0x74, 0x64, 0x6c,
-	0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73,
-	0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63,
-	0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3e, 0x0a, 0x0b, 0x44, 0x6f,
-	0x63, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x16, 0x2e, 0x73, 0x74, 0x64, 0x6c,
-	0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65,
-	0x71, 0x1a, 0x17, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65,
-	0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x12, 0x42, 0x0a, 0x0d, 0x44, 0x6f,
-	0x63, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x2e, 0x73, 0x74,
-	0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b,
-	0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63,
-	0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3e,
-	0x0a, 0x0b, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x12, 0x16, 0x2e,
-	0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
-	0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44,
-	0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x73, 0x70, 0x62, 0x06,
-	0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x70, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x63,
+	0x6f, 0x73, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09,
+	0x63, 0x6f, 0x73, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x6f, 0x77,
+	0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x64, 0x6f,
+	0x77, 0x6e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x12, 0x22, 0x0a, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63,
+	0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73,
+	0x6f, 0x75, 0x72, 0x63, 0x65, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x64,
+	0x6f, 0x63, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x03,
+	0x52, 0x0b, 0x64, 0x6f, 0x63, 0x46, 0x69, 0x6c, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x12, 0x20, 0x0a,
+	0x0b, 0x64, 0x6f, 0x63, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x18, 0x0b, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x0b, 0x64, 0x6f, 0x63, 0x50, 0x61, 0x67, 0x65, 0x53, 0x69, 0x7a, 0x65, 0x22,
+	0x76, 0x0a, 0x0f, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65,
+	0x73, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
+	0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x6d, 0x73, 0x67, 0x18, 0x02, 0x20,
+	0x01, 0x28, 0x09, 0x52, 0x03, 0x6d, 0x73, 0x67, 0x12, 0x27, 0x0a, 0x04, 0x64, 0x6f, 0x63, 0x73,
+	0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e,
+	0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x04, 0x64, 0x6f, 0x63,
+	0x73, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05,
+	0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x32, 0xba, 0x03, 0x0a, 0x06, 0x53, 0x74, 0x64, 0x6c,
+	0x69, 0x62, 0x12, 0x3d, 0x0a, 0x08, 0x44, 0x6f, 0x63, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x17,
+	0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x51, 0x75, 0x65, 0x72, 0x79,
+	0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x18, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62,
+	0x2e, 0x44, 0x6f, 0x63, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
+	0x65, 0x12, 0x34, 0x0a, 0x05, 0x44, 0x6f, 0x63, 0x4f, 0x6e, 0x12, 0x14, 0x2e, 0x73, 0x74, 0x64,
+	0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71,
+	0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61,
+	0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x35, 0x0a, 0x06, 0x44, 0x6f, 0x63, 0x4f, 0x66,
+	0x66, 0x12, 0x14, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68,
+	0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62,
+	0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x40,
+	0x0a, 0x0d, 0x44, 0x6f, 0x63, 0x53, 0x74, 0x61, 0x74, 0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x12,
+	0x18, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x53, 0x74, 0x61, 0x74,
+	0x69, 0x73, 0x74, 0x69, 0x63, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x73, 0x74, 0x64, 0x6c,
+	0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x3e, 0x0a, 0x0b, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12,
+	0x16, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43,
+	0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62,
+	0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x42, 0x0a, 0x0d, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+	0x74, 0x12, 0x16, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65,
+	0x74, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x73, 0x74, 0x64, 0x6c,
+	0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x47, 0x65, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+	0x52, 0x65, 0x73, 0x70, 0x12, 0x3e, 0x0a, 0x0b, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76,
+	0x69, 0x74, 0x79, 0x12, 0x16, 0x2e, 0x73, 0x74, 0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63,
+	0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x73, 0x74,
+	0x64, 0x6c, 0x69, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79,
+	0x52, 0x65, 0x73, 0x70, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (

+ 7 - 7
rpc/stdlib/stdlibclient/stdlib.go

@@ -14,19 +14,19 @@ import (
 )
 
 type (
+	DocQueryRequest   = stdlib.DocQueryRequest
+	DocGetCheckResp   = stdlib.DocGetCheckResp
+	DocActivity       = stdlib.DocActivity
+	DocActivityResp   = stdlib.DocActivityResp
+	DocInfo           = stdlib.DocInfo
 	DocGetContentResp = stdlib.DocGetContentResp
-	DocActivityReq    = stdlib.DocActivityReq
 	DocQueryResponse  = stdlib.DocQueryResponse
 	Doc               = stdlib.Doc
+	DocChangeReq      = stdlib.DocChangeReq
 	DocChangeResp     = stdlib.DocChangeResp
 	DocStatisticsReq  = stdlib.DocStatisticsReq
 	DocGetCheckReq    = stdlib.DocGetCheckReq
-	DocGetCheckResp   = stdlib.DocGetCheckResp
-	DocActivity       = stdlib.DocActivity
-	DocQueryRequest   = stdlib.DocQueryRequest
-	DocChangeReq      = stdlib.DocChangeReq
-	DocInfo           = stdlib.DocInfo
-	DocActivityResp   = stdlib.DocActivityResp
+	DocActivityReq    = stdlib.DocActivityReq
 
 	Stdlib interface {
 		DocQuery(ctx context.Context, in *DocQueryRequest) (*DocQueryResponse, error)

+ 26 - 10
services/model/stdlib.go

@@ -64,15 +64,17 @@ func (ud *UserDoc) TableName() string {
 }
 
 type DocActivity struct {
-	Id         int    `json:"id" gorm:"primaryKey"`
-	DocId      string `json:"doc_id" gorm:"column:docId"`
-	ActivityId int    `json:"activity_id" gorm:"column:activityId"`
-	AppId      string `json:"app_id" gorm:"column:appId"`
-	DocTitle   string `json:"doc_title" gorm:"column:docTitle"`
-	DocSummary string `json:"doc_summary" gorm:"column:docSummary"`
-	DocImg     string `json:"doc_img" gorm:"column:docImg"`
-	Price      int    `json:"price" gorm:"column:price"`
-	CostPrice  int    `json:"cost_price" gorm:"column:costPrice"`
+	Id          int    `json:"id" gorm:"primaryKey"`
+	DocId       string `json:"doc_id" gorm:"column:docId"`
+	ActivityId  int    `json:"activity_id" gorm:"column:activityId"`
+	AppId       string `json:"app_id" gorm:"column:appId"`
+	DocTitle    string `json:"doc_title" gorm:"column:docTitle"`
+	DocSummary  string `json:"doc_summary" gorm:"column:docSummary"`
+	DocImg      string `json:"doc_img" gorm:"column:docImg"`
+	Price       int    `json:"price" gorm:"column:price"`
+	CostPrice   int    `json:"cost_price" gorm:"column:costPrice"`
+	DocFileSize int    `json:"doc_file_size" gorm:"column:docFileSize"`
+	DocPageSize int    `json:"doc_page_size" gorm:"column:docPageSize"`
 }
 
 func (ud *DocActivity) TableName() string {
@@ -80,7 +82,7 @@ func (ud *DocActivity) TableName() string {
 }
 
 type UserDocData struct {
-	Id           string `json:"id"`
+	Id           int    `json:"id" gorm:"primaryKey"`
 	UserId       string `json:"user_id"  gorm:"column:userId"`
 	DocId        string `json:"doc_id" gorm:"column:docId"`
 	IsCollection int    `json:"is_collection" gorm:"column:isCollection"`
@@ -90,3 +92,17 @@ type UserDocData struct {
 func (ud *UserDocData) TableName() string {
 	return "user_doc"
 }
+
+type DocStatistics struct {
+	Id         int       `json:"id"`
+	AppId      string    `json:"app_id"  gorm:"column:appId"`
+	DocId      string    `json:"doc_id" gorm:"column:docId"`
+	UpdateDate time.Time `json:"update_date" gorm:"column:updateDate"`
+	score      int       `json:"score" gorm:"column:score"`
+	DownTimes  int       `json:"down_times" gorm:"column:downTimes"`
+	ViewTimes  int       `json:"view_times" gorm:"column:viewTimes"`
+}
+
+func (ud *DocStatistics) TableName() string {
+	return "doc_statistics"
+}

+ 21 - 5
services/stdlib/docActivity.go

@@ -1,13 +1,12 @@
 package stdlib
 
 import (
-	"log"
-
+	"app.yhyue.com/moapp/jy_docs/rpc/stdlib/stdlib"
 	"app.yhyue.com/moapp/jy_docs/services/model"
 	jyDocsRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
 )
 
-func DocActivityList(pageSize, pageNum, activityId int, appId string) ([]model.DocActivity, int) {
+func DocActivityList(pageSize, pageNum, activityId int, appId string) (*stdlib.DocActivityResp, int) {
 	var docActivity []model.DocActivity
 	// var docs []map[string]interface{}
 	var count int64
@@ -17,6 +16,23 @@ func DocActivityList(pageSize, pageNum, activityId int, appId string) ([]model.D
 	} else {
 		count = 0
 	}
-	log.Println("docActivity ", docActivity)
-	return docActivity, int(count)
+	docActivityResp := &stdlib.DocActivityResp{Code: 1, Msg: "ok", Total: int32(count)}
+	for _, v := range docActivity {
+		docStatistics := model.DocStatistics{}
+		jyDocsRpcUtil.GetJyDocsDB().First(&docStatistics, &model.DocStatistics{AppId: appId, DocId: v.DocId})
+		docActivityResp.Docs = append(docActivityResp.Docs, &stdlib.DocActivity{
+			DocId:       v.DocId,
+			DocImg:      v.DocImg,
+			DocTitle:    v.DocTitle,
+			DocSummary:  v.DocSummary,
+			ActivityId:  int64(v.ActivityId),
+			Price:       int64(v.Price),
+			CostPrice:   int64(v.CostPrice),
+			DocFileSize: int64(v.DocFileSize),
+			DocPageSize: int64(v.DocPageSize),
+			DownTimes:   int64(docStatistics.DownTimes),
+		})
+	}
+
+	return docActivityResp, int(count)
 }

+ 4 - 11
services/stdlib/docGet.go

@@ -22,15 +22,8 @@ func DocGetCheck(docId, userId, appId string) stdlib.DocGetCheckResp {
 	jyDocsRpcUtil.GetJyDocsDB().Where("id = ? and appId = ?", docId, appId).Find(doc)
 	if doc.DocName != "" {
 		// docPrice = docData["price"].(int)
-		docStatistics := map[string]interface{}{}
-		jyDocsRpcUtil.GetJyDocsDB().Table("doc_statistics").Where("docId = ? and appId = ?", docId, appId).First(&docStatistics)
-		downTimes, viewTimes := int64(0), int64(0)
-		if dt, ok := docStatistics["downTimes"].(int64); ok {
-			downTimes = dt
-		}
-		if vt, ok := docStatistics["viewTimes"].(int64); ok {
-			viewTimes = vt
-		}
+		docStatistics := model.DocStatistics{}
+		jyDocsRpcUtil.GetJyDocsDB().First(&docStatistics, &model.DocStatistics{AppId: appId, DocId: docId})
 		docCheck := stdlib.DocGetCheckResp{
 			Code:  1,
 			Msg:   "ok",
@@ -42,8 +35,8 @@ func DocGetCheck(docId, userId, appId string) stdlib.DocGetCheckResp {
 				DocFileSize:  int64(doc.DocFileSize),
 				DocPageSize:  int64(doc.DocPageSize),
 				Tags:         doc.DocTags,
-				DownTimes:    downTimes,
-				ViewTimes:    viewTimes,
+				DownTimes:    int64(docStatistics.DownTimes),
+				ViewTimes:    int64(docStatistics.ViewTimes),
 				UploadDate:   doc.UploadDate.Format("2006-01-02 15:04:05"),
 				DocSummary:   doc.DocSummary,
 				DocFileType:  int64(doc.DocFileType),