Browse Source

fix:请求入参调整

Roc 2 years ago
parent
commit
d290833e10

+ 6 - 6
controller/community/comment.go

@@ -49,8 +49,8 @@ func DeleteComment(c *gin.Context) {
 
 
 // HotList 获取精选留言
 // HotList 获取精选留言
 func HotList(c *gin.Context) {
 func HotList(c *gin.Context) {
-	communityQuestionCommentIDStr := c.DefaultQuery("community_question_comment_id", "")
-	communityQuestionCommentID, err := strconv.Atoi(communityQuestionCommentIDStr)
+	communityQuestionIDStr := c.DefaultQuery("community_question_id", "")
+	communityQuestionID, err := strconv.Atoi(communityQuestionIDStr)
 	if err != nil {
 	if err != nil {
 		response.Fail("问答id异常", c)
 		response.Fail("问答id异常", c)
 		return
 		return
@@ -59,7 +59,7 @@ func HotList(c *gin.Context) {
 	page := services.GetCurrPageByClaims(c)
 	page := services.GetCurrPageByClaims(c)
 	pageSize := services.GetPageSizeByClaims(c)
 	pageSize := services.GetPageSizeByClaims(c)
 
 
-	list, total, err, errMsg := yb_community_question.List(userinfo.UserID, communityQuestionCommentID, true, page, pageSize)
+	list, total, err, errMsg := yb_community_question.List(userinfo.UserID, communityQuestionID, true, page, pageSize)
 	if err != nil {
 	if err != nil {
 		response.FailMsg(errMsg, err.Error(), c)
 		response.FailMsg(errMsg, err.Error(), c)
 		return
 		return
@@ -74,8 +74,8 @@ func HotList(c *gin.Context) {
 
 
 // MyList 获取我的留言
 // MyList 获取我的留言
 func MyList(c *gin.Context) {
 func MyList(c *gin.Context) {
-	communityQuestionCommentIDStr := c.DefaultQuery("community_question_comment_id", "")
-	communityQuestionCommentID, err := strconv.Atoi(communityQuestionCommentIDStr)
+	communityQuestionIDStr := c.DefaultQuery("community_question_id", "")
+	communityQuestionID, err := strconv.Atoi(communityQuestionIDStr)
 	if err != nil {
 	if err != nil {
 		response.Fail("问答id异常", c)
 		response.Fail("问答id异常", c)
 		return
 		return
@@ -84,7 +84,7 @@ func MyList(c *gin.Context) {
 	page := services.GetCurrPageByClaims(c)
 	page := services.GetCurrPageByClaims(c)
 	pageSize := services.GetPageSizeByClaims(c)
 	pageSize := services.GetPageSizeByClaims(c)
 
 
-	list, total, isShowName, err, errMsg := yb_community_question.MyList(userinfo.UserID, communityQuestionCommentID, page, pageSize)
+	list, total, isShowName, err, errMsg := yb_community_question.MyList(userinfo.UserID, communityQuestionID, page, pageSize)
 	if err != nil {
 	if err != nil {
 		response.FailMsg(errMsg, err.Error(), c)
 		response.FailMsg(errMsg, err.Error(), c)
 		return
 		return

+ 8 - 8
logic/yb_community_question/yb_community_question_comment.go

@@ -140,8 +140,8 @@ func Delete(user user.UserInfo, communityQuestionCommentID uint64) (err error, e
 }
 }
 
 
 // MyList 我的留言列表
 // MyList 我的留言列表
-func MyList(userId uint64, communityQuestionCommentID int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, isShowName int8, err error, errMsg string) {
-	list, total, err, errMsg = List(userId, communityQuestionCommentID, false, page, pageSize)
+func MyList(userId uint64, communityQuestionID int, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, isShowName int8, err error, errMsg string) {
+	list, total, err, errMsg = List(userId, communityQuestionID, false, page, pageSize)
 	if err != nil {
 	if err != nil {
 		return
 		return
 	}
 	}
@@ -154,7 +154,7 @@ func MyList(userId uint64, communityQuestionCommentID int, page, pageSize int) (
 }
 }
 
 
 // List 查询精选留言列表或我的留言列表
 // List 查询精选留言列表或我的留言列表
-func List(userId uint64, communityQuestionCommentID int, hotFlag bool, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, err error, errMsg string) {
+func List(userId uint64, communityQuestionID int, hotFlag bool, page, pageSize int) (list []*response.RespCommunityQuestionCommentItem, total int64, err error, errMsg string) {
 	defer func() {
 	defer func() {
 		if err != nil {
 		if err != nil {
 			global.LOG.Critical(fmt.Sprintf("comment List: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
 			global.LOG.Critical(fmt.Sprintf("comment List: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
@@ -162,7 +162,7 @@ func List(userId uint64, communityQuestionCommentID int, hotFlag bool, page, pag
 	}()
 	}()
 	list = make([]*response.RespCommunityQuestionCommentItem, 0)
 	list = make([]*response.RespCommunityQuestionCommentItem, 0)
 
 
-	if communityQuestionCommentID <= 0 {
+	if communityQuestionID <= 0 {
 		err = errors.New("请输入问答ID")
 		err = errors.New("请输入问答ID")
 		return
 		return
 	}
 	}
@@ -170,24 +170,24 @@ func List(userId uint64, communityQuestionCommentID int, hotFlag bool, page, pag
 	var commentList []*yb_community_question_comment.YbCommunityQuestionComment
 	var commentList []*yb_community_question_comment.YbCommunityQuestionComment
 	//查询精选留言
 	//查询精选留言
 	if hotFlag {
 	if hotFlag {
-		commentList, err = yb_community_question_comment.GetHotListByCommunityQuestionCommentID(communityQuestionCommentID, (page-1)*pageSize, pageSize)
+		commentList, err = yb_community_question_comment.GetHotListByCommunityQuestionID(communityQuestionID, (page-1)*pageSize, pageSize)
 		if err != nil {
 		if err != nil {
 			errMsg = `查询精选留言列表出错`
 			errMsg = `查询精选留言列表出错`
 			return
 			return
 		}
 		}
-		total, err = yb_community_question_comment.GetHotListTotalByCommunityQuestionCommentID(communityQuestionCommentID)
+		total, err = yb_community_question_comment.GetHotListTotalByCommunityQuestionID(communityQuestionID)
 		if err != nil {
 		if err != nil {
 			errMsg = `查询精选留言总数出错`
 			errMsg = `查询精选留言总数出错`
 			return
 			return
 		}
 		}
 	} else {
 	} else {
 		//查询个人留言
 		//查询个人留言
-		commentList, err = yb_community_question_comment.GetListByUserIdCommunityQuestionCommentID(userId, communityQuestionCommentID)
+		commentList, err = yb_community_question_comment.GetListByUserIdCommunityQuestionID(userId, communityQuestionID)
 		if err != nil {
 		if err != nil {
 			errMsg = `查询我的留言列表出错`
 			errMsg = `查询我的留言列表出错`
 			return
 			return
 		}
 		}
-		total, err = yb_community_question_comment.GetListTotalByUserIdCommunityQuestionCommentID(userId, communityQuestionCommentID)
+		total, err = yb_community_question_comment.GetListTotalByUserIdCommunityQuestionID(userId, communityQuestionID)
 		if err != nil {
 		if err != nil {
 			errMsg = `查询我的留言总数出错`
 			errMsg = `查询我的留言总数出错`
 			return
 			return

+ 12 - 12
models/tables/yb_community_question_comment/query.go

@@ -14,10 +14,10 @@ func GetByCommunityQuestionCommentId(communityQuestionCommentId uint64) (item *Y
 	return
 	return
 }
 }
 
 
-// GetListByUserIdCommunityQuestionCommentID 获取用户的留言列表
-func GetListByUserIdCommunityQuestionCommentID(userId uint64, communityQuestionCommentID int) (list []*YbCommunityQuestionComment, err error) {
+// GetListByUserIdCommunityQuestionID 获取用户的留言列表
+func GetListByUserIdCommunityQuestionID(userId uint64, communityQuestionID int) (list []*YbCommunityQuestionComment, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("user_id = ? AND community_question_id = ? AND enabled = 1 ", userId, communityQuestionCommentID).
+		Where("user_id = ? AND community_question_id = ? AND enabled = 1 ", userId, communityQuestionID).
 		Order("create_time desc, community_question_comment_id desc").
 		Order("create_time desc, community_question_comment_id desc").
 		Scan(&list).Error
 		Scan(&list).Error
 	if err == utils.ErrNoRow {
 	if err == utils.ErrNoRow {
@@ -26,18 +26,18 @@ func GetListByUserIdCommunityQuestionCommentID(userId uint64, communityQuestionC
 	return
 	return
 }
 }
 
 
-// GetListTotalByUserIdCommunityQuestionCommentID 获取用户的留言总条数
-func GetListTotalByUserIdCommunityQuestionCommentID(userId uint64, communityQuestionCommentID int) (total int64, err error) {
+// GetListTotalByUserIdCommunityQuestionID 获取用户的留言总条数
+func GetListTotalByUserIdCommunityQuestionID(userId uint64, communityQuestionID int) (total int64, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("user_id = ? AND community_question_id = ? AND enabled = 1 ", userId, communityQuestionCommentID).
+		Where("user_id = ? AND community_question_id = ? AND enabled = 1 ", userId, communityQuestionID).
 		Count(&total).Error
 		Count(&total).Error
 	return
 	return
 }
 }
 
 
-// GetHotListByCommunityQuestionCommentID 获取报告的精选留言列表
-func GetHotListByCommunityQuestionCommentID(communityQuestionCommentID int, offset, limit int) (list []*YbCommunityQuestionComment, err error) {
+// GetHotListByCommunityQuestionID 获取报告的精选留言列表
+func GetHotListByCommunityQuestionID(communityQuestionID int, offset, limit int) (list []*YbCommunityQuestionComment, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("community_question_id = ? AND enabled = 1 AND is_hot = 1 AND type = 1", communityQuestionCommentID).
+		Where("community_question_id = ? AND enabled = 1 AND is_hot = 1 AND type = 1", communityQuestionID).
 		Order("is_top desc, hot_top_time desc, community_question_comment_id desc").
 		Order("is_top desc, hot_top_time desc, community_question_comment_id desc").
 		Offset(offset).
 		Offset(offset).
 		Limit(limit).
 		Limit(limit).
@@ -45,10 +45,10 @@ func GetHotListByCommunityQuestionCommentID(communityQuestionCommentID int, offs
 	return
 	return
 }
 }
 
 
-// GetHotListTotalByCommunityQuestionCommentID 获取精选留言总条数
-func GetHotListTotalByCommunityQuestionCommentID(communityQuestionCommentID int) (total int64, err error) {
+// GetHotListTotalByCommunityQuestionID 获取精选留言总条数
+func GetHotListTotalByCommunityQuestionID(communityQuestionID int) (total int64, err error) {
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
 	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionComment{}).
-		Where("community_question_id = ? AND enabled = 1 AND is_hot = 1 AND type = 1", communityQuestionCommentID).
+		Where("community_question_id = ? AND enabled = 1 AND is_hot = 1 AND type = 1", communityQuestionID).
 		Count(&total).Error
 		Count(&total).Error
 	return
 	return
 }
 }