فهرست منبع

Merge branch 'feature/v1.0.1' of https://jygit.jydev.jianyu360.cn/moapp/jy_docs into feature/v1.0.1

wangshan 1 سال پیش
والد
کامیت
59c91f57b7

+ 2 - 1
rpc/userlib/internal/logic/usertodaycountlogic.go

@@ -27,7 +27,7 @@ func NewUserTodayCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Us
 func (l *UserTodayCountLogic) UserTodayCount(in *userlib.UserTodayCountReq) (*userlib.UserTodayCountRes, error) {
 	// todo: add your logic here and delete this line
 	result := &userlib.UserTodayCountRes{}
-	count, err := userLibService.GetTodayCount(in)
+	count, totalCount, err := userLibService.GetTodayCount(in)
 	if err != nil {
 		result.Code = 0
 		result.Message = err.Error()
@@ -36,5 +36,6 @@ func (l *UserTodayCountLogic) UserTodayCount(in *userlib.UserTodayCountReq) (*us
 	result.Code = 1
 	result.Message = ""
 	result.Count = count
+	result.TotalCount = totalCount
 	return result, nil
 }

+ 14 - 4
rpc/userlib/type/userlib/userlib.pb.go

@@ -1039,9 +1039,10 @@ type UserTodayCountRes struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Code    int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`      //响应代码
-	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` //响应消息
-	Count   int64  `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`    //总数
+	Code       int32  `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`             //响应代码
+	Message    string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`        //响应消息
+	Count      int64  `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`           //总数 豆丁会员免费数量
+	TotalCount int64  `protobuf:"varint,4,opt,name=totalCount,proto3" json:"totalCount,omitempty"` //会员免费总数
 }
 
 func (x *UserTodayCountRes) Reset() {
@@ -1097,6 +1098,13 @@ func (x *UserTodayCountRes) GetCount() int64 {
 	return 0
 }
 
+func (x *UserTodayCountRes) GetTotalCount() int64 {
+	if x != nil {
+		return x.TotalCount
+	}
+	return 0
+}
+
 var File_userlib_proto protoreflect.FileDescriptor
 
 var file_userlib_proto_rawDesc = []byte{
@@ -1196,12 +1204,14 @@ var file_userlib_proto_rawDesc = []byte{
 	0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
 	0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x6f, 0x64,
 	0x75, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0b, 0x70,
-	0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x57, 0x0a, 0x11, 0x55, 0x73,
+	0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x77, 0x0a, 0x11, 0x55, 0x73,
 	0x65, 0x72, 0x54, 0x6f, 0x64, 0x61, 0x79, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 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, 0x12, 0x14, 0x0a,
 	0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f,
+	0x75, 0x6e, 0x74, 0x12, 0x1e, 0x0a, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f, 0x75, 0x6e,
+	0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x43, 0x6f,
 	0x75, 0x6e, 0x74, 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,

+ 2 - 1
rpc/userlib/userlib.proto

@@ -107,7 +107,8 @@ message UserTodayCountReq{
 message UserTodayCountRes {
     int32 code =1;    //响应代码
     string message=2; //响应消息
-    int64 count = 3;  //总数
+    int64 count = 3;  //总数 豆丁会员免费数量
+    int64 totalCount = 4;  //会员免费总数
 }
 service  UserLib {
     rpc UserDocs(UserDocsRequest) returns (UserDocsResponse);//用户文档列表

+ 3 - 3
services/stdlib/docService.go

@@ -114,9 +114,9 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
 			tags := strings.Split(common.ObjToString(v["docTags"]), ",")
 			tmptags := []string{}
 			subTag := ""
-			step3 := time.Now()
+			//step3 := time.Now()
 			for i := 0; i < len(tags); i++ {
-				dtpKey := fmt.Sprintf("p_%s_0_tag", tags[i]) //一级tag
+				dtpKey := fmt.Sprintf("p_%s_0_class", tags[i]) //一级tag
 				if _, ok := partner.DocClassMap[dtpKey]; ok && len(tmptags) == 0 {
 					tmptags = append(tmptags, tags[i])
 				} else {
@@ -127,7 +127,7 @@ func DocQuery(in *stdlib.DocQueryRequest) *stdlib.DocQueryResponse {
 					break
 				}
 			}
-			log.Println("step3", time.Since(step3))
+			//log.Println("step3", time.Since(step3))
 			doc := &stdlib.Doc{
 				DocId:        common.ObjToString(v["id"]),
 				DocName:      common.ObjToString(v["docName"]),

+ 5 - 2
services/userlib/userDocService.go

@@ -476,12 +476,15 @@ func UserMerge(mergeUser, mergedUser, appId string) (bool, string) {
 }
 
 // GetTodayCount 获取今天的数量
-func GetTodayCount(in *userlib.UserTodayCountReq) (count int64, err error) {
+func GetTodayCount(in *userlib.UserTodayCountReq) (count int64, totalCount int64, err error) {
 	todayStart := fmt.Sprintf("%s 00:00:00", date.NowFormat(date.Date_Short_Layout))
 	q := "SELECT count(*) FROM jydocs.download_collection_record dcr left join doc d on(dcr.docId=d.id)  where dcr.userId=? and dcr.date>=? and dcr.category=1   and dcr.appId=? and d.productType=? and d.source=2"
 	err = docRpcUtil.GetJyDocsDB().Raw(q, in.UserId, todayStart, in.AppId, in.ProductType).Count(&count).Error
+	log.Println("GetTodayCount err:", in, err)
+	totalQ := "SELECT count(*) FROM jydocs.download_collection_record dcr left join doc d on(dcr.docId=d.id)  where dcr.userId=? and dcr.date>=? and dcr.category=1   and dcr.appId=? and d.productType=? "
+	err = docRpcUtil.GetJyDocsDB().Raw(totalQ, in.UserId, todayStart, in.AppId, in.ProductType).Count(&totalCount).Error
 	if err != nil {
-		log.Println("GetTodayCount err:", in, err)
+		log.Println("GetTodayCount totalQ err:", in, err)
 	}
 	return
 }