Răsfoiți Sursa

增加appid 缩略图

xuzhiheng 4 ani în urmă
părinte
comite
2eaacd888c

+ 3 - 2
rpc/stdlib/etc/stdlib.yaml

@@ -13,6 +13,7 @@ EsConfig:
   Password: elastic
 Etcd:
   Hosts:
-    - 127.0.0.1:2379
+    - 192.168.3.240:2379
   Key: jydocs.stdlib.rpc
-BucketName: "jydoc-std"
+DocBucketName: "jydoc-stdlib"
+PreviewBucketName: "jydoc-preview"

+ 4 - 3
rpc/stdlib/internal/config/config.go

@@ -5,7 +5,8 @@ import jyDocRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
 
 type Config struct {
 	zrpc.RpcServerConf
-	JyDocsMysqlDB jyDocRpcUtil.MysqlDBConfig
-	EsConfig      jyDocRpcUtil.EsConfig
-	BucketName    string
+	JyDocsMysqlDB     jyDocRpcUtil.MysqlDBConfig
+	EsConfig          jyDocRpcUtil.EsConfig
+	DocBucketName     string
+	PreviewBucketName string
 }

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

@@ -31,7 +31,7 @@ func (l *DocActivityLogic) DocActivity(in *stdlib.DocActivityReq) (*stdlib.DocAc
 	if int(in.PageNum) <= 0 {
 		pageNum = 0
 	}
-	res, count := stdlibService.DocActivityList(int(in.PageSize), pageNum)
+	res, count := stdlibService.DocActivityList(int(in.PageSize), pageNum, in.AppId)
 	docActivityResp := &stdlib.DocActivityResp{Code: 0, Msg: "ok", Total: int32(count)}
 	log.Println("res ", res)
 	log.Println("count ", count)

+ 1 - 1
rpc/stdlib/internal/logic/docgetchecklogic.go

@@ -27,6 +27,6 @@ func NewDocGetCheckLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DocGe
 
 func (l *DocGetCheckLogic) DocGetCheck(in *stdlib.DocGetCheckReq) (*stdlib.DocGetCheckResp, error) {
 	// todo: add your logic here and delete this line
-	res := stdlibService.DocGetCheck(in.DocId, in.UserId)
+	res := stdlibService.DocGetCheck(in.DocId, in.UserId, in.AppId)
 	return &res, nil
 }

+ 1 - 1
rpc/stdlib/internal/logic/docgetcontentlogic.go

@@ -26,6 +26,6 @@ func NewDocGetContentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Doc
 
 func (l *DocGetContentLogic) DocGetContent(in *stdlib.DocGetCheckReq) (*stdlib.DocGetContentResp, error) {
 	// todo: add your logic here and delete this line
-	res := stdlibService.DocGetContent(in.DocId, in.UserId, l.svcCtx.Config.BucketName)
+	res := stdlibService.DocGetContent(in.DocId, in.UserId, l.svcCtx.Config.DocBucketName, in.AppId)
 	return &res, nil
 }

+ 1 - 1
rpc/stdlib/internal/logic/docstatisticslogic.go

@@ -25,6 +25,6 @@ func NewDocStatisticsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Doc
 
 func (l *DocStatisticsLogic) DocStatistics(in *stdlib.DocStatisticsReq) (*stdlib.DocChangeResp, error) {
 	// todo: add your logic here and delete this line
-	state := stdlibService.DocStatistics(in.DocId, int(in.DocStatisticsType))
+	state := stdlibService.DocStatistics(in.DocId, in.AppId, int(in.DocStatisticsType))
 	return &stdlib.DocChangeResp{State: state}, nil
 }

+ 8 - 4
services/model/stdlib.go

@@ -27,6 +27,8 @@ type Doc struct {
 	Price         int       `json:"price" gorm:"column:price"`
 	DownOrUp      int       `json:"downOrUp" gorm:"column:downOrUp"`
 	DocSummary    string    `json:"docSummary" gorm:"column:docSummary"`
+	PreviewImgId  string    `json:"preview_img_id" gorm:"column:previewImgId"`
+	PreviewImgUrl string    `json:"preview_img_url" gorm:"column:previewImgUrl"`
 }
 
 func (ud *Doc) TableName() string {
@@ -52,6 +54,8 @@ type UserDoc struct {
 	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"`
+	PreviewImgId    string    `json:"preview_img_id" gorm:"column:previewImgId"`
+	PreviewImgUrl   string    `json:"preview_img_url" gorm:"column:previewImgUrl"`
 }
 
 func (ud *UserDoc) TableName() string {
@@ -75,11 +79,11 @@ func (ud *DocActivity) TableName() string {
 }
 
 type UserDocData struct {
-	Id          string `json:"id"`
-	UserId      string `json:"user_id"  gorm:"column:userId"`
-	DocId       string `json:"doc_id" gorm:"column:docId"`
+	Id           string `json:"id"`
+	UserId       string `json:"user_id"  gorm:"column:userId"`
+	DocId        string `json:"doc_id" gorm:"column:docId"`
 	IsCollection int    `json:"is_collection" gorm:"column:isCollection"`
-	IsDelete    int    `json:"is_delete" gorm:"column:isDelete"`
+	IsDelete     int    `json:"is_delete" gorm:"column:isDelete"`
 }
 
 func (ud *UserDocData) TableName() string {

+ 2 - 2
services/stdlib/docActivity.go

@@ -7,13 +7,13 @@ import (
 	jyDocsRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
 )
 
-func DocActivityList(pageSize, pageNum int) ([]model.DocActivity, int) {
+func DocActivityList(pageSize, pageNum int, appId string) ([]model.DocActivity, int) {
 	var docActivity []model.DocActivity
 	// var docs []map[string]interface{}
 	var count int64
 	jyDocsRpcUtil.GetJyDocsDB().Model(&model.DocActivity{}).Count(&count)
 	if count > 0 {
-		jyDocsRpcUtil.GetJyDocsDB().Offset((pageNum - 1) * pageSize).Limit(pageSize).Find(&docActivity)
+		jyDocsRpcUtil.GetJyDocsDB().Offset((pageNum-1)*pageSize).Limit(pageSize).Find(&docActivity, &model.DocActivity{AppId: appId})
 	} else {
 		count = 0
 	}

+ 5 - 5
services/stdlib/docGet.go

@@ -9,14 +9,14 @@ import (
 	"app.yhyue.com/moapp/jyfs/rpc/filesystem"
 )
 
-func DocGetCheck(docId, userId string) stdlib.DocGetCheckResp {
+func DocGetCheck(docId, userId, appId string) stdlib.DocGetCheckResp {
 	// docPrice := 0
 	var buyCount int64
-	jyDocsRpcUtil.GetJyDocsDB().Table("doc").Where("docId = ? and userId = ?", docId, userId).Count(&buyCount)
+	jyDocsRpcUtil.GetJyDocsDB().Table("doc").Where("docId = ? and userId = ? and appId = ?", docId, userId, appId).Count(&buyCount)
 	if buyCount > 0 {
 		//已购买
 		doc := &model.Doc{}
-		jyDocsRpcUtil.GetJyDocsDB().Where("id = ?", docId).Find(doc)
+		jyDocsRpcUtil.GetJyDocsDB().Where("id = ? and appId = ?", docId, appId).Find(doc)
 		if doc.DocName != "" {
 			// docPrice = docData["price"].(int)
 			docCheck := stdlib.DocGetCheckResp{
@@ -36,10 +36,10 @@ func DocGetCheck(docId, userId string) stdlib.DocGetCheckResp {
 	return stdlib.DocGetCheckResp{Code: -1, Msg: "查询失败"}
 }
 
-func DocGetContent(docId, userId, bucketName string) stdlib.DocGetContentResp {
+func DocGetContent(docId, userId, bucketName, appId string) stdlib.DocGetContentResp {
 	doc := &model.Doc{}
 	docContent := stdlib.DocGetContentResp{Code: -1, Msg: "查询失败"}
-	jyDocsRpcUtil.GetJyDocsDB().Where("id = ?", docId).Find(doc)
+	jyDocsRpcUtil.GetJyDocsDB().Where("id = ? and appId = ?", docId, appId).Find(doc)
 	if doc.DocName != "" {
 		file := filesystem.LoadFileReq{
 			Domain: bucketName,

+ 4 - 4
services/stdlib/docStatistics.go

@@ -7,18 +7,18 @@ import (
 	jyDocsRpcUtil "app.yhyue.com/moapp/jy_docs/services/util"
 )
 
-func DocStatistics(docId string, dtype int) bool {
+func DocStatistics(docId, appId string, dtype int) bool {
 	sqlStr := ""
 	state := false
 	if dtype == 1 { //下载次数增加1
-		sqlStr = "update doc_statistics set downTimes = downTimes + 1,updateDate = ? where docId = ?"
+		sqlStr = "update doc_statistics set downTimes = downTimes + 1,updateDate = ? where docId = ? and appId = ?"
 	} else if dtype == 2 { //浏览次数增加1
-		sqlStr = "update doc_statistics set viewTimes = viewTimes + 1,updateDate = ? where docId = ?"
+		sqlStr = "update doc_statistics set viewTimes = viewTimes + 1,updateDate = ? where docId = ? and appId = ?"
 	}
 	//mysql
 	log.Println("sql ", sqlStr)
 	updateDate := time.Now().Format("2006-01-02 15:04:05")
-	err := jyDocsRpcUtil.GetJyDocsDB().Exec(sqlStr, updateDate, docId).Error
+	err := jyDocsRpcUtil.GetJyDocsDB().Exec(sqlStr, updateDate, docId, appId).Error
 	if err == nil {
 		state = true
 	}