浏览代码

fix:表名变更

Roc 2 年之前
父节点
当前提交
19e1089cef

+ 8 - 8
controller/community/question.go

@@ -54,7 +54,7 @@ func QuestionList(c *gin.Context) {
 	}
 
 	// 点赞/吐槽数据
-	err = yb_community_question.HandleLikeOrRoastByCommunityQuestionItemList(userinfo.UserID, list)
+	err = yb_community_question.HandleLikeOrTeaseByCommunityQuestionItemList(userinfo.UserID, list)
 	if err != nil {
 		response.FailMsg("获取失败", "QuestionList ErrMsg:"+err.Error(), c)
 		return
@@ -344,25 +344,25 @@ func AddAudioLog(c *gin.Context) {
 	response.Ok("操作成功", c)
 }
 
-// SetLikeOrRoast 问答点赞/吐槽设置
-func SetLikeOrRoast(c *gin.Context) {
-	var req request.ReqCommunityQuestionLikeRoast
+// SetLikeOrTease 问答点赞/吐槽设置
+func SetLikeOrTease(c *gin.Context) {
+	var req request.ReqCommunityQuestionLikeTease
 	if c.ShouldBind(&req) != nil {
 		response.Fail("参数异常", c)
 		return
 	}
 	userinfo := userService.GetInfoByClaims(c)
 
-	communityQuestionLikeRoast, likeNum, roastNum, err, errMsg := yb_community_question.SetLikeOrRoast(userinfo.UserID, req.CommunityQuestionId, req.OpType, req.Enable, req.SourceAgent)
+	communityQuestionLikeTease, likeNum, teaseNum, err, errMsg := yb_community_question.SetLikeOrTease(userinfo.UserID, req.CommunityQuestionId, req.OpType, req.Enable, req.SourceAgent)
 	if err != nil {
 		response.FailMsg(errMsg, err.Error(), c)
 		return
 	}
 
-	response.OkData("操作成功", responseModel.RespCommunityQuestionLikeRoast{
+	response.OkData("操作成功", responseModel.RespCommunityQuestionLikeTease{
 		LikeNum:  likeNum,
-		RoastNum: roastNum,
-		Enabled:  communityQuestionLikeRoast.Enabled,
+		TeaseNum: teaseNum,
+		Enabled:  communityQuestionLikeTease.Enabled,
 	}, c)
 
 	return

+ 30 - 30
logic/yb_community_question/yb_community_question_like_roast.go → logic/yb_community_question/yb_community_question_like_tease.go

@@ -5,12 +5,12 @@ import (
 	"fmt"
 	"hongze/hongze_yb/global"
 	"hongze/hongze_yb/models/response"
-	"hongze/hongze_yb/models/tables/yb_community_question_like_roast"
+	"hongze/hongze_yb/models/tables/yb_community_question_like_tease"
 	"time"
 )
 
-// SetLikeOrRoast 用户对问答进行(取消)点赞或(取消)吐槽
-func SetLikeOrRoast(userId uint64, communityQuestionId uint32, opType, enable, sourceAgent int8) (ybCommunityQuestionLikeRoast *yb_community_question_like_roast.YbCommunityQuestionLikeRoast, likeNum, roastNum int64, err error, errMsg string) {
+// SetLikeOrTease 用户对问答进行(取消)点赞或(取消)吐槽
+func SetLikeOrTease(userId uint64, communityQuestionId uint32, opType, enable, sourceAgent int8) (ybCommunityQuestionLikeTease *yb_community_question_like_tease.YbCommunityQuestionLikeTease, likeNum, teaseNum int64, err error, errMsg string) {
 	//user.UserID
 	defer func() {
 		if err != nil {
@@ -33,16 +33,16 @@ func SetLikeOrRoast(userId uint64, communityQuestionId uint32, opType, enable, s
 	//}
 
 	//查询用户对问答的点赞/吐槽状态
-	ybCommunityQuestionLikeRoast, err = yb_community_question_like_roast.GetByUserIdAndCommunityQuestionId(userId, communityQuestionId)
+	ybCommunityQuestionLikeTease, err = yb_community_question_like_tease.GetByUserIdAndCommunityQuestionId(userId, communityQuestionId)
 	if err != nil {
 		errMsg = "查询点赞/吐槽记录出错"
 		return
 	}
 	//如果未点赞则新增点赞记录
 	now := time.Now()
-	if ybCommunityQuestionLikeRoast.CommunityQuestionLikeRoastID <= 0 {
-		ybCommunityQuestionLikeRoast = &yb_community_question_like_roast.YbCommunityQuestionLikeRoast{
-			//CommunityQuestionLikeRoastID: 0,
+	if ybCommunityQuestionLikeTease.CommunityQuestionLikeTeaseID <= 0 {
+		ybCommunityQuestionLikeTease = &yb_community_question_like_tease.YbCommunityQuestionLikeTease{
+			//CommunityQuestionLikeTeaseID: 0,
 			UserID:              userId,
 			OpType:              opType,
 			Enabled:             1,
@@ -51,30 +51,30 @@ func SetLikeOrRoast(userId uint64, communityQuestionId uint32, opType, enable, s
 			CommunityQuestionID: communityQuestionId,
 			SourceAgent:         sourceAgent,
 		}
-		err = ybCommunityQuestionLikeRoast.Create()
+		err = ybCommunityQuestionLikeTease.Create()
 		if err != nil {
 			errMsg = err.Error()
 			err = errors.New("新增点赞/吐槽记录出错")
 			return
 		}
 	} else {
-		ybCommunityQuestionLikeRoast.OpType = opType
-		ybCommunityQuestionLikeRoast.Enabled = enable
-		ybCommunityQuestionLikeRoast.ModifyTime = now
+		ybCommunityQuestionLikeTease.OpType = opType
+		ybCommunityQuestionLikeTease.Enabled = enable
+		ybCommunityQuestionLikeTease.ModifyTime = now
 		updates := []string{"op_type", "enabled", "modify_time"}
-		err = ybCommunityQuestionLikeRoast.Update(updates)
+		err = ybCommunityQuestionLikeTease.Update(updates)
 		if err != nil {
 			errMsg = "更新点赞记录出错"
 			return
 		}
 	}
 	//查询总的点赞数
-	likeNum, err = yb_community_question_like_roast.GetLikeNumByCommunityQuestionId(communityQuestionId)
+	likeNum, err = yb_community_question_like_tease.GetLikeNumByCommunityQuestionId(communityQuestionId)
 	if err != nil {
 		errMsg = err.Error()
 		err = errors.New("查询点赞数出错")
 	}
-	roastNum, err = yb_community_question_like_roast.GetRoastNumByCommunityQuestionId(communityQuestionId)
+	teaseNum, err = yb_community_question_like_tease.GetTeaseNumByCommunityQuestionId(communityQuestionId)
 	if err != nil {
 		errMsg = err.Error()
 		err = errors.New("查询吐槽数出错")
@@ -82,8 +82,8 @@ func SetLikeOrRoast(userId uint64, communityQuestionId uint32, opType, enable, s
 	return
 }
 
-// HandleLikeOrRoastByCommunityQuestionItemList 问答 点赞/吐槽 数据
-func HandleLikeOrRoastByCommunityQuestionItemList(userId uint64, questionList []*response.CommunityQuestionItem) (err error) {
+// HandleLikeOrTeaseByCommunityQuestionItemList 问答 点赞/吐槽 数据
+func HandleLikeOrTeaseByCommunityQuestionItemList(userId uint64, questionList []*response.CommunityQuestionItem) (err error) {
 	listLen := len(questionList)
 	if listLen == 0 {
 		return
@@ -94,20 +94,20 @@ func HandleLikeOrRoastByCommunityQuestionItemList(userId uint64, questionList []
 	}
 
 	// 获取点赞和吐槽数据
-	ybCommunityQuestionLikeRoastMap := make(map[uint32]*yb_community_question_like_roast.YbCommunityQuestionLikeRoast)
-	ybCommunityQuestionLikeRoastList, err := yb_community_question_like_roast.GetByUserIdAndCommunityQuestionIds(userId, idArr)
+	ybCommunityQuestionLikeTeaseMap := make(map[uint32]*yb_community_question_like_tease.YbCommunityQuestionLikeTease)
+	ybCommunityQuestionLikeTeaseList, err := yb_community_question_like_tease.GetByUserIdAndCommunityQuestionIds(userId, idArr)
 	if err != nil {
 		return
 	}
-	for _, v := range ybCommunityQuestionLikeRoastList {
-		ybCommunityQuestionLikeRoastMap[v.CommunityQuestionID] = v
+	for _, v := range ybCommunityQuestionLikeTeaseList {
+		ybCommunityQuestionLikeTeaseMap[v.CommunityQuestionID] = v
 	}
 
 	// 获取点赞和吐槽汇总数
 	likeMap := make(map[uint32]int)
-	roastMap := make(map[uint32]int)
+	teaseMap := make(map[uint32]int)
 
-	likeList, err := yb_community_question_like_roast.GetLikeNumCommentByCommunityQuestionIds(idArr)
+	likeList, err := yb_community_question_like_tease.GetLikeNumCommentByCommunityQuestionIds(idArr)
 	if err != nil {
 		return
 	}
@@ -115,29 +115,29 @@ func HandleLikeOrRoastByCommunityQuestionItemList(userId uint64, questionList []
 		likeMap[v.CommunityQuestionID] = v.Total
 	}
 
-	roastList, err := yb_community_question_like_roast.GetRoastNumCommentByCommunityQuestionIds(idArr)
+	teaseList, err := yb_community_question_like_tease.GetTeaseNumCommentByCommunityQuestionIds(idArr)
 	if err != nil {
 		return
 	}
-	for _, v := range roastList {
-		roastMap[v.CommunityQuestionID] = v.Total
+	for _, v := range teaseList {
+		teaseMap[v.CommunityQuestionID] = v.Total
 	}
 
 	for _, v := range questionList {
 		if tmpTotal, ok := likeMap[uint32(v.CommunityQuestionID)]; ok {
 			v.LikeTotal = tmpTotal
 		}
-		if tmpTotal, ok := roastMap[uint32(v.CommunityQuestionID)]; ok {
-			v.RoastTotal = tmpTotal
+		if tmpTotal, ok := teaseMap[uint32(v.CommunityQuestionID)]; ok {
+			v.TeaseTotal = tmpTotal
 		}
 
-		if ybCommunityQuestionLikeRoast, ok := ybCommunityQuestionLikeRoastMap[uint32(v.CommunityQuestionID)]; ok {
-			switch ybCommunityQuestionLikeRoast.OpType {
+		if ybCommunityQuestionLikeTease, ok := ybCommunityQuestionLikeTeaseMap[uint32(v.CommunityQuestionID)]; ok {
+			switch ybCommunityQuestionLikeTease.OpType {
 			//类型. 1-点赞 2-吐槽
 			case 1:
 				v.IsLike = true
 			case 2:
-				v.IsRoast = true
+				v.IsTease = true
 			}
 		}
 	}

+ 2 - 2
models/request/community.go

@@ -55,8 +55,8 @@ type VideoPlayLogReq struct {
 	SourceAgent int `json:"source_agent" description:"来源:1-小程序 2-小程序PC 3-公众号 4-Web官网"`
 }
 
-// ReqCommunityQuestionLikeRoast 问答点赞/吐槽请求
-type ReqCommunityQuestionLikeRoast struct {
+// ReqCommunityQuestionLikeTease 问答点赞/吐槽请求
+type ReqCommunityQuestionLikeTease struct {
 	CommunityQuestionId uint32 `description:"问答id" json:"community_question_id" `
 	OpType              int8   `description:"类型. 1-点赞 2-吐槽" json:"op_type"`
 	Enable              int8   `description:"状态. 0-无效数据(已取消点赞/吐槽) 1-有效数据(点赞/吐槽)" json:"enable"`

+ 5 - 5
models/response/community.go

@@ -23,9 +23,9 @@ type CommunityQuestionItem struct {
 	//PermissionInfo          PermissionCheckInfo           `json:"permission_info"`
 	AudioList    []*CommunityQuestionAudioItem `json:"audio_list"`
 	IsLike       bool                          `json:"is_like" description:"是否已经点赞"`
-	IsRoast      bool                          `json:"is_roast" description:"是否已经吐槽"`
+	IsTease      bool                          `json:"is_tease" description:"是否已经吐槽"`
 	LikeTotal    int                           `json:"like_total" description:"点赞数"`
-	RoastTotal   int                           `json:"roast_total" description:"吐槽数"`
+	TeaseTotal   int                           `json:"tease_total" description:"吐槽数"`
 	CommentTotal int                           `json:"comment_total" description:"总共评论数"`
 	Comment      string                        `json:"comment" description:"评论"`
 }
@@ -83,10 +83,10 @@ type CommunityVideoItem struct {
 	ModifyTime          string `json:"modify_time"`
 }
 
-// RespCommunityQuestionLikeRoast
-type RespCommunityQuestionLikeRoast struct {
+// RespCommunityQuestionLikeTease
+type RespCommunityQuestionLikeTease struct {
 	LikeNum  int64 `description:"点赞总数" json:"like_num"`
-	RoastNum int64 `description:"吐槽总数" json:"roast_num"`
+	TeaseNum int64 `description:"吐槽总数" json:"tease_num"`
 	Enabled  int8  `description:"本次点赞/吐槽结果: 0-已取消赞 1-有效赞" json:"like_enabled"`
 }
 

+ 0 - 8
models/tables/yb_community_question_like_roast/create.go

@@ -1,8 +0,0 @@
-package yb_community_question_like_roast
-
-import "hongze/hongze_yb/global"
-
-func (item *YbCommunityQuestionLikeRoast) Create() (err error) {
-	err = global.DEFAULT_MYSQL.Create(item).Error
-	return
-}

+ 8 - 0
models/tables/yb_community_question_like_tease/create.go

@@ -0,0 +1,8 @@
+package yb_community_question_like_tease
+
+import "hongze/hongze_yb/global"
+
+func (item *YbCommunityQuestionLikeTease) Create() (err error) {
+	err = global.DEFAULT_MYSQL.Create(item).Error
+	return
+}

+ 11 - 11
models/tables/yb_community_question_like_roast/query.go → models/tables/yb_community_question_like_tease/query.go

@@ -1,4 +1,4 @@
-package yb_community_question_like_roast
+package yb_community_question_like_tease
 
 import (
 	"hongze/hongze_yb/global"
@@ -6,7 +6,7 @@ import (
 )
 
 // GetByUserIdAndCommunityQuestionId 根据用户和问答id获取点赞/吐槽记录
-func GetByUserIdAndCommunityQuestionId(userId uint64, communityQuestionId uint32) (item *YbCommunityQuestionLikeRoast, err error) {
+func GetByUserIdAndCommunityQuestionId(userId uint64, communityQuestionId uint32) (item *YbCommunityQuestionLikeTease, err error) {
 	err = global.DEFAULT_MYSQL.
 		Where("user_id = ? AND community_question_id = ?", userId, communityQuestionId).
 		First(&item).Error
@@ -18,15 +18,15 @@ func GetByUserIdAndCommunityQuestionId(userId uint64, communityQuestionId uint32
 
 // GetLikeNumByCommunityQuestionId 获取某个问答的点赞数
 func GetLikeNumByCommunityQuestionId(communityQuestionId uint32) (num int64, err error) {
-	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeRoast{}).
+	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeTease{}).
 		Where(" community_question_id = ? AND enabled=1 AND op_type = 1 ", communityQuestionId).
 		Count(&num).Error
 	return
 }
 
-// GetRoastNumByCommunityQuestionId 获取某个问答的吐槽数
-func GetRoastNumByCommunityQuestionId(communityQuestionId uint32) (num int64, err error) {
-	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeRoast{}).
+// GetTeaseNumByCommunityQuestionId 获取某个问答的吐槽数
+func GetTeaseNumByCommunityQuestionId(communityQuestionId uint32) (num int64, err error) {
+	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeTease{}).
 		Where(" community_question_id = ? AND enabled=1 AND op_type = 2 ", communityQuestionId).
 		Count(&num).Error
 	return
@@ -43,25 +43,25 @@ func GetLikeNumCommentByCommunityQuestionIds(communityQuestionIds []uint32) (ite
 	if len(communityQuestionIds) <= 0 {
 		return
 	}
-	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeRoast{}).
+	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeTease{}).
 		Select("community_question_id, count(1) total").
 		Where("community_question_id in (?) AND enabled=1  AND op_type=1", communityQuestionIds).Scan(&items).Error
 	return
 }
 
-// GetRoastNumCommentByCommunityQuestionIds 根据问答id列表获取所有问答的吐槽数
-func GetRoastNumCommentByCommunityQuestionIds(communityQuestionIds []uint32) (items []*NumCommentByCommunityQuestionIds, err error) {
+// GetTeaseNumCommentByCommunityQuestionIds 根据问答id列表获取所有问答的吐槽数
+func GetTeaseNumCommentByCommunityQuestionIds(communityQuestionIds []uint32) (items []*NumCommentByCommunityQuestionIds, err error) {
 	if len(communityQuestionIds) <= 0 {
 		return
 	}
-	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeRoast{}).
+	err = global.DEFAULT_MYSQL.Model(YbCommunityQuestionLikeTease{}).
 		Select("community_question_id, count(1) total").
 		Where("community_question_id in (?) AND enabled=1  AND op_type=2", communityQuestionIds).Scan(&items).Error
 	return
 }
 
 // GetByUserIdAndCommunityQuestionIds 根据用户id和问答id列表获取成功点赞/吐槽记录
-func GetByUserIdAndCommunityQuestionIds(userId uint64, communityQuestionIds []uint32) (items []*YbCommunityQuestionLikeRoast, err error) {
+func GetByUserIdAndCommunityQuestionIds(userId uint64, communityQuestionIds []uint32) (items []*YbCommunityQuestionLikeTease, err error) {
 	if len(communityQuestionIds) <= 0 {
 		return
 	}

+ 2 - 2
models/tables/yb_community_question_like_roast/update.go → models/tables/yb_community_question_like_tease/update.go

@@ -1,9 +1,9 @@
-package yb_community_question_like_roast
+package yb_community_question_like_tease
 
 import "hongze/hongze_yb/global"
 
 // Update 更新对应字段数据
-func (item *YbCommunityQuestionLikeRoast) Update(updateCols []string) (err error) {
+func (item *YbCommunityQuestionLikeTease) Update(updateCols []string) (err error) {
 	err = global.DEFAULT_MYSQL.Model(item).Select(updateCols).Updates(*item).Error
 	return
 }

+ 10 - 10
models/tables/yb_community_question_like_roast/yb_community_question_like_roast.go → models/tables/yb_community_question_like_tease/yb_community_question_like_tease.go

@@ -1,12 +1,12 @@
-package yb_community_question_like_roast
+package yb_community_question_like_tease
 
 import (
 	"time"
 )
 
-// YbCommunityQuestionLikeRoast 问答点赞/吐槽表
-type YbCommunityQuestionLikeRoast struct {
-	CommunityQuestionLikeRoastID uint64    `gorm:"primaryKey;column:community_question_like_roast_id;type:bigint(20) unsigned;not null" json:"-"`    // 点赞/吐槽自增id
+// YbCommunityQuestionLikeTease 问答点赞/吐槽表
+type YbCommunityQuestionLikeTease struct {
+	CommunityQuestionLikeTeaseID uint64    `gorm:"primaryKey;column:community_question_like_tease_id;type:bigint(20) unsigned;not null" json:"-"`    // 点赞/吐槽自增id
 	UserID                       uint64    `gorm:"column:user_id;type:bigint(20) unsigned;not null;default:0" json:"userId"`                         // 用户id
 	OpType                       int8      `gorm:"column:op_type;type:tinyint(1);not null;default:1" json:"opType"`                                  // 类型. 1-点赞 2-吐槽
 	Enabled                      int8      `gorm:"column:enabled;type:tinyint(1);not null;default:1" json:"enabled"`                                 // 状态. 0-无效数据(已取消点赞/吐槽) 1-有效数据(点赞/吐槽)
@@ -17,13 +17,13 @@ type YbCommunityQuestionLikeRoast struct {
 }
 
 // TableName get sql table name.获取数据库表名
-func (m *YbCommunityQuestionLikeRoast) TableName() string {
-	return "yb_community_question_like_roast"
+func (m *YbCommunityQuestionLikeTease) TableName() string {
+	return "yb_community_question_like_tease"
 }
 
-// YbCommunityQuestionLikeRoastColumns get sql column name.获取数据库列名
-var YbCommunityQuestionLikeRoastColumns = struct {
-	CommunityQuestionLikeRoastID string
+// YbCommunityQuestionLikeTeaseColumns get sql column name.获取数据库列名
+var YbCommunityQuestionLikeTeaseColumns = struct {
+	CommunityQuestionLikeTeaseID string
 	UserID                       string
 	OpType                       string
 	Enabled                      string
@@ -32,7 +32,7 @@ var YbCommunityQuestionLikeRoastColumns = struct {
 	CommunityQuestionID          string
 	SourceAgent                  string
 }{
-	CommunityQuestionLikeRoastID: "community_question_like_roast_id",
+	CommunityQuestionLikeTeaseID: "community_question_like_tease_id",
 	UserID:                       "user_id",
 	OpType:                       "op_type",
 	Enabled:                      "enabled",

+ 1 - 1
routers/community.go

@@ -26,7 +26,7 @@ func InitCommunity(r *gin.Engine) {
 	noAuthGroup.POST("/video/play_log", community.VideoPlayLog)
 
 	//点赞、吐槽、评论
-	rGroup.POST("/set_like_or_roast", community.SetLikeOrRoast)
+	rGroup.POST("/set_like_or_tease", community.SetLikeOrTease)
 	rGroup.POST("/comment", community.Comment)
 	rGroup.POST("/comment/delete", community.DeleteComment)
 	rGroup.GET("/need_anonymous_user_tips", community.GetNeedCommentAnonymousUserTips)