ソースを参照

添加收藏、下载地址改为https

wangkaiyue 4 年 前
コミット
2b7f6ed7be

+ 4 - 4
jydocs-back/rpc/stdDocRpc.go

@@ -106,7 +106,7 @@ return
 	DocInfo 文库详情
 	error 异常
 */
-func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, error) {
+func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, bool, error) {
 	resp, err := jyStdDocStdlib.DocGetCheck(context.Background(), &stdlib.DocGetCheckReq{
 		AppId:  config.JyDocsAppConfig.AppId,
 		UserId: userId,
@@ -114,11 +114,11 @@ func GetDocDetail(userId, docId string) (*stdlib.DocInfo, bool, error) {
 	})
 	if err != nil {
 		log.Printf("%s GetDocDetail call error %v\n", userId, err)
-		return nil, false, err
+		return nil, false, false, err
 	}
 	if resp.Code != 1 {
 		log.Printf("%s GetDocDetail fail Message %v\n", userId, resp.Msg)
-		return nil, false, fmt.Errorf("获取内容失败")
+		return nil, false, false, fmt.Errorf("获取内容失败")
 	}
-	return resp.DocDeail, resp.IsBuy, nil
+	return resp.DocDeail, resp.IsBuy, resp.IsCollect, nil
 }

+ 8 - 4
jydocs-back/servers/stdDoc.go

@@ -71,7 +71,7 @@ func (stdDoc *StdDoc) Detail() {
 		if from != "" { //分享赚积分
 			go public.OpenShareJydoc(encrypt.SE.DecodeString(from), userId, docId)
 		}
-		detail, isBuy, err := rpc.GetDocDetail(userId, docId)
+		detail, isBuy, IsCollect, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}
@@ -80,8 +80,9 @@ func (stdDoc *StdDoc) Detail() {
 		detail.OssDocId = ""
 		detail.PreviewImgId = fmt.Sprintf("https://%s.%s/%s", config.JyDocsAppConfig.OssBucket.Priv, config.JyDocsAppConfig.OssAdmin, detail.PreviewImgId)
 		return map[string]interface{}{
-			"status": common.If(isBuy, 1, 0),
-			"detail": detail,
+			"status":  common.If(isBuy, 1, 0),
+			"collect": common.If(IsCollect, 1, 0),
+			"detail":  detail,
 		}, nil
 	}()
 	if errMsg != nil {
@@ -97,7 +98,7 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		if docId == "" {
 			return nil, fmt.Errorf("参数异常")
 		}
-		detail, isBuy, err := rpc.GetDocDetail(userId, docId)
+		detail, isBuy, _, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}
@@ -112,6 +113,9 @@ func (stdDoc *StdDoc) GetDoc(sign string) {
 		if err != nil {
 			return nil, err
 		}
+		if strings.HasPrefix(url, "http://") {
+			url = strings.Replace(url, "http://", "https://", 1)
+		}
 		return url, nil
 	}()
 	if errMsg != nil {

+ 1 - 1
jydocs-back/servers/userDoc.go

@@ -100,7 +100,7 @@ func (userDoc *UserDoc) DocBuy() {
 			return nil, err
 		}
 		//查询文档所需积分
-		docInfo, isBuy, err := rpc.GetDocDetail(userId, docId)
+		docInfo, isBuy, _, err := rpc.GetDocDetail(userId, docId)
 		if err != nil {
 			return nil, err
 		}