Browse Source

Merge branch 'master' into feature/migrate_wecht_msg

xiexiaoyuan 2 years ago
parent
commit
46dc50bf81

+ 7 - 1
controllers/message.go

@@ -161,7 +161,12 @@ func (c *MessageCommon) MessageList() {
 		c.FailWithMessage("获取失败", "获取消息总数失败,Err:"+err.Error())
 		return
 	}
-	list, err := company_approval_message.GetCompanyApprovalMessageList(sysUserId, sourceType, startSize, pageSize)
+	// 消息类型为6-评论时, 查询6-问答评论,7-视频评论
+	sourceTypeStr := strconv.Itoa(sourceType)
+	if sourceType == services.CompanyApprovalMessageSourceTypeByQuestionComment {
+		sourceTypeStr = fmt.Sprintf("%d,%d", services.CompanyApprovalMessageSourceTypeByQuestionComment, services.CompanyApprovalMessageSourceTypeByVideoComment)
+	}
+	list, err := company_approval_message.GetCompanyApprovalMessageList(sysUserId, startSize, pageSize, sourceTypeStr)
 	if err != nil {
 		c.FailWithMessage("获取失败", "获取消息列表失败,Err:"+err.Error())
 		return
@@ -377,6 +382,7 @@ func getMessageInfo(companyApprovalMessageList []*company_approval_message.Compa
 			ApplyTime:   createTime,
 			Content:     tmpMessageInfo.Content,
 			CompanyName: tmpMessageInfo.CompanyName,
+			Extra:       tmpMessageInfo.Extra,
 		}
 		v.ApprovalInfo = approvalInfo
 	}

+ 8 - 2
controllers/yb/community_question_comment.go

@@ -35,7 +35,13 @@ func (c *CommunityQuestionCommentController) List() {
 	condition := ""
 	pars := make([]interface{}, 0)
 
-	//问答id
+	// 来源
+	source, _ := c.GetInt("Source", 1)
+	if source <= 0 {
+		source = 1
+	}
+
+	// 评论ID
 	communityQuestionCommentId, _ := c.GetInt("CommunityQuestionCommentId", 0)
 	if communityQuestionCommentId > 0 {
 		condition += ` AND a.community_question_comment_id = ? `
@@ -65,7 +71,7 @@ func (c *CommunityQuestionCommentController) List() {
 	}
 	startSize = paging.StartIndex(currentIndex, pageSize)
 
-	total, list, err := yb.GetCommunityQuestionCommentList(condition, pars, startSize, pageSize)
+	total, list, err := yb.GetCommunityQuestionCommentList(condition, pars, startSize, pageSize, source)
 	if err != nil {
 		c.FailWithMessage("获取问答列表失败", "QuestionList ErrMsg:"+err.Error())
 		return

+ 2 - 0
models/response/yb/community_question.go

@@ -97,4 +97,6 @@ type CommunityQuestionCommentItem struct {
 	UserName                   string    `description:"评论人名称"`
 	CompanyName                string    `description:"客户名称"`
 	CompanyProductStatus       string    `description:"客户ficc状态"`
+	Source                     int       `description:"来源: 1-问答社区; 2-视频社区"`
+	TagName                    string    `description:"标签名称"`
 }

+ 10 - 5
models/tables/company_approval_message/company_approval_message.go

@@ -67,6 +67,7 @@ type ApprovalInfo struct {
 	CompanyName  string    `description:"客户信息"`
 	ApplyTime    time.Time `description:"提交时间"`
 	ApprovalTime time.Time `description:"审批时间"`
+	Extra        string    `description:"附加字段: 比如视频评论的标签"`
 }
 
 type CompanyApprovalMessageListResp struct {
@@ -91,13 +92,17 @@ func GetCompanyApprovalMessageCount(sysUserId, sourceType int) (count int, err e
 }
 
 //消息列表页
-func GetCompanyApprovalMessageList(sysUserId, sourceType, startSize, pageSize int) (items []*CompanyApprovalMessageList, err error) {
-	sql := `SELECT a.*,b.real_name FROM company_approval_message AS a
-			INNER JOIN admin AS b ON a.create_user_id=b.admin_id
-			WHERE receive_user_id=? AND message_status !=2 AND a.source_type=? `
+func GetCompanyApprovalMessageList(sysUserId, startSize, pageSize int, sourceType string) (items []*CompanyApprovalMessageList, err error) {
+	sql := `SELECT
+				a.*, b.real_name
+			FROM
+				company_approval_message AS a
+			INNER JOIN admin AS b ON a.create_user_id = b.admin_id
+			WHERE
+				receive_user_id =? AND message_status != 2 AND a.source_type IN (` + sourceType + `)`
 	sql += ` ORDER BY create_time DESC LIMIT ?,? `
 	o := orm.NewOrm()
-	_, err = o.Raw(sql, sysUserId, sourceType, startSize, pageSize).QueryRows(&items)
+	_, err = o.Raw(sql, sysUserId, startSize, pageSize).QueryRows(&items)
 	return
 }
 

+ 31 - 2
models/tables/yb_community_question_comment/yb_community_question_comment.go

@@ -24,6 +24,7 @@ type YbCommunityQuestionComment struct {
 	HotTime                    time.Time `orm:"column(hot_time)" description:"设置精选的时间"`
 	ModifyTime                 time.Time `orm:"column(modify_time)" description:"修改时间"`
 	CreateTime                 time.Time `orm:"column(create_time)" description:"创建时间"`
+	Source                     int       `orm:"column(source)" description:"来源: 1-问答社区; 2-视频社区"`
 }
 
 // GetQuestionCommentById 主键获取提问评论
@@ -59,7 +60,9 @@ type YbCommunityQuestionCommentAndQuestion struct {
 	HotTime                    time.Time `orm:"column(hot_time)" description:"设置精选的时间"`
 	ModifyTime                 time.Time `orm:"column(modify_time)" description:"修改时间"`
 	CreateTime                 time.Time `orm:"column(create_time)" description:"创建时间"`
+	Source                     int       `orm:"column(source)" description:"来源:1-问答社区; 2-视频社区"`
 	QuestionContent            string    `description:"问题内容"`
+	TagName                    string    `description:"标签名称"`
 }
 
 // GetCommunityQuestionCommentList 获取问答列表
@@ -67,14 +70,14 @@ func GetCommunityQuestionCommentList(condition string, pars []interface{}, start
 	o := orm.NewOrm()
 
 	//汇总数据
-	totalSQl := `SELECT COUNT(1) total FROM yb_community_question_comment a join yb_community_question b on a.community_question_id = b.community_question_id WHERE a.enabled = 1 and b.is_deleted=0 `
+	totalSQl := `SELECT COUNT(1) total FROM yb_community_question_comment a join yb_community_question b on a.community_question_id = b.community_question_id WHERE a.enabled = 1 and b.is_deleted=0 AND source = 1 `
 	totalSQl += condition
 	if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
 		return
 	}
 
 	// 列表数据
-	sql := `SELECT a.*,b.question_content FROM yb_community_question_comment a join yb_community_question b on a.community_question_id = b.community_question_id WHERE a.enabled = 1 and b.is_deleted=0 `
+	sql := `SELECT a.*,b.question_content FROM yb_community_question_comment a join yb_community_question b on a.community_question_id = b.community_question_id WHERE a.enabled = 1 and b.is_deleted=0 AND source = 1 `
 	sql += condition
 	sql += ` ORDER BY a.create_time DESC LIMIT ?,?`
 	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
@@ -89,3 +92,29 @@ func GetCommunityQuestionCommentListByIds(CommunityQuestionCommentIds string) (l
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
+
+// GetCommunityVideoCommentList 获取视频评论列表
+func GetCommunityVideoCommentList(condition string, pars []interface{}, startSize, pageSize int) (total int, list []*YbCommunityQuestionCommentAndQuestion, err error) {
+	o := orm.NewOrm()
+
+	//汇总数据
+	totalSQl := `SELECT COUNT(1) total FROM yb_community_question_comment a JOIN yb_community_video b ON a.community_question_id = b.community_video_id WHERE a.enabled = 1 AND b.is_deleted = 0 AND source = 2 `
+	totalSQl += condition
+	if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
+		return
+	}
+
+	// 列表数据
+	sql := `SELECT
+				a.*, b.title AS question_content,
+				b.variety_tag_name AS tag_name
+			FROM
+				yb_community_question_comment a
+			JOIN yb_community_video b ON a.community_question_id = b.community_video_id
+			WHERE
+				a.enabled = 1 AND b.is_deleted = 0 AND source = 2 `
+	sql += condition
+	sql += ` ORDER BY a.create_time DESC LIMIT ?,?`
+	_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
+	return
+}

+ 3 - 1
services/company_approval_message.go

@@ -8,7 +8,7 @@ import (
 	"time"
 )
 
-//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论
+//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论,7:视频评论
 const (
 	CompanyApprovalMessageSourceTypeByCompany         = 1
 	CompanyApprovalMessageSourceTypeByContract        = 2
@@ -16,6 +16,7 @@ const (
 	CompanyApprovalMessageSourceTypeByEdbInfo         = 4
 	CompanyApprovalMessageSourceTypeByQuestion        = 5
 	CompanyApprovalMessageSourceTypeByQuestionComment = 6
+	CompanyApprovalMessageSourceTypeByVideoComment    = 7
 )
 
 // 1:申请消息,2:审批结果,3:消息通知
@@ -42,6 +43,7 @@ type MessageInfo struct {
 	UserId               uint64    `json:"user_id"`
 	UserName             string    `json:"user_name"`
 	CreateTime           time.Time `json:"create_time"`
+	Extra                string    `json:"extra" description:"附加字段"`
 }
 
 // AddCompanyApprovalMessage 添加待办消息

+ 28 - 6
services/yb/community_question_comment.go

@@ -15,13 +15,29 @@ import (
 )
 
 // GetCommunityQuestionCommentList 问答评论列表
-func GetCommunityQuestionCommentList(condition string, pars []interface{}, startSize, pageSize int) (total int, commentList []*ybResponse.CommunityQuestionCommentItem, err error) {
+func GetCommunityQuestionCommentList(condition string, pars []interface{}, startSize, pageSize, source int) (total int, commentList []*ybResponse.CommunityQuestionCommentItem, err error) {
 	commentList = make([]*ybResponse.CommunityQuestionCommentItem, 0)
-	total, list, e := yb_community_question_comment.GetCommunityQuestionCommentList(condition, pars, startSize, pageSize)
-	if e != nil {
-		err = errors.New("获取问题列表失败 Err:" + e.Error())
-		return
+	list := make([]*yb_community_question_comment.YbCommunityQuestionCommentAndQuestion, 0)
+	// 来源
+	if source == 1 {
+		qaTotal, qaList, e := yb_community_question_comment.GetCommunityQuestionCommentList(condition, pars, startSize, pageSize)
+		if e != nil {
+			err = errors.New("获取问题列表失败 Err:" + e.Error())
+			return
+		}
+		list = qaList
+		total = qaTotal
+	} else {
+		// 视频社区
+		vcTotal, vcList, e := yb_community_question_comment.GetCommunityVideoCommentList(condition, pars, startSize, pageSize)
+		if e != nil {
+			err = errors.New("获取视频评论列表失败 Err:" + e.Error())
+			return
+		}
+		list = vcList
+		total = vcTotal
 	}
+
 	if len(list) == 0 {
 		return
 	}
@@ -65,6 +81,8 @@ func GetCommunityQuestionCommentList(condition string, pars []interface{}, start
 			UserName:                   "",
 			CompanyName:                "",
 			CompanyProductStatus:       "",
+			Source:                     v.Source,
+			TagName:                    v.TagName,
 		}
 
 		//评论人信息
@@ -143,6 +161,10 @@ func afterDeleteComment(communityQuestionComment *yb_community_question_comment.
 			go alarm_msg.SendAlarmMsg("问答评论信息删除后,标记站内消息失败"+time.Now().Format(utils.FormatDateTime)+";Err:"+err.Error(), 3)
 		}
 	}()
-	err = company_approval_message.CancelCompanyApprovalMessage(int(communityQuestionComment.CommunityQuestionCommentId), services.CompanyApprovalMessageSourceTypeByQuestionComment)
+	sourceType := services.CompanyApprovalMessageSourceTypeByQuestionComment
+	if communityQuestionComment.Source == 2 {
+		sourceType = services.CompanyApprovalMessageSourceTypeByVideoComment
+	}
+	err = company_approval_message.CancelCompanyApprovalMessage(int(communityQuestionComment.CommunityQuestionCommentId), sourceType)
 	return
 }