Browse Source

fix:是否匿名弹框

Roc 2 years ago
parent
commit
ef32c462c5

+ 7 - 0
controller/community/comment.go

@@ -108,11 +108,18 @@ func MyList(c *gin.Context) {
 // GetNeedCommentAnonymousUserTips 获取是否 弹出让去设置头像 的提示框
 func GetNeedCommentAnonymousUserTips(c *gin.Context) {
 	userinfo := userService.GetInfoByClaims(c)
+
+	// true 不弹框,false弹框
+	if userinfo.NickName != `` {
+		response.OkData("获取成功", true, c)
+		return
+	}
 	ok, err := yb_community_question.GetNeedCommentAnonymousUserTips(userinfo.UserID)
 	if err != nil {
 		response.FailMsg("获取失败", err.Error(), c)
 		return
 	}
+
 	response.OkData("获取成功", ok, c)
 }
 

+ 2 - 2
logic/yb_community_question/yb_community_question_comment.go

@@ -285,8 +285,8 @@ func GetNeedCommentAnonymousUserTips(userId uint64) (ok bool, err error) {
 	if err != nil {
 		return
 	}
-	//如果找不到,那么认为是第一次评论,那么需要弹框提示
-	if ybCommentAnonymousUser.UserID <= 0 {
+	//如果能找到,那么认为是有设置过匿名评论,那么不需要需要弹框提示
+	if ybCommentAnonymousUser.UserID > 0 {
 		ok = true
 	}
 	return

+ 1 - 1
models/tables/yb_comment_anonymous_user/create.go

@@ -12,7 +12,7 @@ func (item *YbCommentAnonymousUser) Create() (err error) {
 
 // CreateBySql 通过sql创建记录
 func CreateBySql(userId uint64, createTime time.Time) (err error) {
-	sql := "INSERT INTO `yb_comment_anonymous_user` (`user_id`,`create_time`) VALUES (51988,'2022-07-12 14:33:30.443')"
+	sql := "INSERT INTO `yb_comment_anonymous_user` (`user_id`,`create_time`) VALUES (?,?)"
 	err = global.DEFAULT_MYSQL.Exec(sql, userId, createTime).Error
 	return
 }