Browse Source

报告详情增加用户头像

kobe6258 9 months ago
parent
commit
15bbc4e09f
1 changed files with 35 additions and 7 deletions
  1. 35 7
      domian/report/report_service.go

+ 35 - 7
domian/report/report_service.go

@@ -61,6 +61,7 @@ type ReportDTO struct {
 	OrgId            int             `json:"orgId"`
 	Title            string          `json:"title"`
 	Author           string          `json:"author"`
+	AuthorInfo       []Anthor        `json:"authorInfo"`
 	Source           string          `json:"source"`
 	Abstract         string          `json:"abstract"`
 	PublishedTime    string          `json:"publishedTime"`
@@ -83,19 +84,46 @@ type PermissionDTO struct {
 	ParentID int
 }
 
+type Anthor struct {
+	Id         int    `json:"id"`
+	Name       string `json:"name"`
+	HeadImgUrl string `json:"headImgUrl"`
+}
+
 func GetGetReportById(reportId int) (ReportDTO ReportDTO, err error) {
 	report, err := reportDao.GetReportById(reportId)
 	if err != nil {
 		return
 	}
-	//orgId := report.OrgID
-	//names, _ := reportDao.GetAuthorByOrgId(orgId, string(report.Source))
-	//if names != nil && len(names) > 1 {
-	//	names = stringUtils.UniqueItems(names)
-	//	report.Author = strings.Join(names, ",")
-	//}
-	//report.PublishedTime = report.PublishedTime
+
 	ReportDTO = convertReportDTO(report, true)
+
+	authorStr := ReportDTO.Author
+	authorNames := strings.Split(authorStr, ",")
+	authorNames = stringUtils.RemoveEmptyStrings(authorNames)
+	var authorList []Anthor
+	if len(authorNames) > 0 {
+		for _, name := range authorNames {
+			var author analystService.FinancialAnalystDTO
+			author, err = analystService.GetAnalystByName(name)
+			var item Anthor
+			if err != nil {
+				item = Anthor{
+					Id:         0,
+					Name:       name,
+					HeadImgUrl: "",
+				}
+			} else {
+				item = Anthor{
+					Id:         author.Id,
+					Name:       author.Name,
+					HeadImgUrl: author.HeadImgUrl,
+				}
+			}
+			authorList = append(authorList, item)
+		}
+	}
+	ReportDTO.AuthorInfo = authorList
 	return
 }