|
@@ -133,18 +133,7 @@ func GetFollowingAnalystList(userId int) (list []UserAnalystFollowList, err erro
|
|
|
err = db.Select(listColumns).Where("user_id = ? and followed = ?", userId, Following).Order("followed_time desc").Find(&list).Error
|
|
|
return
|
|
|
}
|
|
|
-func GetFollowing(userId int, analystId int) string {
|
|
|
- db := models.Main()
|
|
|
- var dbFollow UserAnalystFollowList
|
|
|
- err := db.Model(&UserAnalystFollowList{}).Where("user_id = ? and financial_analyst_id = ?", userId, analystId).First(&dbFollow).Error
|
|
|
- if err != nil {
|
|
|
- if !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
- logger.Error("查询用户关注状态失败:%v", err)
|
|
|
- }
|
|
|
- return string(Unfollowed)
|
|
|
- }
|
|
|
- return string(dbFollow.Followed)
|
|
|
-}
|
|
|
+
|
|
|
func FollowAnalyst(follow UserAnalystFollowList) (err error) {
|
|
|
if follow.Followed == "" {
|
|
|
err = errors.New("关注状态非法")
|
|
@@ -188,3 +177,15 @@ func GetFollowed(userId int, analystId int) string {
|
|
|
}
|
|
|
return string(record.Followed)
|
|
|
}
|
|
|
+func GetFollowing(userId int, analystId int) string {
|
|
|
+ db := models.Main()
|
|
|
+ var dbFollow UserAnalystFollowList
|
|
|
+ err := db.Model(&UserAnalystFollowList{}).Where("user_id = ? and financial_analyst_id = ?", userId, analystId).First(&dbFollow).Error
|
|
|
+ if err != nil {
|
|
|
+ if !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
+ logger.Error("查询用户关注状态失败:%v", err)
|
|
|
+ }
|
|
|
+ return string(Unfollowed)
|
|
|
+ }
|
|
|
+ return string(dbFollow.Followed)
|
|
|
+}
|