作者 yangfu
正在显示 61 个修改的文件 包含 1530 行增加504 行删除
... ... @@ -293,34 +293,6 @@
]
}
},
"v1/mini/article_comment/at_user/select": {
"post": {
"summary": "小程序获取回复@人可选列表",
"operationId": "MiniArticleCommentAtUser",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtUserResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniArticleCommentAtUserRequest"
}
}
],
"requestBody": {},
"tags": [
"comment"
]
}
},
"v1/mini/article_comment/at_who/list": {
"post": {
"summary": "小程序展示评论时@人可选列表",
... ... @@ -631,22 +603,6 @@
"required": false,
"type": "integer",
"format": "int64"
},
{
"name": "articleId",
"description": " 文章id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
},
{
"name": "tagId",
"description": " 标签id",
"in": "query",
"required": true,
"type": "integer",
"format": "int64"
}
],
"requestBody": {},
... ... @@ -1211,6 +1167,64 @@
]
}
},
"v1/system/article": {
"put": {
"summary": "管理后台编辑帖子",
"operationId": "SystemUpdateArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleUpdateResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "编辑",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/history": {
"post": {
"summary": "管理后台编辑历史",
"operationId": "SystemHistoryArticle",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/SystemArticleHistoryResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "历史",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/SystemArticleHistoryRequest"
}
}
],
"requestBody": {},
"tags": [
"article"
]
}
},
"v1/system/article/search": {
"post": {
"summary": "管理后台获取文章列表",
... ... @@ -2240,6 +2254,25 @@
"totalComment"
]
},
"ArticleTagGroup": {
"type": "object",
"properties": {
"group": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagItem"
}
}
},
"title": "ArticleTagGroup",
"required": [
"group",
"tags"
]
},
"ArticleTagItem": {
"type": "object",
"properties": {
... ... @@ -2252,13 +2285,17 @@
},
"name": {
"type": "string"
},
"image": {
"type": "string"
}
},
"title": "ArticleTagItem",
"required": [
"id",
"group",
"name"
"name",
"image"
]
},
"Auth": {
... ... @@ -2294,6 +2331,9 @@
},
"name": {
"type": "string"
},
"firstLetter": {
"type": "string"
}
},
"title": "CommentAtWho",
... ... @@ -2806,23 +2846,9 @@
"type": "integer",
"format": "int64",
"description": " 公司id"
},
"articleId": {
"type": "integer",
"format": "int64",
"description": " 文章id"
},
"tagId": {
"type": "integer",
"format": "int64",
"description": " 标签id"
}
},
"title": "MiniAllArticleTagRequest",
"required": [
"articleId",
"tagId"
]
"title": "MiniAllArticleTagRequest"
},
"MiniAllArticleTagResponse": {
"type": "object",
... ... @@ -2830,20 +2856,13 @@
"tagGroup": {
"type": "array",
"items": {
"type": "string"
}
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagItem"
"$ref": "#/definitions/ArticleTagGroup"
}
}
},
"title": "MiniAllArticleTagResponse",
"required": [
"tagGroup",
"tags"
"tagGroup"
]
},
"MiniArticleBackupItem": {
... ... @@ -2931,23 +2950,6 @@
"list"
]
},
"MiniArticleCommentAtUserRequest": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64"
}
},
"title": "MiniArticleCommentAtUserRequest",
"required": [
"articleId"
]
},
"MiniArticleCommentAtUserResponse": {
"type": "object",
"title": "MiniArticleCommentAtUserResponse"
},
"MiniArticleCommentAtWhoRequest": {
"type": "object",
"properties": {
... ... @@ -5022,6 +5024,96 @@
"show"
]
},
"SystemArticleHistory": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"author": {
"type": "string",
"description": "编辑人"
},
"action": {
"type": "string",
"description": "编辑类型"
},
"updatedAt": {
"type": "integer",
"format": "int64",
"description": "编辑时间"
}
},
"title": "SystemArticleHistory",
"required": [
"id",
"author",
"action",
"updatedAt"
]
},
"SystemArticleHistoryRequest": {
"type": "object",
"properties": {
"articleId": {
"type": "integer",
"format": "int64",
"description": "文章ID"
},
"author": {
"type": "string",
"description": "发布人"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": "开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": "结束时间"
},
"page": {
"type": "integer",
"format": "int32",
"description": "页码"
},
"size": {
"type": "integer",
"format": "int32",
"description": "每页行数"
}
},
"title": "SystemArticleHistoryRequest",
"required": [
"articleId",
"page",
"size"
]
},
"SystemArticleHistoryResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/SystemArticleHistory"
}
}
},
"title": "SystemArticleHistoryResponse",
"required": [
"total",
"list"
]
},
"SystemArticleSearch": {
"type": "object",
"properties": {
... ... @@ -5149,17 +5241,37 @@
"SystemArticleSearchRequest": {
"type": "object",
"properties": {
"": {
"companyId": {
"type": "integer",
"format": "int64"
},
"title": {
"type": "string",
"description": "标题"
},
"author": {
"type": "string",
"description": "发布人"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": "开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": "结束时间"
},
"page": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "页码"
},
"size": {
"type": "integer",
"format": "int32"
"format": "int32",
"description": "每页行数"
}
},
"title": "SystemArticleSearchRequest",
... ... @@ -5188,6 +5300,149 @@
"list"
]
},
"SystemArticleUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"companyId": {
"type": "integer",
"format": "int64"
},
"template": {
"type": "integer",
"format": "int32",
"description": " 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式"
},
"section": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSection"
},
"description": " 填写的内容"
},
"title": {
"type": "string",
"description": " 标题"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 评论人"
},
"location": {
"$ref": "#/definitions/Location",
"description": " 坐标"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
}
},
"title": "SystemArticleUpdateRequest",
"required": [
"id",
"template",
"section",
"title",
"images",
"whoRead",
"whoReview",
"location",
"targetUser"
]
},
"SystemArticleUpdateResponse": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"title": {
"type": "string",
"description": "标题"
},
"author": {
"type": "string",
"description": "发布人"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": "图片"
},
"createdAt": {
"type": "integer",
"format": "int64",
"description": "文章的创建日期"
},
"countLove": {
"type": "integer",
"format": "int32",
"description": "点赞数量"
},
"CountComment": {
"type": "integer",
"format": "int32",
"description": "评论数量"
},
"show": {
"type": "integer",
"format": "int32",
"description": "是否隐藏 [0显示、1不显示]"
},
"tags": {
"type": "array",
"items": {
"type": "string"
},
"description": "标签"
},
"targetUser": {
"type": "integer",
"format": "int32",
"description": "分发方式 [0分发给所有人、1分发给指定的人]"
}
},
"title": "SystemArticleUpdateResponse",
"required": [
"id",
"title",
"author",
"images",
"createdAt",
"countLove",
"CountComment",
"show",
"tags",
"targetUser"
]
},
"SystemUser": {
"type": "object",
"properties": {
... ... @@ -5608,7 +5863,7 @@
"TagCreateRequest": {
"type": "object",
"properties": {
"companyId": {
"": {
"type": "integer",
"format": "int64"
},
... ... @@ -5619,21 +5874,24 @@
"type": "string",
"description": " 标签名称"
},
"group": {
"category": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
},
"other": {
"type": "string"
}
},
"title": "TagCreateRequest",
"required": [
"companyId",
"image",
"name",
"group"
"category",
"other"
]
},
"TagCreateResponse": {
... ... @@ -5656,15 +5914,14 @@
"type": "integer",
"format": "int64"
},
"companyId": {
"": {
"type": "integer",
"format": "int64"
}
},
"title": "TagDeleteRequest",
"required": [
"id",
"-"
"id"
]
},
"TagDeleteResponse": {
... ... @@ -5687,7 +5944,7 @@
"type": "integer",
"format": "int64"
},
"companyId": {
"": {
"type": "integer",
"format": "int64"
},
... ... @@ -5698,22 +5955,25 @@
"type": "string",
"description": " 标签名称"
},
"group": {
"category": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
},
"other": {
"type": "string"
}
},
"title": "TagEditRequest",
"required": [
"id",
"-",
"image",
"name",
"group"
"category",
"other"
]
},
"TagEditResponse": {
... ... @@ -5736,15 +5996,14 @@
"type": "integer",
"format": "int64"
},
"companyId": {
"": {
"type": "integer",
"format": "int64"
}
},
"title": "TagGetRequest",
"required": [
"id",
"-"
"id"
]
},
"TagGetResponse": {
... ... @@ -5761,13 +6020,16 @@
"type": "string",
"description": " 标签名称"
},
"group": {
"category": {
"type": "string",
"description": " 标签分类"
},
"remark": {
"type": "string",
"description": " 备注"
},
"other": {
"type": "string"
}
},
"title": "TagGetResponse",
... ... @@ -5775,8 +6037,9 @@
"id",
"image",
"name",
"group",
"remark"
"category",
"remark",
"other"
]
},
"TagItem": {
... ... @@ -5793,7 +6056,7 @@
"type": "string",
"description": " 标签名称"
},
"group": {
"category": {
"type": "string",
"description": " 标签分类"
},
... ... @@ -5811,7 +6074,7 @@
"id",
"image",
"name",
"group",
"category",
"remark",
"createdAt"
]
... ... @@ -5827,14 +6090,14 @@
"type": "integer",
"format": "int32"
},
"companyId": {
"": {
"type": "integer",
"format": "int64"
},
"tagName": {
"type": "string"
},
"group": {
"category": {
"type": "string"
},
"remark": {
... ... @@ -5844,8 +6107,7 @@
"title": "TagListRequest",
"required": [
"page",
"size",
"-"
"size"
]
},
"TagListResponse": {
... ... @@ -6054,8 +6316,7 @@
"format": "int32"
},
"name": {
"type": "integer",
"format": "int32"
"type": "string"
}
},
"title": "UserShowName",
... ... @@ -6126,6 +6387,10 @@
"type": "string",
"description": " 人员头像"
},
"position": {
"type": "string",
"description": " 职位"
},
"createdAt": {
"type": "integer",
"format": "int64",
... ... @@ -6138,6 +6403,7 @@
"userId",
"name",
"avatar",
"position",
"createdAt"
]
}
... ...
... ... @@ -89,7 +89,20 @@ service Core {
@handler SystemSearchArticle
post /article/search (SystemArticleSearchRequest) returns (SystemArticleSearchResponse)
@doc "管理后台编辑帖子"
@handler SystemUpdateArticle
put /article (SystemArticleUpdateRequest) returns (SystemArticleUpdateResponse)
@doc "管理后台编辑历史"
@handler SystemHistoryArticle
post /article/history (SystemArticleHistoryRequest) returns (SystemArticleHistoryResponse)
@doc "管理后台帖子历史详情"
@handler SystemArticleGetHistory
get /article/history/:id (SystemArticleGetHistoryRequest) returns (SystemArticleGetHistoryResponse)
@doc "管理后台获取我发布的文章"
@handler SystemArticleSearchMe
post /article/search/me (SystemArticleSearchMeRequest) returns (SystemArticleSearchMeResponse)
}
\ No newline at end of file
... ...
... ... @@ -8,14 +8,42 @@ info(
version: "v1"
)
@server(
prefix: v1/system
group: tags
jwt: SystemAuth
)
service Core {
@doc "后台创建文章标签"
@handler CreateTag
post /article_tag (TagCreateRequest) returns (TagCreateResponse)
@doc "后台编辑文章标签"
@handler EditTag
put /article_tag (TagEditRequest) returns (TagEditResponse)
@doc "后台获取文章标签"
@handler GetTag
get /article_tag/:id (TagGetRequest) returns (TagGetResponse)
@doc "后台删除文章标签"
@handler DeleteTag
delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)
@doc "后台搜索标签"
@handler SearchTag
post/article_tag/search (TagListRequest) returns (TagListResponse)
}
// 创建标签
type (
TagCreateRequest {
CompanyId int64 `json:"companyId"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
TagCreateResponse {
... ... @@ -27,11 +55,12 @@ type (
type (
TagEditRequest {
Id int64 `json:"id"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
TagEditResponse {
... ... @@ -43,14 +72,15 @@ type (
type (
TagGetRequest {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
TagGetResponse {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
Other string `json:"other"`
}
)
... ... @@ -59,9 +89,9 @@ type (
TagListRequest {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
TagName string `json:"tagName,optional"`
Group string `json:"group,optional"`
Category string `json:"category,optional"`
Remark string `json:"remark,optional"`
}
TagListResponse {
... ... @@ -71,9 +101,9 @@ type (
TagItem {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
}
)
... ... @@ -82,36 +112,9 @@ type (
type (
TagDeleteRequest {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
TagDeleteResponse {
Id int64 `json:"id"`
}
)
@server(
prefix: v1/system
group: tags
jwt: MiniAuth
)
service Core {
@doc "后台创建文章标签"
@handler CreateTag
post /article_tag (TagCreateRequest) returns (TagCreateResponse)
@doc "后台编辑文章标签"
@handler EditTag
put /article_tag (TagEditRequest) returns (TagEditResponse)
@doc "后台获取文章标签"
@handler GetTag
get /article_tag/:id (TagGetRequest) returns (TagGetResponse)
@doc "后台删除文章标签"
@handler DeleteTag
delete /article_tag/:id (TagDeleteRequest) returns (TagDeleteResponse)
@doc "后台搜索标签"
@handler SearchTag
post/article_tag/search (TagListRequest) returns (TagListResponse)
}
\ No newline at end of file
)
\ No newline at end of file
... ...
... ... @@ -35,15 +35,15 @@ type (
//小程序端查看文章的详情
type (
MiniArticleGetRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`//当前公司
UserId int `path:",optional"` //当前用户
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"` //当前公司
UserId int `path:",optional"` //当前用户
}
MiniArticleGetResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人id
Author ArticleAuthor `json:"author"` //发布人
Author ArticleAuthor `json:"author"` //发布人
CreatedAt int64 `json:"createdAt"` //文章的发布时间
Section []ArticleSection `json:"section"` //文章的文本内容
Images []string `json:"images"` //图片
... ... @@ -55,7 +55,7 @@ type (
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Edit int `json:"edit"` // 文章是否存在变更记录 (0 不存在 1存在)
MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
MeLoveFlag int `json:"meLoveFlag"` // 当前人员对文章的点赞标识 (0 没有点赞 1有点赞)
}
ArticleSection {
Id int64 `json:"id"` //段落id
... ... @@ -92,9 +92,9 @@ type (
SystemArticleSearchMeRequest {
Page int `json:"page"`
Size int `json:"size"`
AuthorId int64 `json:"authorId"` // 用户
AuthorId int64 `json:"authorId"` // 用户
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleSearchMeResponse {
Total int `json:"total"`
... ... @@ -119,6 +119,7 @@ type (
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
Position string `json:"position"` // 职位
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
)
... ... @@ -270,8 +271,8 @@ type (
// 小程序端获取我的浏览记录
type (
MiniArticleMarkListRequest {
Page int `json:"page"`
Size int `json:"size"`
Page int `json:"page"`
Size int `json:"size"`
}
MiniArticleMarkListResponse {
... ... @@ -292,42 +293,38 @@ type (
//小程序端设置文章的定性标签
type (
MiniArticleSetTagRequest{
MiniArticleSetTagRequest {
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
MiniArticleSetTagResponse{
MiniArticleSetTagResponse {
Id int64 `json:"id"`
}
)
//小程序端获取所有的定性标签
type (
MiniAllArticleTagRequest{
MiniAllArticleTagRequest {
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
MiniAllArticleTagResponse{
TagGroup []ArticleTagGroup `json:"tagGroup"`
}
MiniAllArticleTagResponse {
TagGroup []ArticleTagGroup `json:"tagGroup"`
}
ArticleTagGroup {
Group string `json:"group"`
Tags []ArticleTagItem `json:"tags"`
Group string `json:"group"`
Tags []ArticleTagItem `json:"tags"`
}
ArticleTagItem {
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Image string `json:"image"`
}
)
//管理后台获取文章详情
type (
SystemArticleGetRequest {
... ... @@ -336,15 +333,15 @@ type (
}
UserShowName {
Id int `json:"id"`
Name int `json:"name"`
Id int `json:"id"`
Name string `json:"name"`
}
SystemArticleGetResponse {
Id int64 `json:"id"` // id
Title string `json:"title"` // 标题
AuthorId int64 `json:"authorId"` // 发布人id
Author ArticleAuthor `json:"author"` // 发布人
Author ArticleAuthor `json:"author"` // 发布人
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
... ... @@ -357,15 +354,21 @@ type (
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
}
)
//管理后台获取文章列表
type (
SystemArticleSearchRequest {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:"companyId,optional"`
Title string `json:"title,optional"` //标题
Author string `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
}
SystemArticleSearchResponse {
... ... @@ -384,4 +387,73 @@ type (
Tags []string `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
//编辑
SystemArticleUpdateRequest {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
}
SystemArticleUpdateResponse {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []int64 `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
//历史
SystemArticleHistoryRequest {
ArticleId int64 `json:"articleId"` //文章ID
Author string `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
}
SystemArticleHistoryResponse {
Total int `json:"total"`
List []SystemArticleHistory `json:"list"`
}
SystemArticleHistory {
Id int64 `json:"id"` //id
Author string `json:"author"` //编辑人
Action string `json:"action"` //编辑类型
UpdatedAt int64 `json:"updatedAt"` //编辑时间
}
SystemArticleGetHistoryRequest {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
SystemArticleGetHistoryResponse {
Id int64 `json:"id"` // id
ArticleId int64 `json:"articleId"` // 文章ID
Title string `json:"title"` // 标题
AuthorId int64 `json:"authorId"` // 发布人id
Author ArticleAuthor `json:"author"` // 发布人
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
Location Location `json:"location"` // 定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
\ No newline at end of file
... ...
... ... @@ -16,10 +16,6 @@ info(
)
service Core {
@doc "小程序获取回复@人可选列表"
@handler MiniArticleCommentAtUser
post /article_comment/at_user/select (MiniArticleCommentAtUserRequest) returns (MiniArticleCommentAtUserResponse)
@doc "小程序填写文章的评论"
@handler MiniCreateArticleComment
post /article_comment (MiniCreateArticleCommentRequest) returns (MiniCreateArticleCommentResponse)
... ... @@ -58,17 +54,6 @@ service Core {
post /article_comment/search/me (SystemArticleCommentSearchMeRequest) returns (SystemArticleCommentSearchMeResponse)
}
//
// 小程序获取回复@人可选列表
type (
MiniArticleCommentAtUserRequest {
ArtitceId int64 `json:"articleId"`
}
MiniArticleCommentAtUserResponse {
}
)
//评论的填写人
type CommentAuthor {
Id int64 `json:"id"` // 人员id
... ... @@ -91,8 +76,9 @@ type (
}
CommentAtWho {
Id int64 `json:"id"`
Name string `json:"name,optional"`
Id int64 `json:"id"`
Name string `json:"name,optional"`
FirstLetter string `json:"firstLetter,optional"`
}
MiniCreateArticleCommentResponse {
Id int64 `json:"id"`
... ... @@ -151,7 +137,7 @@ type (
AtWho []CommentAtWho `json:"atWho"` // 填写评论时@的人
CreatedAt int64 `json:"createdAt"` //
MeLoveFlag int `json:"meLoveFlag"` //当前人员对评论的点赞标识 (0 没有点赞 1有点赞)
Content string `json:"content"` // 评论的内容
Content string `json:"content"` // 评论的内容
}
)
... ... @@ -205,16 +191,16 @@ type (
}
)
type(
SystemArticleCommentSearchMeRequest{
type (
SystemArticleCommentSearchMeRequest {
Page int `json:"page"`
Size int `json:"size"`
AuthorId int64 `json:"authorId"` // 用户
AuthorId int64 `json:"authorId"` // 用户
BeginTime int64 `json:"beginTime,optional"` // 开始时间
EndTime int64 `json:"endTime,optional"` // 结束时间
EndTime int64 `json:"endTime,optional"` // 结束时间
}
SystemArticleCommentSearchMeResponse{
SystemArticleCommentSearchMeResponse {
List []ArticleCommentItem `json:"list"`
Total int64 `json:"total"`
Total int64 `json:"total"`
}
)
\ No newline at end of file
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
// 小程序接口
@server(
prefix: v1
group: company
prefix: v1
group: company
)
service Core {
@doc "公司搜索(公开的)"
@handler miniCompanySearch
post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse)
@doc "公司搜索(公开的)"
@handler miniCompanySearch
post /mini/company/search(CompanySearchRequest) returns (CompanySearchResponse)
}
// 小程序接口
@server(
prefix: v1
group: company
jwt : MiniAuth
prefix: v1
group: company
jwt : MiniAuth
)
service Core {
@doc "搜索已加入的公司"
@handler miniCompanySearchJoined
post /mini/company/search-joined(CompanySearchRequest) returns (CompanySearchResponse)
@doc "搜索已加入的公司"
@handler miniCompanySearchJoined
post /mini/company/search-joined(CompanySearchRequest) returns (CompanySearchResponse)
}
// 小程序接口
@server(
prefix: v1
group: company
jwt : SystemAuth
prefix: v1
group: company
jwt : SystemAuth
)
service Core {
@doc "公司搜索"
@handler systemCompanySearch
post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
@doc "公司搜索"
@handler systemCompanySearch
post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
}
type (
CompanySearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司
UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业)
Code string `json:"code,optional"` // 按编码搜索
}
CompanySearchResponse{
List []Company `json:"list"`
Total int64 `json:"total"`
}
Company struct{
Id int64 `json:"id,omitempty"` // 唯一标识
Name string `json:"name,omitempty"` // 名称
Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
Logo string `json:"logo,omitempty"` // 公司LOGO
}
CompanySearchRequest {
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Flag int `json:"flag,optional"` // 1:用户已加入的 2:用户未加入的公司
UserId int64 `json:"userId,optional"` // 按用户搜索(用户所加入的企业)
Code string `json:"code,optional"` // 按编码搜索
}
CompanySearchResponse {
List []Company `json:"list"`
Total int64 `json:"total"`
}
Company {
Id int64 `json:"id,omitempty"` // 唯一标识
Name string `json:"name,omitempty"` // 名称
Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
Logo string `json:"logo,omitempty"` // 公司LOGO
}
)
\ No newline at end of file
... ...
syntax = "v1"
info(
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
title: "天联鹰蜓"
desc: "天联鹰蜓"
author: "email"
email: "email"
version: "v1"
)
@server(
prefix: v1
group: role
middleware: LoginStatusCheck
jwt: SystemAuth
prefix: v1
group: role
middleware: LoginStatusCheck
jwt: SystemAuth
)
service Core {
@doc "角色详情"
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@doc "角色新增"
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@doc "角色删除"
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@doc "角色更新"
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@doc "角色列表搜索"
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
@doc "角色详情"
@handler systemGetRole
get /system/role/:id (RoleGetRequest) returns (RoleGetResponse)
@doc "角色新增"
@handler systemSaveRole
post /system/role (RoleSaveRequest) returns (RoleSaveResponse)
@doc "角色删除"
@handler systemDeleteRole
delete /system/role/:id (RoleDeleteRequest) returns (RoleDeleteResponse)
@doc "角色更新"
@handler systemUpdateRole
put /system/role/:id (RoleUpdateRequest) returns (RoleUpdateResponse)
@doc "角色列表搜索"
@handler systemSearchRole
post /system/role/search (RoleSearchRequest) returns (RoleSearchResponse)
}
type (
RoleGetRequest {
Id int64 `path:"id"`
}
RoleGetResponse struct{
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
RoleGetRequest {
Id int64 `path:"id"`
}
RoleGetResponse {
Role RoleItem `json:"role"`
AuthList []Auth `json:"authList"`
}
RoleSaveRequest struct{
Role RoleItem `json:"role"`
}
RoleSaveResponse struct{}
RoleSaveRequest {
Role RoleItem `json:"role"`
}
RoleSaveResponse struct{}
RoleDeleteRequest struct{
Id int64 `path:"id"`
}
RoleDeleteResponse struct{}
RoleDeleteRequest {
Id int64 `path:"id"`
}
RoleDeleteResponse struct{}
RoleUpdateRequest struct{
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
RoleUpdateResponse struct{}
RoleUpdateRequest {
Id int64 `path:"id"`
Role RoleItem `json:"role"`
}
RoleUpdateResponse struct{}
RoleSearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
RoleSearchResponse{
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
RoleItem struct{
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
RoleUser {
Id int64 `json:"id"`
Name string `json:"name"`
}
Auth {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
RoleSearchRequest {
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Style string `json:"style,options=[simple,,full]"` // simple:只返回角色ID名称 full:所有字段都返回
}
RoleSearchResponse {
List []RoleItem `json:"list"`
Total int64 `json:"total"`
}
RoleItem {
Id int64 `json:"id,optional"` // 角色ID
CompanyId int64 `json:"companyId,optional,omitempty"` // 公司ID
Name string `json:"name"` // 角色名称
AuthIds []int64 `json:"authIds,optional,omitempty"` // 角色权限列表
AuthsDesc string `json:"authsDesc,optional,omitempty"` // 权限列表描述
UsersDesc string `json:"usersDesc,optional,omitempty"` // 用户列表描述
Remark string `json:"remark,optional,omitempty"` // 备注
Users []RoleUser `json:"users,optional,omitempty"` // 绑定的用户
UpdatedAt int64 `json:"updatedAt,optional,omitempty"` // 更新时间
}
RoleUser {
Id int64 `json:"id"`
Name string `json:"name"`
}
Auth {
Id int64 `json:"id"` // ID
Name string `json:"name"` // 名称
Code string `json:"code"` // 编码
}
)
\ No newline at end of file
... ...
... ... @@ -29,4 +29,4 @@ DB:
ApiAuth:
Name: ApiAuth
Host: http://digital-platform-dev.fjmaimaimai.com
Timeout: 0s
\ No newline at end of file
Timeout: 0s
... ...
... ... @@ -7,6 +7,8 @@ import (
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,10 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniAllArticleTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,10 @@ func MiniArticleSetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := article.NewMiniArticleSetTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.UserId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniArticleSetTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
package article
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/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"
)
func SystemArticleGetHistoryHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleGetHistoryRequest
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := article.NewSystemArticleGetHistoryLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleGetHistory(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -15,7 +15,7 @@ func SystemGetArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
package comment
package article
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/comment"
"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"
)
func MiniArticleCommentAtUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
func SystemHistoryArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleCommentAtUserRequest
var req types.SystemArticleHistoryRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
l := comment.NewMiniArticleCommentAtUserLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleCommentAtUser(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
l := article.NewSystemHistoryArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemHistoryArticle(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -15,7 +15,7 @@ func SystemSearchArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
package article
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/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"
)
func SystemUpdateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.SystemArticleUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
result.ParamErrorResult(r, w, err)
return
}
l := article.NewSystemUpdateArticleLogic(r.Context(), svcCtx)
resp, err := l.SystemUpdateArticle(&req, r.Header.Get("x-mmm-accesstoken"))
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -14,7 +14,7 @@ func SystemAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentAddRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func SystemDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func SystemGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func SystemListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentListRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func SystemUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DepartmentUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func MiniBusinessHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MessageBusinessRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -14,7 +14,7 @@ func MiniSystemHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MessageSystemRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -22,11 +22,6 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_comment/at_user/select",
Handler: comment.MiniArticleCommentAtUserHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_comment",
Handler: comment.MiniCreateArticleCommentHandler(serverCtx),
},
... ... @@ -120,7 +115,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: tags.SearchTagHandler(serverCtx),
},
},
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
... ... @@ -387,6 +382,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: article.SystemSearchArticleHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article",
Handler: article.SystemUpdateArticleHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/history",
Handler: article.SystemHistoryArticleHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article/history/:id",
Handler: article.SystemArticleGetHistoryHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article/search/me",
Handler: article.SystemArticleSearchMeHandler(serverCtx),
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func CreateTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewCreateTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.CreateTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func DeleteTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewDeleteTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.DeleteTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func EditTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewEditTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.EditTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -16,13 +18,10 @@ func GetTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
httpx.ErrorCtx(r.Context(), w, err)
return
}
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
l := tags.NewGetTagLogic(r.Context(), svcCtx)
resp, err := l.GetTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
"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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,9 @@ func SearchTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := tags.NewSearchTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
resp, err := l.SearchTag(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -14,7 +14,7 @@ func MiniMyLikeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniMyLikeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
result.ParamErrorResult(r, w, err)
return
}
... ...
... ... @@ -5,6 +5,8 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -24,7 +26,44 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().WithFindOnly()
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
}
// 合并输出数据
var group []string
tagMap := map[string][]types.ArticleTagItem{}
for _, val := range tagList {
if m, ok := tagMap[val.Category]; ok {
m = append(m, types.ArticleTagItem{
Id: val.Id,
Group: val.Category,
Name: val.Name,
Image: val.Image.Url,
})
tagMap[val.Category] = m
} else {
group = append(group, val.Category)
tagMap[val.Category] = []types.ArticleTagItem{
{
Id: val.Id,
Group: val.Category,
Name: val.Name,
Image: val.Image.Url,
},
}
}
}
resp = &types.MiniAllArticleTagResponse{
TagGroup: make([]types.ArticleTagGroup, 0),
}
for i := range group {
resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
Group: group[i],
Tags: tagMap[group[i]],
})
}
return resp, nil
}
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
... ... @@ -25,6 +26,7 @@ func NewMiniArticleMarkListLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
}
// 获取我的文章浏览记录
func (l *MiniArticleMarkListLogic) MiniArticleMarkList(req *types.MiniArticleMarkListRequest) (resp *types.MiniArticleMarkListResponse, err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
... ...
... ... @@ -5,6 +5,9 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -23,8 +26,65 @@ func NewMiniArticleSetTagLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
}
// 设置文章的定性标签
func (l *MiniArticleSetTagLogic) MiniArticleSetTag(req *types.MiniArticleSetTagRequest) (resp *types.MiniArticleSetTagResponse, err error) {
// todo: add your logic here and delete this line
var conn = l.svcCtx.DefaultDBConn()
//
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取文章信息失败", err)
}
if articleInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("获取文章信息失败")
}
return
tagInfo, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.TagId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签信息失败", err)
}
if tagInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("获取标签信息失败")
}
// 查询可能存在的 ArticleAndTag
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("articleId", articleInfo.Id)
_, oldTags, err := l.svcCtx.ArticleAndTagRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("检查文章的标签失败", err)
}
// 更新article中的tags
articleInfo.Tags = []int64{tagInfo.Id}
// 额外保存一份ArticleAndTag
articleAndTag := domain.ArticleAndTag{
Id: 0,
CompanyId: articleInfo.CompanyId,
CreatedAt: 0,
UpdatedAt: 0,
ArticleId: articleInfo.Id,
TagId: tagInfo.Id,
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
//清理可能存在的 ArticleAndTag
for _, v := range oldTags {
_, err = l.svcCtx.ArticleAndTagRepository.Delete(ctx, c, v)
if err != nil {
return err
}
}
// 更新article
_, err = l.svcCtx.ArticleRepository.UpdateWithVersion(ctx, c, articleInfo)
if err != nil {
return err
}
_, err = l.svcCtx.ArticleAndTagRepository.Insert(ctx, c, &articleAndTag)
if err != nil {
return err
}
return nil
}, true)
resp = &types.MiniArticleSetTagResponse{
Id: articleAndTag.Id,
}
return resp, nil
}
... ...
... ... @@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr
if u, ok := userMap[val.UserId]; ok {
item.Name = u.Name
item.Avatar = u.Avatar
item.Position = u.Position
}
resp.List[i] = item
}
... ...
package comment
package article
import (
"context"
... ... @@ -9,22 +9,22 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
type MiniArticleCommentAtUserLogic struct {
type SystemArticleGetHistoryLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleCommentAtUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleCommentAtUserLogic {
return &MiniArticleCommentAtUserLogic{
func NewSystemArticleGetHistoryLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleGetHistoryLogic {
return &SystemArticleGetHistoryLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleCommentAtUserLogic) MiniArticleCommentAtUser(req *types.MiniArticleCommentAtUserRequest) (resp *types.MiniArticleCommentAtUserResponse, err error) {
// todo: add your logic here and delete this line
func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.SystemArticleGetHistoryRequest) (resp *types.SystemArticleGetHistoryResponse, err error) {
//var conn = l.svcCtx.DefaultDBConn()
return
}
... ...
... ... @@ -2,6 +2,9 @@ package article
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/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"
... ... @@ -24,7 +27,94 @@ func NewSystemGetArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *
}
func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequest) (resp *types.SystemArticleGetResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
images := make([]string, 0)
lo.ForEach(article.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
resp = &types.SystemArticleGetResponse{
Id: article.Id,
Title: article.Title,
AuthorId: article.AuthorId,
Author: types.ArticleAuthor{
Id: article.Author.Id,
Name: article.Author.Name,
Avatar: article.Author.Avatar,
Position: article.Author.Position,
Company: article.Author.Company,
},
CreatedAt: article.CreatedAt,
Section: make([]types.ArticleSection, 0),
Images: images,
WhoRead: article.WhoRead,
WhoReadInfo: make([]types.UserShowName, 0),
WhoReview: article.WhoReview,
WhoReviewInfo: make([]types.UserShowName, 0),
Location: types.Location{
Longitude: article.Location.Longitude,
Latitude: article.Location.Latitude,
Descript: article.Location.Descript,
},
CountLove: article.CountLove,
CountComment: article.CountComment,
CountRead: article.CountRead,
Show: int(article.Show),
Tags: make([]types.ArticleTagItem, 0),
}
//标签
if len(article.Tags) > 0 {
_, tags, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, article.CompanyId, domain.NewQueryOptions().WithKV("ids", article.Tags))
if err == nil && len(tags) > 0 {
lo.ForEach(tags, func(tag *domain.ArticleTag, index int) {
resp.Tags = append(resp.Tags, types.ArticleTagItem{
Id: tag.Id,
Group: tag.Category,
Name: tag.Name,
Image: tag.Image.Url,
})
})
}
}
//文章段落
_, articleSections, err := l.svcCtx.ArticleSectionRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("articleId", req.Id))
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
lo.ForEach(articleSections, func(item *domain.ArticleSection, index int) {
resp.Section = append(resp.Section, types.ArticleSection{
Id: item.Id,
Content: item.Content,
SortBy: item.SortBy,
TotalComment: item.TotalComment,
})
})
userIds := lo.Union(resp.WhoRead, resp.WhoReview)
if len(userIds) > 0 {
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithKV("ids", userIds))
if err != nil {
return nil, xerr.NewErrMsgErr("获取帖子异常", err)
}
userSlices := make(map[int64]types.UserShowName)
lo.ForEach(users, func(user *domain.User, index int) {
userSlices[user.Id] = types.UserShowName{
Id: int(user.Id),
Name: user.Name,
}
})
lo.ForEach(resp.WhoRead, func(userId int64, index int) {
if value, ok := userSlices[userId]; ok {
resp.WhoReadInfo = append(resp.WhoReadInfo, value)
}
})
lo.ForEach(resp.WhoReview, func(userId int64, index int) {
if value, ok := userSlices[userId]; ok {
resp.WhoReviewInfo = append(resp.WhoReviewInfo, value)
}
})
}
return resp, nil
}
... ...
package article
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/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 SystemHistoryArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemHistoryArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemHistoryArticleLogic {
return &SystemHistoryArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemHistoryArticleLogic) SystemHistoryArticle(req *types.SystemArticleHistoryRequest) (resp *types.SystemArticleHistoryResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
total, list, err := l.svcCtx.ArticleBackupRepository.Find(
l.ctx,
conn,
domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("articleId", req.ArticleId).
WithKV("operator", req.Author).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime),
)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索编辑历史异常", err)
}
resp = &types.SystemArticleHistoryResponse{
Total: int(total),
List: make([]types.SystemArticleHistory, 0),
}
lo.ForEach(list, func(item *domain.ArticleBackup, index int) {
resp.List = append(resp.List, types.SystemArticleHistory{
Id: item.Id,
Author: item.Operator.Name,
Action: item.Action,
UpdatedAt: item.CreatedAt,
})
})
return
}
... ...
... ... @@ -2,9 +2,11 @@ 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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -24,7 +26,38 @@ func NewSystemSearchArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext
}
func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleSearchRequest) (resp *types.SystemArticleSearchResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
queryOptions := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
WithKV("title", req.Title).
WithKV("author", req.Author).
WithKV("beginCreatedAt", req.BeginTime).
WithKV("endCreatedAt", req.EndTime)
total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
if err != nil {
return nil, xerr.NewErrMsgErr("搜索帖子异常", err)
}
resp = &types.SystemArticleSearchResponse{
Total: int(total),
List: make([]types.SystemArticleSearch, 0),
}
lo.ForEach(articles, func(item *domain.Article, index int) {
images := make([]string, 0)
lo.ForEach(item.Images, func(img domain.Image, n int) {
images = append(images, img.Url)
})
resp.List = append(resp.List, types.SystemArticleSearch{
Id: item.Id,
Title: item.Title,
Author: item.Author.Name,
Images: images,
CreatedAt: item.CreatedAt,
CountLove: item.CountLove,
CountComment: item.CountComment,
Show: int(item.Show),
Tags: nil,
TargetUser: int(item.TargetUser),
})
})
return resp, nil
}
... ...
package article
import (
"context"
"github.com/samber/lo"
"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/cmd/discuss/interanl/pkg/gateway/authlib"
"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 SystemUpdateArticleLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemUpdateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateArticleLogic {
return &SystemUpdateArticleLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleUpdateRequest, accessToken string) (resp *types.SystemArticleUpdateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
userToken := contextdata.GetUserTokenFromCtx(l.ctx)
article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("帖子不存在", err)
}
//TODO 获取图片的尺寸大小
images := []domain.Image{}
for _, val := range req.Images {
images = append(images, domain.Image{
Url: val,
Width: 0,
Height: 0,
})
}
article.Title = req.Title
article.Version = article.Version + 1
article.Images = images
article.WhoRead = req.WhoRead
article.WhoReview = req.WhoReview
article.TargetUser = domain.ArticleTarget(req.TargetUser)
article.Location = domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
}
article.Tags = req.Tags
//文章内容
articleSections := []domain.ArticleSection{}
lo.ForEach(req.Section, func(item types.ArticleSection, index int) {
articleSections = append(articleSections, domain.ArticleSection{
Id: item.Id,
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: item.Content,
SortBy: index + 1,
})
})
//设置内容概要
if len(req.Section) > 0 {
// 截取内容 30个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range req.Section[0].Content {
if runeNumber > 30 {
break
}
runeNumber += 1
stringIndex = i
}
article.Summary = req.Section[0].Content[0:stringIndex]
}
//获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: accessToken})
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article)
if err != nil {
return xerr.NewErrMsgErr("保存文章失败", err)
}
//文章内容
updateSectionIds := []int64{}
for _, item := range articleSections {
if item.Id > 0 {
section, err := l.svcCtx.ArticleSectionRepository.FindOne(ctx, c, item.Id)
if err != nil {
return xerr.NewErrMsgErr("获取文章段落内容失败", err)
}
section.Content = item.Content
section.ArticleId = item.ArticleId
section.Version = item.Version
section.SortBy = item.SortBy
section.CompanyId = item.CompanyId
_, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section)
if err != nil {
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
} else {
_, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, &item)
if err != nil {
return xerr.NewErrMsgErr("保存文章段落内容失败", err)
}
}
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))
if err != nil {
return 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,
}, articleSections)
backup.Action = "编辑"
_, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup)
if err != nil {
return xerr.NewErrMsgErr("保存文章内容失败", err)
}
return nil
}, true)
resp = &types.SystemArticleUpdateResponse{
Id: article.Id,
Title: article.Title,
Images: req.Images,
CreatedAt: article.CreatedAt,
CountLove: article.CountLove,
CountComment: article.CountComment,
Show: int(article.Show),
TargetUser: int(article.TargetUser),
Tags: article.Tags,
}
return
}
... ...
... ... @@ -2,9 +2,12 @@ package comment
import (
"context"
"sort"
"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/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -24,6 +27,7 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
}
// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表
func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
... ... @@ -35,11 +39,42 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
return resp, nil
}
// userList := []*domain.User{}
// if len(articleInfo.WhoRead) == 0 {
var userList []*domain.User
if len(articleInfo.WhoRead) == 0 {
//获取所有人
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
} else {
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
}
// return
// }
uList := make([]types.CommentAtWho, len(userList))
return
for i := range userList {
uList[i] = types.CommentAtWho{
Id: userList[i].Id,
Name: userList[i].Name,
FirstLetter: "",
}
for _, val := range userList[i].PinYinName {
uList[i].FirstLetter = strings.ToUpper(string(val))
break
}
}
sort.Slice(uList, func(i, j int) bool {
return uList[i].FirstLetter < uList[j].FirstLetter
})
resp = &types.MiniArticleCommentAtWhoResponse{
List: uList,
}
return resp, nil
}
... ...
... ... @@ -52,12 +52,12 @@ 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 len(articleInfo.WhoReview) > 0 {
ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
if ok < 0 {
return nil, xerr.NewErrMsg("没有评论权限")
}
}
// 对段落进行评论
var selctionInfo *domain.ArticleSection
if req.SectionId > 0 {
... ...
... ... @@ -43,7 +43,6 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
}
insert := &domain.Department{
Id: 0,
ParentId: 0,
CompanyId: userToken.CompanyId,
Name: req.Name,
... ...
... ... @@ -32,14 +32,14 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
//检查重复
cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{
"name": req.Name,
"group": req.Group,
"category": req.Category,
"countOnly": true,
})
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
}
if cnt > 0 {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name))
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
//TODO 获取图片的尺寸大小
... ... @@ -55,9 +55,10 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
Width: 0,
Height: 0,
},
Name: req.Name,
Group: req.Group,
Remark: req.Remark,
Name: req.Name,
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
}
newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag)
... ...
... ... @@ -33,7 +33,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
queryOptions := domain.NewQueryOptions().
WithFindOnly().
MustWithKV("name", req.Name).
MustWithKV("group", req.Group).
MustWithKV("category", req.Category).
WithOffsetLimit(1, 1)
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
... ... @@ -42,7 +42,7 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
}
if len(tagList) > 0 {
if tagList[0].Id != req.Id {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Group, req.Name))
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
}
oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id)
... ... @@ -55,11 +55,11 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
//TODO 获取图片的尺寸大小
oldTag.Group = req.Group
oldTag.Category = req.Category
oldTag.Image.Url = req.Image
oldTag.Name = req.Name
oldTag.Remark = req.Remark
oldTag.Other = req.Other
oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
... ...
... ... @@ -35,11 +35,12 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
return nil, xerr.NewErrMsg("获取标签失败")
}
resp = &types.TagGetResponse{
Id: oldTag.Id,
Image: oldTag.Image.Url,
Name: oldTag.Name,
Group: oldTag.Group,
Remark: oldTag.Remark,
Id: oldTag.Id,
Image: oldTag.Image.Url,
Name: oldTag.Name,
Category: oldTag.Category,
Remark: oldTag.Remark,
Other: oldTag.Other,
}
return
}
... ...
... ... @@ -27,8 +27,8 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
var conn = l.svcCtx.DefaultDBConn()
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
if len(req.Group) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Group)
if len(req.Category) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Category)
}
if len(req.TagName) > 0 {
queryOptions = queryOptions.MustWithKV("name", req.TagName)
... ... @@ -50,10 +50,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
Id: tagList[i].Id,
Image: tagList[i].Image.Url,
Name: tagList[i].Name,
Group: tagList[i].Group,
Category: tagList[i].Category,
Remark: tagList[i].Remark,
CreatedAt: tagList[i].CreatedAt,
}
}
return
return resp, nil
}
... ...
... ... @@ -26,6 +26,7 @@ type ServiceContext struct {
ArticleRepository domain.ArticleRepository
ArticleSectionRepository domain.ArticleSectionRepository
ArticleTagRepository domain.ArticleTagRepository
ArticleAndTagRepository domain.ArticleAndTagRepository
CompanyRepository domain.CompanyRepository
CommentRepository domain.CommentRepository // 待移除
... ... @@ -59,12 +60,14 @@ func NewServiceContext(c config.Config) *ServiceContext {
ApiAuthService: apiAuth,
LoginStatusCheck: middleware.NewLoginStatusCheckMiddleware(apiAuth).Handle,
CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)),
ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)),
ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)),
CommentRepository: repository.NewCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleBackupRepository: repository.NewArticleBackupRepository(cache.NewCachedRepository(mlCache)),
ArticleCommentRepository: repository.NewArticleCommentRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftRepository: repository.NewArticleDraftRepository(cache.NewCachedRepository(mlCache)),
ArticleRepository: repository.NewArticleRepository(cache.NewCachedRepository(mlCache)),
ArticleSectionRepository: repository.NewArticleSectionRepository(cache.NewCachedRepository(mlCache)),
ArticleAndTagRepository: repository.NewArticleAndTagRepository(cache.NewCachedRepository(mlCache)),
CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)),
DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)),
MessageBusinessRepository: repository.NewMessageBusinessRepository(cache.NewCachedRepository(mlCache)),
... ...
// Code generated by goctl. DO NOT EDIT.
package types
type MiniArticleCommentAtUserRequest struct {
ArtitceId int64 `json:"articleId"`
}
type MiniArticleCommentAtUserResponse struct {
}
type CommentAuthor struct {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
... ... @@ -27,8 +20,9 @@ type MiniCreateArticleCommentRequest struct {
}
type CommentAtWho struct {
Id int64 `json:"id"`
Name string `json:"name,optional"`
Id int64 `json:"id"`
Name string `json:"name,optional"`
FirstLetter string `json:"firstLetter,optional"`
}
type MiniCreateArticleCommentResponse struct {
... ... @@ -208,11 +202,12 @@ type SimpleArticle struct {
}
type TagCreateRequest struct {
CompanyId int64 `json:"companyId"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
type TagCreateResponse struct {
... ... @@ -221,11 +216,12 @@ type TagCreateResponse struct {
type TagEditRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
}
type TagEditResponse struct {
... ... @@ -234,23 +230,24 @@ type TagEditResponse struct {
type TagGetRequest struct {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
type TagGetResponse struct {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
Other string `json:"other"`
}
type TagListRequest struct {
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:"-"`
CompanyId int64 `json:",optional"`
TagName string `json:"tagName,optional"`
Group string `json:"group,optional"`
Category string `json:"category,optional"`
Remark string `json:"remark,optional"`
}
... ... @@ -262,15 +259,15 @@ type TagListResponse struct {
type TagItem struct {
Id int64 `json:"id"`
Image string `json:"image"`
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark"` // 备注
CreatedAt int64 `json:"createdAt"`
}
type TagDeleteRequest struct {
Id int64 `path:"id"`
CompanyId int64 `path:"-"`
CompanyId int64 `path:",optional"`
}
type TagDeleteResponse struct {
... ... @@ -682,6 +679,7 @@ type WhichUserLikeArticle struct {
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
Position string `json:"position"` // 职位
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
... ... @@ -844,8 +842,6 @@ type MiniArticleSetTagResponse struct {
type MiniAllArticleTagRequest struct {
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
type MiniAllArticleTagResponse struct {
... ... @@ -861,6 +857,7 @@ type ArticleTagItem struct {
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Image string `json:"image"`
}
type SystemArticleGetRequest struct {
... ... @@ -869,8 +866,8 @@ type SystemArticleGetRequest struct {
}
type UserShowName struct {
Id int `json:"id"`
Name int `json:"name"`
Id int `json:"id"`
Name string `json:"name"`
}
type SystemArticleGetResponse struct {
... ... @@ -890,12 +887,18 @@ type SystemArticleGetResponse struct {
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
}
type SystemArticleSearchRequest struct {
CompanyId int64 `json:",optional"`
Page int `json:"page"`
Size int `json:"size"`
CompanyId int64 `json:"companyId,optional"`
Title string `json:"title,optional"` //标题
Author string `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Tags []int64 `json:"tags,optional"` //标签
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
}
type SystemArticleSearchResponse struct {
... ... @@ -916,6 +919,80 @@ type SystemArticleSearch struct {
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleUpdateRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,optional"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
}
type SystemArticleUpdateResponse struct {
Id int64 `json:"id"` //id
Title string `json:"title"` //标题
Author string `json:"author"` //发布人
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
CountLove int `json:"countLove"` //点赞数量
CountComment int `json:"CountComment"` //评论数量
Show int `json:"show"` //是否隐藏 [0显示、1不显示]
Tags []int64 `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleHistoryRequest struct {
ArticleId int64 `json:"articleId"` //文章ID
Author string `json:"author,optional"` //发布人
BeginTime int64 `json:"beginTime,optional"` //开始时间
EndTime int64 `json:"endTime,optional"` //结束时间
Page int `json:"page"` //页码
Size int `json:"size"` //每页行数
}
type SystemArticleHistoryResponse struct {
Total int `json:"total"`
List []SystemArticleHistory `json:"list"`
}
type SystemArticleHistory struct {
Id int64 `json:"id"` //id
Author string `json:"author"` //编辑人
Action string `json:"action"` //编辑类型
UpdatedAt int64 `json:"updatedAt"` //编辑时间
}
type SystemArticleGetHistoryRequest struct {
Id int64 `path:"id"` //id
CompanyId int64 `path:",optional"`
}
type SystemArticleGetHistoryResponse struct {
Id int64 `json:"id"` // id
ArticleId int64 `json:"articleId"` // 文章ID
Title string `json:"title"` // 标题
AuthorId int64 `json:"authorId"` // 发布人id
Author ArticleAuthor `json:"author"` // 发布人
CreatedAt int64 `json:"createdAt"` // 文章的发布时间
Section []ArticleSection `json:"section"` // 文章的文本内容
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可查看
WhoReadInfo []UserShowName `json:"whoReadInfo"` // 谁可查看
WhoReview []int64 `json:"whoReview"` // 谁可评论
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
Location Location `json:"location"` // 定位坐标
CountLove int `json:"countLove"` // 点赞数量
CountComment int `json:"countComment"` // 评论数量
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type RoleGetRequest struct {
Id int64 `path:"id"`
}
... ...
... ... @@ -22,6 +22,7 @@ func Migrate(db *gorm.DB) {
&models.MessageSystem{},
&models.MessageBusiness{},
&models.Department{},
&models.ArticleAndTag{},
}
db.AutoMigrate(modelsList...)
... ...
... ... @@ -10,12 +10,12 @@ import (
// 保存文章和标签的关系,主要用于分组统计用
type ArticleAndTag struct {
Id int64 // 唯一标识
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
ArticleId int64 `json:"articleId"`
TagId int64 `json:"tagId"`
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
ArticleId int64
TagId int64
}
func (m *ArticleAndTag) TableName() string {
... ...
... ... @@ -20,9 +20,10 @@ type ArticleTag struct {
Version int
Image domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
Name string // 标签名称
Group string // 标签分类
Remark string // 备注
Category string // 标签分类
SortBy int64 // 顺序
Other string // 其他
}
func (m *ArticleTag) TableName() string {
... ...
... ... @@ -2,9 +2,10 @@ package models
import (
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"time"
)
type UserFollow struct {
... ...
... ... @@ -97,6 +97,9 @@ func (repository *ArticleAndTagRepository) Find(ctx context.Context, conn transa
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id=?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -120,6 +120,18 @@ func (repository *ArticleBackupRepository) Find(ctx context.Context, conn transa
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["beginCreatedAt"]; ok {
tx = tx.Where("created_at >= ?", v)
}
if v, ok := queryOptions["endCreatedAt"]; ok {
tx = tx.Where("created_at < ?", v)
}
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id = ?", v)
}
if v, ok := queryOptions["operator"]; ok && v.(string) != "" {
tx = tx.Where(`operator #>> '{"name"}' like ?`, "%"+v.(string)+"%")
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -121,11 +121,13 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc").Where("company_id=?", companyId)
if v, ok := queryOptions["ids"]; ok {
tx.Where("id in (?)", v)
tx = tx.Where("id in (?)", v)
}
if v, ok := queryOptions["authorId"]; ok {
tx = tx.Where("author_id = ?", v)
if v, ok := queryOptions["title"]; ok && v.(string) != "" {
tx = tx.Where("title like ?", "%"+v.(string)+"%")
}
if v, ok := queryOptions["author"]; ok && v.(string) != "" {
tx = tx.Where(`author #>> '{"name"}' like ?`, "%"+v.(string)+"%")
}
if v, ok := queryOptions["beginCreatedAt"]; ok {
tx = tx.Where("created_at >= ?", v)
... ... @@ -275,3 +277,35 @@ func (repository *ArticleRepository) IncreaseCountComment(ctx context.Context, c
func NewArticleRepository(cache *cache.CachedRepository) domain.ArticleRepository {
return &ArticleRepository{CachedRepository: cache}
}
// with
// -- 按查看权限查询文章
// t_article as(
// select article.id
// from article
// where article.deleted_at=0
// and article.company_id =1598224576532189184
// and article."show" =0
// and (article.target_user =0 or article.who_read @>'[1]')
// ),
// -- 获取有标签的文章
// t_article_and_tag as (
// select article_and_tag.article_id ,article_and_tag.tag_id
// from article_and_tag
// where article_and_tag.company_id =1598224576532189184
// ),
// -- 过滤出可展示的文章id
// t_article_and_tag_2 as (
// select t_article_and_tag.article_id, t_article_and_tag.tag_id
// from t_article_and_tag
// join t_article on t_article_and_tag.article_id = t_article.id
// ),
// -- 查询人员已查看的文章
// t_user_read as(
// select user_read_article.article_id from user_read_article where user_read_article.user_id =1
// )
// -- 汇总统计 cnt_1符合条件的文章总数,cnt_2 已浏览的数量
// select count(t_article_and_tag_2.article_id) as cnt_1 ,count(t_user_read.article_id) as cnt_2, t_article_and_tag_2.tag_id
// from t_article_and_tag_2
// left join t_user_read on t_article_and_tag_2.article_id=t_user_read.article_id
// group by t_article_and_tag_2.tag_id
... ...
... ... @@ -90,6 +90,28 @@ func (repository *ArticleSectionRepository) Delete(ctx context.Context, conn tra
return repository.ModelToDomainModel(m)
}
func (repository *ArticleSectionRepository) DeleteBy(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) error {
var (
tx = conn.DB()
m = &models.ArticleSection{}
)
queryFunc := func() (interface{}, error) {
tx = tx.Where("id = ?", m.Id)
if v, ok := queryOptions["articleId"]; ok {
tx = tx.Where("article_id = ?", v)
}
if v, ok := queryOptions["notIds"]; ok {
tx = tx.Where("id not in (?)", v)
}
tx.Delete(m)
return m, tx.Error
}
if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return err
}
return nil
}
func (repository *ArticleSectionRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleSection, error) {
var (
err error
... ...
... ... @@ -122,13 +122,16 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).
Where("company_id=?", companyId).
Order("id desc")
Order("id asc")
if v, ok := queryOptions["name"]; ok {
tx = tx.Where("name like ?", v)
}
if v, ok := queryOptions["group"]; ok {
tx = tx.Where("group like ?", v)
if v, ok := queryOptions["category"]; ok {
tx = tx.Where("category like ?", v)
}
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
... ...
... ... @@ -86,7 +86,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []ArticleSection) *Art
CreatedAt: 0,
UpdatedAt: 0,
DeletedAt: 0,
Version: 0,
Version: m.Version,
Operator: operator,
ArticleId: m.Id,
Title: m.Title,
... ...
... ... @@ -14,8 +14,8 @@ type ArticleBackup struct {
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Operator UserSimple `json:"operator"` // 操作人
ArticleId int64 `json:"articleId"`
Operator UserSimple `json:"operator"` // 操作人
ArticleId int64 `json:"articleId"` //
Title string `json:"title"` // 标题
Section []ArticleSection `json:"section"` // 分段内容
Images []Image `json:"images"` // 图片
... ...
... ... @@ -25,6 +25,7 @@ type ArticleSectionRepository interface {
Update(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleSection) (*ArticleSection, error)
DeleteBy(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) error
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleSection, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleSection, error)
IncreaseCountComment(ctx context.Context, conn transaction.Conn, incr int, sectionId int64) error //评论数量变动
... ...
... ... @@ -15,11 +15,12 @@ type ArticleTag struct {
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
Image Image `json:"image"` // 图片
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
SortBy int64 `json:"sortBy"` // 顺序
Image Image `json:"image"` // 图片
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类 [紧急重要]、[机会风险]
Remark string `json:"remark"` // 备注
SortBy int64 `json:"sortBy"` // 顺序
Other string `json:"other"` //
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
... ...
... ... @@ -29,11 +29,9 @@ type Opinion struct {
}
type UserSimple struct {
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar,omitempty"` // 人员头像URL
// GroupId int64 `json:"groupId"` //分组id
//Group string `json:"group,omitempty"` // 人员的分组
Id int64 `json:"id"` // 人员id
Name string `json:"name"` // 人员的名字
Avatar string `json:"avatar,omitempty"` // 人员头像URL
Position string `json:"position,omitempty"` // 职位
Company string `json:"company,omitempty"` // 公司
CompanyId int64 `json:"companyId"`
... ...