作者 郑周

1. 消息列表

... ... @@ -15,6 +15,119 @@
"application/json"
],
"paths": {
"v1/mini/article_tag": {
"delete": {
"summary": "后台删除文章标签",
"operationId": "DeleteTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagDeleteResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
},
"post": {
"summary": "后台创建文章标签",
"operationId": "CreateTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagCreateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
},
"put": {
"summary": "后台编辑文章标签",
"operationId": "EditTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagEditResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagEditRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/mini/article_tag/{id}": {
"get": {
"summary": "后台获取文章标签",
"operationId": "GetTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/mini/comment": {
"get": {
"summary": "小程序评论",
... ... @@ -97,7 +210,7 @@
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MessageBusinessResponse"
"$ref": "#/definitions/MessageSystemResponse"
}
}
},
... ... @@ -589,11 +702,6 @@
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
},
"type": {
"type": "integer",
"format": "int32",
... ... @@ -604,10 +712,15 @@
"format": "int32",
"description": " 操作类型(1针对文章、1针对评论、2针对圆桌)"
},
"triggerId": {
"companyId": {
"type": "integer",
"format": "int64",
"description": " 操作人公司ID"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 触发者ID"
"description": " 操作人用户ID"
},
"recipientId": {
"type": "integer",
... ... @@ -643,18 +756,26 @@
"format": "int64",
"description": " 创建时间"
},
"userTrigger": {
"user": {
"$ref": "#/definitions/User",
"description": " 触发者"
"description": " 操作人"
},
"article": {
"$ref": "#/definitions/SimpleArticle",
"description": " 文章"
},
"comment": {
"$ref": "#/definitions/Comment",
"description": " 评论(不一定是自己,可能是被人@到)"
}
},
"title": "MessageBusinessItem",
"required": [
"id",
"companyId",
"type",
"optType",
"triggerId",
"companyId",
"userId",
"recipientId",
"articleId",
"commentId",
... ... @@ -662,12 +783,18 @@
"discussionOpinionId",
"content",
"createdAt",
"userTrigger"
"user",
"article",
"comment"
]
},
"MessageBusinessRequest": {
"type": "object",
"properties": {
"type": {
"type": "integer",
"format": "int32"
},
"page": {
"type": "integer",
"format": "int32"
... ... @@ -679,6 +806,7 @@
},
"title": "MessageBusinessRequest",
"required": [
"type",
"page",
"size"
]
... ... @@ -723,6 +851,11 @@
"content": {
"type": "string",
"description": " 内容"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
}
},
"title": "MessageSystemItem",
... ... @@ -730,7 +863,8 @@
"id",
"type",
"title",
"content"
"content",
"createdAt"
]
},
"MessageSystemRequest": {
... ... @@ -938,6 +1072,277 @@
"success"
]
},
"SimpleArticle": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string",
"description": " 文章标题"
},
"countLove": {
"type": "integer",
"format": "int32",
"description": " 点赞数量"
},
"countComment": {
"type": "integer",
"format": "int32",
"description": " 评论数量"
}
},
"title": "SimpleArticle",
"required": [
"id",
"title",
"countLove",
"countComment"
]
},
"TagCreateRequest": {
"type": "object",
"properties": {
"companyId": {
"type": "integer",
"format": "int64"
},
"image": {
"type": "string"
},
"name": {
"type": "string",
"description": " 标签名称"
},
"group": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
}
},
"title": "TagCreateRequest",
"required": [
"companyId",
"image",
"name",
"group",
"remark"
]
},
"TagCreateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "TagCreateResponse",
"required": [
"id"
]
},
"TagDeleteRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "TagDeleteRequest",
"required": [
"id"
]
},
"TagDeleteResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "TagDeleteResponse",
"required": [
"id"
]
},
"TagEditRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
},
"image": {
"type": "string"
},
"name": {
"type": "string",
"description": " 标签名称"
},
"group": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
}
},
"title": "TagEditRequest",
"required": [
"id",
"companyId",
"image",
"name",
"group",
"remark"
]
},
"TagEditResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "TagEditResponse",
"required": [
"id"
]
},
"TagGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "TagGetRequest",
"required": [
"id"
]
},
"TagGetResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"image": {
"type": "string"
},
"name": {
"type": "string",
"description": " 标签名称"
},
"group": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
}
},
"title": "TagGetResponse",
"required": [
"id",
"image",
"name",
"group",
"remark"
]
},
"TagItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"image": {
"type": "string"
},
"name": {
"type": "string",
"description": " 标签名称"
},
"group": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
},
"createdAt": {
"type": "integer",
"format": "int64"
}
},
"title": "TagItem",
"required": [
"id",
"image",
"name",
"group",
"remark",
"createdAt"
]
},
"TagListRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "TagListRequest",
"required": [
"page",
"size"
]
},
"TagListResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/TagItem"
}
}
},
"title": "TagListResponse",
"required": [
"total",
"list"
]
},
"User": {
"type": "object",
"properties": {
... ... @@ -950,10 +1355,9 @@
"format": "int64",
"description": " 公司ID"
},
"departmentId": {
"type": "integer",
"format": "int64",
"description": " 部门ID"
"companyName": {
"type": "string",
"description": " 公司名称"
},
"name": {
"type": "string",
... ... @@ -972,7 +1376,7 @@
"required": [
"id",
"companyId",
"departmentId",
"companyName",
"name",
"avatar",
"position"
... ...
... ... @@ -2,10 +2,11 @@ package message
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -137,29 +138,26 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
}
}
// 只有这个才需要
if msgType == int(domain.MsgTypeReply) || msgType == int(domain.MsgTypeLike) {
// 获取文章数据
if len(articleIds) > 0 {
_, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
domain.NewQueryOptions().
WithFindOnly().
WithKV("ids", articleIds).
WithKV("limit", len(articleIds)))
if err != nil {
return nil, err
}
for i := range articleList {
articleIdMap[articleList[i].Id] = articleList[i]
}
// 获取文章数据
if len(articleIds) > 0 {
_, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(),
domain.NewQueryOptions().
WithFindOnly().
WithKV("ids", articleIds).
WithKV("limit", len(articleIds)))
if err != nil {
return nil, err
}
for i := range articleList {
articleIdMap[articleList[i].Id] = articleList[i]
}
}
for _, item := range list {
to := types.MessageBusinessItem{
Id: item.Id,
Type: item.Type,
OptType: item.OptType,
Type: int(item.Type),
OptType: int(item.OptType),
CompanyId: item.CompanyId,
UserId: item.UserId,
RecipientId: item.RecipientId,
... ... @@ -177,6 +175,7 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
CompanyId: v.CompanyId,
Position: v.Position,
Name: v.Name,
Avatar: v.Avatar,
}
if v, ok := companyIdMap[item.CompanyId]; ok {
... ... @@ -206,3 +205,53 @@ func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (res
}
return resp, nil
}
// CommentArticle 评论文章
func (l *MiniBusinessLogic) CommentArticle(conn transaction.Conn, articleId int64, content string, at []int64) (err error) {
return l.submit(conn, domain.MsgTypeReply, domain.OptTypeArticle, articleId, 0, content, at)
}
// CommentReply 评论回复
func (l *MiniBusinessLogic) CommentReply(conn transaction.Conn, articleId int64, commentId int64, content string, at []int64) (err error) {
return l.submit(conn, domain.MsgTypeReply, domain.OptTypeComment, articleId, commentId, content, at)
}
// LikeArticle 点赞文章
func (l *MiniBusinessLogic) LikeArticle(conn transaction.Conn, articleId int64, at int64) (err error) {
return l.submit(conn, domain.MsgTypeLike, domain.OptTypeArticle, articleId, 0, "", []int64{at})
}
// LikeComment 点赞评论
func (l *MiniBusinessLogic) LikeComment(conn transaction.Conn, articleId int64, commentId int64, at int64) (err error) {
return l.submit(conn, domain.MsgTypeLike, domain.OptTypeComment, articleId, commentId, "", []int64{at})
}
func (l *MiniBusinessLogic) submit(
conn transaction.Conn,
msgType domain.MsgBusinessType,
optType domain.MsgBusinessOpt,
articleId int64,
commentId int64,
content string,
at []int64) (err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
// 评论中携带了 @其他用户
for i := range at {
var msg = &domain.MessageBusiness{
Type: msgType,
OptType: optType,
CompanyId: userToken.CompanyId,
UserId: userToken.UserId,
RecipientId: at[i],
ArticleId: articleId,
CommentId: commentId,
Content: content,
}
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
if err != nil {
return err
}
}
return nil
}
... ...
... ... @@ -6,28 +6,28 @@ import (
)
type MessageBusiness struct {
Id int64 // 唯一标识
Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论ID
DiscussionId int64 `json:"discussionId"` // 圆桌ID
DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
Content string `json:"content"` // 消息内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
Id int64 // 唯一标识
Type MsgBusinessType `json:"type"` // 分类 (1回复 2点赞 3被采纳)
OptType MsgBusinessOpt `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌)
CompanyId int64 `json:"companyId"` // 操作人公司ID
UserId int64 `json:"userId"` // 操作人用户ID
RecipientId int64 `json:"recipientId"` // 接收人用户ID
ArticleId int64 `json:"articleId"` // 文章ID
CommentId int64 `json:"commentId"` // 评论ID
DiscussionId int64 `json:"discussionId"` // 圆桌ID
DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID
Content string `json:"content"` // 消息内容
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
}
type MsgBusinessType int
type MsgBusinessOpt int
const (
MsgTypeReply MsgBusinessType = 1 // 消息分类-回复
MsgTypeReply MsgBusinessType = 1 // 消息分类-评论
MsgTypeLike MsgBusinessType = 2 // 消息分类-点赞
MsgTypeAccept MsgBusinessType = 3 // 消息分类-被采纳
)
... ...