作者 yangfu

Merge branch 'test'

正在显示 28 个修改的文件 包含 1789 行增加186 行删除
... ... @@ -15,6 +15,22 @@
"application/json"
],
"paths": {
"v1/clear": {
"get": {
"summary": "清理缓存",
"operationId": "commonGetClearCache",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"requestBody": {},
"tags": [
"common"
]
}
},
"v1/common/sms/code": {
"post": {
"summary": "短信验证码",
... ... @@ -401,6 +417,34 @@
]
}
},
"v1/mini/article_comment/list_reply": {
"post": {
"summary": "小程序展示评论对应的一级回复列表",
"operationId": "MiniListReplyArticleComment",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniListReplyArticleCommentResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniListReplyArticleCommentRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/top5": {
"post": {
"summary": "小程序展示文章的评论列表TOP5",
... ... @@ -719,6 +763,118 @@
]
}
},
"v1/mini/homepage/user_beliked": {
"post": {
"summary": "个人主页-获赞的列表",
"operationId": "miniHomepageUserBeliked",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomePageUserBeLikedResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniHomePageUserBeLikedRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/homepage/user_follower": {
"post": {
"summary": "个人主页-关注我的人",
"operationId": "miniHomepageUserFollower",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomePageUserFollowerSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniHomePageUserFollowerSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/homepage/user_info": {
"post": {
"summary": "个人主页用户信息",
"operationId": "miniHomePageUserInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomePageUserInfoResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniHomePageUserInfoRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/homepage/user_news": {
"post": {
"summary": "个人主页-用户发布的信息",
"operationId": "miniHomepageUserNews",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniHomepageUserNewsResposne"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniHomepageUserNewsRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/message/comment": {
"post": {
"summary": "评论消息",
... ... @@ -803,6 +959,32 @@
]
}
},
"v1/mini/qrcode": {
"post": {
"summary": "微信二维码",
"operationId": "miniQrcodeInvite",
"responses": {
"200": {
"description": "A successful response.",
"schema": {}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniQrCodeRequest"
}
}
],
"requestBody": {},
"tags": [
"common"
]
}
},
"v1/mini/show/home_page": {
"get": {
"summary": "小程序首页数据展示",
... ... @@ -1121,6 +1303,34 @@
]
}
},
"v1/mini/user/info/edit": {
"post": {
"summary": "编辑用户信息",
"operationId": "miniEditUserInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniEditUserInfoResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniEditUserInfoRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/login": {
"post": {
"summary": "用户登录",
... ... @@ -1149,9 +1359,65 @@
]
}
},
"v1/mini/user/my_following_news": {
"post": {
"summary": "我关注人发布的信息",
"operationId": "miniUserMyFollowingNews",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniUserNewsResposne"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniUserNewsRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/mybeliked": {
"post": {
"summary": "我被点赞-文章或评论列表",
"operationId": "miniMyBeLiked",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniBeLikedResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniBeLikedRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/user/mylike": {
"post": {
"summary": "我点赞的文章或评论",
"summary": "我点赞的-文章或评论列表",
"operationId": "miniMyLike",
"responses": {
"200": {
... ... @@ -1677,6 +1943,34 @@
]
}
},
"v1/system/article_comment/edit/love": {
"post": {
"summary": "编辑评论的运营点赞数",
"operationId": "SystemEditAticleCommentLove",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemEditCommentLoveResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemEditCommentLoveRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/system/article_comment/edit_show": {
"post": {
"summary": "管理后台变更评论的显示状态",
... ... @@ -2203,21 +2497,37 @@
]
}
},
"v1/system/role/search": {
"post": {
"summary": "角色列表搜索",
"operationId": "systemSearchRole",
"v1/system/role/auths": {
"get": {
"summary": "角色权限列表",
"operationId": "systemGetRoleAuths",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSearchResponse"
}
"schema": {}
}
},
"parameters": [
{
"name": "body",
"requestBody": {},
"tags": [
"role"
]
}
},
"v1/system/role/search": {
"post": {
"summary": "角色列表搜索",
"operationId": "systemSearchRole",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/RoleSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
... ... @@ -2661,6 +2971,10 @@
},
"description": " 填写评论时@的人"
},
"matchUrl": {
"type": "object",
"description": " 评论内容中的url文本"
},
"createdAt": {
"type": "integer",
"format": "int64"
... ... @@ -2668,7 +2982,7 @@
"meLoveFlag": {
"type": "integer",
"format": "int32",
"description": "当前人员对评论的点赞标识 (0 没有点赞 1有点赞)"
"description": " 当前人员对评论的点赞标识 (0 没有点赞 1有点赞)"
},
"content": {
"type": "string",
... ... @@ -2691,6 +3005,7 @@
"countUserLove",
"countAdminLove",
"atWho",
"matchUrl",
"createdAt",
"meLoveFlag",
"content"
... ... @@ -2725,11 +3040,16 @@
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"countComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
},
"countRead": {
"type": "integer",
"format": "int32",
"description": "浏览数量"
},
"show": {
"type": "integer",
"format": "int32",
... ... @@ -2743,7 +3063,8 @@
"images",
"createdAt",
"countLove",
"CountComment",
"countComment",
"countRead",
"show"
]
},
... ... @@ -2811,6 +3132,11 @@
"type": "integer",
"format": "int32",
"description": " 已读的标签数量"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
}
},
"title": "ArticleTagCount",
... ... @@ -2821,7 +3147,8 @@
"tagName",
"tagRemark",
"totalArticle",
"readArticle"
"readArticle",
"sortBy"
]
},
"ArticleTagGroup": {
... ... @@ -2858,6 +3185,10 @@
},
"image": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32"
}
},
"title": "ArticleTagItem",
... ... @@ -2865,7 +3196,8 @@
"id",
"category",
"name",
"image"
"image",
"sortBy"
]
},
"Auth": {
... ... @@ -2899,6 +3231,10 @@
"type": "integer",
"format": "int64"
},
"avatar": {
"type": "string",
"description": " 人员头像URL"
},
"name": {
"type": "string"
},
... ... @@ -3268,7 +3604,7 @@
"optType": {
"type": "integer",
"format": "int32",
"description": " 操作类型(1针对文章、1针对评论、2针对圆桌)"
"description": " 操作类型(1针对文章或段落、2针对评论、3针对圆桌)"
},
"companyId": {
"type": "integer",
... ... @@ -3290,25 +3626,6 @@
"format": "int64",
"description": " 文章ID"
},
"commentId": {
"type": "integer",
"format": "int64",
"description": " 评论ID"
},
"discussionId": {
"type": "integer",
"format": "int64",
"description": " 圆桌ID"
},
"discussionOpinionId": {
"type": "integer",
"format": "int64",
"description": " 观点ID"
},
"content": {
"type": "string",
"description": " 消息内容"
},
"createdAt": {
"type": "integer",
"format": "int64",
... ... @@ -3324,7 +3641,11 @@
},
"comment": {
"$ref": "#/definitions/SimpleComment",
"description": " 评论(不一定是自己,可能是被人@到)"
"description": " 评论"
},
"commentParent": {
"$ref": "#/definitions/SimpleComment",
"description": " 被回复的评论"
}
},
"title": "MessageBusinessItem",
... ... @@ -3336,14 +3657,11 @@
"userId",
"recipientId",
"articleId",
"commentId",
"discussionId",
"discussionOpinionId",
"content",
"createdAt",
"user",
"article",
"comment"
"comment",
"commentParent"
]
},
"MessageBusinessResponse": {
... ... @@ -3637,12 +3955,17 @@
"location": {
"$ref": "#/definitions/Location",
"description": "定位坐标"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
}
},
"title": "MiniArticleCreateRequest",
"required": [
"title",
"section"
"section",
"matchUrl"
]
},
"MiniArticleCreateResponse": {
... ... @@ -3712,6 +4035,10 @@
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
}
},
"title": "MiniArticleDraftCreateRequest",
... ... @@ -3722,7 +4049,8 @@
"images",
"whoRead",
"whoReview",
"location"
"location",
"matchUrl"
]
},
"MiniArticleDraftCreateResponse": {
... ... @@ -3846,6 +4174,9 @@
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"matchUrl": {
"type": "object"
}
},
"title": "MiniArticleDraftGetMeResponse",
... ... @@ -3857,7 +4188,8 @@
"images",
"whoRead",
"whoReview",
"location"
"location",
"matchUrl"
]
},
"MiniArticleDraftItem": {
... ... @@ -3893,6 +4225,10 @@
"createdAt": {
"type": "integer",
"format": "int64"
},
"matchUrl": {
"type": "object",
"description": "匹配内容中的url文本"
}
},
"title": "MiniArticleDraftItem",
... ... @@ -3902,7 +4238,8 @@
"section",
"title",
"images",
"createdAt"
"createdAt",
"matchUrl"
]
},
"MiniArticleDraftSearchMeRequest": {
... ... @@ -4011,6 +4348,10 @@
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
}
},
"title": "MiniArticleDraftUpdateRequest",
... ... @@ -4022,7 +4363,8 @@
"images",
"whoRead",
"whoReview",
"location"
"location",
"matchUrl"
]
},
"MiniArticleDraftUpdateResponse": {
... ... @@ -4102,6 +4444,13 @@
},
"description": "图片"
},
"videos": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": "视频"
},
"whoRead": {
"type": "array",
"items": {
... ... @@ -4163,6 +4512,10 @@
"type": "string"
},
"description": " 文章的标签"
},
"matchUrl": {
"type": "object",
"description": " 匹配文章内容中的url文本"
}
},
"title": "MiniArticleGetResponse",
... ... @@ -4174,6 +4527,7 @@
"createdAt",
"section",
"images",
"videos",
"whoRead",
"whoReview",
"location",
... ... @@ -4184,7 +4538,8 @@
"edit",
"meLoveFlag",
"meFollowFlag",
"tags"
"tags",
"matchUrl"
]
},
"MiniArticleMarkItem": {
... ... @@ -4369,8 +4724,11 @@
"description": " 文章id"
},
"tagId": {
"type": "integer",
"format": "int64",
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 标签id"
}
},
... ... @@ -4384,8 +4742,11 @@
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
}
},
"title": "MiniArticleSetTagResponse",
... ... @@ -4393,6 +4754,44 @@
"id"
]
},
"MiniBeLikedRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniBeLikedRequest",
"required": [
"page",
"size"
]
},
"MiniBeLikedResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MyBeLikedItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniBeLikedResponse",
"required": [
"list",
"total"
]
},
"MiniCreateArticleCommentRequest": {
"type": "object",
"properties": {
... ... @@ -4431,15 +4830,17 @@
"$ref": "#/definitions/CommentAtWho"
},
"description": " 填写评论时@的人"
},
"matchUrl": {
"type": "object",
"description": " 评论内容中的url文本"
}
},
"title": "MiniCreateArticleCommentRequest",
"required": [
"articleId",
"sectionId",
"pid",
"content",
"atWho"
"content"
]
},
"MiniCreateArticleCommentResponse": {
... ... @@ -4511,6 +4912,10 @@
},
"description": " 填写评论时@的人"
},
"matchUrl": {
"type": "object",
"description": " 评论内容中的url文本"
},
"createdAt": {
"type": "integer",
"format": "int64"
... ... @@ -4532,6 +4937,7 @@
"countUserLove",
"countAdminLove",
"atWho",
"matchUrl",
"createdAt"
]
},
... ... @@ -4569,6 +4975,22 @@
"id"
]
},
"MiniEditUserInfoRequest": {
"type": "object",
"properties": {
"avatar": {
"$ref": "#/definitions/string"
}
},
"title": "MiniEditUserInfoRequest",
"required": [
"avatar"
]
},
"MiniEditUserInfoResponse": {
"type": "object",
"title": "MiniEditUserInfoResponse"
},
"MiniGetArticleCommentRequest": {
"type": "object",
"properties": {
... ... @@ -4622,29 +5044,281 @@
"type": "string"
}
},
"tags": {
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagCount"
}
}
},
"title": "MiniHomePageResponse",
"required": [
"tagCategory",
"tags"
]
},
"MiniHomePageUserBeLikedRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int32"
},
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniHomePageUserBeLikedRequest",
"required": [
"userId",
"page",
"size"
]
},
"MiniHomePageUserBeLikedResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/MyBeLikedItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniHomePageUserBeLikedResponse",
"required": [
"list",
"total"
]
},
"MiniHomePageUserFollowerSearchRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int32"
},
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
}
},
"title": "MiniHomePageUserFollowerSearchRequest",
"required": [
"userId"
]
},
"MiniHomePageUserFollowerSearchResponse": {
"type": "object",
"properties": {
"users": {
"type": "array",
"items": {
"$ref": "#/definitions/UserFollowItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniHomePageUserFollowerSearchResponse",
"required": [
"users",
"total"
]
},
"MiniHomePageUserInfoRequest": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int64",
"description": " 用户ID"
}
},
"title": "MiniHomePageUserInfoRequest",
"required": [
"userId"
]
},
"MiniHomePageUserInfoResponse": {
"type": "object",
"properties": {
"user": {
"$ref": "#/definitions/UserItem",
"description": " 用户信息"
},
"totalFollower": {
"type": "integer",
"format": "int32",
"description": " 关注他的人数"
},
"totalBeLoved": {
"type": "integer",
"format": "int32",
"description": " 获赞数"
},
"followed": {
"type": "boolean",
"format": "boolean",
"description": " 关注"
},
"mutualFollowed": {
"type": "boolean",
"format": "boolean",
"description": " 互相关注标识"
}
},
"title": "MiniHomePageUserInfoResponse",
"required": [
"user",
"totalFollower",
"totalBeLoved",
"followed",
"mutualFollowed"
]
},
"MiniHomepageUserNewsRequest": {
"type": "object",
"properties": {
"authorId": {
"type": "integer",
"format": "int64",
"description": " 特定作者ID"
},
"lastArticleId": {
"type": "integer",
"format": "int64",
"description": " 最后文章ID"
},
"size": {
"type": "integer",
"format": "int32",
"description": " 数量"
},
"orderByHotScore": {
"type": "string",
"default": "desc",
"description": " 热度排序 升序 asc 降序 desc"
},
"keywords": {
"type": "string",
"description": " 关键字"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "MiniHomepageUserNewsRequest",
"required": [
"authorId",
"size",
"orderByHotScore"
]
},
"MiniHomepageUserNewsResposne": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/UserNewsItem"
}
},
"lastArticleId": {
"type": "integer",
"format": "int64",
"description": " 最后文章ID"
}
},
"title": "MiniHomepageUserNewsResposne",
"required": [
"list",
"lastArticleId"
]
},
"MiniListArticleCommentRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"": {
"type": "integer",
"format": "int64"
},
"": {
"type": "integer",
"format": "int64"
},
"articleId": {
"type": "integer",
"format": "int64"
},
"sectionId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniListArticleCommentRequest",
"required": [
"page",
"size",
"articleId"
]
},
"MiniListArticleCommentResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int64"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagCount"
"$ref": "#/definitions/ArticleCommentAndReply"
}
}
},
"title": "MiniHomePageResponse",
"title": "MiniListArticleCommentResponse",
"required": [
"tagCategory",
"tags"
"total",
"list"
]
},
"MiniListArticleCommentRequest": {
"MiniListReplyArticleCommentRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"commentId": {
"type": "integer",
"format": "int32"
"format": "int64"
},
"": {
"type": "integer",
... ... @@ -4654,23 +5328,23 @@
"type": "integer",
"format": "int64"
},
"articleId": {
"page": {
"type": "integer",
"format": "int64"
"format": "int32"
},
"sectionId": {
"size": {
"type": "integer",
"format": "int64"
"format": "int32"
}
},
"title": "MiniListArticleCommentRequest",
"title": "MiniListReplyArticleCommentRequest",
"required": [
"commentId",
"page",
"size",
"articleId"
"size"
]
},
"MiniListArticleCommentResponse": {
"MiniListReplyArticleCommentResponse": {
"type": "object",
"properties": {
"total": {
... ... @@ -4680,11 +5354,11 @@
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleCommentAndReply"
"$ref": "#/definitions/ArticleCommentItem"
}
}
},
"title": "MiniListArticleCommentResponse",
"title": "MiniListReplyArticleCommentResponse",
"required": [
"total",
"list"
... ... @@ -4728,6 +5402,24 @@
"total"
]
},
"MiniQrCodeRequest": {
"type": "object",
"properties": {
"page": {
"type": "string",
"description": " 微信页面入口"
},
"scene": {
"type": "string",
"description": " 参数"
}
},
"title": "MiniQrCodeRequest",
"required": [
"page",
"scene"
]
},
"MiniSearchArticleItem": {
"type": "object",
"properties": {
... ... @@ -4738,6 +5430,10 @@
"title": {
"type": "string"
},
"authorId": {
"type": "integer",
"format": "int64"
},
"author": {
"type": "string",
"description": " 发布人"
... ... @@ -4766,6 +5462,7 @@
"required": [
"articleId",
"title",
"authorId",
"author",
"avatar",
"images",
... ... @@ -5281,10 +5978,61 @@
"type": "integer",
"format": "int64",
"description": " 按角色角色关联的用户"
},
"keywords": {
"type": "string",
"description": " 按关键字搜索(名称)"
}
},
"title": "MiniUsersListRequest"
},
"MyBeLikedItem": {
"type": "object",
"properties": {
"userId": {
"type": "integer",
"format": "int64",
"description": " 点赞人id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"commentId": {
"type": "integer",
"format": "int64",
"description": " 评论id"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": " 创建时间"
},
"user": {
"$ref": "#/definitions/SimpleUser",
"description": " 点赞人"
},
"article": {
"$ref": "#/definitions/SimpleArticle",
"description": " 文章"
},
"comment": {
"$ref": "#/definitions/SimpleComment",
"description": " 评论"
}
},
"title": "MyBeLikedItem",
"required": [
"userId",
"articleId",
"commentId",
"createdAt",
"user",
"article",
"comment"
]
},
"MyLikeItem": {
"type": "object",
"properties": {
... ... @@ -5602,29 +6350,42 @@
"type": "string",
"description": " 评论内容"
},
"countLove": {
"show": {
"type": "integer",
"format": "int32",
"description": " 点赞数量"
"description": " 评论的展示状态(0显示、1不显示)"
},
"countComment": {
"atWho": {
"type": "array",
"items": {
"$ref": "#/definitions/CommentAtWho"
},
"description": " 填写评论时@的人"
},
"matchUrl": {
"type": "object",
"description": " 评论内容中的url文本"
},
"countReply": {
"type": "integer",
"format": "int32",
"description": " 评论数量"
"description": " 用户回复数量"
},
"show": {
"countUserLove": {
"type": "integer",
"format": "int32",
"description": " 评论的展示状态(0显示、1不显示)"
"description": " 用户点赞数量"
}
},
"title": "SimpleComment",
"required": [
"id",
"content",
"countLove",
"countComment",
"show"
"show",
"atWho",
"matchUrl",
"countReply",
"countUserLove"
]
},
"SimpleUser": {
... ... @@ -5744,6 +6505,17 @@
"type": "string",
"description": " 评论的内容"
},
"atWho": {
"type": "array",
"items": {
"$ref": "#/definitions/CommentAtWho"
},
"description": " 填写评论时@的人"
},
"matchUrl": {
"type": "object",
"description": " 评论内容中的url文本"
},
"show": {
"type": "integer",
"format": "int32",
... ... @@ -5764,6 +6536,8 @@
"countAdminLove",
"createdAt",
"content",
"atWho",
"matchUrl",
"show"
]
},
... ... @@ -5843,7 +6617,8 @@
"description": " 文章顶层ID"
},
"author": {
"type": "string",
"type": "integer",
"format": "int64",
"description": " 用户"
},
"show": {
... ... @@ -5943,6 +6718,12 @@
},
"description": " 图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
}
},
"whoRead": {
"type": "array",
"items": {
... ... @@ -5999,6 +6780,7 @@
"createdAt",
"section",
"images",
"video",
"whoRead",
"whoReadInfo",
"whoReview",
... ... @@ -6066,6 +6848,13 @@
},
"description": " 图片"
},
"videos": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"whoRead": {
"type": "array",
"items": {
... ... @@ -6142,6 +6931,7 @@
"createdAt",
"section",
"images",
"videos",
"whoRead",
"whoReadInfo",
"whoReview",
... ... @@ -6296,6 +7086,11 @@
"type": "string",
"description": "标题"
},
"authorId": {
"type": "integer",
"format": "int64",
"description": "发布人ID"
},
"author": {
"type": "string",
"description": "发布人"
... ... @@ -6317,7 +7112,7 @@
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"countComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
... ... @@ -6344,11 +7139,12 @@
"required": [
"id",
"title",
"authorId",
"author",
"images",
"createdAt",
"countLove",
"CountComment",
"countComment",
"show",
"tags",
"targetUser"
... ... @@ -6420,7 +7216,8 @@
"description": "标题"
},
"author": {
"type": "string",
"type": "integer",
"format": "int64",
"description": "发布人"
},
"beginTime": {
... ... @@ -6512,6 +7309,13 @@
},
"description": " 图片"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"whoRead": {
"type": "array",
"items": {
... ... @@ -6553,6 +7357,7 @@
"section",
"title",
"images",
"video",
"whoRead",
"whoReview",
"targetUser",
... ... @@ -6593,6 +7398,13 @@
"format": "int32",
"description": "点赞数量"
},
"video": {
"type": "array",
"items": {
"$ref": "#/definitions/Video"
},
"description": " 视频"
},
"countComment": {
"type": "integer",
"format": "int32",
... ... @@ -6625,6 +7437,7 @@
"images",
"createdAt",
"countLove",
"video",
"countComment",
"show",
"tags",
... ... @@ -6712,6 +7525,40 @@
"countAdminLove"
]
},
"SystemEditCommentLoveRequest": {
"type": "object",
"properties": {
"": {
"type": "integer",
"format": "int64"
},
"paramList": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemEditLove"
}
}
},
"title": "SystemEditCommentLoveRequest",
"required": [
"paramList"
]
},
"SystemEditCommentLoveResponse": {
"type": "object",
"properties": {
"paramList": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemEditLove"
}
}
},
"title": "SystemEditCommentLoveResponse",
"required": [
"paramList"
]
},
"SystemEditCommentRequest": {
"type": "object",
"properties": {
... ... @@ -6728,6 +7575,9 @@
"format": "int32",
"description": "[1 显示评论] [2: 隐藏评论]"
},
"content": {
"type": "string"
},
"countAdminLove": {
"type": "integer",
"format": "int32"
... ... @@ -6794,6 +7644,23 @@
"id"
]
},
"SystemEditLove": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"countAdminLove": {
"type": "integer",
"format": "int32"
}
},
"title": "SystemEditLove",
"required": [
"id"
]
},
"SystemGetCommentRequest": {
"type": "object",
"properties": {
... ... @@ -6917,8 +7784,9 @@
"format": "int64",
"description": " 评论的顶层ID"
},
"fromUser": {
"type": "string",
"fromUserId": {
"type": "integer",
"format": "int64",
"description": " 用户"
},
"show": {
... ... @@ -7430,6 +8298,11 @@
},
"other": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": "排序"
}
},
"title": "TagCreateRequest",
... ... @@ -7510,6 +8383,11 @@
},
"other": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
}
},
"title": "TagEditRequest",
... ... @@ -7574,6 +8452,11 @@
},
"other": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
}
},
"title": "TagGetResponse",
... ... @@ -7611,6 +8494,11 @@
"createdAt": {
"type": "integer",
"format": "int64"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
}
},
"title": "TagItem",
... ... @@ -7846,6 +8734,11 @@
"$ref": "#/definitions/int",
"description": " 审核状态 0:待审核 1:审核通过 2:拒绝"
},
"auditAt": {
"type": "integer",
"format": "int64",
"description": " 审核时间"
},
"followers": {
"type": "array",
"items": {
... ... @@ -7889,6 +8782,7 @@
"position",
"enable",
"auditStatus",
"auditAt",
"followers",
"following",
"departments",
... ... @@ -8027,22 +8921,58 @@
"properties": {
"totalArticle": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": " 累计发布文章"
},
"totalComment": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": " 累计发布评论"
},
"totalLoved": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": " 累计赞别人"
},
"totalBeLoved": {
"type": "integer",
"format": "int32",
"description": " 累计收到的赞"
}
},
"title": "UserStatisticsResponse",
"required": [
"totalArticle",
"totalComment",
"totalLoved"
"totalLoved",
"totalBeLoved"
]
},
"Video": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "视频文件的地址"
},
"cover": {
"type": "string",
"description": "封面"
},
"width": {
"type": "integer",
"format": "int32",
"description": "封面图片宽"
},
"height": {
"type": "integer",
"format": "int32",
"description": "封面图片长"
}
},
"title": "Video",
"required": [
"url"
]
},
"WhichUserLikeArticle": {
... ...
... ... @@ -82,6 +82,19 @@ service Core {
@doc "我被点赞-文章或评论列表"
@handler miniMyBeLiked
post /mini/user/mybeliked (MiniBeLikedRequest)returns (MiniBeLikedResponse)
@doc "个人主页用户信息"
@handler miniHomePageUserInfo
post /mini/homepage/user_info (MiniHomePageUserInfoRequest) returns (MiniHomePageUserInfoResponse)
@doc "个人主页-关注我的人"
@handler miniHomepageUserFollower
post /mini/homepage/user_follower (MiniHomePageUserFollowerSearchRequest)returns(MiniHomePageUserFollowerSearchResponse)
@doc "个人主页-获赞的列表"
@handler miniHomepageUserBeLiked
post /mini/homepage/user_beliked (MiniHomePageUserBeLikedRequest)returns(MiniHomePageUserBeLikedResponse)
@doc "个人主页-用户发布的信息"
@handler miniHomepageUserNews
post /mini/homepage/user_news (MiniHomepageUserNewsRequest)returns(MiniHomepageUserNewsResposne)
}
type(
... ... @@ -93,6 +106,58 @@ type(
}
)
// 个人主页
type(
MiniHomePageUserInfoRequest {
UserId int64 `json:"userId"` // 用户ID
}
MiniHomePageUserInfoResponse {
User *UserItem `json:"user,omitempty"` // 用户信息
TotalFollower int `json:"totalFollower"` // 关注他的人数
TotalBeLoved int `json:"totalBeLoved"` // 获赞数
Followed bool `json:"followed"` // 关注
MutualFollowed bool `json:"mutualFollowed"` // 互相关注标识
}
MiniHomePageUserFollowerSearchRequest{
UserId int `json:"userId"`
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Name string `json:"name,optional"`
}
MiniHomePageUserFollowerSearchResponse{
List []*UserFollowItem `json:"users"`
Total int64 `json:"total"`
}
MiniHomePageUserBeLikedRequest{
UserId int `json:"userId"`
Page int `json:"page"`
Size int `json:"size"`
}
MiniHomePageUserBeLikedResponse {
List []MyBeLikedItem `json:"list"`
Total int64 `json:"total"`
}
MiniHomepageUserNewsRequest{
AuthorId int64 `json:"authorId"` // 特定作者ID
LastArticleId int64 `json:"lastArticleId,optional"`// 最后文章ID
Size int `json:"size"` // 数量
//OrderByHotScore string `json:"orderByHotScore,options=asc|desc,optional,default=desc"` // 热度排序 升序 asc 降序 desc
OrderByKey string `json:"orderByKey,options=HotScore|All|Time,optional,default=desc"` // 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)
OrderByValue string `json:"orderByValue,options=asc||desc,optional"` // 排序值 升序 asc 降序 desc
Keywords string `json:"keywords,optional"` // 关键字
BeginTime int64 `json:"beginTime,optional"`// 开始时间
EndTime int64 `json:"endTime,optional"`// 结束时间
}
MiniHomepageUserNewsResposne{
List []UserNewsItem `json:"list"`
LastArticleId int64 `json:"lastArticleId"`// 最后文章ID
Total int64 `json:"total"`
}
)
type(
MiniUserLoginRequest {
LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
... ... @@ -143,6 +208,7 @@ type(
MiniUsersListRequest{
ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户)
RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户
Keywords string `json:"keywords,optional"` // 按关键字搜索(名称)
}
MiniUserNewsRequest{
AuthorId int64 `json:"authorId,optional"` // 特定作者ID
... ...
... ... @@ -319,6 +319,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Path: "/mini/user/mybeliked",
Handler: user.MiniMyBeLikedHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/mini/homepage/user_info",
Handler: user.MiniHomePageUserInfoHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/mini/homepage/user_follower",
Handler: user.MiniHomepageUserFollowerHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/mini/homepage/user_beliked",
Handler: user.MiniHomepageUserBeLikedHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/mini/homepage/user_news",
Handler: user.MiniHomepageUserNewsHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
... ... @@ -19,10 +20,6 @@ func MiniEditUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
l := user.NewMiniEditUserInfoLogic(r.Context(), svcCtx)
resp, err := l.MiniEditUserInfo(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniHomePageUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniHomePageUserInfoRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user.NewMiniHomePageUserInfoLogic(r.Context(), svcCtx)
resp, err := l.MiniHomePageUserInfo(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniHomepageUserBeLikedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniHomePageUserBeLikedRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user.NewMiniHomepageUserBeLikedLogic(r.Context(), svcCtx)
resp, err := l.MiniHomepageUserBeLiked(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniHomepageUserFollowerHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniHomePageUserFollowerSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user.NewMiniHomepageUserFollowerLogic(r.Context(), svcCtx)
resp, err := l.MiniHomepageUserFollower(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package user
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniHomepageUserNewsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniHomepageUserNewsRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := user.NewMiniHomepageUserNewsLogic(r.Context(), svcCtx)
resp, err := l.MiniHomepageUserNews(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -185,14 +185,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
}
}
//增加评论回复计数
if pComment != nil {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id)
if err != nil {
return err
}
}
// if pComment != nil {
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, pComment.Id)
// if err != nil {
// return err
// }
// }
// 增加最顶层的评论回复计数
if newComment.TopId != 0 && newComment.Pid != newComment.TopId {
// if newComment.TopId != 0 && newComment.Pid != newComment.TopId {
if newComment.TopId != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, newComment.TopId)
if err != nil {
return err
... ...
... ... @@ -2,6 +2,7 @@ package comment
import (
"context"
"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"
... ... @@ -52,14 +53,15 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini
return err
}
// 减少上级评论的回复数量
if commentInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
if err != nil {
return err
}
}
// if commentInfo.Pid != 0 {
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
// if err != nil {
// return err
// }
// }
// 减少最顶层的评论回复计数
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
// if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
if commentInfo.TopId != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
if err != nil {
return err
... ... @@ -67,18 +69,32 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini
}
//减少加段落评论计数
if commentInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
if commentInfo.TopId == 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.SectionId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
}
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
if commentInfo.TopId == 0 {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.ArticleId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
}
}
//// 评论被隐藏消息
// 评论被隐藏消息
//var messageLogic = message.NewMiniSystemLogic(l.ctx, l.svcCtx)
//err = messageLogic.AbnormalCommentHidden(c, commentInfo.CompanyId, commentInfo.FromUserId, commentInfo.Content)
//if err != nil {
... ...
... ... @@ -70,13 +70,13 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
// 设置为显示评论
if commetInfo.Show != domain.CommentShowEnable {
commetInfo.Show = domain.CommentShowEnable
increaseCount = 1
increaseCount = commetInfo.CountReply + 1
}
case 2:
// 设置为隐藏评论
if commetInfo.Show != domain.CommentShowDisable {
commetInfo.Show = domain.CommentShowDisable
increaseCount = -1
increaseCount = -(commetInfo.CountReply + 1)
}
}
... ... @@ -88,14 +88,15 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
}
if increaseCount != 0 {
// 增加上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.Pid)
if err != nil {
return err
}
}
// if commetInfo.Pid != 0 {
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.Pid)
// if err != nil {
// return err
// }
// }
// 增加最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
// if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
if commetInfo.TopId != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, increaseCount, commetInfo.TopId)
if err != nil {
return err
... ...
... ... @@ -2,6 +2,7 @@ package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
... ... @@ -80,14 +81,15 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI
return err
}
// 减少上级评论的回复数量
if commentInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
if err != nil {
return err
}
}
// if commentInfo.Pid != 0 {
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.Pid)
// if err != nil {
// return err
// }
// }
// 减少最顶层的评论回复计数
if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
// if commentInfo.TopId != 0 && commentInfo.Pid != commentInfo.TopId {
if commentInfo.TopId != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
if err != nil {
return err
... ... @@ -95,15 +97,29 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI
}
//减少加段落评论计数
if commentInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
if commentInfo.TopId == 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.SectionId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, -1, commentInfo.SectionId)
if err != nil {
return err
}
}
}
// 减少文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
if commentInfo.TopId == 0 {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -(commentInfo.CountReply + 1), commentInfo.ArticleId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, -1, commentInfo.ArticleId)
if err != nil {
return err
}
}
// 评论被隐藏消息
... ... @@ -142,14 +158,15 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId
return err
}
// 增加上级评论的回复数量
if commetInfo.Pid != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid)
if err != nil {
return err
}
}
// if commetInfo.Pid != 0 {
// err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.Pid)
// if err != nil {
// return err
// }
// }
// 增加最顶层的评论回复计数
if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
// if commetInfo.TopId != 0 && commetInfo.Pid != commetInfo.TopId {
if commetInfo.TopId != 0 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId)
if err != nil {
return err
... ... @@ -157,15 +174,29 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId
}
//增加加段落评论计数
if commetInfo.SectionId > 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId)
if err != nil {
return err
if commetInfo.TopId == 0 {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.SectionId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleSectionRepository.IncreaseCountComment(ctx, c, 1, commetInfo.SectionId)
if err != nil {
return err
}
}
}
// 增加文章的评论数
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId)
if err != nil {
return err
if commetInfo.TopId == 0 {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, commetInfo.CountReply+1, commetInfo.ArticleId)
if err != nil {
return err
}
} else {
err = l.svcCtx.ArticleRepository.IncreaseCountComment(ctx, c, 1, commetInfo.ArticleId)
if err != nil {
return err
}
}
return nil
}, true)
... ...
package user
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniHomePageUserInfoLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniHomePageUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniHomePageUserInfoLogic {
return &MiniHomePageUserInfoLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniHomePageUserInfoLogic) MiniHomePageUserInfo(req *types.MiniHomePageUserInfoRequest) (resp *types.MiniHomePageUserInfoResponse, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
companyMap = make(map[int64]*domain.Company)
currentUser *domain.User
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if currentUser, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if user.CompanyId != currentUser.CompanyId {
return nil, xerr.NewErrMsgErr("无查看权限", err)
}
resp = &types.MiniHomePageUserInfoResponse{
User: &types.UserItem{
Id: user.Id,
Name: user.Name,
Avatar: lo.ToPtr(user.Avatar),
Position: user.Position,
AuditStatus: lo.ToPtr(user.AuditStatus),
Enable: user.Enable,
},
TotalFollower: len(user.Follower),
Followed: currentUser.IsFollowed(user.Id),
MutualFollowed: currentUser.IsFriend(user.Id),
}
if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil {
resp.User.CompanyName = company.Name
resp.User.CompanyCode = company.Code
resp.User.CompanyLogo = lo.ToPtr(company.Logo)
}
var total int64
total, _, _ = l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, domain.IndexCompanyId(0)().WithCountOnly().MustWithKV("toUserId", user.Id))
resp.TotalBeLoved = int(total)
return
}
... ...
package user
import (
"context"
"github.com/samber/lo"
"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/domain"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniHomepageUserBeLikedLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniHomepageUserBeLikedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniHomepageUserBeLikedLogic {
return &MiniHomepageUserBeLikedLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniHomepageUserBeLikedLogic) MiniHomepageUserBeLiked(req *types.MiniHomePageUserBeLikedRequest) (resp *types.MiniHomePageUserBeLikedResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
total, list, err := l.svcCtx.UserLoveFlagRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
//WithKV("companyId", userToken.CompanyId). 不存在字段
WithKV("toUserId", req.UserId))
if err != nil {
return nil, err
}
resp = &types.MiniHomePageUserBeLikedResponse{}
resp.Total = total
resp.List = make([]types.MyBeLikedItem, 0)
if total == 0 || len(list) == 0 {
return resp, nil
}
var companyMap = make(map[int64]*domain.Company)
var userMap = make(map[int64]*domain.User)
var articleMap = make(map[int64]*domain.Article)
var commentMap = make(map[int64]*domain.ArticleComment)
lo.ForEach(list, func(item *domain.UserLoveFlag, index int) {
var (
company *domain.Company
user *domain.User
article *domain.Article
comment *domain.ArticleComment
)
user, _ = domain.LazyLoad(userMap, l.ctx, conn, item.UserId, l.svcCtx.UserRepository.FindOne)
if user != nil {
company, _ = domain.LazyLoad(companyMap, l.ctx, conn, user.CompanyId, l.svcCtx.CompanyRepository.FindOne)
}
article, _ = domain.LazyLoad(articleMap, l.ctx, conn, item.ArticleId, l.svcCtx.ArticleRepository.FindOne)
// 点赞评论
if item.CommentId != 0 {
comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne)
}
itemBeLiked := NewItemSimple(item, company, user, article, comment)
// 无权限的隐藏
resp.List = append(resp.List, itemBeLiked)
})
return resp, nil
}
... ...
package user
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniHomepageUserFollowerLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniHomepageUserFollowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniHomepageUserFollowerLogic {
return &MiniHomepageUserFollowerLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniHomepageUserFollowerLogic) MiniHomepageUserFollower(req *types.MiniHomePageUserFollowerSearchRequest) (resp *types.MiniHomePageUserFollowerSearchResponse, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
currentUser *domain.User
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, int64(req.UserId)); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if currentUser, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if user.CompanyId != currentUser.CompanyId {
return nil, xerr.NewErrMsgErr("无查看权限", err)
}
resp = &types.MiniHomePageUserFollowerSearchResponse{}
resp.Total, resp.List = follower(l.ctx, l.svcCtx, user, req.Page, req.Size, req.Name)
return
}
... ...
package user
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniHomepageUserNewsLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniHomepageUserNewsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniHomepageUserNewsLogic {
return &MiniHomepageUserNewsLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniHomepageUserNewsLogic) MiniHomepageUserNews(req *types.MiniHomepageUserNewsRequest) (resp *types.MiniHomepageUserNewsResposne, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
currentUser *domain.User
articles []*domain.Article
readArticles = make([]*domain.UserReadArticle, 0)
userMap = make(map[int64]*domain.User)
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if currentUser, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
if user.CompanyId != currentUser.CompanyId {
return nil, xerr.NewErrMsgErr("无查看权限", err)
}
queryOptions := domain.IndexCompanyId(userToken.CompanyId)().
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime).
WithKV("keywords", req.Keywords)
if len(req.OrderByKey) > 0 && len(req.OrderByValue) > 0 {
switch req.OrderByKey {
case "HotScore":
queryOptions.WithKV("orderByHotScore", req.OrderByValue)
case "All":
queryOptions.WithKV("orderByAll", req.OrderByValue)
case "Time":
queryOptions.WithKV("orderByAll", req.OrderByValue)
}
}
var users = []int64{req.AuthorId}
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, currentUser.Id, req.LastArticleId, req.Size, queryOptions.Copy().WithFindOnly()); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
}
var total int64
if total, _, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, currentUser.Id, 0, 1, queryOptions.Copy().WithCountOnly()); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
}
resp = &types.MiniHomepageUserNewsResposne{
List: make([]types.UserNewsItem, 0),
Total: total,
}
articleIds := domain.Values(articles, func(item *domain.Article) int64 {
return item.Id
})
if len(articleIds) > 0 {
resp.LastArticleId = articleIds[len(articleIds)-1]
_, readArticles, _ = l.svcCtx.UserReadArticleRepository.Find(l.ctx, conn, domain.IndexCompanyId(userToken.CompanyId)().WithFindOnly().WithKV("articleIds", articleIds))
}
readArticlesMap := lo.KeyBy(readArticles, func(item *domain.UserReadArticle) int64 {
return item.ArticleId
})
lo.ForEach(articles, func(item *domain.Article, index int) {
newsItem := types.UserNewsItem{
NewsId: item.Id,
Type: "article",
Title: item.Title,
Summary: item.Summary,
Time: item.CreatedAt,
Images: make([]string, 0),
ReadFlag: false,
}
if author, _ := domain.LazyLoad(userMap, l.ctx, conn, item.AuthorId, l.svcCtx.UserRepository.FindOne); author != nil {
newsItem.Author = types.UserItem{
Id: author.Id,
Name: author.Name,
Avatar: lo.ToPtr(author.Avatar),
}
}
for _, img := range item.Images {
newsItem.Images = append(newsItem.Images, img.Url)
}
if _, ok := readArticlesMap[item.Id]; ok {
newsItem.ReadFlag = true
}
resp.List = append(resp.List, newsItem)
})
return
}
... ...
... ... @@ -67,13 +67,13 @@ func (l *MiniMyBeLikedLogic) MiniMyBeLiked(req *types.MiniBeLikedRequest) (resp
comment, _ = domain.LazyLoad(commentMap, l.ctx, conn, item.CommentId, l.svcCtx.ArticleCommentRepository.FindOne)
}
resp.List = append(resp.List, l.NewItemSimple(item, company, user, article, comment))
resp.List = append(resp.List, NewItemSimple(item, company, user, article, comment))
})
return resp, nil
}
func (l *MiniMyBeLikedLogic) NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem {
func NewItemSimple(love *domain.UserLoveFlag, company *domain.Company, user *domain.User, article *domain.Article, comment *domain.ArticleComment) types.MyBeLikedItem {
item := types.MyBeLikedItem{
UserId: love.UserId,
ArticleId: love.ArticleId,
... ...
... ... @@ -40,6 +40,9 @@ func (l *MiniUserAuditListLogic) MiniUserAuditList(req *types.UserSearchRequest)
MustWithKV("accountFrom", []string{domain.AccountFromSearchJoin})
if req.AuditFlag != nil && *req.AuditFlag >= 0 {
queryOptions.MustWithKV("auditStatus", []int{*req.AuditFlag})
if *req.AuditFlag == 2 {
queryOptions.MustWithKV("unscoped", true)
}
}
if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil {
return nil, xerr.NewErrMsgErr("查询审核列表失败", err)
... ...
... ... @@ -41,6 +41,11 @@ func (l *MiniUserAuditLogic) MiniUserAudit(req *types.MiniUserAuditRequest) (err
if user, err = l.svcCtx.UserRepository.UpdateWithVersion(ctx, conn, user); err != nil {
return err
}
if req.Status == domain.UserAuditStatusReject {
if user, err = l.svcCtx.UserRepository.Delete(ctx, conn, user); err != nil {
return err
}
}
return nil
}, true); err != nil {
return xerr.NewErrMsgErr("审核失败", err)
... ...
... ... @@ -30,55 +30,61 @@ func NewMiniUserFollowerLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
func (l *MiniUserFollowerLogic) MiniUserFollower(req *types.MiniUserFollowedSearchRequest) (resp *types.MiniUserFollowedSearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
user *domain.User
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
companyMap = make(map[int64]*domain.Company)
conn = l.svcCtx.DefaultDBConn()
user *domain.User
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
resp = &types.MiniUserFollowedSearchResponse{
Total: 0,
List: make([]*types.UserFollowItem, 0),
}
resp.Total, resp.List = follower(l.ctx, l.svcCtx, user, req.Page, req.Size, req.Name)
return
}
func follower(ctx context.Context, svcCtx *svc.ServiceContext, user *domain.User, page, size int, name string) (total int64, list []*types.UserFollowItem) {
var (
users = user.Follower
total = int64(len(users))
offset, limit = domain.OffsetLimit(req.Page, req.Size)
offset, limit = domain.OffsetLimit(page, size)
conn = svcCtx.DefaultDBConn()
companyMap = make(map[int64]*domain.Company)
)
total = int64(len(users))
users = lo.Slice(users, offset, offset+limit)
resp = &types.MiniUserFollowedSearchResponse{
Total: total,
List: make([]*types.UserFollowItem, 0),
}
list = make([]*types.UserFollowItem, 0)
for {
if offset > len(user.Follower) {
break
}
users = lo.Slice(users, offset, offset+limit)
lo.ForEach(users, func(item int64, index int) {
if foundUser, _ := l.svcCtx.UserRepository.FindOne(l.ctx, conn, item); foundUser != nil {
if len(req.Name) > 0 && !strings.Contains(foundUser.Name, req.Name) {
if foundUser, _ := svcCtx.UserRepository.FindOne(ctx, conn, item); foundUser != nil {
if len(name) > 0 && !strings.Contains(foundUser.Name, name) {
return
}
var companyName = ""
if company, _ := domain.LazyLoad(companyMap, l.ctx, conn, foundUser.CompanyId, l.svcCtx.CompanyRepository.FindOne); company != nil {
if company, _ := domain.LazyLoad(companyMap, ctx, conn, foundUser.CompanyId, svcCtx.CompanyRepository.FindOne); company != nil {
companyName = company.Name
}
resp.List = append(resp.List, &types.UserFollowItem{
list = append(list, &types.UserFollowItem{
Id: foundUser.Id,
Name: foundUser.Name,
CompanyName: companyName,
Avatar: foundUser.Avatar,
Position: foundUser.Position,
Followed: true,
MutualFollowed: lo.Contains(user.Following, item),
MutualFollowed: user.IsFriend(item),
})
}
})
if len(resp.List) >= limit {
if len(list) >= limit {
break
}
req.Page += 1
offset, limit = domain.OffsetLimit(req.Page, req.Size)
page += 1
offset, limit = domain.OffsetLimit(page, size)
}
return
}
... ...
... ... @@ -45,7 +45,7 @@ func (l *MiniUserMyFollowingNewsLogic) MiniUserMyFollowingNews(req *types.MiniUs
if req.AuthorId > 0 {
users = []int64{req.AuthorId}
}
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size); err != nil {
if _, articles, err = l.svcCtx.ArticleRepository.FindAuthorsLatestArticle(l.ctx, conn, user.CompanyId, users, user.Id, req.LastArticleId, req.Size, domain.NewQueryOptions().WithFindOnly()); err != nil {
return nil, xerr.NewErrMsgErr("获取快讯异常", err)
}
resp = &types.MiniUserNewsResposne{
... ...
... ... @@ -43,7 +43,7 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest)
onlyUsers = article.WhoRead
}
}
if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithFindOnly()); err != nil {
if _, users, err = l.svcCtx.UserRepository.FindDepartmentUsers(l.ctx, conn, userToken.CompanyId, domain.NewQueryOptions().WithKV("name", req.Keywords).WithFindOnly()); err != nil {
return nil, xerr.NewErrMsgErr("用户列表获取失败", err)
}
if len(onlyUsers) > 0 {
... ... @@ -63,6 +63,8 @@ func (l *MiniAtUsersListLogic) MiniAtUsersList(req *types.MiniUsersListRequest)
Id: item.Id,
Name: item.Name,
PinYinName: item.PinYinName,
Avatar: item.Avatar,
Position: item.Position,
})
})
return map[string]interface{}{
... ...
... ... @@ -449,6 +449,58 @@ type MiniEditUserInfoRequest struct {
type MiniEditUserInfoResponse struct {
}
type MiniHomePageUserInfoRequest struct {
UserId int64 `json:"userId"` // 用户ID
}
type MiniHomePageUserInfoResponse struct {
User *UserItem `json:"user,omitempty"` // 用户信息
TotalFollower int `json:"totalFollower"` // 关注他的人数
TotalBeLoved int `json:"totalBeLoved"` // 获赞数
Followed bool `json:"followed"` // 关注
MutualFollowed bool `json:"mutualFollowed"` // 互相关注标识
}
type MiniHomePageUserFollowerSearchRequest struct {
UserId int `json:"userId"`
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Name string `json:"name,optional"`
}
type MiniHomePageUserFollowerSearchResponse struct {
List []*UserFollowItem `json:"users"`
Total int64 `json:"total"`
}
type MiniHomePageUserBeLikedRequest struct {
UserId int `json:"userId"`
Page int `json:"page"`
Size int `json:"size"`
}
type MiniHomePageUserBeLikedResponse struct {
List []MyBeLikedItem `json:"list"`
Total int64 `json:"total"`
}
type MiniHomepageUserNewsRequest struct {
AuthorId int64 `json:"authorId"` // 特定作者ID
LastArticleId int64 `json:"lastArticleId,optional"` // 最后文章ID
Size int `json:"size"` // 数量
OrderByKey string `json:"orderByKey,options=HotScore|All|Time,optional,default=desc"` // 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)
OrderByValue string `json:"orderByValue,options=asc||desc,optional"`
Keywords string `json:"keywords,optional"` // 关键字
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
type MiniHomepageUserNewsResposne struct {
List []UserNewsItem `json:"list"`
LastArticleId int64 `json:"lastArticleId"` // 最后文章ID
Total int64 `json:"total"`
}
type MiniUserLoginRequest struct {
LoginType string `json:"loginType"` // 登录类型 wechat-login whchat-phone-login phone-password-login phone-smscode-login
WechatAuthCode string `json:"wechatAuthcode,optional"` // 微信登录 授权码
... ... @@ -503,8 +555,9 @@ type MiniUserDepartmentUsersResponse struct {
}
type MiniUsersListRequest struct {
ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户)
RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户
ArticleId int64 `json:"articleId,optional"` // 按文章ID(返回文章可见的用户)
RoleId int64 `json:"roleId,optional"` // 按角色角色关联的用户
Keywords string `json:"keywords,optional"` // 按关键字搜索(名称)
}
type MiniUserNewsRequest struct {
... ...
... ... @@ -207,7 +207,7 @@ func (repository *ArticleRepository) FindLatestAccessibleArticle(ctx context.Con
// FindAuthorsLatestArticle 作者最新的文章
func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn,
companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*domain.Article, error) {
companyId int64, authors []int64, whoRead int64, lastId int64, limit int, queryOptions map[string]interface{}) (int64, []*domain.Article, error) {
var (
tx = conn.DB()
ms []*models.Article
... ... @@ -223,11 +223,26 @@ func (repository *ArticleRepository) FindAuthorsLatestArticle(ctx context.Contex
if lastId > 0 {
tx.Where("id < ?", lastId)
}
tx.Order("id desc")
if v, ok := queryOptions["beginTime"]; ok {
tx.Where("created_at >= ?", v)
}
if v, ok := queryOptions["endTime"]; ok {
tx.Where("created_at < ?", v)
}
if v, ok := queryOptions["keywords"]; ok {
tx.Where("title like ?", fmt.Sprintf("%%%v%%", v))
}
if v, ok := queryOptions["orderByHotScore"]; ok {
tx.Order(fmt.Sprintf("(count_comment+count_love) %v", v))
} else if v, ok := queryOptions["orderByAll"]; ok {
tx.Order(fmt.Sprintf("id %v", v))
} else {
tx.Order("id desc")
}
if limit > 0 {
tx.Limit(limit)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, domain.NewQueryOptions().WithFindOnly(), &ms); tx.Error != nil {
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
return dms, nil
... ...
... ... @@ -158,6 +158,45 @@ func (repository *UserLoveFlagRepository) Find(ctx context.Context, conn transac
return total, dms, nil
}
//func (repository *UserLoveFlagRepository) FindByUserVisible(ctx context.Context, conn transaction.Conn,companyId, toUserId int64,currentUserId, queryOptions map[string]interface{}) (int64, []*domain.UserLoveFlag, error) {
// var (
// tx = conn.DB()
// ms []*models.UserLoveFlag
// dms = make([]*domain.UserLoveFlag, 0)
// total int64
// )
// queryFunc := func() (interface{}, error) {
// tx = tx.Model(&ms).Order("id desc")
// if v, ok := queryOptions["companyId"]; ok {
// tx = tx.Where("company_id=?", v)
// }
// tx = tx.Where("article_id in (SELECT id FROM \"article\" WHERE company_id=? AND author_id in (?) AND (author_id = ? or target_user=0 or who_read @>'[?]') AND show = 1 AND \"article\".\"is_del\" = 0)", companyId,toUserId)
// if v, ok := queryOptions["toUserId"]; ok {
// tx = tx.Where("to_user_id=?", v)
// }
// if v, ok := queryOptions["commentIdList"]; ok {
// tx = tx.Where("comment_id in (?)", v)
// }
// if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
// return dms, tx.Error
// }
// return dms, nil
// }
//
// if _, err := repository.Query(queryFunc); err != nil {
// return 0, nil, err
// }
//
// for _, item := range ms {
// if dm, err := repository.ModelToDomainModel(item); err != nil {
// return 0, dms, err
// } else {
// dms = append(dms, dm)
// }
// }
// return total, dms, nil
//}
func (repository *UserLoveFlagRepository) ModelToDomainModel(from *models.UserLoveFlag) (*domain.UserLoveFlag, error) {
to := &domain.UserLoveFlag{
Id: from.Id,
... ...
... ... @@ -144,6 +144,9 @@ func (repository *UserRepository) Find(ctx context.Context, conn transaction.Con
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms)
if v, ok := queryOptions["unscoped"]; ok && v.(bool) {
tx.Unscoped()
}
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ?", v)
}
... ... @@ -223,6 +226,9 @@ func (repository *UserRepository) FindDepartmentUsers(ctx context.Context, conn
tx.Where("company_id = ?", companyId)
tx.Where("audit_status in (?)", domain.UserAuditStatusPassed)
tx.Where("enable = ?", domain.UserEnable)
if v, ok := queryOptions["name"]; ok {
tx.Where("name like ?", fmt.Sprintf("%%%v%%", v))
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -43,7 +43,7 @@ type ArticleRepository interface {
Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*Article, error)
FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error)
FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error)
FindAuthorsLatestArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, lastId int64, limit int, queryOptions map[string]interface{}) (int64, []*Article, error)
FindLatestAccessibleArticle(ctx context.Context, conn transaction.Conn, companyId int64, whoRead int64, lastId int64, limit int) (int64, []*Article, error)
IncreaseCountLove(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //点赞数量变动
IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, articleId int64) error //评论数量变动
... ...
... ... @@ -136,6 +136,15 @@ func (m *User) WithName(name string) *User {
return m
}
func (m *User) IsFollowed(userId int64) bool {
return lo.Contains(m.Following, userId)
}
// IsFriend 如果是好友,为互相关注
func (m *User) IsFriend(userId int64) bool {
return lo.Contains(m.Following, userId) && lo.Contains(m.Follower, userId)
}
type (
LoginCreator interface {
WechatLogin(r WechatLoginRequest) (*LoginInfo, error)
... ...