kobe6258 1 settimana fa
parent
commit
17ccce53ca

+ 4 - 0
common/component/es/es.go

@@ -30,6 +30,10 @@ type ESClient struct {
 	esOp *elasticsearch.Client
 }
 
+func (es *ESClient) GetESClient() *elasticsearch.Client {
+	return es.esOp
+}
+
 type SearchType string
 
 const (

+ 2 - 0
common/exception/exc_enums.go

@@ -185,6 +185,7 @@ const (
 	IllegalSourceId
 	BookMarkFailed
 	BookMarkListFailed
+	CheckBookMarkFailed
 )
 
 // ErrorMap 用于存储错误码和错误信息的映射
@@ -318,6 +319,7 @@ var ErrorMap = map[int]string{
 	BookMarkFailed:       "收藏失败",
 	BookMarkListFailed:   "获取收藏列表失败",
 	IllegalSearchKeyword: "搜索关键字不能为空",
+	CheckBookMarkFailed:  "获取收藏状态失败",
 }
 
 func Equals(code int, message string) bool {

+ 1 - 0
controllers/list_contoller.go

@@ -23,6 +23,7 @@ const (
 )
 
 func (l *ListController) Prepare() {
+	l.BaseController.Prepare()
 	pageSize, _ := l.GetInt("pageSize")
 	currentIndex, _ := l.GetInt("currentIndex")
 	LatestId, _ := l.GetInt64("latestId")

+ 1 - 1
controllers/user/bookmark_controller.go

@@ -145,7 +145,7 @@ func (bk *BookMarkController) CheckBookMark() {
 		}
 		isBookMarked, err := userService.CheckBookMarkStatus(userInfo.Id, bookMark.SourceId, bookMark.SourceType)
 		if err != nil {
-			err = exception.NewWithException(exception.FeedBackError, err.Error())
+			err = exception.NewWithException(exception.CheckBookMarkFailed, err.Error())
 			bk.FailedResult("获取是否收藏失败", result)
 			return
 		}

+ 20 - 15
domian/report/report_service.go

@@ -326,21 +326,26 @@ func SearchMaxReportIdWithRange(key string, reportIds []int) (total int64) {
 	}
 	count := re.Count
 	total = int64(count)
-	if total > 0 {
-		request = match(key, 0, count, sort)
-		re, err = elastic().Search(request)
-		if err != nil {
-			logger.Error("es搜索异常:%v", err)
-		}
-		hits := elastic().GetSource(re.Hits)
-		data := hits[0].Source
-		report := ReportDTO{}
-		err = json.Unmarshal(data, &report)
-		if err != nil {
-			logger.Error("获取当前最大研报id失败:%v", err)
-			return
-		}
-	}
+	//if total > 0 {
+	//	if count < 10000 {
+	//		request = match(key, 0, count, sort)
+	//	} else {
+	//
+	//	}
+	//
+	//	re, err = elastic().Search(request)
+	//	if err != nil {
+	//		logger.Error("es搜索异常:%v", err)
+	//	}
+	//	hits := elastic().GetSource(re.Hits)
+	//	data := hits[0].Source
+	//	report := ReportDTO{}
+	//	err = json.Unmarshal(data, &report)
+	//	if err != nil {
+	//		logger.Error("获取当前最大研报id失败:%v", err)
+	//		return
+	//	}
+	//}
 	return
 }
 

+ 1 - 0
domian/user/bookmark_service.go

@@ -59,6 +59,7 @@ func CheckBookMarkStatus(templateUserId int, sourceId int, sourceType string) (s
 	}
 	if errors.Is(err, gorm.ErrRecordNotFound) {
 		status = string(userDao.Unmark)
+		err = nil
 		return
 	}
 	status = string(bookmark.Status)