Răsfoiți Sursa

增加一期研报同步

kobe6258 8 luni în urmă
părinte
comite
62f91b1efe
3 a modificat fișierele cu 16 adăugiri și 7 ștergeri
  1. 4 1
      domian/report/report_service.go
  2. 1 2
      routers/router.go
  3. 11 4
      service/report/report_service.go

+ 4 - 1
domian/report/report_service.go

@@ -69,7 +69,8 @@ type ReportDTO struct {
 	PermissionNames  interface{}     `json:"permissionNames,omitempty"`
 	Highlight        []string        `json:"highlight,omitempty"`
 	Detail           json.RawMessage `json:"detail,omitempty"`
-	CoverSrc         int             `json:"coverSrc"`
+	CoverSrc         int             `json:"-"`
+	CoverUrl         string          `json:"coverUrl"`
 }
 
 type Detail struct {
@@ -599,6 +600,7 @@ func convertHTReport(etaRp ht.HTReport) reportDao.Report {
 		Abstract:      etaRp.Abstract,
 		Author:        etaRp.Author,
 		PublishedTime: etaRp.PublishTime,
+		CoverSrc:      0,
 		Source:        reportDao.SourceHT,
 		SendStatus:    reportDao.UNSEND,
 		Status:        reportDao.StatusInit,
@@ -625,6 +627,7 @@ func convertReportDTO(report reportDao.Report) (reportDTO ReportDTO) {
 		OrgId:         report.OrgID,
 		Author:        report.Author,
 		Source:        string(report.Source),
+		CoverSrc:      report.CoverSrc,
 		Abstract:      report.Abstract,
 		PublishedTime: report.PublishedTime,
 	}

+ 1 - 2
routers/router.go

@@ -4,7 +4,6 @@ import (
 	"eta/eta_mini_ht_api/controllers/media"
 	"eta/eta_mini_ht_api/controllers/report"
 	"eta/eta_mini_ht_api/controllers/user"
-	"eta/eta_mini_ht_api/middleware"
 	"github.com/beego/beego/v2/server/web"
 	"github.com/beego/beego/v2/server/web/filter/cors"
 	"time"
@@ -20,7 +19,7 @@ func init() {
 		MaxAge:           12 * time.Hour,
 	}))
 	//增加授权拦截
-	web.InsertFilter("*", web.BeforeRouter, middleware.AuthMiddleware())
+	//web.InsertFilter("*", web.BeforeRouter, middleware.AuthMiddleware())
 
 	ns := web.NewNamespace("/htapi",
 		web.NSNamespace("/user",

+ 11 - 4
service/report/report_service.go

@@ -25,7 +25,7 @@ type PublishRankedReport struct {
 	Abstract        string      `json:"abstract"`
 	PermissionNames interface{} `json:"permissionNames,omitempty"`
 	PublishedTime   string      `json:"publishedTime"`
-	CoverSrc        string      `json:"coverSrc"`
+	CoverUrl        string      `json:"coverUrl"`
 }
 
 type HotRankedReport struct {
@@ -38,7 +38,7 @@ type HotRankedReport struct {
 	SecondPermissions map[int]string `json:"-"`
 	Permissions       map[int]string `json:"-"`
 	PermissionNames   interface{}    `json:"permissionNames,omitempty"`
-	CoverSrc          string         `json:"coverSrc"`
+	CoverUrl          string         `json:"coverUrl"`
 }
 
 type PermissionNode struct {
@@ -116,6 +116,13 @@ func SearchReportList(key string, pageInfo page.PageInfo) (reports []reportServi
 		go func(report *reportService.ReportDTO) {
 			defer wg.Done()
 			report.PermissionNames = getReportPermissionNames(report.OrgId, report.Source)
+			src, err := mediaService.GetImageSrc(report.CoverSrc)
+			if err != nil {
+				logger.Error("获取图片地址失败:%v", err)
+				src = ""
+			} else {
+				report.CoverUrl = src
+			}
 		}(&reports[i])
 	}
 	wg.Wait()
@@ -309,7 +316,7 @@ func convertToHotRankedReport(dto reportService.ReportDTO) (report HotRankedRepo
 		SecondPermissions: dto.SecondPermission,
 		Permissions:       dto.Permissions,
 		PermissionNames:   dto.PermissionNames,
-		CoverSrc:          src,
+		CoverUrl:          src,
 	}
 	return
 }
@@ -328,7 +335,7 @@ func convertToPublishRankedReportList(dtoList []reportService.ReportDTO) (report
 			Abstract:        dto.Abstract,
 			Title:           dto.Title,
 			PermissionNames: dto.PermissionNames,
-			CoverSrc:        src,
+			CoverUrl:        src,
 		}
 		reports = append(reports, report)
 	}