소스 검색

关注非法的id报错拦截

kobe6258 9 달 전
부모
커밋
17cf192bc2
1개의 변경된 파일24개의 추가작업 그리고 2개의 파일을 삭제
  1. 24 2
      controllers/user/user_controller.go

+ 24 - 2
controllers/user/user_controller.go

@@ -7,6 +7,7 @@ import (
 	"eta/eta_mini_ht_api/common/exception"
 	authUtils "eta/eta_mini_ht_api/common/utils/auth"
 	"eta/eta_mini_ht_api/controllers"
+	userService "eta/eta_mini_ht_api/domian/user"
 	"eta/eta_mini_ht_api/service/auth"
 	"eta/eta_mini_ht_api/service/user"
 	"fmt"
@@ -91,6 +92,10 @@ func (u *UserController) Feedback() {
 	})
 }
 
+type BatchFollowResp struct {
+	FollowStatus string                  `json:"followStatus"`
+	List         []userService.FollowDTO `json:"list"`
+}
 type FollowResp struct {
 	AnalystId    int    `json:"analystId"`
 	FollowedType string `json:"FollowedType"`
@@ -193,14 +198,31 @@ func (u *UserController) CheckFollowStatus(names string) {
 			nameList[i] = strings.TrimSpace(nameList[i])
 		}
 		list, err := user.CheckFollowStatusByNames(userInfo.Id, nameList)
+		status := true
+		data := BatchFollowResp{
+			List: list,
+		}
+		for i := 0; i < len(list); i++ {
+			if !checkFollowing(list[i].FollowType) {
+				status = false
+				break
+			}
+		}
+		if status {
+			data.FollowStatus = "following"
+		} else {
+			data.FollowStatus = "unfollowed"
+		}
 		if err != nil {
 			u.FailedResult("获取关注状态失败", result)
 			return
 		}
-		u.SuccessResult("获取关注状态成功", list, result)
+		u.SuccessResult("获取关注状态成功", data, result)
 		return
 	})
-
+}
+func checkFollowing(followType string) bool {
+	return followType == "following"
 }
 
 // FollowAnalyst  关注研究员