作者 yangfu

Merge branch 'test'

正在显示 66 个修改的文件 包含 3846 行增加101 行删除

要显示太多修改。

为保证性能只显示 66 of 66+ 个文件。

... ... @@ -11,3 +11,5 @@ import "core/article.api"
import "core/role.api"
import "core/department.api"
import "core/article_category.api"
import "core/article_security.api"
import "core/article_template.api"
\ No newline at end of file
... ...
... ... @@ -789,6 +789,184 @@
]
}
},
"v1/mini/article_template": {
"post": {
"summary": "模板管理-保存",
"operationId": "miniArticleTemplateSave",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateSaveResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateSaveRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/mini/article_template/search": {
"post": {
"summary": "模板搜索",
"operationId": "miniArticleTemplateSearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/mini/article_template/search-mine": {
"post": {
"summary": "我的模板搜索",
"operationId": "miniArticleTemplateSearchMine",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/mini/article_template/{id}": {
"delete": {
"summary": "模板管理-删除",
"operationId": "miniArticleTemplateDelete",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateDeleteResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
},
"put": {
"summary": "模板管理-更新",
"operationId": "miniArticleTemplateUpdate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateUpdateResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/mini/article_template_class/search": {
"post": {
"summary": "模板分类搜索",
"operationId": "miniArticleTemplateClassSearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateClassSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateClassSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/mini/company/search": {
"post": {
"summary": "公司搜索(公开的)",
... ... @@ -1013,6 +1191,64 @@
]
}
},
"v1/mini/message/subscribe/add": {
"post": {
"summary": "增加订阅消息次数",
"operationId": "miniMessageSubscribeAdd",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MessageSubscribeAddResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": " 增加消息订阅次数",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MessageSubscribeAddRequest"
}
}
],
"requestBody": {},
"tags": [
"message"
]
}
},
"v1/mini/message/subscribe/list": {
"post": {
"summary": "获取订阅消息次数",
"operationId": "miniMessageSubscribeList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MessageSubscribeListResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "订阅消息次数详情",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MessageSubscribeListRequest"
}
}
],
"requestBody": {},
"tags": [
"message"
]
}
},
"v1/mini/message/system": {
"post": {
"summary": "系统消息",
... ... @@ -1661,6 +1897,52 @@
]
}
},
"v1/mini/wechat/bind": {
"post": {
"summary": "绑定微信",
"operationId": "miniWechatBind",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniWechatBindResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniWechatBindRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/wechat/info": {
"get": {
"summary": "检测是否绑定微信",
"operationId": "miniWechatInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniWechatInfoResponse"
}
}
},
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/system/account": {
"post": {
"summary": "系统新增账号",
... ... @@ -2623,41 +2905,44 @@
]
}
},
"v1/system/article_tag": {
"v1/system/article_security/audit": {
"post": {
"summary": "后台创建文章标签",
"operationId": "CreateTag",
"summary": "内容安全-审核",
"operationId": "articleSecurityAudit",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagCreateResponse"
"$ref": "#/definitions/ArticleSecurityAuditResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": " ArticleSecuritySaveRequest struct{, ArticleSecurity ArticleSecurityItem `json:\"article_security\"`, }, ArticleSecuritySaveResponse struct{},, ArticleSecurityDeleteRequest struct{, Id int64 `path:\"id\"`, }, ArticleSecurityDeleteResponse struct{},, ArticleSecurityUpdateRequest struct{, Id int64 `path:\"id\"`, ArticleSecurity ArticleSecurityItem `json:\"article_security\"`, }, ArticleSecurityUpdateResponse struct{}",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagCreateRequest"
"$ref": "#/definitions/ArticleSecurityAuditRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
"secuirty"
]
}
},
"put": {
"summary": "后台编辑文章标签",
"operationId": "EditTag",
"v1/system/article_security/search": {
"post": {
"summary": "内容安全-搜索",
"operationId": "articleSecuritySearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagEditResponse"
"$ref": "#/definitions/ArticleSecuritySearchResponse"
}
}
},
... ... @@ -2667,37 +2952,117 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagEditRequest"
"$ref": "#/definitions/ArticleSecuritySearchRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
"secuirty"
]
}
},
"v1/system/article_tag/options": {
"v1/system/article_security/{id}": {
"get": {
"summary": "后台标签下拉列表",
"operationId": "Options",
"summary": "详情",
"operationId": "articleSecurityGet",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagOptionsResponse"
"$ref": "#/definitions/ArticleSecurityGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"tags"
"secuirty"
]
}
},
"v1/system/article_tag/search": {
"v1/system/article_tag": {
"post": {
"summary": "后台搜索标签",
"summary": "后台创建文章标签",
"operationId": "CreateTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagCreateResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagCreateRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
},
"put": {
"summary": "后台编辑文章标签",
"operationId": "EditTag",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagEditResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/TagEditRequest"
}
}
],
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/article_tag/options": {
"get": {
"summary": "后台标签下拉列表",
"operationId": "Options",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/TagOptionsResponse"
}
}
},
"requestBody": {},
"tags": [
"tags"
]
}
},
"v1/system/article_tag/search": {
"post": {
"summary": "后台搜索标签",
"operationId": "SearchTag",
"responses": {
"200": {
... ... @@ -2781,6 +3146,208 @@
]
}
},
"v1/system/article_template": {
"post": {
"summary": "模板管理-保存",
"operationId": "systemArticleTemplateSave",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateSaveResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateSaveRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/system/article_template/batch_delete": {
"delete": {
"summary": "模板管理-批量删除",
"operationId": "systemArticleTemplateBatchDelete",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateBatchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateBatchDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/system/article_template/search": {
"post": {
"summary": "模板管理-搜索",
"operationId": "systemArticleTemplateSearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/system/article_template/{id}": {
"get": {
"summary": "模板管理-详情",
"operationId": "systemArticleTemplateGet",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"template"
]
},
"delete": {
"summary": "模板管理-删除",
"operationId": "systemArticleTemplateDelete",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateDeleteResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateDeleteRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
},
"put": {
"summary": "模板管理-更新",
"operationId": "systemArticleTemplateUpdate",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateUpdateResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateUpdateRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/system/article_template_class/search": {
"post": {
"summary": "模板管理-分类搜索",
"operationId": "systemArticleTemplateClassSearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleTemplateClassSearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleTemplateClassSearchRequest"
}
}
],
"requestBody": {},
"tags": [
"template"
]
}
},
"v1/system/company/positions/search": {
"post": {
"summary": "公司职位搜索",
... ... @@ -3765,6 +4332,16 @@
"format": "int64"
},
"description": "谁可查看"
},
"isDel": {
"type": "integer",
"format": "int32",
"description": "是否删除 1-删除 0-否"
},
"deletedType": {
"type": "integer",
"format": "int32",
"description": "类型 1-运营删除 2-用户删除"
}
},
"title": "ArticleSearchMe",
... ... @@ -3778,7 +4355,9 @@
"countRead",
"show",
"targetUser",
"whoRead"
"whoRead",
"isDel",
"deletedType"
]
},
"ArticleSection": {
... ... @@ -3812,19 +4391,213 @@
"totalComment"
]
},
"ArticleTagCount": {
"ArticleSecurityAuditRequest": {
"type": "object",
"properties": {
"tagCategory": {
"type": "string",
"description": " 标签分组"
},
"tagId": {
"id": {
"type": "integer",
"format": "int64",
"description": " 标签id"
"description": "id"
},
"tagImage": {
"status": {
"type": "integer",
"format": "int32",
"description": " 1:成功 0:失败"
}
},
"title": "ArticleSecurityAuditRequest",
"required": [
"id",
"status"
]
},
"ArticleSecurityAuditResponse": {
"type": "object",
"title": "ArticleSecurityAuditResponse"
},
"ArticleSecurityGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleSecurityGetRequest",
"required": [
"id"
]
},
"ArticleSecurityGetResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/ArticleSecurityItem"
}
},
"title": "ArticleSecurityGetResponse",
"required": [
"item"
]
},
"ArticleSecurityItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 唯一标识"
},
"contentKeyWords": {
"type": "string",
"description": " 内容关键字"
},
"content": {
"$ref": "#/definitions/ContentDetailItem",
"description": " 内容详情"
},
"label": {
"type": "string",
"description": " 风控标签"
},
"prob": {
"type": "integer",
"format": "int32",
"description": " 分值"
},
"suggest": {
"type": "string",
"description": " 建议 通过、风险、人工审核"
},
"author": {
"type": "string",
"description": " 发布人"
},
"releaseAt": {
"type": "integer",
"format": "int64",
"description": " 发布时间"
},
"reviewStatus": {
"type": "integer",
"format": "int32",
"description": " 审核结果 1:待审核 2:通过 3:拒绝"
},
"reviewer": {
"type": "string",
"description": " 审核人"
},
"reviewAt": {
"type": "integer",
"format": "int64",
"description": " 审核时间(人工处置时间)"
},
"checkList": {
"type": "array",
"items": {
"$ref": "#/definitions/CheckDetailItem"
},
"description": " 检查列表"
}
},
"title": "ArticleSecurityItem",
"required": [
"id",
"contentKeyWords",
"content",
"label",
"prob",
"suggest",
"author",
"releaseAt",
"reviewStatus",
"reviewer",
"reviewAt",
"checkList"
]
},
"ArticleSecuritySearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"reviewStatus": {
"type": "integer",
"format": "int32",
"description": " 审核结果 1:待审核 2:通过 3:拒绝"
},
"suggest": {
"type": "string",
"description": " 建议 通过、风险、人工审核"
},
"contentType": {
"type": "integer",
"format": "int32",
"description": " 内容类型 (1:文章 2:评论)"
},
"authorName": {
"type": "string",
"description": " 作者名称"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "ArticleSecuritySearchRequest",
"required": [
"suggest",
"contentType",
"authorName",
"beginTime",
"endTime"
]
},
"ArticleSecuritySearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSecurityItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleSecuritySearchResponse",
"required": [
"list",
"total"
]
},
"ArticleTagCount": {
"type": "object",
"properties": {
"tagCategory": {
"type": "string",
"description": " 标签分组"
},
"tagId": {
"type": "integer",
"format": "int64",
"description": " 标签id"
},
"tagImage": {
"type": "string",
"description": " 对应的图标"
},
... ... @@ -3877,42 +4650,328 @@
}
}
},
"title": "ArticleTagGroup",
"title": "ArticleTagGroup",
"required": [
"category",
"tags"
]
},
"ArticleTagItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"type": "string"
},
"name": {
"type": "string"
},
"image": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32"
}
},
"title": "ArticleTagItem",
"required": [
"id",
"category",
"name",
"image",
"sortBy"
]
},
"ArticleTemplateBatchDeleteRequest": {
"type": "object",
"properties": {
"ids": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
}
}
},
"title": "ArticleTemplateBatchDeleteRequest",
"required": [
"ids"
]
},
"ArticleTemplateBatchResponse": {
"type": "object",
"title": "ArticleTemplateBatchResponse"
},
"ArticleTemplateClassItem": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": " 名称"
}
},
"title": "ArticleTemplateClassItem",
"required": [
"name"
]
},
"ArticleTemplateClassSearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string",
"description": " 模板名称"
}
},
"title": "ArticleTemplateClassSearchRequest"
},
"ArticleTemplateClassSearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTemplateClassItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleTemplateClassSearchResponse",
"required": [
"list",
"total"
]
},
"ArticleTemplateDeleteRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleTemplateDeleteRequest",
"required": [
"id"
]
},
"ArticleTemplateDeleteResponse": {
"type": "object",
"title": "ArticleTemplateDeleteResponse"
},
"ArticleTemplateGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleTemplateGetRequest",
"required": [
"id"
]
},
"ArticleTemplateGetResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"title": "ArticleTemplateGetResponse",
"required": [
"item"
]
},
"ArticleTemplateItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 唯一标识"
},
"name": {
"type": "string",
"description": " 模板名称"
},
"templateClass": {
"type": "string",
"description": " 模板分类"
},
"paragraphs": {
"type": "array",
"items": {
"$ref": "#/definitions/Paragraph"
},
"description": " 段落列表"
},
"icon": {
"type": "string",
"description": " 图标地址"
},
"targetWhoRead": {
"type": "integer",
"format": "int32",
"description": " 分发方式 0 分发给所有人 1 分发给指定的人"
},
"targetWhoReview": {
"type": "integer",
"format": "int32",
"description": " 分发方式 0 分发给所有人 1 分发给指定的人"
},
"whoRead": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 谁可以看"
},
"whoReview": {
"type": "array",
"items": {
"type": "integer",
"format": "int64"
},
"description": " 查看、评论人"
},
"whoReadInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/TargetUser"
},
"description": " 谁可查看"
},
"whoReviewInfo": {
"type": "array",
"items": {
"$ref": "#/definitions/TargetUser"
},
"description": " 谁可评论"
},
"": {
"type": "string",
"description": " 操作人"
},
"": {
"type": "integer",
"format": "int64",
"description": " 更新时间戳"
}
},
"title": "ArticleTemplateItem",
"required": [
"name",
"templateClass",
"paragraphs",
""
]
},
"ArticleTemplateSaveRequest": {
"type": "object",
"properties": {
"AccessToken": {
"type": "string",
"description": " 授权token"
},
"item": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"title": "ArticleTemplateSaveRequest",
"required": [
"x-mmm-accesstoken",
"item"
]
},
"ArticleTemplateSaveResponse": {
"type": "object",
"title": "ArticleTemplateSaveResponse"
},
"ArticleTemplateSearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string",
"description": " 模板名称"
},
"templateClass": {
"type": "string",
"description": " 模板分类"
},
"target": {
"$ref": "#/definitions/int",
"description": " 目标 0 全员 1 指定人"
}
},
"title": "ArticleTemplateSearchRequest"
},
"ArticleTemplateSearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleTemplateSearchResponse",
"required": [
"category",
"tags"
"list",
"total"
]
},
"ArticleTagItem": {
"ArticleTemplateUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"category": {
"type": "string"
},
"name": {
"type": "string"
},
"image": {
"type": "string"
},
"sortBy": {
"type": "integer",
"format": "int32"
"item": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"title": "ArticleTagItem",
"title": "ArticleTemplateUpdateRequest",
"required": [
"id",
"category",
"name",
"image",
"sortBy"
"item"
]
},
"ArticleTemplateUpdateResponse": {
"type": "object",
"title": "ArticleTemplateUpdateResponse"
},
"Auth": {
"type": "object",
"properties": {
... ... @@ -3967,12 +5026,18 @@
"label": {
"type": "string",
"description": " 分组名称"
},
"enable": {
"type": "integer",
"format": "int32",
"description": " 启用状态 1:启用"
}
},
"title": "CategoryOptions",
"required": [
"value",
"label"
"label",
"enable"
]
},
"CategoryOptionsRequest": {
... ... @@ -4001,6 +5066,29 @@
"options"
]
},
"CheckDetailItem": {
"type": "object",
"properties": {
"label": {
"type": "string",
"description": " 命中标签"
},
"prob": {
"$ref": "#/definitions/uint",
"description": " 置信度。0-100,越高代表越有可能属于当前返回的标签(label)"
},
"suggest": {
"type": "string",
"description": " 建议"
}
},
"title": "CheckDetailItem",
"required": [
"label",
"prob",
"suggest"
]
},
"CommentAtWho": {
"type": "object",
"properties": {
... ... @@ -4200,6 +5288,31 @@
"type": "object",
"title": "CompanyVisibleSwitchResponse"
},
"ContentDetailItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 内容ID"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 内容类型 (1:文章 2:评论)"
},
"text": {
"type": "string",
"description": " 内容文本"
}
},
"title": "ContentDetailItem",
"required": [
"id",
"type",
"text"
]
},
"Department": {
"type": "object",
"properties": {
... ... @@ -4229,6 +5342,11 @@
"format": "int64"
},
"description": " 部门下的用户"
},
"totalUser": {
"type": "integer",
"format": "int32",
"description": " 累计用户"
}
},
"title": "Department",
... ... @@ -4237,7 +5355,8 @@
"companyId",
"parentId",
"name",
"userIds"
"userIds",
"totalUser"
]
},
"DepartmentAddRequest": {
... ... @@ -4297,6 +5416,16 @@
"size": {
"type": "integer",
"format": "int32"
},
"includeRootCompany": {
"type": "boolean",
"format": "boolean",
"description": " 包含公司(把公司当作部门作为顶级节点 部门ID:0)"
},
"includeDefaultDepartment": {
"type": "boolean",
"format": "boolean",
"description": " 包含默认分组"
}
},
"title": "DepartmentListRequest",
... ... @@ -4497,6 +5626,89 @@
"size"
]
},
"MessageSubscribeAddRequest": {
"type": "object",
"properties": {
"types": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"description": " 订阅消息类型"
}
},
"title": "MessageSubscribeAddRequest",
"required": [
"types"
]
},
"MessageSubscribeAddResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSubscribeItem"
}
}
},
"title": "MessageSubscribeAddResponse",
"required": [
"items"
]
},
"MessageSubscribeItem": {
"type": "object",
"properties": {
"type": {
"type": "integer",
"format": "int32",
"description": " 订阅消息类型"
},
"count": {
"type": "integer",
"format": "int32",
"description": " 订阅次数"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 用户ID"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
}
},
"title": "MessageSubscribeItem",
"required": [
"type",
"count",
"userId",
"companyId"
]
},
"MessageSubscribeListRequest": {
"type": "object",
"title": "MessageSubscribeListRequest"
},
"MessageSubscribeListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSubscribeItem"
}
}
},
"title": "MessageSubscribeListResponse",
"required": [
"items"
]
},
"MessageSystemItem": {
"type": "object",
"properties": {
... ... @@ -6975,10 +8187,89 @@
"keywords": {
"type": "string",
"description": " 按关键字搜索(名称)"
},
"departmentId": {
"$ref": "#/definitions/int64",
"description": " 按部门过滤"
}
},
"title": "MiniUsersListRequest"
},
"MiniWechatBindRequest": {
"type": "object",
"properties": {
"wechatAuthcode": {
"type": "string",
"description": " 微信登录 授权码"
},
"wechatEncryptedData": {
"type": "string",
"description": " 微信登录 加密数据"
},
"wechatIV": {
"type": "string",
"description": " 微信登录 加密算法初始向量"
}
},
"title": "MiniWechatBindRequest",
"required": [
"wechatAuthcode",
"wechatEncryptedData",
"wechatIV"
]
},
"MiniWechatBindResponse": {
"type": "object",
"properties": {
"bind": {
"type": "boolean",
"format": "boolean",
"description": " 绑定结果 true-已绑定 false-未绑定"
},
"openId": {
"type": "string",
"description": " 绑定的微信openId"
},
"phone": {
"type": "string",
"description": " 绑定手机号"
}
},
"title": "MiniWechatBindResponse",
"required": [
"bind",
"openId",
"phone"
]
},
"MiniWechatInfoRequest": {
"type": "object",
"title": "MiniWechatInfoRequest"
},
"MiniWechatInfoResponse": {
"type": "object",
"properties": {
"bind": {
"type": "boolean",
"format": "boolean",
"description": " 绑定结果 true-已绑定 false-未绑定"
},
"openId": {
"type": "string",
"description": " 绑定的微信openId"
},
"phone": {
"type": "string",
"description": " 绑定手机号"
}
},
"title": "MiniWechatInfoResponse",
"required": [
"bind",
"openId",
"phone"
]
},
"MyBeLikedItem": {
"type": "object",
"properties": {
... ... @@ -7092,6 +8383,49 @@
"name"
]
},
"Paragraph": {
"type": "object",
"properties": {
"id": {
"type": "string",
"description": " 唯一标识"
},
"title": {
"type": "string",
"description": " 标题"
},
"prompt": {
"type": "string",
"description": " 文本提示"
},
"required": {
"type": "boolean",
"format": "boolean",
"description": " 必填"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 段落类型 1:文本 2:图片"
},
"text": {
"type": "string",
"description": " 文本内容"
},
"images": {
"type": "array",
"items": {
"type": "string"
},
"description": " 图片地址列表"
}
},
"title": "Paragraph",
"required": [
"text",
"images"
]
},
"Position": {
"type": "object",
"properties": {
... ... @@ -7828,11 +9162,16 @@
"type": "integer",
"format": "int64",
"description": "id"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDeleteRequest",
"required": [
"id"
"id",
"x-mmm-accesstoken"
]
},
"SystemArticleDeleteResponse": {
... ... @@ -7866,11 +9205,16 @@
"type": "integer",
"format": "int64",
"description": "ID"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDeletedRestoreRequest",
"required": [
"id"
"id",
"x-mmm-accesstoken"
]
},
"SystemArticleDeletedRestoreResponse": {
... ... @@ -10180,6 +11524,10 @@
},
"code": {
"type": "string"
},
"companyVisible": {
"type": "boolean",
"format": "boolean"
}
},
"title": "SystemUserInfoResponse",
... ... @@ -10189,7 +11537,8 @@
"avatar",
"companyId",
"companyName",
"code"
"code",
"companyVisible"
]
},
"SystemUserSearchRequest": {
... ... @@ -10221,8 +11570,7 @@
"description": " 启用状态 1:启用 2:禁用"
},
"departmentId": {
"type": "integer",
"format": "int64",
"$ref": "#/definitions/int64",
"description": " 所属部门"
}
},
... ... @@ -10666,6 +12014,23 @@
"options"
]
},
"TargetUser": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
},
"title": "TargetUser",
"required": [
"id",
"name"
]
},
"UserFollowItem": {
"type": "object",
"properties": {
... ...
@server(
prefix: v1/system
group: secuirty
middleware: LoginStatusCheck,LogRequest
jwt: SystemAuth
)
service Core {
@doc "内容安全-搜索"
@handler articleSecuritySearch
post /article_security/search (ArticleSecuritySearchRequest) returns (ArticleSecuritySearchResponse)
@doc "详情"
@handler articleSecurityGet
get /article_security/:id (ArticleSecurityGetRequest) returns (ArticleSecurityGetResponse)
@doc "内容安全-审核"
@handler articleSecurityAudit
post /article_security/audit (ArticleSecurityAuditRequest) returns (ArticleSecurityAuditResponse)
}
type (
ArticleSecurityGetRequest {
Id int64 `path:"id"`
}
ArticleSecurityGetResponse struct{
ArticleSecurity ArticleSecurityItem `json:"item"`
}
// ArticleSecuritySaveRequest struct{
// ArticleSecurity ArticleSecurityItem `json:"article_security"`
// }
// ArticleSecuritySaveResponse struct{}
//
// ArticleSecurityDeleteRequest struct{
// Id int64 `path:"id"`
// }
// ArticleSecurityDeleteResponse struct{}
//
// ArticleSecurityUpdateRequest struct{
// Id int64 `path:"id"`
// ArticleSecurity ArticleSecurityItem `json:"article_security"`
// }
// ArticleSecurityUpdateResponse struct{}
ArticleSecurityAuditRequest struct{
Id int64 `json:"id"` //id
Status int `json:"status"` // 1:成功 0:失败
}
ArticleSecurityAuditResponse struct{
}
ArticleSecuritySearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
ReviewStatus int `json:"reviewStatus,optional"` // 审核结果 1:待审核 2:通过 3:拒绝
Suggest string `json:"suggest"` // 建议 通过、风险、人工审核
ContentType int `json:"contentType"` // 内容类型 (1:文章 2:评论)
AuthorName string `json:"authorName"` // 作者名称
BeginTime int64 `json:"beginTime"` // 开始时间
EndTime int64 `json:"endTime"` // 结束时间
}
ArticleSecuritySearchResponse{
List []ArticleSecurityItem `json:"list"`
Total int64 `json:"total"`
}
ArticleSecurityItem struct{
Id int64 `json:"id"` // 唯一标识
ContentKeyWords string `json:"contentKeyWords"` // 内容关键字
Content ContentDetailItem `json:"content"` // 内容详情
Label string `json:"label"` // 风控标签
Prob int `json:"prob"` // 分值
Suggest string `json:"suggest"` // 建议 通过、风险、人工审核
Author string `json:"author"` // 发布人
ReleaseAt int64 `json:"releaseAt"` // 发布时间
ReviewStatus int `json:"reviewStatus"` // 审核结果 1:待审核 2:通过 3:拒绝
Reviewer string `json:"reviewer"` // 审核人
ReviewAt int64 `json:"reviewAt"` // 审核时间(人工处置时间)
CheckList []CheckDetailItem `json:"checkList"` // 检查列表
}
CheckDetailItem struct{
Label string `json:"label"` // 命中标签
Prob uint `json:"prob"` // 置信度。0-100,越高代表越有可能属于当前返回的标签(label)
Suggest string `json:"suggest"` // 建议
}
ContentDetailItem struct{
Id int64 `json:"id"` // 内容ID
Type int `json:"type"` // 内容类型 (1:文章 2:评论)
Text string `json:"text"` // 内容文本
}
)
\ No newline at end of file
... ...
@server(
prefix: v1/system
group: template
middleware: LoginStatusCheck,LogRequest
jwt: SystemAuth
)
service Core {
@doc "模板管理-详情"
@handler systemArticleTemplateGet
get /article_template/:id (ArticleTemplateGetRequest) returns (ArticleTemplateGetResponse)
@doc "模板管理-保存"
@handler systemArticleTemplateSave
post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse)
@doc "模板管理-删除"
@handler systemArticleTemplateDelete
delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse)
@doc "模板管理-批量删除"
@handler systemArticleTemplateBatchDelete
delete /article_template/batch_delete (ArticleTemplateBatchDeleteRequest) returns (ArticleTemplateBatchResponse)
@doc "模板管理-更新"
@handler systemArticleTemplateUpdate
put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse)
@doc "模板管理-搜索"
@handler systemArticleTemplateSearch
post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse)
@doc "模板管理-分类搜索"
@handler systemArticleTemplateClassSearch
post /article_template_class/search (ArticleTemplateClassSearchRequest) returns (ArticleTemplateClassSearchResponse)
}
@server(
prefix: v1/mini
group: template
middleware: LogRequest
jwt: MiniAuth
)
service Core {
@doc "模板搜索"
@handler miniArticleTemplateSearch
post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse)
@doc "我的模板搜索"
@handler miniArticleTemplateSearchMine
post /article_template/search-mine (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse)
@doc "模板分类搜索"
@handler miniArticleTemplateClassSearch
post /article_template_class/search (ArticleTemplateClassSearchRequest) returns (ArticleTemplateClassSearchResponse)
@doc "模板管理-保存"
@handler miniArticleTemplateSave
post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse)
@doc "模板管理-删除"
@handler miniArticleTemplateDelete
delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse)
@doc "模板管理-更新"
@handler miniArticleTemplateUpdate
put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse)
}
type (
ArticleTemplateGetRequest {
Id int64 `path:"id"`
}
ArticleTemplateGetResponse struct{
ArticleTemplate ArticleTemplateItem `json:"item"`
}
ArticleTemplateSaveRequest struct{
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
ArticleTemplate ArticleTemplateItem `json:"item"`
BelongTo int `json:"belongTo,optional,default=2"` // 模板属于: 1:企业 、2:个人
}
ArticleTemplateSaveResponse struct{}
ArticleTemplateDeleteRequest struct{
Id int64 `path:"id"`
}
ArticleTemplateDeleteResponse struct{}
ArticleTemplateBatchDeleteRequest struct{
Ids []int64 `json:"ids"`
}
ArticleTemplateBatchResponse struct{
}
ArticleTemplateUpdateRequest struct{
Id int64 `path:"id"`
ArticleTemplate ArticleTemplateItem `json:"item"`
}
ArticleTemplateUpdateResponse struct{}
ArticleTemplateSearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Name string `json:"name,optional"` // 模板名称
TemplateClass string `json:"templateClass,optional"` // 模板分类
Target *int `json:"target,optional"` // 目标 0 全员 1 指定人
TargetUser string `json:"targetUser,optional"` // 目标用户
// BelongTos []int `json:"belongTos,optional"` // 归属
CompanyId int64 `json:",optional"` // 属于企业时有值
UserId int64 `json:",optional"` // 属于个人时有值
}
ArticleTemplateSearchResponse{
List []ArticleTemplateItem `json:"list"`
Total int64 `json:"total"`
}
ArticleTemplateClassSearchRequest struct{
Page int `json:"page,optional"`
Size int `json:"size,optional"`
Name string `json:"name,optional"` // 模板名称
CompanyId int64 `json:",optional"` // 属于企业时有值
UserId int64 `json:",optional"` // 属于个人时有值
}
ArticleTemplateClassSearchResponse{
List []ArticleTemplateClassItem `json:"list"`
Total int64 `json:"total"`
}
ArticleTemplateClassItem struct{
Name string `json:"name"` // 名称
}
ArticleTemplateItem struct{
Id int64 `json:"id,optional"` // 唯一标识
//CompanyId int64 `json:",optional"` // 属于企业时有值
//UserId int64 `json:",optional"` // 属于个人时有值
//BelongTo int `json:"belongTo,optional"` // 模板属于: 1:企业 、2:个人
Name string `json:"name"` // 模板名称
Description string `json:"description,optional"` // 描述
TemplateClass string `json:"templateClass"` // 模板分类
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落列表
Icon string `json:"icon,optional"` // 图标地址
TargetWhoRead int `json:"targetWhoRead,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人
TargetWhoReview int `json:"targetWhoReview,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人
WhoRead []int64 `json:"whoRead,optional"` // 谁可以看
WhoReview []int64 `json:"whoReview,optional"` // 查看、评论人
WhoReadInfo []TargetUser `json:"whoReadInfo,optional"` // 谁可查看
WhoReviewInfo []TargetUser `json:"whoReviewInfo,optional"` // 谁可评论
Operator string `json:"operator,omitempty,optional"` // 操作人
UpdatedAt int64 `json:"updatedAt,omitempty,optional"` // 更新时间戳
}
Paragraph struct {
ID string `json:"id,optional"` // 唯一标识
Title string `json:"title,optional"` // 标题
Prompt string `json:"prompt,optional"` // 文本提示
Required bool `json:"required,optional"` // 必填
Type int `json:"type,optional"` // 段落类型 1:文本 2:图片
Text string `json:"text,optional,omitempty"` // 文本内容
Images []string `json:"images,optional,omitempty"` // 图片地址列表
}
TargetUser struct{
Id int64 `json:"id"`
Name string `json:"name"`
}
)
\ No newline at end of file
... ...
... ... @@ -34,13 +34,15 @@ type Operator {
type (
MiniArticleCreateRequest {
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
Section []string `json:"section,optional"` //文章的文本内容
AuthorId int64 `json:"authorId,optional"` //发布人id
Images []string `json:"images,optional"` //图片
WhoRead []int64 `json:"whoRead,optional"` //谁可查看
WhoReview []int64 `json:"whoReview,optional"` //谁可评论
Location Location `json:"location,optional"` //定位坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
MiniArticleCreateResponse {
Id int64 `json:"id"`
... ... @@ -75,12 +77,16 @@ type (
MeFollowFlag int `json:"meFollowFlag"` // 当前人员对作者的关注标识 (0 没有关注 1有关注)
Tags []string `json:"tags"` // 文章的标签
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Cover string `json:"cover"` //封面
}
ArticleSection {
Id int64 `json:"id"` //段落id
Content string `json:"content"` // 文本内容
Content string `json:"content,optional"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Images []string `json:"images,optional"` // 照片列表
ParagraphType int `json:"paragraphType"` // 段落类型 0:无样式 1:模板文本 2:模板图片
ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板
}
)
... ... @@ -111,6 +117,7 @@ type (
WhoRead []int64 `json:"whoRead"` //谁可查看
IsDel int `json:"isDel"` //是否删除 1-删除 0-否
DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除
Cover string `json:"cover"` //封面
}
SystemArticleSearchMeRequest {
... ... @@ -211,6 +218,7 @@ type (
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
Cover string `json:"cover"` //封面
}
)
... ... @@ -230,6 +238,7 @@ type (
Location Location `json:"location"`
Action string `json:"action"`
Show int `json:"show"`
Cover string `json:"cover"` //封面
}
)
... ... @@ -253,14 +262,16 @@ type (
MiniArticleDraftCreateRequest {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 5、演绎式 3、归纳式 10、其他业务类型模板
Section []string `json:"section,optional"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
MiniArticleDraftCreateResponse {
... ... @@ -275,13 +286,15 @@ type (
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
Section []string `json:"section,optional"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
MiniArticleDraftUpdateResponse {
... ... @@ -305,11 +318,13 @@ type (
MiniArticleDraftItem {
Id int64 `json:"id"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
Section []string `json:"section,optional"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`//
MatchUrl map[string]string `json:"matchUrl"` //匹配内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
Cover string `json:"cover"` //封面
}
)
... ... @@ -331,6 +346,8 @@ type (
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` //
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
Cover string `json:"cover"` //封面
}
)
... ... @@ -436,6 +453,7 @@ type (
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
Cover string `json:"cover"` //封面
}
)
... ... @@ -462,6 +480,7 @@ type (
Title string `json:"title"` //标题
AuthorId int64 `json:"authorId"` //发布人ID
Author string `json:"author"` //发布人
Cover string `json:"cover"` //封面
Images []string `json:"images"` //图片
CreatedAt int64 `json:"createdAt"` //文章的创建日期
UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期
... ... @@ -481,9 +500,9 @@ type (
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,optional"`
Template int `json:"template,optional"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []ArticleSection `json:"section"` // 填写的内容
Section []ArticleSection `json:"section,optional"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
Images []string `json:"images,optional"` // 图片
Videos []Video `json:"video"` // 视频
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
... ... @@ -519,6 +538,8 @@ type (
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
SystemArticleCreateResponse {
Id int64 `json:"id"` //id
... ... @@ -588,6 +609,7 @@ type (
Location Location `json:"location"` // 定位坐标
TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人]
Tags []int64 `json:"tags"` // 标签
Cover string `json:"cover"` //封面
}
)
// 管理后台文章恢复
... ... @@ -653,6 +675,7 @@ type (
Images []string `json:"images"`
CreatedAt int64 `json:"createdAt"`
MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
Cover string `json:"cover"` //封面
}
)
... ... @@ -670,6 +693,7 @@ type (
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
SystemArticleDraftCreateResponse {
Id int64 `json:"id"` //ID
... ... @@ -701,6 +725,7 @@ type (
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
SystemArticleDraftUpdateResponse {
Id int64 `json:"id"` //ID
... ... @@ -740,6 +765,7 @@ type (
AuthorId int64 `json:"authorId"` //发布人id
Author string `json:"author"` //发布人
UpdatedAt int64 `json:"updatedAt"` //编辑时间
Cover string `json:"cover"` //封面
}
)
... ... @@ -783,6 +809,8 @@ type (
WhoReviewInfo []UserShowName `json:"whoReviewInfo"` // 谁可评论
MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本
Tags []int64 `json:"tags"` // 标签
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
Cover string `json:"cover"` //封面
}
)
... ...
... ... @@ -236,6 +236,7 @@ type(
ReadFlag bool `json:"readFlag"` // 已读标识 true:已读 false:未读
Images []string `json:"images"` // 图片列表
Author UserItem `json:"author"` // 作者
Cover string `json:"cover"` //封面
}
MiniUserFollowedSearchRequest{
Page int `json:"page,optional"`
... ...
... ... @@ -7,6 +7,7 @@ Timeout: 30000
# CertFile: ./key/fjmaimaimai.com_bundle.crt
# KeyFile: ./key/fjmaimaimai.com.key
LogRequest: true # 记录详细请求日志
ContentSecurityCheck: true # 内容安全检查(调用微信接口)
Log:
Mode: file
... ...
... ... @@ -17,6 +17,7 @@ type Config struct {
ApiAuth ApiService
DebugSmsCode string `json:",optional,default=999512"`
LogRequest bool `json:",optional,default=true"`
ContentSecurityCheck bool `json:",optional,default=false"`
}
type ApiService struct {
... ...
... ... @@ -11,7 +11,9 @@ import (
department "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/department"
message "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/message"
role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role"
secuirty "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/secuirty"
tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags"
template "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/template"
user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
... ... @@ -809,4 +811,114 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_security/search",
Handler: secuirty.ArticleSecuritySearchHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_security/:id",
Handler: secuirty.ArticleSecurityGetHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_security/audit",
Handler: secuirty.ArticleSecurityAuditHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest},
[]rest.Route{
{
Method: http.MethodGet,
Path: "/article_template/:id",
Handler: template.SystemArticleTemplateGetHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template",
Handler: template.SystemArticleTemplateSaveHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_template/:id",
Handler: template.SystemArticleTemplateDeleteHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_template/batch_delete",
Handler: template.SystemArticleTemplateBatchDeleteHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_template/:id",
Handler: template.SystemArticleTemplateUpdateHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template/search",
Handler: template.SystemArticleTemplateSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template_class/search",
Handler: template.SystemArticleTemplateClassSearchHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
rest.WithPrefix("/v1/system"),
)
server.AddRoutes(
rest.WithMiddlewares(
[]rest.Middleware{serverCtx.LogRequest},
[]rest.Route{
{
Method: http.MethodPost,
Path: "/article_template/search",
Handler: template.MiniArticleTemplateSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template/search-mine",
Handler: template.MiniArticleTemplateSearchMineHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template_class/search",
Handler: template.MiniArticleTemplateClassSearchHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_template",
Handler: template.MiniArticleTemplateSaveHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_template/:id",
Handler: template.MiniArticleTemplateDeleteHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_template/:id",
Handler: template.MiniArticleTemplateUpdateHandler(serverCtx),
},
}...,
),
rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret),
rest.WithPrefix("/v1/mini"),
)
}
... ...
package secuirty
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/secuirty"
"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 ArticleSecurityAuditHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleSecurityAuditRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := secuirty.NewArticleSecurityAuditLogic(r.Context(), svcCtx)
resp, err := l.ArticleSecurityAudit(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package secuirty
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/secuirty"
"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 ArticleSecurityGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleSecurityGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := secuirty.NewArticleSecurityGetLogic(r.Context(), svcCtx)
resp, err := l.ArticleSecurityGet(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package secuirty
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/secuirty"
"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 ArticleSecuritySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleSecuritySearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := secuirty.NewArticleSecuritySearchLogic(r.Context(), svcCtx)
resp, err := l.ArticleSecuritySearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateClassSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateClassSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateClassSearchLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateClassSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateDeleteLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateDelete(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateSaveRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateSaveLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateSave(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateSearchLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateSearchMineHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateSearchMineLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateSearchMine(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 MiniArticleTemplateUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewMiniArticleTemplateUpdateLogic(r.Context(), svcCtx)
resp, err := l.MiniArticleTemplateUpdate(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateBatchDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateBatchDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateBatchDeleteLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateBatchDelete(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateClassSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateClassSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateClassSearchLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateClassSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateDeleteRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateDeleteLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateDelete(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateGetRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateGetLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateGet(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateSaveRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateSaveLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateSave(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"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/template"
"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 SystemArticleTemplateSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateSearchRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateSearchLogic(r.Context(), svcCtx)
userToken := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = userToken.CompanyId
resp, err := l.SystemArticleTemplateSearch(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
package template
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/template"
"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 SystemArticleTemplateUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.ArticleTemplateUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := template.NewSystemArticleTemplateUpdateLogic(r.Context(), svcCtx)
resp, err := l.SystemArticleTemplateUpdate(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -65,7 +65,7 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr
Id: backupList[i].Id,
Title: "",
Content: "",
Images: []string{},
Images: backupList[i].GetImages(),
Videos: []types.Video{},
CreatedAt: backupList[i].CreatedAt,
Location: types.Location{
... ... @@ -76,6 +76,7 @@ func (l *MiniArticleBackupSearchLogic) MiniArticleBackupSearch(req *types.MiniAr
ChangeField: backupList[i].ChangeField,
Action: backupList[i].Action,
Show: int(backupList[i].Show),
Cover: backupList[i].GetCover(),
}
//根据修改的内容替换展示内容
changeFiled := []string{}
... ...
... ... @@ -52,14 +52,10 @@ func (l *MiniArticleSearchMeLogic) MiniArticleSearchMe(req *types.MiniArticleSea
}
func NewArticle(article *domain.Article) types.ArticleSearchMe {
images := []string{}
for _, val2 := range article.Images {
images = append(images, val2.Url)
}
articleSearchMe := types.ArticleSearchMe{
Id: article.Id,
Title: article.Title,
Images: images,
Images: article.GetImages(),
CreatedAt: article.CreatedAt,
CountLove: article.CountLove,
CountComment: article.CountComment,
... ... @@ -69,6 +65,7 @@ func NewArticle(article *domain.Article) types.ArticleSearchMe {
WhoRead: article.WhoRead,
IsDel: article.IsDel,
DeletedType: article.DeletedType,
Cover: article.GetCover(),
}
return articleSearchMe
}
... ...
... ... @@ -54,6 +54,7 @@ func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArti
Descript: req.Location.Descript,
},
MatchUrl: map[string]string{},
Section: NewArticleSectionFromParagraphs(req.Paragraphs, req.CompanyId, 0),
}
for _, val := range req.Images {
newDraft.Images = append(newDraft.Images, domain.Image{
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"strconv"
"strings"
... ... @@ -128,6 +129,202 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
//切分文章分段
sectionList := NewArticleSectionFromParagraphs(req.Paragraphs, author.CompanyId, 0)
//newStr := ""
//for _, paragraph := range req.Paragraphs {
// strList := []string{paragraph.Text}
// // 无模板样式的
// if paragraph.Type == 0 {
// strList = strings.Split(paragraph.Text, "\n")
// }
// for i2 := range strList {
// newStr = template.HTMLEscapeString(strList[i2])
// newSection := domain.ArticleSection{
// Id: 0,
// CompanyId: author.CompanyId,
// ArticleId: 0,
// Content: newStr,
// SortBy: len(sectionList),
// TotalComment: 0,
//
// Images: paragraph.Images,
// ParagraphType: paragraph.Type,
// ParagraphTemplate: core.NewDomainParagraph(paragraph),
// }
// sectionList = append(sectionList, &newSection)
// }
//}
newArticle := &domain.Article{
Id: 0,
CompanyId: author.CompanyId,
AuthorId: author.Id,
Author: articleAuthor,
Title: req.Title,
Images: images,
WhoRead: whoRead,
WhoReview: whoReview,
Location: domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
},
TargetUser: domain.ArticleTargetAll,
CountLove: 0,
CountComment: 0,
CountRead: 0,
Show: domain.ArticleShowEnable,
Tags: []int64{},
MatchUrl: map[string]string{},
Videos: []domain.Video{},
}
if len(whoRead) > 0 {
newArticle.TargetUser = domain.ArticleTargetLimit
}
for k, v := range req.MatchUrl {
newArticle.MatchUrl[k] = v
}
//设置内容概要
newArticle.SetSummary(sectionList)
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
newArticle, err = l.svcCtx.ArticleRepository.Insert(ctx, c, newArticle)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
for i := range sectionList {
sectionList[i].ArticleId = newArticle.Id
_, 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)
}
//发送订阅消息
err = message.NewMiniSubscribeLogic(l.ctx, l.svcCtx).FollowArticle(conn, newArticle)
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
// 内容安全检查
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, c, author, core.NewContentFromArticle(newArticle, sectionList)); err != nil {
return err
}
return nil
}, true)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章失败", err)
}
resp = &types.MiniArticleCreateResponse{
Id: newArticle.Id,
}
return
}
func (l *MiniCreateArticleLogic) MiniCreateArticleBak(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
err = l.validateTextLimit(req)
if err != nil {
return nil, err
}
// 检查发布人
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, author.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("创建文章内容失败", err)
}
articleAuthor := domain.UserSimple{
Id: author.Id,
Name: author.Name,
Avatar: author.Avatar,
Position: author.Position,
Company: companyInfo.Name,
CompanyId: author.CompanyId,
}
if len(req.Images) > 9 {
return nil, xerr.NewErrMsg("图片数量最多9张")
}
//获取图片的尺寸大小
images := []domain.Image{}
for _, val := range req.Images {
fInfo, _ := oss.GetImageInfo(val)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
images = append(images, domain.Image{
Url: val,
Width: w,
Height: h,
})
}
//检查文章可被哪些人查看
whoRead := []int64{}
if len(req.WhoRead) > 0 {
whoRead = lo.Uniq(req.WhoRead)
var u *domain.User
for _, val := range whoRead {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val)
if err != nil {
return nil, xerr.NewErrMsgErr("文章可查看人设置错误", err)
}
if u.CompanyId != author.CompanyId {
return nil, xerr.NewErrMsg("文章可查看人设置错误")
}
}
}
//检查文章可被哪些人评论
whoReview := []int64{}
if len(req.WhoReview) > 0 {
whoReview = lo.Uniq(req.WhoReview)
}
//有指定可查看人的情况
if len(whoRead) > 0 {
if len(whoReview) > 0 {
// 检查 whoRead 是否 完全包含 whoReview
ok := lo.Every(whoRead, whoReview)
if !ok {
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
if len(whoReview) == 0 {
//有指定可查看人 ,但未指定可评论人
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
//没有指定可查看人的情况
if len(whoRead) == 0 {
if len(whoReview) > 0 {
// 未指定可查看人(全员可看),有指定可评论人,
var u *domain.User
for _, val := range whoReview {
u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val)
if err != nil {
return nil, xerr.NewErrMsgErr("文章可评论人设置错误", err)
}
if u.CompanyId != author.CompanyId {
return nil, xerr.NewErrMsg("文章可评论人设置错误")
}
}
}
// if len(whoReview) == 0 {
// 未指定可查看人(全员可看),未指定可评论人 ,忽略判断
// }
}
//切分文章分段
sectionList := []*domain.ArticleSection{}
newStr := ""
for i := range req.Section {
... ... @@ -205,6 +402,11 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
if err != nil {
return xerr.NewErrMsgErr("创建文章失败", err)
}
// 内容安全检查
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, c, author, core.NewContentFromArticle(newArticle, sectionList)); err != nil {
return err
}
return nil
}, true)
if err != nil {
... ... @@ -228,10 +430,12 @@ func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateR
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i])
wordNum += num
if num > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
}
}
if wordNum > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
//return xerr.NewErrMsg("内容最多只能输入1000字")
}
return nil
}
... ...
... ... @@ -67,6 +67,7 @@ func (l *MiniGetArticleBackupLogic) MiniGetArticleBackup(req *types.MiniGetArtic
ChangeField: backupInfo.ChangeField,
Action: backupInfo.Action,
Show: int(backupInfo.Show),
Cover: backupInfo.GetCover(),
}
return
... ...
... ... @@ -2,6 +2,9 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -37,10 +40,25 @@ func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticl
return nil, xerr.NewErrMsg("获取草稿失败")
}
}
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(draftInfo.Section, func(p *domain.ArticleSection, index int) {
paragraphTemplate := core.NewTypesParagraph(p.ParagraphTemplate)
paragraphTemplate.Images = p.Images
paragraphTemplate.Text = p.Content
paragraphs = append(paragraphs, paragraphTemplate)
})
if len(paragraphs) == 0 && len(draftInfo.Content) > 0 {
lo.ForEach(draftInfo.Content, func(item string, index int) {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(item))
})
}
resp = &types.MiniArticleDraftGetMeResponse{
Id: draftInfo.Id,
Template: draftInfo.Template,
Section: draftInfo.Content,
//Section: draftInfo.Content,
Title: draftInfo.Title,
Images: []string{},
WhoRead: draftInfo.WhoRead,
... ... @@ -51,6 +69,8 @@ func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticl
Descript: draftInfo.Location.Descript,
},
MatchUrl: map[string]string{},
Paragraphs: paragraphs,
Cover: draftInfo.GetCover(),
}
for k, v := range draftInfo.MatchUrl {
resp.MatchUrl[k] = v
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"sort"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
... ... @@ -101,11 +102,18 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
articleSection := []types.ArticleSection{}
for _, val := range sortBy {
paragraphTemplate := core.NewTypesParagraph(val.ParagraphTemplate)
paragraphTemplate.Images = val.Images
paragraphTemplate.Text = val.Content
articleSection = append(articleSection, types.ArticleSection{
Id: val.Id,
Content: val.Content,
SortBy: val.SortBy,
TotalComment: val.TotalComment,
Images: val.Images,
ParagraphTemplate: core.NewTypesParagraph(val.ParagraphTemplate),
ParagraphType: val.ParagraphType,
})
}
resp = &types.MiniArticleGetResponse{
... ... @@ -139,6 +147,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
Tags: tags,
MatchUrl: map[string]string{},
Videos: []types.Video{},
Cover: articleInfo.GetCover(),
}
if backupCount > 1 {
resp.Edit = 1
... ...
... ... @@ -2,6 +2,8 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
... ... @@ -45,6 +47,21 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
}
for i := range draftList {
draftInfo := draftList[i]
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(draftInfo.Section, func(p *domain.ArticleSection, index int) {
item := core.NewTypesParagraph(p.ParagraphTemplate)
item.Text = p.Content
item.Images = p.Images
paragraphs = append(paragraphs, item)
})
if len(paragraphs) == 0 && len(draftInfo.Content) > 0 {
lo.ForEach(draftInfo.Content, func(item string, index int) {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(item))
})
}
images := []string{}
for _, val := range draftList[i].Images {
images = append(images, val.Url)
... ... @@ -52,11 +69,13 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
resp.List[i] = types.MiniArticleDraftItem{
Id: draftList[i].Id,
Template: draftList[i].Template,
Section: draftList[i].Content,
//Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
Images: draftList[i].GetImages(),
CreatedAt: draftList[i].CreatedAt,
MatchUrl: draftList[i].MatchUrl,
Paragraphs: paragraphs,
Cover: draftList[i].GetCover(),
}
}
return resp, nil
... ...
... ... @@ -73,17 +73,15 @@ func (l *MiniSearchArticlePageLogic) MiniSearchArticlePage(req *types.MiniSearch
AuthorId: val.AuthorId,
Author: author.Name,
Avatar: author.Avatar,
Images: []string{},
Images: val.GetImages(),
CreatedAt: val.CreatedAt,
MeReadFlag: 0,
Cover: val.GetCover(),
}
if _, ok := readFlag[val.Id]; ok {
item.MeReadFlag = 1
}
for _, img := range val.Images {
item.Images = append(item.Images, img.Url)
}
resp.List[i] = item
}
... ...
... ... @@ -62,6 +62,7 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti
for k, v := range req.MatchUrl {
draftInfo.MatchUrl[k] = v
}
draftInfo.Section = NewArticleSectionFromParagraphs(req.Paragraphs, req.CompanyId, 0)
_, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo)
if err != nil {
return nil, xerr.NewErrMsgErr("更新草稿失败", err)
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
... ... @@ -53,6 +54,7 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System
TargetUser: int(backup.TargetUser),
Tags: backup.Tags,
Videos: make([]types.Video, 0),
Cover: backup.GetCover(),
}
//文章段落内容
... ... @@ -62,6 +64,9 @@ func (l *SystemArticleGetHistoryLogic) SystemArticleGetHistory(req *types.System
Content: item.Content,
SortBy: item.SortBy,
TotalComment: item.TotalComment,
Images: item.Images,
ParagraphTemplate: core.NewTypesParagraph(item.ParagraphTemplate),
ParagraphType: item.ParagraphType,
})
})
//图片
... ...
... ... @@ -75,6 +75,7 @@ func (l *SystemCreateArticleDraftLogic) SystemCreateArticleDraft(req *types.Syst
Name: userMe.User.NickName,
},
Tags: req.Tags,
Section: NewArticleSectionFromParagraphs(req.Paragraphs, companyInfo.Id, 0),
}
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Insert(ctx, conn, articleDraft)
... ...
... ... @@ -4,6 +4,7 @@ import (
"context"
"github.com/pkg/errors"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"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"
... ... @@ -11,6 +12,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"html/template"
"strconv"
"strings"
"unicode/utf8"
... ... @@ -115,7 +117,7 @@ func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleC
}
article.WhoRead = whoRead
article.WhoReview = whoReview
sections := l.getSections(req, article)
sections := NewArticleSectionFromParagraphs(req.Paragraphs, author.CompanyId, 0) //l.getSections(req, article)
//设置内容摘要
article.SetSummary(sections)
//草稿ID
... ... @@ -186,9 +188,9 @@ func (l *SystemCreateArticleLogic) validate(req *types.SystemArticleCreateReques
return errors.New("标题最多只能输入64字")
}
//文章内容
if utf8.RuneCountInString(req.Content) > 1000 {
return errors.New("内容最多只能输入1000字")
}
//if utf8.RuneCountInString(req.Content) > 1000 {
// return errors.New("内容最多只能输入1000字")
//}
//图片
if len(req.Images) > 9 {
return errors.New("图片数量最多9张")
... ... @@ -296,18 +298,56 @@ func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview
func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection {
articleSections := make([]*domain.ArticleSection, 0)
sortBy := 1
sections := strings.Split(req.Content, "\n")
lo.ForEach(sections, func(item string, index int) {
lo.ForEach(req.Paragraphs, func(paragraph types.Paragraph, index int) {
//去除空
item = strings.TrimSpace(item)
if item != "" {
strList := []string{paragraph.Text}
// 无模板样式的
if paragraph.Type == 0 {
strList = strings.Split(paragraph.Text, "\n")
}
for i2 := range strList {
newStr := template.HTMLEscapeString(strList[i2])
section := domain.ArticleSection{
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: item,
Content: newStr,
SortBy: sortBy,
Images: paragraph.Images,
ParagraphType: paragraph.Type,
ParagraphTemplate: core.NewDomainParagraph(paragraph),
}
articleSections = append(articleSections, &section)
sortBy++
}
})
return articleSections
}
func NewArticleSectionFromParagraphs(paragraphs []types.Paragraph, companyId int64, articleId int64) []*domain.ArticleSection {
articleSections := make([]*domain.ArticleSection, 0)
sortBy := 1
lo.ForEach(paragraphs, func(paragraph types.Paragraph, index int) {
//去除空
strList := []string{paragraph.Text}
// 无模板样式的
if paragraph.Type == 0 {
strList = strings.Split(paragraph.Text, "\n")
}
for i2 := range strList {
newStr := template.HTMLEscapeString(strList[i2])
section := domain.ArticleSection{
CompanyId: companyId,
ArticleId: articleId,
Content: newStr,
SortBy: sortBy,
Images: paragraph.Images,
ParagraphType: paragraph.Type,
ParagraphTemplate: core.NewDomainParagraph(paragraph),
}
section.Images = paragraph.Images
articleSections = append(articleSections, &section)
sortBy++
}
... ...
... ... @@ -3,6 +3,7 @@ package article
import (
"context"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"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"
... ... @@ -57,6 +58,15 @@ func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArti
Height: video.Height,
})
})
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(articleDraft.Section, func(p *domain.ArticleSection, index int) {
paragraphs = append(paragraphs, core.NewTypesParagraph(p.ParagraphTemplate))
})
if len(paragraphs) == 0 && len(articleDraft.Content) > 0 {
paragraphs = append(paragraphs, core.NewNoneTypesParagraph(articleDraft.Content))
}
resp = &types.SystemArticleDraftGetResponse{
Id: articleDraft.Id,
Title: articleDraft.Title,
... ... @@ -71,6 +81,7 @@ func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArti
WhoReviewInfo: make([]types.UserShowName, 0),
MatchUrl: articleDraft.MatchUrl,
Tags: articleDraft.Tags,
Cover: articleDraft.GetCover(),
}
userIds := lo.Union(resp.WhoRead, resp.WhoReview)
if len(userIds) > 0 {
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"github.com/samber/lo"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
... ... @@ -67,6 +68,7 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
Tags: make([]types.ArticleTagItem, 0),
TargetUser: int(article.TargetUser),
Videos: make([]types.Video, 0),
Cover: article.GetCover(),
}
for _, val := range article.Videos {
... ... @@ -102,8 +104,12 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
Content: item.Content,
SortBy: item.SortBy,
TotalComment: item.TotalComment,
Images: item.Images,
ParagraphTemplate: core.NewTypesParagraph(item.ParagraphTemplate),
ParagraphType: item.ParagraphType,
})
})
resp.Cover = article.GetCoverWithSections(articleSections)
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))
... ...
... ... @@ -67,11 +67,12 @@ func (l *SystemSearchArticleDraftLogic) SystemSearchArticleDraft(req *types.Syst
resp.List = append(resp.List, types.SystemArticleDraftSearch{
Id: item.Id,
Title: item.Title,
Images: images,
Images: item.GetImages(),
Operator: item.Operator.Name,
AuthorId: item.AuthorId,
Author: author,
UpdatedAt: item.UpdatedAt,
Cover: item.GetCover(),
})
})
return
... ...
... ... @@ -54,11 +54,6 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
//获取标签
_, tags, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions())
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)
})
//发布人
author := item.Author.Name
for _, user := range users {
... ... @@ -80,7 +75,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
Title: item.Title,
AuthorId: item.AuthorId,
Author: author,
Images: images,
Images: item.GetImages(),
CreatedAt: item.CreatedAt,
UpdatedAt: item.UpdatedAt,
CountLove: item.CountLove,
... ... @@ -93,6 +88,7 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS
Id: item.Operator.Id,
Name: item.Operator.Name,
},
Cover: item.GetCover(),
})
})
return
... ...
... ... @@ -68,6 +68,7 @@ func (l *SystemUpdateArticleDraftLogic) SystemUpdateArticleDraft(req *types.Syst
Id: userToken.UserId,
Name: userMe.User.NickName,
}
articleDraft.Section = NewArticleSectionFromParagraphs(req.Paragraphs, articleDraft.CompanyId, 0)
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error {
_, err := l.svcCtx.ArticleDraftOperationRepository.Update(ctx, conn, articleDraft)
if err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"strconv"
"unicode/utf8"
... ... @@ -139,6 +140,9 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
section.ArticleId = item.ArticleId
section.Version = item.Version
section.SortBy = item.SortBy
section.Images = item.Images
section.ParagraphType = item.ParagraphType
section.ParagraphTemplate = item.ParagraphTemplate
section.CompanyId = item.CompanyId
_, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section)
if err != nil {
... ... @@ -196,10 +200,13 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd
wordNum := 0
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i].Content)
if num > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
}
wordNum += num
}
if wordNum > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
//return xerr.NewErrMsg("内容最多只能输入1000字")
}
return nil
}
... ... @@ -323,7 +330,7 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq
lo.ForEach(req.Section, func(item types.ArticleSection, index int) {
strList := strings.Split(item.Content, "\n")
for key, value := range strList {
if value == "" {
if value == "" && item.ParagraphType == domain.ParagraphTypeNone {
continue
}
section := domain.ArticleSection{
... ... @@ -332,6 +339,9 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq
ArticleId: article.Id,
Content: value,
SortBy: sortBy,
Images: item.Images,
ParagraphType: item.ParagraphType,
ParagraphTemplate: core.NewDomainParagraph(item.ParagraphTemplate),
}
if key == 0 {
section.Id = item.Id
... ...
... ... @@ -2,6 +2,7 @@ package comment
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
... ... @@ -211,6 +212,11 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
if err != nil {
return err
}
// 内容安全检查
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, conn, fromUser, core.NewContentFromComment(&newComment)); err != nil {
return err
}
return nil
}, true)
... ...
package core
import (
"bytes"
"context"
"fmt"
"github.com/silenceper/wechat/v2/miniprogram/security"
"github.com/zeromicro/go-zero/core/executors"
"github.com/zeromicro/go-zero/core/logx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"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"
"time"
)
func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, toUser *domain.User, content ContentBody) error {
if !svcCtx.Config.ContentSecurityCheck {
return nil
}
var (
scene security.MsgScene
)
if content.Type == 1 {
scene = security.MsgSceneSocialLog
} else {
scene = security.MsgSceneComment
}
var (
resp domain.MsgCheckDetail
userWechat *domain.UserWechat
)
if userWechat, _ = svcCtx.UserWechatRepository.FindOneByPhone(ctx, conn, toUser.Phone); userWechat == nil {
logx.Debug(fmt.Sprintf("用户%s(%s)未绑定微信,无法进行内容检查", toUser.Name, toUser.Phone))
return nil
}
respTmp, err := svcCtx.MiniProgram.GetSecurity().MsgCheck(&security.MsgCheckRequest{
OpenID: userWechat.OpenId,
Scene: scene,
Content: content.Content,
})
if err != nil {
logx.Error(err)
return nil
}
resp = domain.MsgCheckDetail(respTmp)
var (
keyWords = make([]string, 0)
prob int
)
for i := range resp.Detail {
item := resp.Detail[i]
if prob == 0 {
prob = int(item.Prob)
}
if item.Keyword == "" {
continue
}
keyWords = append(keyWords, item.Keyword)
}
dm := &domain.ArticleSecurity{
CompanyId: toUser.CompanyId,
ContentKeyWords: keyWords,
ContentType: content.Type,
ContentId: content.Id,
AuthorId: content.AuthorId,
AuthorName: toUser.Name,
Reviewer: 0,
ReviewStatus: domain.ReviewStatusWait,
Label: resp.Result.Label.String(),
Prob: prob,
Suggest: string(resp.Result.Suggest),
Detail: resp,
AutoReviewAt: time.Now().Unix(),
AutoReviewErrorCode: fmt.Sprintf("%d", resp.ErrCode),
}
if resp.Result.Suggest == security.CheckSuggestPass {
dm.ReviewStatus = domain.ReviewStatusPass
}
if len(dm.ContentKeyWords) == 0 {
dm.ContentKeyWords = append(dm.ContentKeyWords, content.Summary)
}
// 延迟任务(认定为风险的、人工审核),帖子或评论先隐藏,状态改为非法
if resp.Result.Suggest == security.CheckSuggestRisky { // || resp.Result.Suggest == security.CheckSuggestReview
executors.NewDelayExecutor(func() {
HandlerSecurityContent(ctx, svcCtx, svcCtx.DefaultDBConn(), content, dm.ReviewStatus)
}, time.Second*5).Trigger()
}
if dm, err = svcCtx.ArticleSecurityRepository.Insert(ctx, conn, dm); err != nil {
logx.Error(err)
return nil
}
return nil
}
func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, c ContentBody, status int) error {
if !svcCtx.Config.ContentSecurityCheck {
return nil
}
var (
article *domain.Article
comment *domain.ArticleComment
err error
show = int(domain.ArticleShowIllegal)
)
if status == domain.ReviewStatusPass {
show = int(domain.ArticleShowEnable)
}
mnl := NewMessageNoticeLogic(ctx, svcCtx)
if c.Type == domain.TypeArticle {
if article, err = svcCtx.ArticleRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("文章不存在")
}
article.Show = domain.ArticleShow(show)
if _, err = svcCtx.ArticleRepository.UpdateWithVersion(ctx, conn, article); err != nil {
return err
}
if show == int(domain.ArticleShowIllegal) {
mnl.ArticleIllegal(conn, article.CompanyId, article.AuthorId, time.Unix(article.CreatedAt, 0).Format("2006-01-02 15:04"), article.Title)
}
} else if c.Type == domain.TypeComment {
if comment, err = svcCtx.ArticleCommentRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("评论不存在")
}
comment.Show = domain.CommentShow(show)
if _, err = svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, conn, comment); err != nil {
return err
}
if show == int(domain.CommentShowIllegal) {
mnl.ArticleIllegal(conn, comment.CompanyId, comment.FromUserId, time.Unix(comment.CreatedAt, 0).Format("2006-01-02 15:04"), comment.Content)
}
}
return nil
}
type ContentBody struct {
Id int64
Type int
Content string
AuthorId int64
Summary string
}
func NewContentFromComment(c *domain.ArticleComment) ContentBody {
return ContentBody{
Id: c.Id,
Type: domain.TypeComment,
Content: c.Content,
AuthorId: c.FromUserId,
Summary: c.Content,
}
}
func NewContentFromArticle(c *domain.Article, sections []*domain.ArticleSection) ContentBody {
content := bytes.NewBuffer(nil)
for _, sec := range sections {
content.WriteString(sec.Content)
}
return ContentBody{
Id: c.Id,
Type: domain.TypeArticle,
Content: content.String(),
AuthorId: c.AuthorId,
Summary: c.Summary,
}
}
... ...
package core
import (
"context"
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"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"
)
type MessageNotice struct {
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMessageNoticeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MessageNotice {
return &MessageNotice{
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MessageNotice) ArticleIllegal(conn transaction.Conn, companyId, at int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的帖子[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
// CommentIllegal 评论违规
func (l *MessageNotice) CommentIllegal(conn transaction.Conn, at int64, companyId int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的评论[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
func (l *MessageNotice) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
var msg = &domain.MessageSystem{
Type: msgType,
CompanyId: companyId,
RecipientId: at,
Title: title,
Content: content,
}
msg, err = l.svcCtx.MessageSystemRepository.Insert(l.ctx, conn, msg)
return err
}
... ...
package core
import (
"github.com/google/uuid"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
)
func NewDomainParagraph(item types.Paragraph) domain.Paragraph {
id := item.ID
if item.ID == "" {
idGen, _ := uuid.NewUUID()
id = idGen.String()
}
return domain.Paragraph{
ID: id,
Title: item.Title,
Prompt: item.Prompt,
Required: item.Required,
Type: item.Type,
}
}
func NewTypesParagraph(item domain.Paragraph) types.Paragraph {
return types.Paragraph{
ID: item.ID,
Title: item.Title,
Prompt: item.Prompt,
Required: item.Required,
Type: item.Type,
}
}
func NewNoneTypesParagraph(item string) types.Paragraph {
return types.Paragraph{
ID: "",
Title: "",
Prompt: "",
Required: false,
Type: 0,
Text: item,
}
}
... ...
... ... @@ -62,6 +62,11 @@ func (l *MiniSystemLogic) ArticleDeleted(conn transaction.Conn, companyId, at in
return l.createMessage(conn, companyId, at, domain.MsgTypeDeleted, "帖子已删除", fmt.Sprintf("你于%v发布的帖子[%v]已被删除,如有疑问,请联系运营管理员了解详情。", createdTime, title))
}
// ArticleIllegal 帖子违规
func (l *MiniSystemLogic) ArticleIllegal(conn transaction.Conn, companyId, at int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeDeleted, "文本内容违规", fmt.Sprintf("你于%v发布的帖子[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
//// ArticleAuth 文章权限变更
//func (l *MiniSystemLogic) ArticleAuth(conn transaction.Conn, companyId, at int64, item string) (err error) {
// return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "权限变更", fmt.Sprintf("您的帖子[%s]可见权限已添加,如有疑问,请联系运营管理员了解详情。", item))
... ... @@ -92,6 +97,11 @@ func (l *MiniSystemLogic) AbnormalCommentHidden(conn transaction.Conn, companyId
return l.createMessage(conn, companyId, at, domain.MsgTypeAbnormal, "评论被隐藏", fmt.Sprintf("您的评论[%s]已被隐藏,如有疑问,请联系运营管理员了解详情。", item))
}
// CommentIllegal 评论违规
func (l *MiniSystemLogic) CommentIllegal(conn transaction.Conn, at int64, companyId int64, createdTime, title string) (err error) {
return l.createMessage(conn, companyId, at, domain.MsgTypeIllegal, "文本内容违规", fmt.Sprintf("你于%v发布的评论[%v]含有违规信息,未通过审核,已被禁止发布。请自觉遵守相关规定,若有疑问,请咨询运营管理员了解详情。", createdTime, title))
}
func (l *MiniSystemLogic) createMessage(conn transaction.Conn, companyId, at int64, msgType domain.MsgSystemType, title string, content string) (err error) {
var msg = &domain.MessageSystem{
Type: msgType,
... ...
package secuirty
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"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"
"time"
"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 ArticleSecurityAuditLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewArticleSecurityAuditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleSecurityAuditLogic {
return &ArticleSecurityAuditLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ArticleSecurityAuditLogic) ArticleSecurityAudit(req *types.ArticleSecurityAuditRequest) (resp *types.ArticleSecurityAuditResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleSecurity
)
if dm, err = l.svcCtx.ArticleSecurityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("不存在", err)
}
// 不可编辑判断
//if dm.ReviewStatus != domain.ReviewStatusWait {
// return nil, xerr.NewErrMsgErr("内容已审核", err)
//}
// 赋值
if req.Status == 1 {
dm.ReviewStatus = domain.ReviewStatusPass
} else {
dm.ReviewStatus = domain.ReviewStatusFail
}
dm.ReviewAt = time.Now().Unix()
// 更新
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
dm, err = l.svcCtx.ArticleSecurityRepository.UpdateWithVersion(l.ctx, conn, dm)
if err != nil {
return err
}
if err = core.HandlerSecurityContent(l.ctx, l.svcCtx, conn, core.ContentBody{Id: dm.ContentId, Type: dm.ContentType}, dm.ReviewStatus); err != nil {
return err
}
// 更新文章/评论可见
return err
}, true); err != nil {
return nil, xerr.NewErrMsg("更新失败")
}
resp = &types.ArticleSecurityAuditResponse{}
return
}
... ...
package secuirty
import (
"context"
"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 ArticleSecurityGetLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewArticleSecurityGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleSecurityGetLogic {
return &ArticleSecurityGetLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ArticleSecurityGetLogic) ArticleSecurityGet(req *types.ArticleSecurityGetRequest) (resp *types.ArticleSecurityGetResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleSecurity
reviewer *domain.User
article *domain.Article
comment *domain.ArticleComment
)
// 货号唯一
if dm, err = l.svcCtx.ArticleSecurityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("不存在", err)
}
if dm.Reviewer > 0 {
if reviewer, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, dm.Reviewer); err != nil {
return nil, err
}
}
resp = &types.ArticleSecurityGetResponse{
ArticleSecurity: NewTypesArticleSecurity(dm, reviewer),
}
if dm.ContentType == domain.TypeArticle {
if article, _ = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, dm.ContentId); article != nil {
resp.ArticleSecurity.Content.Text = article.Summary
}
} else if dm.ContentType == domain.TypeComment {
if comment, _ = l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, dm.ContentId); comment != nil {
resp.ArticleSecurity.Content.Text = comment.Content
}
}
return
}
... ...
package secuirty
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/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"strings"
"github.com/zeromicro/go-zero/core/logx"
)
type ArticleSecuritySearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewArticleSecuritySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleSecuritySearchLogic {
return &ArticleSecuritySearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *ArticleSecuritySearchLogic) ArticleSecuritySearch(req *types.ArticleSecuritySearchRequest) (resp *types.ArticleSecuritySearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleSecurity
total int64
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
queryOptions := domain.IndexCompanyId(userToken.CompanyId)().WithOffsetLimit(req.Page, req.Size).
WithKV("reviewStatus", req.ReviewStatus).
WithKV("suggest", req.Suggest).
WithKV("contentType", req.ContentType).
WithKV("authorName", req.AuthorName).
WithKV("beginTime", req.BeginTime).
WithKV("endTime", req.EndTime)
total, dms, err = l.svcCtx.ArticleSecurityRepository.Find(l.ctx, conn, queryOptions)
list := make([]types.ArticleSecurityItem, 0)
for i := range dms {
list = append(list, NewTypesArticleSecurity(dms[i], nil))
}
resp = &types.ArticleSecuritySearchResponse{
List: list,
Total: total,
}
return
}
func NewDomainArticleSecurity(item types.ArticleSecurityItem) *domain.ArticleSecurity {
return &domain.ArticleSecurity{}
}
func NewTypesArticleSecurity(item *domain.ArticleSecurity, reviewer *domain.User) types.ArticleSecurityItem {
result := types.ArticleSecurityItem{
Id: item.Id,
Content: types.ContentDetailItem{
Id: item.ContentId,
Type: item.ContentType,
},
ContentKeyWords: strings.Join(item.ContentKeyWords, ","),
Label: item.Label,
Prob: item.Prob,
Suggest: describeSuggest(item.Suggest),
Author: item.AuthorName,
ReviewAt: item.CreatedAt,
ReviewStatus: item.ReviewStatus,
ReleaseAt: item.CreatedAt,
Reviewer: "",
}
if reviewer != nil {
result.Reviewer = reviewer.Name
}
for _, detail := range item.Detail.Detail {
if detail.Label.String() == "0" {
continue
}
result.CheckList = append(result.CheckList, types.CheckDetailItem{
Label: detail.Label.String(),
Prob: detail.Prob,
Suggest: describeSuggest(detail.Suggest),
})
}
return result
}
func describeContentType(t int) string {
if t == domain.TypeArticle {
return "文本-帖子"
}
if t == domain.TypeComment {
return "文本-评论"
}
return ""
}
func describeSuggest(s string) string {
if s == "risk" {
return "风险"
}
if s == "pass" {
return "通过"
}
if s == "review" {
return "人工审核"
}
return ""
}
... ...
package template
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 MiniArticleTemplateClassSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateClassSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateClassSearchLogic {
return &MiniArticleTemplateClassSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateClassSearchLogic) MiniArticleTemplateClassSearch(req *types.ArticleTemplateClassSearchRequest) (resp *types.ArticleTemplateClassSearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleTemplate
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
// 企业有的类目
queryOptions := domain.NewQueryOptions().WithKV("name", req.Name).
MustWithKV("companyId", userToken.CompanyId)
_, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions)
class := domain.Values(dms, func(item *domain.ArticleTemplate) string {
return item.TemplateClass
})
// 个人有的类目
queryOptions = domain.NewQueryOptions().WithKV("name", req.Name).
MustWithKV("userId", user.Id)
_, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions)
class = append(class, domain.Values(dms, func(item *domain.ArticleTemplate) string {
return item.TemplateClass
})...)
class = lo.Uniq(class)
resp = &types.ArticleTemplateClassSearchResponse{
Total: int64(len(class)),
}
lo.ForEach(class, func(item string, index int) {
resp.List = append(resp.List, types.ArticleTemplateClassItem{
Name: item,
})
})
return
}
... ...
package template
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"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniArticleTemplateDeleteLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateDeleteLogic {
return &MiniArticleTemplateDeleteLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateDeleteLogic) MiniArticleTemplateDelete(req *types.ArticleTemplateDeleteRequest) (resp *types.ArticleTemplateDeleteResponse, err error) {
logic := NewSystemArticleTemplateDeleteLogic(l.ctx, l.svcCtx)
return logic.SystemArticleTemplateDelete(req)
}
... ...
package template
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"
"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 MiniArticleTemplateSaveLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSaveLogic {
return &MiniArticleTemplateSaveLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateSaveLogic) MiniArticleTemplateSave(req *types.ArticleTemplateSaveRequest) (resp *types.ArticleTemplateSaveResponse, err error) {
var (
dm *domain.ArticleTemplate
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
user *domain.User
conn = l.svcCtx.DefaultDBConn()
)
// 唯一判断
// 获取当前用户信息
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
dm = NewDomainArticleTemplate(req.ArticleTemplate)
dm.CompanyId = 0
dm.Operator = domain.Operator{
Id: userToken.UserId,
Name: user.Name,
Type: domain.OperatorTypeUser,
}
if req.BelongTo == int(domain.BelongToCompany) {
dm.BelongTo = domain.BelongToCompany
dm.CompanyId = user.CompanyId
} else {
dm.BelongTo = domain.BelongToIndividual
dm.UserId = userToken.UserId
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
dm, err = l.svcCtx.ArticleTemplateRepository.Insert(l.ctx, conn, dm)
return err
}, true); err != nil {
return nil, xerr.NewErrMsg("保存失败")
}
resp = &types.ArticleTemplateSaveResponse{}
return
}
... ...
package template
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 MiniArticleTemplateSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSearchLogic {
return &MiniArticleTemplateSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateSearchLogic) MiniArticleTemplateSearch(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
conn = l.svcCtx.DefaultDBConn()
user *domain.User
)
if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil {
return nil, xerr.NewErrMsgErr("用户不存在", err)
}
req.CompanyId = user.CompanyId
logic := NewSystemArticleTemplateSearchLogic(l.ctx, l.svcCtx)
resp, err = logic.SystemArticleTemplateSearch(req)
if err != nil {
return nil, err
}
// 过滤可见性
list := make([]types.ArticleTemplateItem, 0)
lo.ForEach(resp.List, func(item types.ArticleTemplateItem, index int) {
if item.TargetWhoRead == int(domain.ArticleTemplateLimit) {
if !lo.Contains(item.WhoRead, user.Id) {
return
}
}
list = append(list, item)
})
resp.List = list
resp.Total = int64(len(list))
return
}
... ...
package template
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"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 MiniArticleTemplateSearchMineLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateSearchMineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSearchMineLogic {
return &MiniArticleTemplateSearchMineLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateSearchMineLogic) MiniArticleTemplateSearchMine(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) {
var (
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
req.UserId = userToken.UserId
logic := NewSystemArticleTemplateSearchLogic(l.ctx, l.svcCtx)
return logic.SystemArticleTemplateSearch(req)
}
... ...
package template
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"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniArticleTemplateUpdateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniArticleTemplateUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateUpdateLogic {
return &MiniArticleTemplateUpdateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniArticleTemplateUpdateLogic) MiniArticleTemplateUpdate(req *types.ArticleTemplateUpdateRequest) (resp *types.ArticleTemplateUpdateResponse, err error) {
logic := NewSystemArticleTemplateUpdateLogic(l.ctx, l.svcCtx)
return logic.SystemArticleTemplateUpdate(req)
}
... ...
package template
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/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 SystemArticleTemplateBatchDeleteLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateBatchDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateBatchDeleteLogic {
return &SystemArticleTemplateBatchDeleteLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateBatchDeleteLogic) SystemArticleTemplateBatchDelete(req *types.ArticleTemplateBatchDeleteRequest) (resp *types.ArticleTemplateBatchResponse, err error) {
var (
dm *domain.ArticleTemplate
)
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
for _, id := range req.Ids {
if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, int64(id)); err != nil {
return xerr.NewErrMsgErr("不存在", err)
}
if dm.TemplateClass == domain.DefaultTemplateClass {
return xerr.NewErrMsgErr("默认模板不可删除", nil)
}
if dm, err = l.svcCtx.ArticleTemplateRepository.Delete(l.ctx, conn, dm); err != nil {
return err
}
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("移除失败", err)
}
resp = &types.ArticleTemplateBatchResponse{}
return
}
... ...
package template
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/contextdata"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemArticleTemplateClassSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateClassSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateClassSearchLogic {
return &SystemArticleTemplateClassSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateClassSearchLogic) SystemArticleTemplateClassSearch(req *types.ArticleTemplateClassSearchRequest) (resp *types.ArticleTemplateClassSearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleTemplate
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
queryOptions := domain.NewQueryOptions()
queryOptions.WithKV("name", req.Name).
MustWithKV("companyId", userToken.CompanyId)
_, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions)
class := lo.Uniq(domain.Values(dms, func(item *domain.ArticleTemplate) string {
return item.TemplateClass
}))
resp = &types.ArticleTemplateClassSearchResponse{
Total: int64(len(class)),
}
lo.ForEach(class, func(item string, index int) {
resp.List = append(resp.List, types.ArticleTemplateClassItem{
Name: item,
})
})
return
}
... ...
package template
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/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 SystemArticleTemplateDeleteLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateDeleteLogic {
return &SystemArticleTemplateDeleteLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateDeleteLogic) SystemArticleTemplateDelete(req *types.ArticleTemplateDeleteRequest) (resp *types.ArticleTemplateDeleteResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleTemplate
)
if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("不存在", err)
}
if dm.TemplateClass == domain.DefaultTemplateClass {
return nil, xerr.NewErrMsgErr("默认模板不可删除", nil)
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
if dm, err = l.svcCtx.ArticleTemplateRepository.Delete(l.ctx, conn, dm); err != nil {
return err
}
return nil
}, true); err != nil {
return nil, xerr.NewErrMsgErr("移除失败", err)
}
resp = &types.ArticleTemplateDeleteResponse{}
return
}
... ...
package template
import (
"context"
"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 SystemArticleTemplateGetLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateGetLogic {
return &SystemArticleTemplateGetLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateGetLogic) SystemArticleTemplateGet(req *types.ArticleTemplateGetRequest) (resp *types.ArticleTemplateGetResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleTemplate
userMap = make(map[int64]*domain.User)
)
// 货号唯一
if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("不存在", err)
}
item := NewTypesArticleTemplate(dm)
for _, id := range dm.WhoRead {
if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil {
item.WhoReadInfo = append(item.WhoReadInfo, types.TargetUser{
Id: user.Id,
Name: user.Name,
})
}
}
for _, id := range dm.WhoReview {
if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil {
item.WhoReviewInfo = append(item.WhoReviewInfo, types.TargetUser{
Id: user.Id,
Name: user.Name,
})
}
}
resp = &types.ArticleTemplateGetResponse{
ArticleTemplate: item,
}
return
}
... ...
package template
import (
"context"
"github.com/google/uuid"
"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 SystemArticleTemplateSaveLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateSaveLogic {
return &SystemArticleTemplateSaveLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateSaveLogic) SystemArticleTemplateSave(req *types.ArticleTemplateSaveRequest) (resp *types.ArticleTemplateSaveResponse, err error) {
var (
dm *domain.ArticleTemplate
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
// 唯一判断
// 获取当前用户信息
userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken})
if err != nil {
return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err)
}
dm = NewDomainArticleTemplate(req.ArticleTemplate)
dm.CompanyId = userToken.CompanyId
dm.UserId = 0
dm.BelongTo = domain.BelongToCompany
dm.Operator = domain.Operator{
Id: userToken.UserId,
Name: userMe.User.NickName,
Type: domain.OperatorTypeAdmin,
}
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
dm, err = l.svcCtx.ArticleTemplateRepository.Insert(l.ctx, conn, dm)
return err
}, true); err != nil {
return nil, xerr.NewErrMsg("保存失败")
}
resp = &types.ArticleTemplateSaveResponse{}
return
}
func NewDomainArticleTemplate(item types.ArticleTemplateItem) *domain.ArticleTemplate {
var paragraphs = make([]domain.Paragraph, 0)
lo.ForEach(item.Paragraphs, func(p types.Paragraph, index int) {
paragraphs = append(paragraphs, NewDomainParagraph(p))
})
return &domain.ArticleTemplate{
Name: item.Name,
TemplateClass: item.TemplateClass,
Paragraphs: paragraphs,
Icon: item.Icon,
TargetWhoRead: domain.ArticleTemplateTarget(item.TargetWhoRead),
TargetWhoReview: domain.ArticleTemplateTarget(item.TargetWhoReview),
WhoRead: item.WhoRead,
WhoReview: item.WhoReview,
Sort: 1,
}
}
func NewTypesArticleTemplate(item *domain.ArticleTemplate) types.ArticleTemplateItem {
var paragraphs = make([]types.Paragraph, 0)
lo.ForEach(item.Paragraphs, func(p domain.Paragraph, index int) {
paragraphs = append(paragraphs, NewTypesParagraph(p))
})
// 目前固定,后期有需要添加描述字段
var description string
if item.TemplateClass == domain.DefaultTemplateClass {
if item.Name == "演绎式" {
description = "从分析现象开始,查找发生原因,找出解决方案"
} else if item.Name == "归纳式" {
description = "从个别事务中概括出一般性概念、原则或结论"
}
}
return types.ArticleTemplateItem{
Id: item.Id,
Name: item.Name,
Description: description,
TemplateClass: item.TemplateClass,
Paragraphs: paragraphs,
Icon: item.Icon,
TargetWhoRead: int(item.TargetWhoRead),
TargetWhoReview: int(item.TargetWhoReview),
WhoRead: item.WhoRead,
WhoReview: item.WhoReview,
Operator: item.Operator.Name,
WhoReadInfo: make([]types.TargetUser, 0),
WhoReviewInfo: make([]types.TargetUser, 0),
UpdatedAt: item.UpdatedAt,
}
}
func NewDomainParagraph(item types.Paragraph) domain.Paragraph {
idGen, _ := uuid.NewUUID()
return domain.Paragraph{
ID: idGen.String(),
Title: item.Title,
Prompt: item.Prompt,
Required: item.Required,
Type: item.Type,
}
}
func NewTypesParagraph(item domain.Paragraph) types.Paragraph {
return types.Paragraph{
ID: item.ID,
Title: item.Title,
Prompt: item.Prompt,
Required: item.Required,
Type: item.Type,
}
}
... ...
package template
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type SystemArticleTemplateSearchLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateSearchLogic {
return &SystemArticleTemplateSearchLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateSearchLogic) SystemArticleTemplateSearch(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleTemplate
total int64
userMap = make(map[int64]*domain.User)
)
queryOptions := domain.NewQueryOptions()
if req.Page > 0 && req.Size > 0 {
queryOptions.WithOffsetLimit(req.Page, req.Size)
}
queryOptions.WithKV("name", req.Name).
WithKV("templateClass", req.TemplateClass).
WithKV("companyId", req.CompanyId).
WithKV("userId", req.UserId).
WithKV("targetUser", req.TargetUser)
if req.Target != nil {
queryOptions.MustWithKV("target", *req.Target)
}
total, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions)
list := make([]types.ArticleTemplateItem, 0)
for i := range dms {
item := NewTypesArticleTemplate(dms[i])
for _, id := range dms[i].WhoRead {
if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil {
item.WhoReadInfo = append(item.WhoReadInfo, types.TargetUser{
Id: user.Id,
Name: user.Name,
})
}
}
for _, id := range dms[i].WhoReview {
if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil {
item.WhoReviewInfo = append(item.WhoReviewInfo, types.TargetUser{
Id: user.Id,
Name: user.Name,
})
}
}
list = append(list, item)
}
resp = &types.ArticleTemplateSearchResponse{
List: list,
Total: total,
}
return
}
... ...
package template
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/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 SystemArticleTemplateUpdateLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewSystemArticleTemplateUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateUpdateLogic {
return &SystemArticleTemplateUpdateLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *SystemArticleTemplateUpdateLogic) SystemArticleTemplateUpdate(req *types.ArticleTemplateUpdateRequest) (resp *types.ArticleTemplateUpdateResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleTemplate
)
if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil {
return nil, xerr.NewErrMsgErr("不存在", err)
}
// 不可编辑判断
// 赋值
item := req.ArticleTemplate
var paragraphs = make([]domain.Paragraph, 0)
lo.ForEach(item.Paragraphs, func(p types.Paragraph, index int) {
paragraphs = append(paragraphs, NewDomainParagraph(p))
})
dm.Name = item.Name
dm.TemplateClass = item.TemplateClass
dm.Paragraphs = paragraphs
dm.Icon = item.Icon
dm.TargetWhoRead = domain.ArticleTemplateTarget(item.TargetWhoRead)
dm.TargetWhoReview = domain.ArticleTemplateTarget(item.TargetWhoReview)
dm.WhoRead = item.WhoRead
dm.WhoReview = item.WhoReview
// 更新
if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
dm, err = l.svcCtx.ArticleTemplateRepository.UpdateWithVersion(l.ctx, conn, dm)
return err
}, true); err != nil {
return nil, xerr.NewErrMsg("更新失败")
}
resp = &types.ArticleTemplateUpdateResponse{}
return
}
... ...
... ... @@ -62,8 +62,9 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
Title: item.Title,
Summary: item.Summary,
Time: item.CreatedAt,
Images: make([]string, 0),
Images: item.GetImages(),
ReadFlag: false,
Cover: item.GetCover(),
}
if author, _ := domain.LazyLoad(userMap, l.ctx, conn, item.AuthorId, l.svcCtx.UserRepository.FindOne); author != nil {
newsItem.Author = types.UserItem{
... ... @@ -72,9 +73,6 @@ func (l *MiniUserNewsLogic) MiniUserNews(req *types.MiniUserNewsRequest) (resp *
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
}
... ...