作者 庄敏学

merge

正在显示 74 个修改的文件 包含 2418 行增加445 行删除
... ... @@ -32,3 +32,4 @@ lastupdate.tmp
public/*
logs/
cmd/discuss/api/etc/core.local.yaml
... ...
... ... @@ -9,6 +9,9 @@
样例账号 18860183050 密码 123456
### 正式环境
服务端域名 https://sumifcc-discuss-prd.sumifcc.com/
日志地址 https://sumifcc-discuss-prd.sumifcc.com/v1/log/access
### 可设置环境变量
- DataSource
... ...
... ... @@ -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": {
... ...
... ... @@ -65,6 +65,9 @@ service Core {
@handler MiniArticleBackupSearch
post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse)
@doc "小程序获取文章的编辑记录"
@handler MiniGetArticleBackup
get /article_backup/:id (MiniGetArticleBackupRequest) returns (MiniGetArticleBackupResponse)
@doc "小程序设置文章的定性标签"
@handler MiniArticleSetTag
... ...
... ... @@ -168,14 +168,40 @@ type (
List []MiniArticleBackupItem `json:"list"`
}
MiniArticleBackupItem {
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
Videos []Video `json:"videos"`
ChangeField []string `json:"changeField"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
}
)
type (
MiniGetArticleBackupRequest {
BackupId int64 `path:"id"`
CompanyId int64 `path:",optional"` // 服务端自动获取
}
MiniGetArticleBackupResponse {
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
Videos []Video `json:"videos"`
ChangeField []string `json:"changeField"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
}
)
// 标记人员浏览了那个文章
type (
MiniArticleMarkUserReadRequest {
... ... @@ -391,6 +417,7 @@ type (
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
OrderMode string `json:"orderMode,optional"` //排序方式
}
SystemArticleSearchResponse {
... ... @@ -417,7 +444,7 @@ type (
SystemArticleUpdateRequest {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Template int `json:"template,optional"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
... ...
... ... @@ -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
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"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/pkg/result"
)
func MiniGetArticleBackupHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniGetArticleBackupRequest
if err := httpx.Parse(r, &req); err != nil {
result.HttpResult(r, w, nil, err)
return
}
l := article.NewMiniGetArticleBackupLogic(r.Context(), svcCtx)
resp, err := l.MiniGetArticleBackup(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -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),
... ... @@ -509,6 +529,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: article.MiniArticleBackupSearchHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_backup/:id",
Handler: article.MiniGetArticleBackupHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/set_tag",
Handler: article.MiniArticleSetTagHandler(serverCtx),
... ...
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)
}
}
... ...
... ... @@ -51,18 +51,60 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr
for _, val2 := range backupList[i].Images {
images = append(images, val2.Url)
}
resp.List[i] = types.MiniArticleBackupItem{
videos := []types.Video{}
for _, val2 := range backupList[i].Videos {
videos = append(videos, types.Video{
Url: val2.Url,
Cover: val2.Cover,
Width: val2.Width,
Height: val2.Height,
})
}
item := types.MiniArticleBackupItem{
Id: backupList[i].Id,
Title: backupList[i].Title,
Content: content.String(),
Images: images,
Title: "",
Content: "",
Images: []string{},
Videos: []types.Video{},
CreatedAt: backupList[i].CreatedAt,
Location: types.Location{
Longitude: backupList[i].Location.Longitude,
Latitude: backupList[i].Location.Latitude,
Descript: backupList[i].Location.Descript,
},
ChangeField: backupList[i].ChangeField,
Action: backupList[i].Action,
Show: int(backupList[i].Show),
}
//根据修改的内容替换展示内容
changeFiled := []string{}
for _, val := range item.ChangeField {
switch val {
case "WhoRead":
changeFiled = append(changeFiled, "修改了分发对象")
case "WhoReview":
changeFiled = append(changeFiled, "修改了评论范围")
case "Section":
{
item.Title = backupList[i].Title
item.Content = content.String()
item.Images = images
item.Videos = videos
}
}
}
if len(changeFiled) > 0 {
item.ChangeField = changeFiled
} else {
item.Title = backupList[i].Title
item.Content = content.String()
item.Images = images
item.Videos = videos
}
resp.List[i] = item
}
return resp, nil
}
... ...
... ... @@ -28,8 +28,8 @@ func NewMiniArticleSearchMeLogic(ctx context.Context, svcCtx *svc.ServiceContext
// MiniArticleSearchMe 获取我发布的文章
func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
if req.Size > 2000 {
req.Size = 2000
}
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
... ...
... ... @@ -127,7 +127,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
//切分文章分段
sectionList := []domain.ArticleSection{}
sectionList := []*domain.ArticleSection{}
newStr := ""
for i := range req.Section {
strList := strings.Split(req.Section[i], "\n")
... ... @@ -141,7 +141,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
SortBy: len(sectionList),
TotalComment: 0,
}
sectionList = append(sectionList, newSection)
sectionList = append(sectionList, &newSection)
}
}
... ... @@ -185,11 +185,19 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
for i := range sectionList {
sectionList[i].ArticleId = newArticle.Id
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &sectionList[i])
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, sectionList[i])
if err != nil {
return xerr.NewErrMsgErr("创建文章内容失败", err)
}
}
// 生成 备份数据
var backupData domain.ArticleBackup
backupData.MakeBackup(articleAuthor, newArticle, sectionList, "原始版本")
_, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, &backupData)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
return nil
}, true)
if err != nil {
... ...
package article
import (
"context"
"strings"
"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/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniGetArticleBackupLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniGetArticleBackupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleBackupLogic {
return &MiniGetArticleBackupLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniGetArticleBackupLogic) MiniGetArticleBackup(req *types.MiniGetArticleBackupRequest) (resp *types.MiniGetArticleBackupResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
backupInfo, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.BackupId)
if err != nil {
return &types.MiniGetArticleBackupResponse{}, xerr.NewErrMsgErr("获取编辑记录失败", err)
}
content := strings.Builder{}
for _, val2 := range backupInfo.Section {
content.WriteString(val2.Content)
}
images := []string{}
for _, val2 := range backupInfo.Images {
images = append(images, val2.Url)
}
videos := []types.Video{}
for _, val2 := range backupInfo.Videos {
videos = append(videos, types.Video{
Url: val2.Url,
Cover: val2.Cover,
Width: val2.Width,
Height: val2.Height,
})
}
resp = &types.MiniGetArticleBackupResponse{
Id: backupInfo.Id,
Title: backupInfo.Title,
Content: content.String(),
Images: images,
Videos: videos,
CreatedAt: backupInfo.CreatedAt,
Location: types.Location{
Longitude: backupInfo.Location.Longitude,
Latitude: backupInfo.Location.Latitude,
Descript: backupInfo.Location.Descript,
},
ChangeField: backupInfo.ChangeField,
Action: backupInfo.Action,
Show: int(backupInfo.Show),
}
return
}
... ...
... ... @@ -42,25 +42,8 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
return nil, xerr.NewErrMsg("没有查看权限")
}
// 检查文章的可查看人
if articleInfo.AuthorId != int64(req.UserId) {
if len(articleInfo.WhoRead) > 0 {
inWhoRead := false
for _, val := range articleInfo.WhoRead {
if req.UserId == int(val) {
inWhoRead = true
}
}
if !inWhoRead {
// 文章内容不显示
// resp = &types.MiniArticleGetResponse{
// Id: articleInfo.Id,
// Title: articleInfo.Title,
// Show: int(domain.ArticleShowDisable),
// }
// return resp, nil
return nil, xerr.NewErrMsg("没有查看权限")
}
}
if ok := articleInfo.WhoCanRead(int64(req.UserId)); !ok {
return nil, xerr.NewErrMsg("没有查看权限")
}
if articleInfo.Show == domain.ArticleShowDisable {
// 文章内容不显示
... ... @@ -110,8 +93,8 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
follow, _ := l.svcCtx.UserFollowRepository.FindOneUserFollowing(l.ctx, conn, int64(req.UserId), articleInfo.AuthorId)
queryOption = domain.NewQueryOptions().WithFindOnly().WithOffsetLimit(1, 1).WithKV("articleId", articleInfo.Id)
_, backupList, _ := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption)
queryOption = domain.NewQueryOptions().WithCountOnly().WithOffsetLimit(1, 1).WithKV("articleId", articleInfo.Id)
backupCount, _, _ := l.svcCtx.ArticleBackupRepository.Find(l.ctx, conn, queryOption)
sortBy := domain.SortArticleSection(sectionList)
sort.Sort(sortBy)
... ... @@ -157,7 +140,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
MatchUrl: map[string]string{},
Videos: []types.Video{},
}
if len(backupList) > 0 {
if backupCount > 1 {
resp.Edit = 1
}
if author != nil {
... ...
... ... @@ -28,8 +28,8 @@ func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceCo
// 查询我的草稿箱内容列表
func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
if req.Size > 2000 {
req.Size = 2000
}
queryOption := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
... ...
... ... @@ -32,8 +32,8 @@ func NewMiniSearchArticlePageLogic(ctx context.Context, svcCtx *svc.ServiceConte
func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearchArticleRequest) (resp *types.MiniSearchArticleResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
if req.Size > 100 {
req.Size = 100
if req.Size > 2000 {
req.Size = 2000
}
cnt, articleList, err := l.svcCtx.ArticleRepository.CustomSearchBy(l.ctx, conn, req.UserId, req.CompanyId,
req.TagCategory, req.TagId, [2]int64{req.BeginTime, req.EndTime}, req.SearchWord, req.Page, req.Size)
... ...
... ... @@ -39,6 +39,9 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章汇总数量失败", err)
}
//TODO 拆分统计
countDataMap := map[int64]*domain.CountArticleTagRead{}
for _, val := range countData {
countDataMap[val.TagId] = val
... ...
... ... @@ -32,7 +32,7 @@ func NewSystemArticleRestoreLogic(ctx context.Context, svcCtx *svc.ServiceContex
func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticleRestoreRequest) (resp *types.SystemArticleRestoreResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
backup, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.Id)
oldBackup, err := l.svcCtx.ArticleBackupRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("获取编辑历史记录失败", err)
}
... ... @@ -42,7 +42,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, backup.ArticleId)
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, oldBackup.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章失败", err)
}
... ... @@ -50,24 +50,26 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章段落内容失败", err)
}
// 备份数据
newBackUp := article.MakeBackup(domain.UserSimple{
var newBackUp domain.ArticleBackup
newBackUp.MakeBackup(domain.UserSimple{
Id: userToken.UserId,
Name: userMe.User.NickName,
Avatar: userMe.User.Avatar,
CompanyId: userToken.CompanyId,
Company: userMe.CurrentCompany.Name,
}, sectionList)
newBackUp.Action = "恢复"
}, article, sectionList, "恢复")
_ = newBackUp.CheckChangeField(oldBackup)
article.Version = article.Version + 1
article.Images = backup.Images
article.Videos = backup.Videos
article.Title = backup.Title
article.MatchUrl = backup.MatchUrl
articleSections := make([]domain.ArticleSection, 0)
lo.ForEach(backup.Section, func(item domain.ArticleSection, index int) {
articleSections = append(articleSections, domain.ArticleSection{
article.Images = oldBackup.Images
article.Videos = oldBackup.Videos
article.Title = oldBackup.Title
article.MatchUrl = oldBackup.MatchUrl
articleSections := make([]*domain.ArticleSection, 0)
lo.ForEach(oldBackup.Section, func(item domain.ArticleSection, index int) {
articleSections = append(articleSections, &domain.ArticleSection{
Id: item.Id,
CompanyId: item.CompanyId,
Version: article.Version,
... ... @@ -98,7 +100,7 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
return xerr.NewErrMsgErr("恢复文章版本失败", err)
}
} else {
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &item)
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, item)
if err != nil {
return xerr.NewErrMsgErr("恢复文章版本失败", err)
}
... ... @@ -106,13 +108,14 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
updateSectionIds = append(updateSectionIds, item.Id)
}
if len(updateSectionIds) > 0 {
err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds))
queryOption := domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds)
err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, queryOption)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
}
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, newBackUp)
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, &newBackUp)
if err != nil {
return xerr.NewErrMsgErr("恢复文章版本失败", err)
}
... ...
... ... @@ -2,6 +2,7 @@ package article
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"
... ... @@ -33,7 +34,9 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
WithKV("authorId", req.Author).
WithKV("tags", req.Tags).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
WithKV("endCreatedAt", req.EndTime).
WithKV("orderMode", req.OrderMode)
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索帖子异常", err)
... ...
... ... @@ -57,24 +57,26 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
operator := domain.UserSimple{
Id: userToken.UserId,
Name: userMe.User.NickName,
Avatar: userMe.User.Avatar,
CompanyId: userToken.CompanyId,
Company: userMe.CurrentCompany.Name,
}
// 文章数据
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
_, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, map[string]interface{}{"articleId": article.Id})
//
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", req.Id)
_, sectionList, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, l.conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章段落内容失败", err)
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
//备份数据
backup := article.MakeBackup(domain.UserSimple{
Id: userToken.UserId,
Name: userMe.User.NickName,
Avatar: userMe.User.Avatar,
CompanyId: userToken.CompanyId,
Company: userMe.CurrentCompany.Name,
}, sectionList)
backup.Action = "编辑"
var oldBackup domain.ArticleBackup
oldBackup.MakeBackup(operator, article, sectionList, "编辑")
// 获取图片的尺寸大小
images, err := l.getImages(req)
... ... @@ -126,6 +128,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
}
//文章内容
updateSectionIds := []int64{}
updateSection := []*domain.ArticleSection{}
for _, item := range articleSections {
if item.Id > 0 {
section, err := l.svcCtx.ArticleSectionRepository.FindOne(ctx, c, item.Id)
... ... @@ -142,22 +145,29 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
} else {
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &item)
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, item)
if err != nil {
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
}
updateSectionIds = append(updateSectionIds, item.Id)
updateSection = append(updateSection, item)
}
if len(updateSectionIds) > 0 {
err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds))
queryOption := domain.NewQueryOptions().WithKV("articleId", article.Id).WithKV("notIds", updateSectionIds)
err = l.svcCtx.ArticleSectionRepository.DeleteBy(ctx, c, queryOption)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
}
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
var backup domain.ArticleBackup
backup.MakeBackup(operator, article, updateSection, "编辑")
if ok := backup.CheckChangeField(&oldBackup); ok {
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, &backup)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
}
//文章定性
err = l.setTags(c, article)
... ... @@ -307,8 +317,8 @@ func (l *SystemUpdateArticleLogic) getVideos(req *types.SystemArticleUpdateReque
return videos, nil
}
func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateRequest, article *domain.Article) []domain.ArticleSection {
articleSections := make([]domain.ArticleSection, 0)
func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateRequest, article *domain.Article) []*domain.ArticleSection {
articleSections := make([]*domain.ArticleSection, 0)
sortBy := 1
lo.ForEach(req.Section, func(item types.ArticleSection, index int) {
strList := strings.Split(item.Content, "\n")
... ... @@ -326,7 +336,7 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq
if key == 0 {
section.Id = item.Id
}
articleSections = append(articleSections, section)
articleSections = append(articleSections, &section)
sortBy++
}
})
... ...
... ... @@ -42,7 +42,10 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
var userList []*domain.User
if articleInfo.TargetUser == domain.ArticleTargetAll {
//获取所有人
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
queryOption := domain.NewQueryOptions().WithFindOnly().
MustWithKV("companyId", articleInfo.CompanyId).
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
... ...
... ... @@ -52,11 +52,8 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
return nil, xerr.NewErrMsg("没有评论权限")
}
//查看评论权限,
if len(articleInfo.WhoReview) > 0 {
ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
if ok < 0 {
return nil, xerr.NewErrMsg("没有评论权限")
}
if ok := articleInfo.WhoCanReview(req.FromUserId); !ok {
return nil, xerr.NewErrMsg("没有评论权限")
}
// 对段落进行评论
var selctionInfo *domain.ArticleSection
... ... @@ -91,7 +88,9 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
atWhoIds = append(atWhoIds, val.Id)
}
atWhoIds = lo.Uniq(atWhoIds)
queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", atWhoIds)
queryOption := domain.NewQueryOptions().WithFindOnly().
WithKV("ids", atWhoIds).
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed})
_, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
... ... @@ -182,15 +181,8 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
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 {
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"
... ... @@ -51,15 +52,9 @@ func (l *MiniDeleteArticleCommentLogic) MiniDeleteArticleComment(req *types.Mini
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 +62,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 {
... ...
... ... @@ -36,8 +36,8 @@ func (l *MiniListArticleCommentLogic) MiniListArticleComment(req *types.MiniList
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论信息失败", err)
}
if req.Size > 100 {
req.Size = 100
if req.Size > 2000 {
req.Size = 2000
}
queryOption := domain.NewQueryOptions().
... ...
... ... @@ -49,7 +49,9 @@ func (l *SystemEditAticleCommentLogic) SystemEditAticleComment(req *types.System
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
queryOption := domain.NewQueryOptions().WithCountOnly().
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", err)
... ... @@ -68,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)
}
}
... ... @@ -86,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
... ...
... ... @@ -61,7 +61,9 @@ func (l *SystemEditAticleCommentLoveLogic) SystemEditAticleCommentLove(req *type
maxCount = commetInfo.MaxCountAdminLove(len(articleInfo.WhoRead))
} else {
//统计全员人数
queryOption := domain.NewQueryOptions().WithCountOnly().MustWithKV("companyId", req.CompanyId)
queryOption := domain.NewQueryOptions().WithCountOnly().
MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}).
MustWithKV("companyId", req.CompanyId)
cnt, _, err := l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取人员数据失败", 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"
... ... @@ -79,15 +80,7 @@ func (l *SystemEditAticleCommentShowLogic) disableShow(commentId int64, companyI
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 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, -1, commentInfo.TopId)
if err != nil {
return err
... ... @@ -95,15 +88,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
}
}
// 评论被隐藏消息
... ... @@ -141,15 +148,9 @@ func (l *SystemEditAticleCommentShowLogic) enableShow(commentId int64, companyId
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 {
err = l.svcCtx.ArticleCommentRepository.IncreaseCountReply(l.ctx, c, 1, commetInfo.TopId)
if err != nil {
return err
... ... @@ -157,15 +158,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)
... ...
... ... @@ -69,7 +69,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
}
} else if req.Flag == 2 {
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions.MustWithKV("excludeIds", companyJoinedList))
if len(companyJoinedList) > 0 {
queryOptions.MustWithKV("excludeIds", companyJoinedList)
}
total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
}
... ...
... ... @@ -2,6 +2,7 @@ package department
import (
"context"
"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"
... ... @@ -58,7 +59,9 @@ func (l *SystemUpdateLogic) SystemUpdate(req *types.DepartmentUpdateRequest) (re
// 获取公司下的所有用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithFindOnly().
WithKV("companyId", one.CompanyId))
WithKV("companyId", one.CompanyId).MustWithKV("auditStatus", []int{domain.UserAuditStatusPassed}),
)
if err != nil {
return nil, err
}
... ...
... ... @@ -267,22 +267,29 @@ func (l *MiniBusinessLogic) createMessage(
at []int64) (err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
// 评论中携带了 @其他用户
var dupMap = make(map[int64]int64, 0)
// 评论中携带了 @用户
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,
CommentParentId: commentParentId,
}
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
if err != nil {
return err
if _, ok := dupMap[at[i]]; ok { /* ID去重 */
// do nothing ...
} else {
var msg = &domain.MessageBusiness{
Type: msgType,
OptType: optType,
CompanyId: userToken.CompanyId,
UserId: userToken.UserId,
RecipientId: at[i],
ArticleId: articleId,
CommentId: commentId,
CommentParentId: commentParentId,
}
msg, err = l.svcCtx.MessageBusinessRepository.Insert(l.ctx, conn, msg)
if err != nil {
return err
}
dupMap[at[i]] = at[i]
}
}
return nil
}
... ...
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
}
... ...
... ... @@ -83,8 +83,8 @@ func (l *MiniUserInfoLogic) MiniUserInfo(req *types.MiniUserInfoRequest) (resp *
CompanyName: companyName,
Logo: logo,
UserId: account.Id,
Name: user.Name,
Position: user.Position,
Name: account.Name,
Position: account.Position,
})
}
// 拥有的权限
... ...
... ... @@ -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{}{
... ...
... ... @@ -43,7 +43,8 @@ func (l *SystemUserAccountSearchLogic) SystemUserAccountSearch(req *types.System
WithKV("roleId", req.RoleId).
WithKV("enable", req.Enable).
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime)
WithKV("endTime", req.EndTime).
WithKV("auditStatus", []int{domain.UserAuditStatusPassed})
if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil {
return nil, xerr.NewErr(err)
}
... ...
... ... @@ -41,7 +41,8 @@ func (l *SystemUserSearchLogic) SystemUserSearch(req *types.SystemUserSearchRequ
WithKV("likePhone", req.Phone).
WithKV("position", req.Position).
WithKV("enable", req.Enable).
WithKV("departmentId", req.DepartmentId)
WithKV("departmentId", req.DepartmentId).
WithKV("auditStatus", []int{domain.UserAuditStatusPassed})
if total, users, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOptions); err != nil {
return nil, xerr.NewErr(err)
}
... ...
... ... @@ -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"` // 排序值 升序 asc 降序 desc
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 {
... ... @@ -976,12 +1029,34 @@ type MiniArticleBackupSearchResponse struct {
}
type MiniArticleBackupItem struct {
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
Videos []Video `json:"videos"`
ChangeField []string `json:"changeField"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
}
type MiniGetArticleBackupRequest struct {
BackupId int64 `path:"id"`
CompanyId int64 `path:",optional"` // 服务端自动获取
}
type MiniGetArticleBackupResponse struct {
Id int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Images []string `json:"images"`
Videos []Video `json:"videos"`
ChangeField []string `json:"changeField"`
CreatedAt int64 `json:"createdAt"`
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
}
type MiniArticleMarkUserReadRequest struct {
... ... @@ -1173,6 +1248,7 @@ type SystemArticleSearchRequest struct {
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
OrderMode string `json:"orderMode,optional"` //排序方式
}
type SystemArticleSearchResponse struct {
... ... @@ -1197,7 +1273,7 @@ type SystemArticleSearch struct {
type SystemArticleUpdateRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Template int `json:"template,optional"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
... ...
... ... @@ -30,7 +30,7 @@ type Article struct {
CountRead int // 浏览数量
CountComment int // 评论数量
Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签
Show int // 评论的展示状态(0显示、1不显示)
Show int // 评论的展示状态(1显示、2不显示)
Summary string // 内容概要
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
}
... ...
... ... @@ -10,26 +10,28 @@ import (
)
type ArticleBackup struct {
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
Operator domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 操作人
ArticleId int64
Title string // 标题
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频
Action string // 操作
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Tags []int64 `gorm:"type:jsonb;serializer:json"` // 标签
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
Operator domain.UserSimple `gorm:"type:jsonb;serializer:json"` // 操作人
ArticleId int64
Title string // 标题
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` // 分段内容
Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频
ChangeField []string `gorm:"type:jsonb;serializer:json"` //
Action string // 操作
WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Tags []int64 `gorm:"type:jsonb;serializer:json"` // 标签
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
TargetUser int // 分发方式 0 分发给所有人 1 分发给指定的人
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Show int
}
func (m *ArticleBackup) TableName() string {
... ...
... ... @@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ... @@ -157,25 +157,27 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa
func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.ArticleBackup) (*domain.ArticleBackup, error) {
to := &domain.ArticleBackup{
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.CreatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
Operator: from.Operator,
ArticleId: from.ArticleId,
Title: from.Title,
Section: from.Section,
Images: from.Images,
Action: from.Action,
TargetUser: domain.ArticleTarget(from.TargetUser),
Location: from.Location,
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Tags: from.Tags,
MatchUrl: from.MatchUrl,
Videos: from.Videos,
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.CreatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
Operator: from.Operator,
ArticleId: from.ArticleId,
Title: from.Title,
Section: from.Section,
Images: from.Images,
Action: from.Action,
TargetUser: domain.ArticleTarget(from.TargetUser),
Location: from.Location,
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Tags: from.Tags,
MatchUrl: from.MatchUrl,
ChangeField: from.ChangeField,
Videos: from.Videos,
Show: domain.ArticleShow(from.Show),
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -183,26 +185,28 @@ func (repository *ArticleBackupRepository) ModelToDomainModel(from *models.Artic
func (repository *ArticleBackupRepository) DomainModelToModel(from *domain.ArticleBackup) (*models.ArticleBackup, error) {
to := &models.ArticleBackup{
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.CreatedAt,
DeletedAt: from.DeletedAt,
IsDel: 0,
Version: from.Version,
Operator: from.Operator,
ArticleId: from.ArticleId,
Title: from.Title,
Section: from.Section,
Images: from.Images,
Action: from.Action,
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Tags: from.Tags,
Location: from.Location,
TargetUser: int(from.TargetUser),
MatchUrl: from.MatchUrl,
Videos: from.Videos,
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.CreatedAt,
DeletedAt: from.DeletedAt,
IsDel: 0,
Version: from.Version,
Operator: from.Operator,
ArticleId: from.ArticleId,
Title: from.Title,
Section: from.Section,
Images: from.Images,
Action: from.Action,
WhoRead: from.WhoRead,
WhoReview: from.WhoReview,
Tags: from.Tags,
Location: from.Location,
TargetUser: int(from.TargetUser),
MatchUrl: from.MatchUrl,
Videos: from.Videos,
ChangeField: from.ChangeField,
Show: int(from.Show),
}
// err := copier.Copy(to, from)
return to, nil
... ...
... ... @@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -44,7 +44,7 @@ func (repository *ArticleRepository) Update(ctx context.Context, conn transactio
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Save(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ... @@ -121,7 +121,22 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc").Where("company_id=?", companyId)
tx = tx.Model(&ms).Where("company_id=?", companyId)
if v, ok := queryOptions["orderMode"]; ok {
mode := v.(string)
switch mode {
case "countComment ascending":
tx = tx.Order("count_comment asc")
case "countComment descending":
tx = tx.Order("count_comment desc")
case "countLove ascending":
tx = tx.Order("count_love asc")
case "countLove descending":
tx = tx.Order("count_love desc")
default:
tx = tx.Order("id desc")
}
}
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
}
... ... @@ -207,7 +222,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 +238,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
... ...
... ... @@ -42,7 +42,7 @@ func (repository *ArticleSectionRepository) Update(ctx context.Context, conn tra
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Save(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != 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,
... ...
... ... @@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ... @@ -143,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)
}
... ... @@ -222,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
}
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -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 //评论数量变动
... ... @@ -95,42 +95,7 @@ func (a ArticleShow) Named() string {
return ""
}
// 设置文章的备份数据
func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *ArticleBackup {
sectionBackup := make([]ArticleSection, len(section))
for i := range section {
sectionBackup[i] = *section[i]
}
b := ArticleBackup{
Id: 0,
CompanyId: m.CompanyId,
CreatedAt: 0,
UpdatedAt: 0,
DeletedAt: 0,
Version: m.Version,
Operator: operator,
ArticleId: m.Id,
Title: m.Title,
Section: sectionBackup,
Images: make([]Image, len(m.Images)),
Videos: make([]Video, len(m.Videos)),
Action: "",
TargetUser: m.TargetUser,
WhoRead: m.WhoRead,
WhoReview: m.WhoReview,
Tags: m.Tags,
MatchUrl: map[string]string{},
Location: m.Location,
}
copy(b.Videos, m.Videos)
copy(b.Images, m.Images)
for k, v := range m.MatchUrl {
b.MatchUrl[k] = v
}
return &b
}
func (m *Article) SetSummary(sectionList []ArticleSection) {
func (m *Article) SetSummary(sectionList []*ArticleSection) {
if len(sectionList) == 0 {
return
}
... ... @@ -156,3 +121,33 @@ func (m *Article) SetSummary(sectionList []ArticleSection) {
}
m.Summary = content[0:stringIndex]
}
func (m *Article) WhoCanRead(userId int64) bool {
if m.AuthorId == userId {
return true
}
if len(m.WhoRead) == 0 {
return true
}
for _, val := range m.WhoRead {
if userId == val {
return true
}
}
return false
}
func (m *Article) WhoCanReview(userId int64) bool {
if m.AuthorId == userId {
return true
}
if len(m.WhoReview) == 0 {
return true
}
for _, val := range m.WhoReview {
if userId == val {
return true
}
}
return false
}
... ...
package domain
import (
"bytes"
"context"
"encoding/json"
"fmt"
"sort"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
// 编辑文章后保存的历史记录
type ArticleBackup struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Operator UserSimple `json:"operator"` // 操作人
ArticleId int64 `json:"articleId"` //
Title string `json:"title"` // 标题
Section []ArticleSection `json:"section"` // 分段内容
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
Action string `json:"action"` // 操作
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
Location Location `json:"location"` // 定位坐标
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Tags []int64 `json:"tags"` // 标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Operator UserSimple `json:"operator"` // 操作人
ArticleId int64 `json:"articleId"` //
Title string `json:"title"` // 标题
Section []ArticleSection `json:"section"` // 分段内容
Images []Image `json:"images"` // 图片
Videos []Video `json:"videos"` // 视频
Action string `json:"action"` // 操作
// 新的备份内容相对与旧的文章信息哪些内容发生了变更,可选值[WhoRead] 修改了分发对象, [WhoReview] 修改了评论范围,[Section] 修改了内容
ChangeField []string `json:"changeField"`
TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
Location Location `json:"location"` // 定位坐标
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Tags []int64 `json:"tags"` // 标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)
}
type ArticleBackupRepository interface {
... ... @@ -37,3 +44,137 @@ type ArticleBackupRepository interface {
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleBackup, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleBackup, error)
}
// 检查新的备份内容相对与旧的文章信息哪些内容发生了变更
// 记录ArticleBackup中数据发生变更的的字段名
func (bk *ArticleBackup) CheckChangeField(oldBackup *ArticleBackup) bool {
bk.ChangeField = make([]string, 0)
//比较 WhoRead
{
whoReadChanged := false
sort.Slice(bk.WhoRead, func(i, j int) bool {
return bk.WhoRead[i] < bk.WhoRead[j]
})
sort.Slice(oldBackup.WhoRead, func(i, j int) bool {
return oldBackup.WhoRead[i] < oldBackup.WhoRead[j]
})
if len(bk.WhoRead) != len(oldBackup.WhoRead) {
whoReadChanged = true
} else {
for i := range bk.WhoRead {
if bk.WhoRead[i] != oldBackup.WhoRead[i] {
whoReadChanged = true
}
}
}
if whoReadChanged {
bk.ChangeField = append(bk.ChangeField, "WhoRead")
}
}
//比较 whoReview
{
whoReviewChanged := false
sort.Slice(bk.WhoReview, func(i, j int) bool {
return bk.WhoReview[i] < bk.WhoReview[j]
})
sort.Slice(oldBackup.WhoReview, func(i, j int) bool {
return oldBackup.WhoReview[i] < oldBackup.WhoReview[j]
})
if len(bk.WhoReview) != len(oldBackup.WhoReview) {
whoReviewChanged = true
} else {
for i := range bk.WhoReview {
if bk.WhoReview[i] != oldBackup.WhoReview[i] {
whoReviewChanged = true
}
}
}
if whoReviewChanged {
bk.ChangeField = append(bk.ChangeField, "WhoReview")
}
}
//比较段落内容+图片+视频 是否发生变更
{
sectionChanged := false
newSectionData := map[string]string{
"title": bk.Title,
}
oldSectionData := map[string]string{
"title": oldBackup.Title,
}
for _, val := range bk.Section {
mkey := fmt.Sprintf("section-%d", val.SortBy)
newSectionData[mkey] = val.Content
}
for _, val := range bk.Images {
newSectionData[val.Url] = ""
}
for _, val := range bk.Videos {
newSectionData[val.Url] = ""
}
for _, val := range oldBackup.Section {
mKey := fmt.Sprintf("section-%d", val.SortBy)
oldSectionData[mKey] = val.Content
}
for _, val := range oldBackup.Images {
oldSectionData[val.Url] = ""
}
for _, val := range oldBackup.Videos {
oldSectionData[val.Url] = ""
}
newSectionJson, _ := json.Marshal(newSectionData)
oldSectionJson, _ := json.Marshal(oldSectionData)
if ok := bytes.Equal(newSectionJson, oldSectionJson); !ok {
sectionChanged = true
}
if sectionChanged {
bk.ChangeField = append(bk.ChangeField, "Section")
}
}
return len(bk.ChangeField) > 0
}
// 创建备份信息
func (bk *ArticleBackup) MakeBackup(operator UserSimple, article *Article, section []*ArticleSection, action string) {
sectionBackup := make([]ArticleSection, len(section))
for i := range section {
sectionBackup[i] = *section[i]
}
b := ArticleBackup{
Id: 0,
CompanyId: article.CompanyId,
CreatedAt: 0,
UpdatedAt: 0,
DeletedAt: 0,
Version: article.Version,
Operator: operator,
ArticleId: article.Id,
Title: article.Title,
Section: sectionBackup,
Images: make([]Image, len(article.Images)),
Videos: make([]Video, len(article.Videos)),
Action: action,
TargetUser: article.TargetUser,
WhoRead: article.WhoRead,
WhoReview: article.WhoReview,
Tags: article.Tags,
MatchUrl: map[string]string{},
Show: article.Show,
Location: article.Location,
}
if action == "原始版本" {
b.ChangeField = append(b.ChangeField, "Section")
}
copy(b.Videos, article.Videos)
copy(b.Images, article.Images)
for k, v := range article.MatchUrl {
b.MatchUrl[k] = v
}
*bk = b
}
... ...
... ... @@ -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)
... ...
... ... @@ -3,14 +3,15 @@ package database
import (
"context"
"fmt"
"log"
"os"
"time"
"github.com/zeromicro/go-zero/core/logx"
"gorm.io/driver/mysql"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"log"
"os"
"time"
)
func OpenGormDB(source string) *gorm.DB {
... ... @@ -44,6 +45,7 @@ func OpenGormPGDB(source string, logMode string) *gorm.DB {
if err != nil {
panic(err)
}
return db
}
... ...