正在显示
10 个修改的文件
包含
235 行增加
和
58 行删除
| @@ -41,6 +41,7 @@ type ( | @@ -41,6 +41,7 @@ type ( | ||
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | MessageBusinessRequest struct { | 43 | MessageBusinessRequest struct { |
| 44 | + Type int `json:"type"` | ||
| 44 | Page int `json:"page"` | 45 | Page int `json:"page"` |
| 45 | Size int `json:"size"` | 46 | Size int `json:"size"` |
| 46 | } | 47 | } |
| @@ -50,10 +51,10 @@ type ( | @@ -50,10 +51,10 @@ type ( | ||
| 50 | } | 51 | } |
| 51 | MessageBusinessItem struct { | 52 | MessageBusinessItem struct { |
| 52 | Id int64 `json:"id"` | 53 | Id int64 `json:"id"` |
| 53 | - CompanyId int64 `json:"companyId"` // 公司ID | ||
| 54 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | 54 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) |
| 55 | OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | 55 | OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) |
| 56 | - TriggerId int64 `json:"triggerId"` // 触发者ID | 56 | + CompanyId int64 `json:"companyId"` // 操作人公司ID |
| 57 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
| 57 | RecipientId int64 `json:"recipientId"` // 接收者ID | 58 | RecipientId int64 `json:"recipientId"` // 接收者ID |
| 58 | ArticleId int64 `json:"articleId"` // 文章ID | 59 | ArticleId int64 `json:"articleId"` // 文章ID |
| 59 | CommentId int64 `json:"commentId"` // 评论ID | 60 | CommentId int64 `json:"commentId"` // 评论ID |
| @@ -61,15 +62,25 @@ type ( | @@ -61,15 +62,25 @@ type ( | ||
| 61 | DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | 62 | DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID |
| 62 | Content string `json:"content"` // 消息内容 | 63 | Content string `json:"content"` // 消息内容 |
| 63 | CreatedAt int64 `json:"createdAt"` // 创建时间 | 64 | CreatedAt int64 `json:"createdAt"` // 创建时间 |
| 64 | - UserTrigger User `json:"userTrigger"` // 触发者 | 65 | + User *User `json:"user"` // 操作人 |
| 66 | + Article *SimpleArticle `json:"article"` // 文章 | ||
| 67 | + Comment *Comment `json:"comment"` // 评论(不一定是自己,可能是被人@到) | ||
| 65 | } | 68 | } |
| 66 | 69 | ||
| 67 | User struct { | 70 | User struct { |
| 68 | Id int64 `json:"id"` | 71 | Id int64 `json:"id"` |
| 69 | CompanyId int64 `json:"companyId,omitempty"` // 公司ID | 72 | CompanyId int64 `json:"companyId,omitempty"` // 公司ID |
| 70 | - DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID | 73 | + CompanyName string `json:"companyName,omitempty"` // 公司名称 |
| 71 | Name string `json:"name,omitempty"` // 名称 | 74 | Name string `json:"name,omitempty"` // 名称 |
| 72 | Avatar string `json:"avatar,omitempty"` // 头像 | 75 | Avatar string `json:"avatar,omitempty"` // 头像 |
| 73 | Position string `json:"position,omitempty"` // 职位 | 76 | Position string `json:"position,omitempty"` // 职位 |
| 74 | } | 77 | } |
| 78 | + | ||
| 79 | + | ||
| 80 | + SimpleArticle struct { | ||
| 81 | + Id int64 `json:"id"` | ||
| 82 | + Title string `json:"title"` // 文章标题 | ||
| 83 | + CountLove int `json:"countLove"` // 点赞数量 | ||
| 84 | + CountComment int `json:"countComment"` // 评论数量 | ||
| 85 | + } | ||
| 75 | ) | 86 | ) |
| 1 | package message | 1 | package message |
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 4 | "net/http" | 5 | "net/http" |
| 5 | 6 | ||
| 6 | "github.com/zeromicro/go-zero/rest/httpx" | 7 | "github.com/zeromicro/go-zero/rest/httpx" |
| @@ -19,13 +20,6 @@ func MiniBusinessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -19,13 +20,6 @@ func MiniBusinessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 19 | 20 | ||
| 20 | l := message.NewMiniBusinessLogic(r.Context(), svcCtx) | 21 | l := message.NewMiniBusinessLogic(r.Context(), svcCtx) |
| 21 | resp, err := l.MiniBusiness(&req) | 22 | resp, err := l.MiniBusiness(&req) |
| 22 | - | ||
| 23 | - //result.HttpResult(r, w, resp, err) | ||
| 24 | - | ||
| 25 | - if err != nil { | ||
| 26 | - httpx.ErrorCtx(r.Context(), w, err) | ||
| 27 | - } else { | ||
| 28 | - httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 29 | - } | 23 | + result.HttpResult(r, w, resp, err) |
| 30 | } | 24 | } |
| 31 | } | 25 | } |
| @@ -21,10 +21,5 @@ func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | @@ -21,10 +21,5 @@ func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 21 | l := message.NewMiniSystemLogic(r.Context(), svcCtx) | 21 | l := message.NewMiniSystemLogic(r.Context(), svcCtx) |
| 22 | resp, err := l.MiniSystem(&req) | 22 | resp, err := l.MiniSystem(&req) |
| 23 | result.HttpResult(r, w, resp, err) | 23 | result.HttpResult(r, w, resp, err) |
| 24 | - //if err != nil { | ||
| 25 | - // httpx.ErrorCtx(r.Context(), w, err) | ||
| 26 | - //} else { | ||
| 27 | - // httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 28 | - //} | ||
| 29 | } | 24 | } |
| 30 | } | 25 | } |
| @@ -25,25 +25,183 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini | @@ -25,25 +25,183 @@ func NewMiniBusinessLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Mini | ||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) { | 27 | func (l *MiniBusinessLogic) MiniBusiness(req *types.MessageBusinessRequest) (resp *types.MessageBusinessResponse, err error) { |
| 28 | - queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | ||
| 29 | - total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), queryOptions) | ||
| 30 | - if err != nil { | ||
| 31 | - return nil, err | ||
| 32 | - } | 28 | + var msgType = req.Type |
| 29 | + | ||
| 30 | + total, list, err := l.svcCtx.MessageBusinessRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), domain.NewQueryOptions(). | ||
| 31 | + WithOffsetLimit(req.Page, req.Size). | ||
| 32 | + WithKV("type", msgType)) | ||
| 33 | if err != nil { | 33 | if err != nil { |
| 34 | return nil, err | 34 | return nil, err |
| 35 | } | 35 | } |
| 36 | + // 输出 | ||
| 36 | resp = &types.MessageBusinessResponse{} | 37 | resp = &types.MessageBusinessResponse{} |
| 37 | resp.Total = total | 38 | resp.Total = total |
| 38 | resp.List = make([]types.MessageBusinessItem, 0) | 39 | resp.List = make([]types.MessageBusinessItem, 0) |
| 40 | + if total == 0 { | ||
| 41 | + return resp, nil | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + var companyIdMap = map[int64]*domain.Company{} | ||
| 45 | + var userIdMap = map[int64]*domain.User{} | ||
| 46 | + var articleIdMap = map[int64]*domain.Article{} | ||
| 47 | + var commentIdMap = map[int64]*domain.Comment{} | ||
| 48 | + //var discussionIdMap = map[int64]int{} | ||
| 49 | + //var discussionOpinionIdMap = map[int64]int{} | ||
| 50 | + for _, item := range list { | ||
| 51 | + if item.CompanyId != 0 { | ||
| 52 | + companyIdMap[item.CompanyId] = nil | ||
| 53 | + } | ||
| 54 | + if item.UserId != 0 { | ||
| 55 | + userIdMap[item.UserId] = nil | ||
| 56 | + } | ||
| 57 | + if item.ArticleId != 0 { | ||
| 58 | + articleIdMap[item.ArticleId] = nil | ||
| 59 | + } | ||
| 60 | + if item.CommentId != 0 { | ||
| 61 | + commentIdMap[item.CommentId] = nil | ||
| 62 | + } | ||
| 63 | + //if item.DiscussionId != 0 { | ||
| 64 | + // discussionIdMap[item.DiscussionId] = 0 | ||
| 65 | + //} | ||
| 66 | + //if item.DiscussionOpinionId != 0 { | ||
| 67 | + // discussionOpinionIdMap[item.DiscussionOpinionId] = 0 | ||
| 68 | + //} | ||
| 69 | + } | ||
| 70 | + var companyIds = make([]int64, 0) // 公司ID | ||
| 71 | + var userIds = make([]int64, 0) // 用户ID | ||
| 72 | + var articleIds = make([]int64, 0) // 文章ID | ||
| 73 | + var commentIds = make([]int64, 0) // 评论ID | ||
| 74 | + //var discussionIds = make([]int64, 0) // 讨论ID 暂时搁置 | ||
| 75 | + //var discussionOpinionIds = make([]int64, 0) // 观点ID | ||
| 76 | + for k, _ := range companyIdMap { | ||
| 77 | + companyIds = append(companyIds, k) | ||
| 78 | + } | ||
| 79 | + for k, _ := range userIdMap { | ||
| 80 | + userIds = append(userIds, k) | ||
| 81 | + } | ||
| 82 | + for k, _ := range articleIdMap { | ||
| 83 | + articleIds = append(articleIds, k) | ||
| 84 | + } | ||
| 85 | + for k, _ := range commentIdMap { | ||
| 86 | + commentIds = append(commentIds, k) | ||
| 87 | + } | ||
| 88 | + //for k, _ := range discussionIdMap { | ||
| 89 | + // discussionIds = append(discussionIds, k) | ||
| 90 | + //} | ||
| 91 | + //for k, _ := range discussionOpinionIdMap { | ||
| 92 | + // discussionOpinionIds = append(discussionOpinionIds, k) | ||
| 93 | + //} | ||
| 94 | + | ||
| 95 | + // 获取公司 | ||
| 96 | + if len(companyIds) > 0 { | ||
| 97 | + _, companyList, err := l.svcCtx.CompanyRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), | ||
| 98 | + domain.NewQueryOptions(). | ||
| 99 | + WithFindOnly(). | ||
| 100 | + WithKV("ids", userIds). | ||
| 101 | + WithKV("limit", len(userIds))) | ||
| 102 | + if err != nil { | ||
| 103 | + return nil, err | ||
| 104 | + } | ||
| 105 | + for i := range companyList { | ||
| 106 | + companyIdMap[companyList[i].Id] = companyList[i] | ||
| 107 | + } | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + // 获取用户 | ||
| 111 | + if len(userIds) > 0 { | ||
| 112 | + _, userList, err := l.svcCtx.UserRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), | ||
| 113 | + domain.NewQueryOptions(). | ||
| 114 | + WithFindOnly(). | ||
| 115 | + WithKV("ids", userIds). | ||
| 116 | + WithKV("limit", len(userIds))) | ||
| 117 | + if err != nil { | ||
| 118 | + return nil, err | ||
| 119 | + } | ||
| 120 | + for i := range userList { | ||
| 121 | + userIdMap[userList[i].Id] = userList[i] | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + // 获取评论 | ||
| 126 | + if len(commentIds) > 0 { | ||
| 127 | + _, commentList, err := l.svcCtx.CommentRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), | ||
| 128 | + domain.NewQueryOptions(). | ||
| 129 | + WithFindOnly(). | ||
| 130 | + WithKV("ids", commentIds). | ||
| 131 | + WithKV("limit", len(commentIds))) | ||
| 132 | + if err != nil { | ||
| 133 | + return nil, err | ||
| 134 | + } | ||
| 135 | + for i := range commentList { | ||
| 136 | + commentIdMap[commentList[i].Id] = commentList[i] | ||
| 137 | + } | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + // 只有这个才需要 | ||
| 141 | + if msgType == int(domain.MsgTypeReply) || msgType == int(domain.MsgTypeLike) { | ||
| 142 | + // 获取文章数据 | ||
| 143 | + if len(articleIds) > 0 { | ||
| 144 | + _, articleList, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.svcCtx.DefaultDBConn(), | ||
| 145 | + domain.NewQueryOptions(). | ||
| 146 | + WithFindOnly(). | ||
| 147 | + WithKV("ids", articleIds). | ||
| 148 | + WithKV("limit", len(articleIds))) | ||
| 149 | + if err != nil { | ||
| 150 | + return nil, err | ||
| 151 | + } | ||
| 152 | + for i := range articleList { | ||
| 153 | + articleIdMap[articleList[i].Id] = articleList[i] | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + | ||
| 39 | for _, item := range list { | 158 | for _, item := range list { |
| 40 | to := types.MessageBusinessItem{ | 159 | to := types.MessageBusinessItem{ |
| 41 | - Id: item.Id, | ||
| 42 | - Type: item.Type, | ||
| 43 | - //Title: item.Title, | ||
| 44 | - Content: item.Content, | ||
| 45 | - CreatedAt: item.CreatedAt, | 160 | + Id: item.Id, |
| 161 | + Type: item.Type, | ||
| 162 | + OptType: item.OptType, | ||
| 163 | + CompanyId: item.CompanyId, | ||
| 164 | + UserId: item.UserId, | ||
| 165 | + RecipientId: item.RecipientId, | ||
| 166 | + ArticleId: item.ArticleId, | ||
| 167 | + CommentId: item.CommentId, | ||
| 168 | + DiscussionId: item.DiscussionId, | ||
| 169 | + DiscussionOpinionId: item.DiscussionOpinionId, | ||
| 170 | + Content: item.Content, | ||
| 171 | + CreatedAt: item.CreatedAt, | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + if v, ok := userIdMap[item.UserId]; ok { | ||
| 175 | + to.User = &types.User{ | ||
| 176 | + Id: v.Id, | ||
| 177 | + CompanyId: v.CompanyId, | ||
| 178 | + Position: v.Position, | ||
| 179 | + Name: v.Name, | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + if v, ok := companyIdMap[item.CompanyId]; ok { | ||
| 183 | + to.User.CompanyName = v.Name | ||
| 184 | + } | ||
| 46 | } | 185 | } |
| 186 | + | ||
| 187 | + if v, ok := articleIdMap[item.ArticleId]; ok { | ||
| 188 | + to.Article = &types.SimpleArticle{ | ||
| 189 | + Id: v.Id, | ||
| 190 | + Title: v.Title, | ||
| 191 | + CountLove: v.CountLove, | ||
| 192 | + CountComment: v.CountComment, | ||
| 193 | + } | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + if _, ok := commentIdMap[item.CommentId]; ok { | ||
| 197 | + to.Comment = &types.Comment{ | ||
| 198 | + //Id: v.Id, | ||
| 199 | + //Title: v.Title, | ||
| 200 | + //CountLove: v.CountLove, | ||
| 201 | + //CountComment: v.CountComment, | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + | ||
| 47 | resp.List = append(resp.List, to) | 205 | resp.List = append(resp.List, to) |
| 48 | } | 206 | } |
| 49 | return resp, nil | 207 | return resp, nil |
| @@ -30,6 +30,7 @@ type MessageSystemItem struct { | @@ -30,6 +30,7 @@ type MessageSystemItem struct { | ||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | type MessageBusinessRequest struct { | 32 | type MessageBusinessRequest struct { |
| 33 | + Type int `json:"type"` | ||
| 33 | Page int `json:"page"` | 34 | Page int `json:"page"` |
| 34 | Size int `json:"size"` | 35 | Size int `json:"size"` |
| 35 | } | 36 | } |
| @@ -40,28 +41,37 @@ type MessageBusinessResponse struct { | @@ -40,28 +41,37 @@ type MessageBusinessResponse struct { | ||
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | type MessageBusinessItem struct { | 43 | type MessageBusinessItem struct { |
| 43 | - Id int64 `json:"id"` | ||
| 44 | - CompanyId int64 `json:"companyId"` // 公司ID | ||
| 45 | - Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
| 46 | - OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 47 | - TriggerId int64 `json:"triggerId"` // 触发者ID | ||
| 48 | - RecipientId int64 `json:"recipientId"` // 接收者ID | ||
| 49 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
| 50 | - CommentId int64 `json:"commentId"` // 评论ID | ||
| 51 | - DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
| 52 | - DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
| 53 | - Content string `json:"content"` // 消息内容 | ||
| 54 | - CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
| 55 | - UserTrigger User `json:"userTrigger"` // 触发者 | 44 | + Id int64 `json:"id"` |
| 45 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
| 46 | + OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 47 | + CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
| 48 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
| 49 | + RecipientId int64 `json:"recipientId"` // 接收者ID | ||
| 50 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 51 | + CommentId int64 `json:"commentId"` // 评论ID | ||
| 52 | + DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
| 53 | + DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
| 54 | + Content string `json:"content"` // 消息内容 | ||
| 55 | + CreatedAt int64 `json:"createdAt"` // 创建时间 | ||
| 56 | + User *User `json:"user"` // 操作人 | ||
| 57 | + Article *SimpleArticle `json:"article"` // 文章 | ||
| 58 | + Comment *Comment `json:"comment"` // 评论(不一定是自己,可能是被人@到) | ||
| 56 | } | 59 | } |
| 57 | 60 | ||
| 58 | type User struct { | 61 | type User struct { |
| 62 | + Id int64 `json:"id"` | ||
| 63 | + CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 64 | + CompanyName string `json:"companyName,omitempty"` // 公司名称 | ||
| 65 | + Name string `json:"name,omitempty"` // 名称 | ||
| 66 | + Avatar string `json:"avatar,omitempty"` // 头像 | ||
| 67 | + Position string `json:"position,omitempty"` // 职位 | ||
| 68 | +} | ||
| 69 | + | ||
| 70 | +type SimpleArticle struct { | ||
| 59 | Id int64 `json:"id"` | 71 | Id int64 `json:"id"` |
| 60 | - CompanyId int64 `json:"companyId,omitempty"` // 公司ID | ||
| 61 | - DepartmentId int64 `json:"departmentId,omitempty"` // 部门ID | ||
| 62 | - Name string `json:"name,omitempty"` // 名称 | ||
| 63 | - Avatar string `json:"avatar,omitempty"` // 头像 | ||
| 64 | - Position string `json:"position,omitempty"` // 职位 | 72 | + Title string `json:"title"` // 文章标题 |
| 73 | + CountLove int `json:"countLove"` // 点赞数量 | ||
| 74 | + CountComment int `json:"countComment"` // 评论数量 | ||
| 65 | } | 75 | } |
| 66 | 76 | ||
| 67 | type TagCreateRequest struct { | 77 | type TagCreateRequest struct { |
| @@ -11,16 +11,16 @@ import ( | @@ -11,16 +11,16 @@ import ( | ||
| 11 | // MessageBusiness 消息中心业务 | 11 | // MessageBusiness 消息中心业务 |
| 12 | type MessageBusiness struct { | 12 | type MessageBusiness struct { |
| 13 | Id int64 // 唯一标识 | 13 | Id int64 // 唯一标识 |
| 14 | - CompanyId int64 `json:"companyId"` // 公司ID | ||
| 15 | - Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | ||
| 16 | - OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 17 | - TriggerId int64 `json:"triggerId"` // 触发者ID | ||
| 18 | - RecipientId int64 `json:"recipientId"` // 接收者ID | ||
| 19 | - ArticleId int64 `json:"articleId"` // 文章ID | ||
| 20 | - CommentId int64 `json:"commentId"` // 评论ID | ||
| 21 | - DiscussionId int64 `json:"discussionId"` // 圆桌ID | ||
| 22 | - DiscussionOpinionId int64 `json:"discussionOpinionId"` // 观点ID | ||
| 23 | - Content string `json:"content"` // 消息内容 | 14 | + Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) |
| 15 | + OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | ||
| 16 | + CompanyId int64 `json:"companyId"` // 操作人公司ID | ||
| 17 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
| 18 | + RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
| 19 | + ArticleId int64 `json:"articleId"` // 文章ID | ||
| 20 | + CommentId int64 `json:"commentId,omitempty"` // 评论ID | ||
| 21 | + DiscussionId int64 `json:"discussionId,omitempty"` // 圆桌ID | ||
| 22 | + DiscussionOpinionId int64 `json:"discussionOpinionId,omitempty"` // 观点ID | ||
| 23 | + Content string `json:"content,omitempty"` // 消息内容 | ||
| 24 | CreatedAt int64 `json:",omitempty"` | 24 | CreatedAt int64 `json:",omitempty"` |
| 25 | UpdatedAt int64 `json:",omitempty"` | 25 | UpdatedAt int64 `json:",omitempty"` |
| 26 | DeletedAt int64 `json:",omitempty"` | 26 | DeletedAt int64 `json:",omitempty"` |
| @@ -120,6 +120,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -120,6 +120,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 120 | ) | 120 | ) |
| 121 | queryFunc := func() (interface{}, error) { | 121 | queryFunc := func() (interface{}, error) { |
| 122 | tx = tx.Model(&ms).Order("id desc") | 122 | tx = tx.Model(&ms).Order("id desc") |
| 123 | + if v, ok := queryOptions["ids"]; ok { | ||
| 124 | + tx.Where("id in (?)", v) | ||
| 125 | + } | ||
| 123 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 126 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 124 | return dms, tx.Error | 127 | return dms, tx.Error |
| 125 | } | 128 | } |
| @@ -139,6 +139,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | @@ -139,6 +139,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | ||
| 139 | ) | 139 | ) |
| 140 | queryFunc := func() (interface{}, error) { | 140 | queryFunc := func() (interface{}, error) { |
| 141 | tx = tx.Model(&ms).Order("id desc") | 141 | tx = tx.Model(&ms).Order("id desc") |
| 142 | + if v, ok := queryOptions["ids"]; ok { | ||
| 143 | + tx.Where("id in (?)", v) | ||
| 144 | + } | ||
| 142 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | 145 | if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { |
| 143 | return dms, tx.Error | 146 | return dms, tx.Error |
| 144 | } | 147 | } |
| @@ -145,6 +145,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | @@ -145,6 +145,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con | ||
| 145 | if v, ok := queryOptions["companyId"]; ok { | 145 | if v, ok := queryOptions["companyId"]; ok { |
| 146 | tx.Where("company_id = ?", v) | 146 | tx.Where("company_id = ?", v) |
| 147 | } | 147 | } |
| 148 | + if v, ok := queryOptions["ids"]; ok { | ||
| 149 | + tx.Where("id in (?)", v) | ||
| 150 | + } | ||
| 148 | if v, ok := queryOptions["phone"]; ok { | 151 | if v, ok := queryOptions["phone"]; ok { |
| 149 | tx.Where("phone = ?", v) | 152 | tx.Where("phone = ?", v) |
| 150 | } | 153 | } |
| @@ -7,11 +7,11 @@ import ( | @@ -7,11 +7,11 @@ import ( | ||
| 7 | 7 | ||
| 8 | type MessageBusiness struct { | 8 | type MessageBusiness struct { |
| 9 | Id int64 // 唯一标识 | 9 | Id int64 // 唯一标识 |
| 10 | - CompanyId int64 `json:"companyId"` // 公司ID | ||
| 11 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) | 10 | Type int `json:"type"` // 分类 (1回复 2点赞 3被采纳) |
| 12 | OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) | 11 | OptType int `json:"optType"` // 操作类型(1针对文章、1针对评论、2针对圆桌) |
| 13 | - TriggerId int64 `json:"triggerId"` // 触发者ID | ||
| 14 | - RecipientId int64 `json:"recipientId"` // 接收者ID | 12 | + CompanyId int64 `json:"companyId"` // 操作人公司ID |
| 13 | + UserId int64 `json:"userId"` // 操作人用户ID | ||
| 14 | + RecipientId int64 `json:"recipientId"` // 接收人用户ID | ||
| 15 | ArticleId int64 `json:"articleId"` // 文章ID | 15 | ArticleId int64 `json:"articleId"` // 文章ID |
| 16 | CommentId int64 `json:"commentId"` // 评论ID | 16 | CommentId int64 `json:"commentId"` // 评论ID |
| 17 | DiscussionId int64 `json:"discussionId"` // 圆桌ID | 17 | DiscussionId int64 `json:"discussionId"` // 圆桌ID |
-
请 注册 或 登录 后发表评论