|
@@ -49,6 +49,7 @@ type AnalystDetail struct {
|
|
|
Position string `json:"position"`
|
|
|
InvestmentCertificate string `json:"investmentCertificate"`
|
|
|
ProfessionalCertificate string `json:"professionalCertificate"`
|
|
|
+ Status bool `json:"status"`
|
|
|
}
|
|
|
|
|
|
type UserProfile struct {
|
|
@@ -264,6 +265,7 @@ func convertToAnalystDetail(dto analystService.FinancialAnalystDTO) AnalystDetai
|
|
|
Position: dto.Position,
|
|
|
InvestmentCertificate: dto.InvestmentCertificate,
|
|
|
ProfessionalCertificate: dto.ProfessionalCertificate,
|
|
|
+ Status: dto.Status,
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -323,7 +325,7 @@ func FollowAnalyst(userId int, analystId int, followType string) (err error) {
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
-func GetFollowingAnalystList(userId int) (analysts []FollowAnalystDTO, err error) {
|
|
|
+func GetFollowingAnalystList(userId int) (followedList []FollowAnalystDTO, err error) {
|
|
|
logger.Info("用户ID:%d", userId)
|
|
|
dtoList, err := userService.GetFollowingAnalystList(userId)
|
|
|
if err != nil {
|
|
@@ -331,7 +333,8 @@ func GetFollowingAnalystList(userId int) (analysts []FollowAnalystDTO, err error
|
|
|
err = exception.New(exception.GetFollowingAnalystListFailed)
|
|
|
return
|
|
|
}
|
|
|
- analysts, err = convertToAnalystList(dtoList)
|
|
|
+ followedList = make([]FollowAnalystDTO, 0)
|
|
|
+ analysts, err := convertToAnalystList(dtoList)
|
|
|
var wg sync.WaitGroup
|
|
|
wg.Add(len(analysts))
|
|
|
for i := 0; i < len(analysts); i++ {
|
|
@@ -346,18 +349,21 @@ func GetFollowingAnalystList(userId int) (analysts []FollowAnalystDTO, err error
|
|
|
} else {
|
|
|
followDTo.HeadImgUrl = analystsDTO.HeadImgUrl
|
|
|
}
|
|
|
+ if analystsDTO.Status {
|
|
|
+ followedList = append(followedList, *followDTo)
|
|
|
+ }
|
|
|
}(&analysts[i])
|
|
|
}
|
|
|
wg.Wait()
|
|
|
//排序
|
|
|
- sort.Slice(analysts, func(i, j int) bool {
|
|
|
+ sort.Slice(followedList, func(i, j int) bool {
|
|
|
// 首先按 NeedNotice 排序
|
|
|
- if analysts[i].NeedNotice == analysts[j].NeedNotice {
|
|
|
+ if followedList[i].NeedNotice == followedList[j].NeedNotice {
|
|
|
// 对于 NeedNotice 相同的情况下,进行倒序排列
|
|
|
- return analysts[i].FollowedTime.After(analysts[j].FollowedTime)
|
|
|
+ return followedList[i].FollowedTime.After(followedList[j].FollowedTime)
|
|
|
}
|
|
|
// NeedNotice 为 true 的排在 false 的前面
|
|
|
- return analysts[i].NeedNotice
|
|
|
+ return followedList[i].NeedNotice
|
|
|
})
|
|
|
//if err != nil {
|
|
|
// logger.Error("转换研究员列表失败:%v", err)
|