作者 yangfu

feat: 内容模板

正在显示 54 个修改的文件 包含 3176 行增加167 行删除
... ... @@ -11,4 +11,5 @@ import "core/article.api"
import "core/role.api"
import "core/department.api"
import "core/article_category.api"
import "core/article_security.api"
\ No newline at end of file
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": "公司搜索(公开的)",
... ... @@ -2968,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": "公司职位搜索",
... ... @@ -4094,7 +4474,8 @@
"description": " 发布人"
},
"releaseAt": {
"type": "string",
"type": "integer",
"format": "int64",
"description": " 发布时间"
},
"reviewStatus": {
... ... @@ -4162,35 +4543,207 @@
},
"authorName": {
"type": "string",
"description": " 作者名称"
},
"beginTime": {
"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": " 对应的图标"
},
"tagName": {
"type": "string",
"description": " 标签名称"
},
"tagRemark": {
"type": "string",
"description": " 标签备注"
},
"totalArticle": {
"type": "integer",
"format": "int32",
"description": " 总的文章数量"
},
"readArticle": {
"type": "integer",
"format": "int32",
"description": " 已读的标签数量"
},
"sortBy": {
"type": "integer",
"format": "int32",
"description": " 排序"
}
},
"title": "ArticleTagCount",
"required": [
"tagCategory",
"tagId",
"tagImage",
"tagName",
"tagRemark",
"totalArticle",
"readArticle",
"sortBy"
]
},
"ArticleTagGroup": {
"type": "object",
"properties": {
"category": {
"type": "string"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagItem"
}
}
},
"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": "int64",
"description": " 开始时间"
"format": "int32"
},
"endTime": {
"size": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
"format": "int32"
},
"name": {
"type": "string",
"description": " 模板名称"
}
},
"title": "ArticleSecuritySearchRequest",
"required": [
"suggest",
"contentType",
"authorName",
"beginTime",
"endTime"
]
"title": "ArticleTemplateClassSearchRequest"
},
"ArticleSecuritySearchResponse": {
"ArticleTemplateClassSearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSecurityItem"
"$ref": "#/definitions/ArticleTemplateClassItem"
}
},
"total": {
... ... @@ -4198,113 +4751,227 @@
"format": "int64"
}
},
"title": "ArticleSecuritySearchResponse",
"title": "ArticleTemplateClassSearchResponse",
"required": [
"list",
"total"
]
},
"ArticleTagCount": {
"ArticleTemplateDeleteRequest": {
"type": "object",
"properties": {
"tagCategory": {
"type": "string",
"description": " 标签分组"
},
"tagId": {
"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": " 标签id"
"description": " 唯一标识"
},
"tagImage": {
"name": {
"type": "string",
"description": " 对应的图标"
"description": " 模板名称"
},
"tagName": {
"templateClass": {
"type": "string",
"description": " 标签名称"
"description": " 模板分类"
},
"tagRemark": {
"paragraphs": {
"type": "array",
"items": {
"$ref": "#/definitions/Paragraph"
},
"description": " 段落列表"
},
"icon": {
"type": "string",
"description": " 标签备注"
"description": " 图标地址"
},
"totalArticle": {
"targetWhoRead": {
"type": "integer",
"format": "int32",
"description": " 总的文章数量"
"description": " 分发方式 0 分发给所有人 1 分发给指定的人"
},
"readArticle": {
"targetWhoReview": {
"type": "integer",
"format": "int32",
"description": " 已读的标签数量"
"description": " 分发方式 0 分发给所有人 1 分发给指定的人"
},
"sortBy": {
"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": "int32",
"description": " 排序"
"format": "int64",
"description": " 更新时间戳"
}
},
"title": "ArticleTagCount",
"title": "ArticleTemplateItem",
"required": [
"tagCategory",
"tagId",
"tagImage",
"tagName",
"tagRemark",
"totalArticle",
"readArticle",
"sortBy"
"name",
"templateClass",
"paragraphs",
""
]
},
"ArticleTagGroup": {
"ArticleTemplateSaveRequest": {
"type": "object",
"properties": {
"category": {
"type": "string"
"AccessToken": {
"type": "string",
"description": " 授权token"
},
"tags": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTagItem"
}
"item": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"title": "ArticleTagGroup",
"title": "ArticleTemplateSaveRequest",
"required": [
"category",
"tags"
"x-mmm-accesstoken",
"item"
]
},
"ArticleTagItem": {
"ArticleTemplateSaveResponse": {
"type": "object",
"title": "ArticleTemplateSaveResponse"
},
"ArticleTemplateSearchRequest": {
"type": "object",
"properties": {
"id": {
"page": {
"type": "integer",
"format": "int64"
"format": "int32"
},
"category": {
"type": "string"
"size": {
"type": "integer",
"format": "int32"
},
"name": {
"type": "string"
"type": "string",
"description": " 模板名称"
},
"image": {
"type": "string"
"templateClass": {
"type": "string",
"description": " 模板分类"
},
"sortBy": {
"target": {
"$ref": "#/definitions/int",
"description": " 目标 0 全员 1 指定人"
}
},
"title": "ArticleTemplateSearchRequest"
},
"ArticleTemplateSearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"total": {
"type": "integer",
"format": "int32"
"format": "int64"
}
},
"title": "ArticleTagItem",
"title": "ArticleTemplateSearchResponse",
"required": [
"list",
"total"
]
},
"ArticleTemplateUpdateRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"item": {
"$ref": "#/definitions/ArticleTemplateItem"
}
},
"title": "ArticleTemplateUpdateRequest",
"required": [
"id",
"category",
"name",
"image",
"sortBy"
"item"
]
},
"ArticleTemplateUpdateResponse": {
"type": "object",
"title": "ArticleTemplateUpdateResponse"
},
"Auth": {
"type": "object",
"properties": {
... ... @@ -7716,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": {
... ... @@ -11304,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: 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 指定人
// 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"` // 模板名称
TemplateClass string `json:"templateClass"` // 模板分类
Paragraphs []Paragraph `json:"paragraphs"` // 段落列表
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"` //文章的文本内容
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"`
... ... @@ -81,6 +83,9 @@ type (
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Images []string `json:"images"` // 照片列表
ParagraphType int `json:"paragraphType"` // 段落类型 0:无样式 1:模板文本 2:模板图片
ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板
}
)
... ... @@ -261,6 +266,8 @@ type (
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
MiniArticleDraftCreateResponse {
... ... @@ -282,6 +289,8 @@ type (
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落
}
MiniArticleDraftUpdateResponse {
... ... @@ -519,6 +528,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
... ...
... ... @@ -13,6 +13,7 @@ import (
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"
... ... @@ -835,4 +836,89 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
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 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)
}
}
... ...
... ... @@ -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{
... ...
... ... @@ -129,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 {
... ...
... ... @@ -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"
... ... @@ -102,10 +103,13 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
for _, val := range sortBy {
articleSection = append(articleSection, types.ArticleSection{
Id: val.Id,
Content: val.Content,
SortBy: val.SortBy,
TotalComment: val.TotalComment,
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{
... ...
... ... @@ -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)
... ...
... ... @@ -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
... ... @@ -296,17 +298,54 @@ 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),
}
articleSections = append(articleSections, &section)
sortBy++
... ...
... ... @@ -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 {
... ... @@ -327,11 +331,14 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq
continue
}
section := domain.ArticleSection{
CompanyId: article.CompanyId,
Version: article.Version,
ArticleId: article.Id,
Content: value,
SortBy: sortBy,
CompanyId: article.CompanyId,
Version: article.Version,
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
... ...
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,
}
}
... ...
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: 2,
}
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, 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 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: 1,
}
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,
}
}
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))
})
return types.ArticleTemplateItem{
Id: item.Id,
Name: item.Name,
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)
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
}
... ...
... ... @@ -37,6 +37,7 @@ type ServiceContext struct {
ArticleAndTagRepository domain.ArticleAndTagRepository
ArticleDraftOperationRepository domain.ArticleDraftOperationRepository
ArticleSecurityRepository domain.ArticleSecurityRepository
ArticleTemplateRepository domain.ArticleTemplateRepository
CompanyRepository domain.CompanyRepository
DepartmentRepository domain.DepartmentRepository
... ... @@ -96,6 +97,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)),
ArticleDraftOperationRepository: repository.NewArticleDraftOperationRepository(cache.NewCachedRepository(mlCache)),
ArticleSecurityRepository: repository.NewArticleSecurityRepository(cache.NewCachedRepository(mlCache)),
ArticleTemplateRepository: repository.NewArticleTemplateRepository(cache.NewCachedRepository(mlCache)),
CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)),
DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)),
... ...
... ... @@ -958,14 +958,15 @@ type Operator struct {
}
type MiniArticleCreateRequest struct {
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
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文本
Title string `json:"title"` //标题
Section []string `json:"section"` //文章的文本内容
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"` // 段落
}
type MiniArticleCreateResponse struct {
... ... @@ -1002,10 +1003,13 @@ type MiniArticleGetResponse struct {
}
type ArticleSection struct {
Id int64 `json:"id"` //段落id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Id int64 `json:"id"` //段落id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Images []string `json:"images"` // 照片列表
ParagraphType int `json:"paragraphType"` // 段落类型 0:无样式 1:模板文本 2:模板图片
ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板
}
type MiniArticleSearchMeRequest struct {
... ... @@ -1156,16 +1160,17 @@ type MiniArticleMarkUserReadResponse struct {
}
type MiniArticleDraftCreateRequest struct {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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文本
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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"` // 段落
}
type MiniArticleDraftCreateResponse struct {
... ... @@ -1173,17 +1178,18 @@ type MiniArticleDraftCreateResponse struct {
}
type MiniArticleDraftUpdateRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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文本
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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"` // 段落
}
type MiniArticleDraftUpdateResponse struct {
... ... @@ -1400,6 +1406,7 @@ type SystemArticleCreateRequest struct {
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"` // 段落
}
type SystemArticleCreateResponse struct {
... ... @@ -1908,3 +1915,105 @@ type ContentDetailItem struct {
Type int `json:"type"` // 内容类型 (1:文章 2:评论)
Text string `json:"text"` // 内容文本
}
type ArticleTemplateGetRequest struct {
Id int64 `path:"id"`
}
type ArticleTemplateGetResponse struct {
ArticleTemplate ArticleTemplateItem `json:"item"`
}
type ArticleTemplateSaveRequest struct {
AccessToken string `header:"x-mmm-accesstoken"` // 授权token
ArticleTemplate ArticleTemplateItem `json:"item"`
BelongTo int `json:"belongTo,optional,default=2"` // 模板属于: 1:企业 、2:个人
}
type ArticleTemplateSaveResponse struct {
}
type ArticleTemplateDeleteRequest struct {
Id int64 `path:"id"`
}
type ArticleTemplateDeleteResponse struct {
}
type ArticleTemplateBatchDeleteRequest struct {
Ids []int64 `json:"ids"`
}
type ArticleTemplateBatchResponse struct {
}
type ArticleTemplateUpdateRequest struct {
Id int64 `path:"id"`
ArticleTemplate ArticleTemplateItem `json:"item"`
}
type ArticleTemplateUpdateResponse struct {
}
type 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 指定人
CompanyId int64 `json:",optional"` // 属于企业时有值
UserId int64 `json:",optional"` // 属于个人时有值
}
type ArticleTemplateSearchResponse struct {
List []ArticleTemplateItem `json:"list"`
Total int64 `json:"total"`
}
type 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"` // 属于个人时有值
}
type ArticleTemplateClassSearchResponse struct {
List []ArticleTemplateClassItem `json:"list"`
Total int64 `json:"total"`
}
type ArticleTemplateClassItem struct {
Name string `json:"name"` // 名称
}
type ArticleTemplateItem struct {
Id int64 `json:"id,optional"` // 唯一标识
Name string `json:"name"` // 模板名称
TemplateClass string `json:"templateClass"` // 模板分类
Paragraphs []Paragraph `json:"paragraphs"` // 段落列表
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"` // 更新时间戳
}
type 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"` // 图片地址列表
}
type TargetUser struct {
Id int64 `json:"id"`
Name string `json:"name"`
}
... ...
syntax = "v1"
info(
title: "xx实例"
desc: "xx实例"
author: "author"
email: "email"
version: "v1"
)
@server(
prefix: article_template/v1
group: article_template
jwt: JwtAuth
)
service Core {
@doc "详情"
@handler article_templateGet
get /article_template/:id (ArticleTemplateGetRequest) returns (ArticleTemplateGetResponse)
@doc "保存"
@handler article_templateSave
post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse)
@doc "删除"
@handler article_templateDelete
delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse)
@doc "更新"
@handler article_templateUpdate
put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse)
@doc "搜索"
@handler article_templateSearch
post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse)
}
type (
ArticleTemplateGetRequest {
Id int64 `path:"id"`
}
ArticleTemplateGetResponse struct{
ArticleTemplate ArticleTemplateItem `json:"article_template"`
}
ArticleTemplateSaveRequest struct{
ArticleTemplate ArticleTemplateItem `json:"article_template"`
}
ArticleTemplateSaveResponse struct{}
ArticleTemplateDeleteRequest struct{
Id int64 `path:"id"`
}
ArticleTemplateDeleteResponse struct{}
ArticleTemplateUpdateRequest struct{
Id int64 `path:"id"`
ArticleTemplate ArticleTemplateItem `json:"article_template"`
}
ArticleTemplateUpdateResponse struct{}
ArticleTemplateSearchRequest struct{
Page int `json:"page"`
Size int `json:"size"`
}
ArticleTemplateSearchResponse{
List []ArticleTemplateItem `json:"list"`
Total int64 `json:"total"`
}
ArticleTemplateItem struct{
}
)
// logic CRUD
// Save
//var (
// conn = l.svcCtx.DefaultDBConn()
// dm *domain.ArticleTemplate
//)
//// 唯一判断
//dm = NewDomainArticleTemplate(req.ArticleTemplate)
//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 {
// return &domain.ArticleTemplate{
// }
//}
//
//func NewTypesArticleTemplate(item *domain.ArticleTemplate) types.ArticleTemplateItem {
// return types.ArticleTemplateItem{
// Id: item.Id,
// }
//}
// Get
//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)
//}
//resp = &types.ArticleTemplateGetResponse{
// ArticleTemplate: NewTypesArticleTemplate(dm),
//}
//return
// Delete
//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 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)
//}
//return
// Search
//var (
// conn = l.svcCtx.DefaultDBConn()
// dms []*domain.ArticleTemplate
// total int64
//)
//
//queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
// WithKV("", "")
//total, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions)
//list := make([]types.ArticleTemplateItem, 0)
//for i := range dms {
// list = append(list, NewTypesArticleTemplate(dms[i]))
//}
//resp = &types.ArticleTemplateSearchResponse{
// List: list,
// Total: total,
//}
//return
// Update
//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 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
... ...
syntax = "proto3";
option go_package ="./pb";
package pb;
message ArticleTemplateGetReq {
int64 Id = 1;
}
message ArticleTemplateGetResp{
ArticleTemplateItem User = 1;
}
message ArticleTemplateSaveReq {
}
message ArticleTemplateSaveResp{
}
message ArticleTemplateDeleteReq {
int64 Id = 1;
}
message ArticleTemplateDeleteResp{
}
message ArticleTemplateUpdateReq {
int64 Id = 1;
}
message ArticleTemplateUpdateResp{
}
message ArticleTemplateSearchReq {
int64 PageNumber = 1;
int64 PageSize = 2;
}
message ArticleTemplateSearchResp{
repeated ArticleTemplateItem List =1;
int64 Total =2;
}
message ArticleTemplateItem {
}
service ArticleTemplateService {
rpc ArticleTemplateGet(ArticleTemplateGetReq) returns(ArticleTemplateGetResp);
rpc ArticleTemplateSave(ArticleTemplateSaveReq) returns(ArticleTemplateSaveResp);
rpc ArticleTemplateDelete(ArticleTemplateDeleteReq) returns(ArticleTemplateDeleteResp);
rpc ArticleTemplateUpdate(ArticleTemplateUpdateReq) returns(ArticleTemplateUpdateResp);
rpc ArticleTemplateSearch(ArticleTemplateSearchReq) returns(ArticleTemplateSearchResp);
}
... ...
... ... @@ -32,6 +32,7 @@ func Migrate(db *gorm.DB) {
//&models.ArticleDraftOperation{},
//&models.ArticleCategory{},
&models.ArticleSecurity{},
&models.ArticleTemplate{},
}
db.AutoMigrate(modelsList...)
... ...
... ... @@ -26,6 +26,8 @@ type ArticleDraft struct {
WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人
Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"`
}
func (m *ArticleDraft) TableName() string {
... ...
... ... @@ -10,17 +10,20 @@ import (
)
type ArticleSection struct {
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
ArticleId int64 // 文章id
Content string // 文本内容
SortBy int // 排序
TotalComment int // 评论的数量
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
ArticleId int64 // 文章id
Content string // 文本内容
SortBy int // 排序
TotalComment int // 评论的数量
ParagraphType int
ParagraphTemplate domain.Paragraph `gorm:"type:jsonb;serializer:json"`
Images []string `gorm:"type:jsonb;serializer:json"`
}
func (m *ArticleSection) TableName() string {
... ...
package models
import (
"fmt"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
)
type ArticleTemplate struct {
Id int64 `json:",omitempty"` // 唯一标识
CompanyId int64 `json:",omitempty"` // 属于企业时有值
UserId int64 `json:",omitempty"` // 属于个人时有值
BelongTo int `json:",omitempty"` // 模板属于: 1:企业 、2:个人
TemplateClass string `json:",omitempty"` // 模板分类
Name string `json:",omitempty"` // 模板名称
Paragraphs []domain.Paragraph `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 段落列表
Icon string `json:",omitempty"` // 图标地址
TargetWhoRead int `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人
TargetWhoReview int `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人
WhoRead []int64 `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 谁可以看
WhoReview []int64 `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 查看、评论人
Operator domain.Operator `gorm:"type:jsonb;serializer:json" json:",omitempty"`
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
}
func (m *ArticleTemplate) TableName() string {
return "article_template"
}
func (m *ArticleTemplate) BeforeCreate(tx *gorm.DB) (err error) {
// m.CreatedAt = time.Now().Unix()
// m.UpdatedAt = time.Now().Unix()
return
}
func (m *ArticleTemplate) BeforeUpdate(tx *gorm.DB) (err error) {
// m.UpdatedAt = time.Now().Unix()
return
}
func (m *ArticleTemplate) CacheKeyFunc() string {
if m.Id == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
}
func (m *ArticleTemplate) CacheKeyFuncByObject(obj interface{}) string {
if v, ok := obj.(*ArticleTemplate); ok {
return v.CacheKeyFunc()
}
return ""
}
func (m *ArticleTemplate) CachePrimaryKeyFunc() string {
if len("") == 0 {
return ""
}
return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
}
... ...
... ... @@ -167,16 +167,19 @@ func (repository *ArticleSectionRepository) Find(ctx context.Context, conn trans
func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.ArticleSection) (*domain.ArticleSection, error) {
to := &domain.ArticleSection{
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
ArticleId: from.ArticleId,
Content: from.Content,
SortBy: from.SortBy,
TotalComment: from.TotalComment,
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
ArticleId: from.ArticleId,
Content: from.Content,
SortBy: from.SortBy,
TotalComment: from.TotalComment,
ParagraphType: from.ParagraphType,
ParagraphTemplate: from.ParagraphTemplate,
Images: from.Images,
}
// err := copier.Copy(to, from)
return to, nil
... ... @@ -184,16 +187,19 @@ func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.Arti
func (repository *ArticleSectionRepository) DomainModelToModel(from *domain.ArticleSection) (*models.ArticleSection, error) {
to := &models.ArticleSection{
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
ArticleId: from.ArticleId,
Content: from.Content,
SortBy: from.SortBy,
TotalComment: from.TotalComment,
Id: from.Id,
CompanyId: from.CompanyId,
CreatedAt: from.CreatedAt,
UpdatedAt: from.UpdatedAt,
DeletedAt: from.DeletedAt,
Version: from.Version,
ArticleId: from.ArticleId,
Content: from.Content,
SortBy: from.SortBy,
TotalComment: from.TotalComment,
ParagraphType: from.ParagraphType,
ParagraphTemplate: from.ParagraphTemplate,
Images: from.Images,
}
// err := copier.Copy(to, from)
return to, nil
... ...
package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
"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"
"gorm.io/gorm"
)
type ArticleTemplateRepository struct {
*cache.CachedRepository
}
func (repository *ArticleTemplateRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) {
var (
err error
m = &models.ArticleTemplate{}
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
if tx = tx.Model(m).Save(m); tx.Error != nil {
return nil, tx.Error
}
dm.Id = m.Id
return repository.ModelToDomainModel(m)
}
func (repository *ArticleTemplateRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) {
var (
err error
m *models.ArticleTemplate
tx = conn.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleTemplateRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) {
var (
err error
m *models.ArticleTemplate
tx = transaction.DB()
)
if m, err = repository.DomainModelToModel(dm); err != nil {
return nil, err
}
oldVersion := dm.Version
m.Version += 1
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m)
if tx.RowsAffected == 0 {
return nil, domain.ErrUpdateFail
}
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleTemplateRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) {
var (
tx = conn.DB()
m = &models.ArticleTemplate{Id: dm.Identify().(int64)}
)
queryFunc := func() (interface{}, error) {
tx = tx.Where("id = ?", m.Id).Delete(m)
return m, tx.Error
}
if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
return dm, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleTemplateRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleTemplate, error) {
var (
err error
tx = conn.DB()
m = new(models.ArticleTemplate)
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Where("id = ?", id).First(m)
if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
return nil, domain.ErrNotFound
}
return m, tx.Error
}
cacheModel := new(models.ArticleTemplate)
cacheModel.Id = id
if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
return nil, err
}
return repository.ModelToDomainModel(m)
}
func (repository *ArticleTemplateRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.ArticleTemplate, error) {
var (
tx = conn.DB()
ms []*models.ArticleTemplate
dms = make([]*domain.ArticleTemplate, 0)
total int64
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ? ", v)
}
if v, ok := queryOptions["userId"]; ok {
tx.Where("user_id = ? ", v)
}
if v, ok := queryOptions["name"]; ok {
tx.Where("name like ? ", fmt.Sprintf("%%%v%%", v))
}
if v, ok := queryOptions["templateClass"]; ok {
tx.Where("template_class = ? ", v)
}
if v, ok := queryOptions["target"]; ok {
tx.Where("target_who_read = ? ", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
return dms, nil
}
if _, err := repository.Query(queryFunc); err != nil {
return 0, nil, err
}
for _, item := range ms {
if dm, err := repository.ModelToDomainModel(item); err != nil {
return 0, dms, err
} else {
dms = append(dms, dm)
}
}
return total, dms, nil
}
func (repository *ArticleTemplateRepository) ModelToDomainModel(from *models.ArticleTemplate) (*domain.ArticleTemplate, error) {
to := &domain.ArticleTemplate{}
err := copier.Copy(to, from)
return to, err
}
func (repository *ArticleTemplateRepository) DomainModelToModel(from *domain.ArticleTemplate) (*models.ArticleTemplate, error) {
to := &models.ArticleTemplate{}
err := copier.Copy(to, from)
return to, err
}
func NewArticleTemplateRepository(cache *cache.CachedRepository) domain.ArticleTemplateRepository {
return &ArticleTemplateRepository{CachedRepository: cache}
}
... ...
... ... @@ -24,6 +24,8 @@ type ArticleDraft struct {
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本
Section []*ArticleSection `json:"section"` // 分段内容
}
type ArticleDraftRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error)
... ...
... ... @@ -8,16 +8,19 @@ import (
// 文章段落内容
type ArticleSection struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
ArticleId int64 `json:"articleId"` // 文章id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Id int64 `json:"id"`
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
DeletedAt int64 `json:"deletedAt,omitempty"`
Version int `json:"version,omitempty"`
ArticleId int64 `json:"articleId"` // 文章id
Content string `json:"content"` // 文本内容
SortBy int `json:"sortBy"` // 排序
TotalComment int `json:"totalComment"` // 评论的数量
Images []string `json:"images"` // 照片列表
ParagraphType int `json:"paragraphType"` // 段落类型 1:文本 2:图片
ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板
}
type ArticleSectionRepository interface {
... ...
package domain
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
type ArticleTemplate struct {
Id int64 `json:",omitempty"` // 唯一标识
CompanyId int64 `json:",omitempty"` // 属于企业时有值
UserId int64 `json:",omitempty"` // 属于个人时有值
BelongTo TemplateBelongToType `json:",omitempty"` // 模板属于: 1:企业 、2:个人
TemplateClass string `json:",omitempty"` // 模板分类
Name string `json:",omitempty"` // 模板名称
Paragraphs []Paragraph `json:",omitempty"` // 段落列表
Icon string `json:",omitempty"` // 图标地址
TargetWhoRead ArticleTemplateTarget `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人
TargetWhoReview ArticleTemplateTarget `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人
WhoRead []int64 `json:",omitempty"` // 谁可以看
WhoReview []int64 `json:",omitempty"` // 查看、评论人
Operator Operator `json:",omitempty"` // 操作人(企业时有值)
CreatedAt int64 `json:",omitempty"`
UpdatedAt int64 `json:",omitempty"`
DeletedAt int64 `json:",omitempty"`
Version int `json:",omitempty"`
}
type ArticleTemplateRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error)
Update(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error)
UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error)
Delete(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error)
FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTemplate, error)
Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleTemplate, error)
}
func (m *ArticleTemplate) Identify() interface{} {
if m.Id == 0 {
return nil
}
return m.Id
}
type Paragraph struct {
ID string `json:",omitempty"` // 唯一标识
Title string `json:",omitempty"` // 标题
Prompt string `json:",omitempty"` // 文本提示
Required bool `json:",omitempty"` // 必填
Type int `json:",omitempty"` // 段落类型 0:未使用模板 1:模板文本 2:模板图片
}
type TemplateBelongToType int
const (
// BelongToCompany 属于公司
BelongToCompany TemplateBelongToType = 1
// BelongToIndividual 属于个人
BelongToIndividual TemplateBelongToType = 2
)
type ArticleTemplateTarget int
const (
ArticleTemplateAll ArticleTarget = 0 //所有人
ArticleTemplateLimit ArticleTarget = 1 //指定的人
)
... ...
... ... @@ -45,8 +45,9 @@ type UserSimple struct {
CompanyId int64 `json:"companyId"`
}
// 运营操作人
// Operator 运营操作人
type Operator struct {
Id int64 `json:"id,string"` // 人员id
Name string `json:"name"` // 人员名字
Type int `json:"type"` // 1:系统管理员 2:个人
}
... ...
... ... @@ -67,4 +67,14 @@ CREATE TABLE `user_wechat`
CREATE TABLE `article_security` (
`id` int(0) NOT NULL COMMENT '唯一标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
CREATE TABLE `article_template` (
`id` int(0) NOT NULL COMMENT '唯一标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
CREATE TABLE `article_template` (
`id` int(0) NOT NULL COMMENT '唯一标识',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
\ No newline at end of file
... ...
alter table article_draft add column section jsonb;
alter table article_section add column paragraph_template jsonb;
alter table article_section add column paragraph_type int8;
alter table article_section add column images jsonb;
update article_section set paragraph_type = 0;
\ No newline at end of file
... ...