瀏覽代碼

fix:删除问答、评论后从站内消息中也删除

Roc 2 年之前
父節點
當前提交
ce8693e3fd
共有 3 個文件被更改,包括 58 次插入0 次删除
  1. 24 0
      services/company_approval_message.go
  2. 16 0
      services/yb/community_question.go
  3. 18 0
      services/yb/community_question_comment.go

+ 24 - 0
services/company_approval_message.go

@@ -8,6 +8,30 @@ import (
 	"time"
 )
 
+//消息来源类型,1:客户,2:合同,3:用印,4:指标替换,5:问答社区,6:问答评论
+const (
+	CompanyApprovalMessageSourceTypeByCompany         = 1
+	CompanyApprovalMessageSourceTypeByContract        = 2
+	CompanyApprovalMessageSourceTypeBySeal            = 3
+	CompanyApprovalMessageSourceTypeByEdbInfo         = 4
+	CompanyApprovalMessageSourceTypeByQuestion        = 5
+	CompanyApprovalMessageSourceTypeByQuestionComment = 6
+)
+
+// 1:申请消息,2:审批结果,3:消息通知
+const (
+	CompanyApprovalMessageMessageTypeByApply          = 1
+	CompanyApprovalMessageMessageTypeByApprovalResult = 2
+	CompanyApprovalMessageMessageTypeByMessage        = 3
+)
+
+//审批状态,1:待审批,2:已审批,3:已驳回
+const (
+	CompanyApprovalMessageApprovalStatusByPending  = 1
+	CompanyApprovalMessageApprovalStatusByApproved = 2
+	CompanyApprovalMessageApprovalStatusByRejected = 3
+)
+
 // MessageInfo 消息主要内容
 type MessageInfo struct {
 	CompanyName          string    `json:"company_name"`

+ 16 - 0
services/yb/community_question.go

@@ -6,6 +6,7 @@ import (
 	ybResponse "hongze/hongze_mobile_admin/models/response/yb"
 	"hongze/hongze_mobile_admin/models/tables/admin"
 	"hongze/hongze_mobile_admin/models/tables/company"
+	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/sys_role"
 	"hongze/hongze_mobile_admin/models/tables/sys_role_admin"
 	"hongze/hongze_mobile_admin/models/tables/user_record"
@@ -274,6 +275,9 @@ func SoftDeleteQuestion(questionId int) (err error) {
 	if e := yb_community_question.DeleteQuestion(questionId); e != nil {
 		err = errors.New("删除提问失败 Err:" + e.Error())
 	}
+
+	// 删除问答后的逻辑处理
+	go afterDeleteQuestion(questionId)
 	return
 }
 
@@ -380,3 +384,15 @@ func CheckCommunityQuestionPermission(adminId int) (errMsg string, err error) {
 	}
 	return
 }
+
+// afterDeleteQuestion 删除问答后的逻辑处理
+func afterDeleteQuestion(questionId int) {
+	var err error
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("问答信息删除后,标记站内消息失败"+time.Now().Format(utils.FormatDateTime)+";Err:"+err.Error(), 3)
+		}
+	}()
+	err = company_approval_message.CancelCompanyApprovalMessage(questionId, services.CompanyApprovalMessageSourceTypeByQuestion)
+	return
+}

+ 18 - 0
services/yb/community_question_comment.go

@@ -4,8 +4,11 @@ import (
 	"errors"
 	"fmt"
 	ybResponse "hongze/hongze_mobile_admin/models/response/yb"
+	"hongze/hongze_mobile_admin/models/tables/company_approval_message"
 	"hongze/hongze_mobile_admin/models/tables/wx_user"
 	"hongze/hongze_mobile_admin/models/tables/yb_community_question_comment"
+	"hongze/hongze_mobile_admin/services"
+	"hongze/hongze_mobile_admin/services/alarm_msg"
 	"hongze/hongze_mobile_admin/utils"
 	"strings"
 	"time"
@@ -96,6 +99,9 @@ func SoftDeleteQuestionComment(questionCommentId int) (err error, errMsg string)
 	if err != nil {
 		errMsg = "删除提问失败"
 	}
+
+	// 删除评论后的逻辑处理
+	go afterDeleteComment(questionCommentInfo)
 	return
 }
 
@@ -127,3 +133,15 @@ func SetHotQuestionComment(questionCommentId int) (err error, errMsg string) {
 	}
 	return
 }
+
+// afterDeleteComment 删除评论后的逻辑处理
+func afterDeleteComment(communityQuestionComment *yb_community_question_comment.YbCommunityQuestionComment) {
+	var err error
+	defer func() {
+		if err != nil {
+			go alarm_msg.SendAlarmMsg("问答评论信息删除后,标记站内消息失败"+time.Now().Format(utils.FormatDateTime)+";Err:"+err.Error(), 3)
+		}
+	}()
+	err = company_approval_message.CancelCompanyApprovalMessage(int(communityQuestionComment.CommunityQuestionCommentId), services.CompanyApprovalMessageSourceTypeByQuestionComment)
+	return
+}