正在显示
78 个修改的文件
包含
3759 行增加
和
66 行删除
| @@ -10,3 +10,4 @@ import "core/article_type.api" | @@ -10,3 +10,4 @@ import "core/article_type.api" | ||
| 10 | import "core/article.api" | 10 | import "core/article.api" |
| 11 | import "core/role.api" | 11 | import "core/role.api" |
| 12 | import "core/department.api" | 12 | import "core/department.api" |
| 13 | +import "core/article_category.api" |
此 diff 太大无法显示。
| @@ -121,4 +121,40 @@ service Core { | @@ -121,4 +121,40 @@ service Core { | ||
| 121 | @doc "管理后台文章恢复" | 121 | @doc "管理后台文章恢复" |
| 122 | @handler SystemArticleRestore | 122 | @handler SystemArticleRestore |
| 123 | post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse) | 123 | post /article/restore (SystemArticleRestoreRequest) returns (SystemArticleRestoreResponse) |
| 124 | + | ||
| 125 | + @doc "管理后台删除文章" | ||
| 126 | + @handler SystemDeleteArticle | ||
| 127 | + delete /article (SystemArticleDeleteRequest) returns (SystemArticleDeleteResponse) | ||
| 128 | + | ||
| 129 | + @doc "管理后台新增文章" | ||
| 130 | + @handler SystemCreateArticle | ||
| 131 | + post /article (SystemArticleCreateRequest) returns (SystemArticleCreateResponse) | ||
| 132 | + | ||
| 133 | + @doc "管理后台新增草稿" | ||
| 134 | + @handler SystemCreateArticleDraft | ||
| 135 | + post /article/draft (SystemArticleDraftCreateRequest) returns (SystemArticleDraftCreateResponse) | ||
| 136 | + | ||
| 137 | + @doc "管理后台编辑草稿" | ||
| 138 | + @handler SystemUpdateArticleDraft | ||
| 139 | + put /article/draft (SystemArticleDraftUpdateRequest) returns (SystemArticleDraftUpdateResponse) | ||
| 140 | + | ||
| 141 | + @doc "管理后台草稿列表" | ||
| 142 | + @handler SystemSearchArticleDraft | ||
| 143 | + post /article/draft/search (SystemArticleDraftSearchRequest) returns (SystemArticleDraftSearchResponse) | ||
| 144 | + | ||
| 145 | + @doc "管理后台删除草稿" | ||
| 146 | + @handler SystemDeleteArticleDraft | ||
| 147 | + delete /article/draft (SystemArticleDraftDeleteRequest) returns (SystemArticleDraftDeleteResponse) | ||
| 148 | + | ||
| 149 | + @doc "管理后台获取草稿" | ||
| 150 | + @handler SystemGetArticleDraft | ||
| 151 | + get /article/draft/:id (SystemArticleDraftGetRequest) returns (SystemArticleDraftGetResponse) | ||
| 152 | + | ||
| 153 | + @doc "管理后台已删除列表" | ||
| 154 | + @handler SystemArticleSearchDeleted | ||
| 155 | + post /article/deleted/list (SystemArticleSearchDeletedRequest) returns (SystemArticleSearchDeletedResponse) | ||
| 156 | + | ||
| 157 | + @doc "管理后台文章删除恢复" | ||
| 158 | + @handler SystemRestoreArticleDeleted | ||
| 159 | + put /article/deleted/restore (SystemArticleDeletedRestoreRequest) returns (SystemArticleDeletedRestoreResponse) | ||
| 124 | } | 160 | } |
| 1 | +@server( | ||
| 2 | + prefix: v1/system | ||
| 3 | + group: tags | ||
| 4 | + middleware: LoginStatusCheck,LogRequest | ||
| 5 | + jwt: SystemAuth | ||
| 6 | +) | ||
| 7 | +service Core { | ||
| 8 | + @doc "标签分类详情" | ||
| 9 | + @handler articleCategoryGet | ||
| 10 | + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse) | ||
| 11 | + @doc "标签分类保存" | ||
| 12 | + @handler articleCategorySave | ||
| 13 | + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse) | ||
| 14 | + @doc "标签分类删除" | ||
| 15 | + @handler articleCategoryDelete | ||
| 16 | + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse) | ||
| 17 | + @doc "标签分类更新" | ||
| 18 | + @handler articleCategoryUpdate | ||
| 19 | + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse) | ||
| 20 | + @doc "标签分类搜索" | ||
| 21 | + @handler articleCategorySearch | ||
| 22 | + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse) | ||
| 23 | + @doc "标签分类下拉列表" | ||
| 24 | + @handler articleCategoryOptions | ||
| 25 | + get /article_category/options (CategoryOptionsRequest) returns (CategoryOptionsResponse) | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +@server( | ||
| 29 | + prefix: v1/system | ||
| 30 | + group: tags | ||
| 31 | +) | ||
| 32 | +service Core { | ||
| 33 | + @doc "标签分类初始化" | ||
| 34 | + @handler articleCategoryInit | ||
| 35 | + get /article_category/init | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +type ( | ||
| 39 | + ArticleCategoryGetRequest { | ||
| 40 | + Id int64 `path:"id"` | ||
| 41 | + } | ||
| 42 | + ArticleCategoryGetResponse struct{ | ||
| 43 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + ArticleCategorySaveRequest struct{ | ||
| 47 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 48 | + } | ||
| 49 | + ArticleCategorySaveResponse struct{} | ||
| 50 | + | ||
| 51 | + ArticleCategoryDeleteRequest struct{ | ||
| 52 | + Id int64 `path:"id"` | ||
| 53 | + } | ||
| 54 | + ArticleCategoryDeleteResponse struct{} | ||
| 55 | + | ||
| 56 | + ArticleCategoryUpdateRequest struct{ | ||
| 57 | + Id int64 `path:"id"` | ||
| 58 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 59 | + } | ||
| 60 | + ArticleCategoryUpdateResponse struct{} | ||
| 61 | + | ||
| 62 | + ArticleCategorySearchRequest struct{ | ||
| 63 | + Page int `json:"page"` | ||
| 64 | + Size int `json:"size"` | ||
| 65 | + } | ||
| 66 | + ArticleCategorySearchResponse{ | ||
| 67 | + List []ArticleCategoryItem `json:"list"` | ||
| 68 | + Total int64 `json:"total"` | ||
| 69 | + } | ||
| 70 | + ArticleCategoryItem struct{ | ||
| 71 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
| 72 | + CompanyId int64 `json:"companyId,optional,omitempty"` | ||
| 73 | + Name string `json:"name"` | ||
| 74 | + SortBy int `json:"sortBy,optional,omitempty"` // 排序 | ||
| 75 | + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | ||
| 76 | + Other string `json:"other,optional,omitempty"` // 其他备注说明 | ||
| 77 | + } | ||
| 78 | +) | ||
| 79 | + | ||
| 80 | +//标签下拉列表 | ||
| 81 | +type ( | ||
| 82 | + CategoryOptionsRequest { | ||
| 83 | + CompanyId int64 `path:",optional"` // 公司ID | ||
| 84 | + } | ||
| 85 | + CategoryOptionsResponse { | ||
| 86 | + Options []CategoryOptions `json:"options"` | ||
| 87 | + } | ||
| 88 | + CategoryOptions { | ||
| 89 | + Value int64 `json:"value"` // 分类ID | ||
| 90 | + Label string `json:"label"` // 分组名称 | ||
| 91 | + //Options []CategoryOptionValue `json:"options,omitempty"` | ||
| 92 | + } | ||
| 93 | + CategoryOptionValue { | ||
| 94 | + Label string `json:"label"` // 名称 | ||
| 95 | + Value int64 `json:"value"` // 分类ID | ||
| 96 | + } | ||
| 97 | +) |
| @@ -46,10 +46,11 @@ type ( | @@ -46,10 +46,11 @@ type ( | ||
| 46 | CompanyId int64 `json:",optional"` | 46 | CompanyId int64 `json:",optional"` |
| 47 | Image string `json:"image"` | 47 | Image string `json:"image"` |
| 48 | Name string `json:"name"` // 标签名称 | 48 | Name string `json:"name"` // 标签名称 |
| 49 | - Category string `json:"category"` // 标签分类 | 49 | + //Category string `json:"category"` // 标签分类 |
| 50 | Remark string `json:"remark,optional"` // 备注 | 50 | Remark string `json:"remark,optional"` // 备注 |
| 51 | Other string `json:"other,optional"` | 51 | Other string `json:"other,optional"` |
| 52 | SortBy int `json:"sortBy,optional"` //排序 | 52 | SortBy int `json:"sortBy,optional"` //排序 |
| 53 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | TagCreateResponse { | 56 | TagCreateResponse { |
| @@ -64,7 +65,8 @@ type ( | @@ -64,7 +65,8 @@ type ( | ||
| 64 | CompanyId int64 `json:",optional"` | 65 | CompanyId int64 `json:",optional"` |
| 65 | Image string `json:"image"` | 66 | Image string `json:"image"` |
| 66 | Name string `json:"name"` // 标签名称 | 67 | Name string `json:"name"` // 标签名称 |
| 67 | - Category string `json:"category"` // 标签分类 | 68 | + //Category string `json:"category"` // 标签分类 |
| 69 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
| 68 | Remark string `json:"remark,optional"` // 备注 | 70 | Remark string `json:"remark,optional"` // 备注 |
| 69 | Other string `json:"other,optional"` | 71 | Other string `json:"other,optional"` |
| 70 | SortBy int `json:"sortBy,optional"` // 排序 | 72 | SortBy int `json:"sortBy,optional"` // 排序 |
| @@ -86,6 +88,7 @@ type ( | @@ -86,6 +88,7 @@ type ( | ||
| 86 | Image string `json:"image"` | 88 | Image string `json:"image"` |
| 87 | Name string `json:"name"` // 标签名称 | 89 | Name string `json:"name"` // 标签名称 |
| 88 | Category string `json:"category"` // 标签分类 | 90 | Category string `json:"category"` // 标签分类 |
| 91 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
| 89 | Remark string `json:"remark"` // 备注 | 92 | Remark string `json:"remark"` // 备注 |
| 90 | Other string `json:"other"` | 93 | Other string `json:"other"` |
| 91 | SortBy int `json:"sortBy,optional"` // 排序 | 94 | SortBy int `json:"sortBy,optional"` // 排序 |
| @@ -99,7 +102,7 @@ type ( | @@ -99,7 +102,7 @@ type ( | ||
| 99 | Size int `json:"size"` | 102 | Size int `json:"size"` |
| 100 | CompanyId int64 `json:",optional"` | 103 | CompanyId int64 `json:",optional"` |
| 101 | TagName string `json:"tagName,optional"` | 104 | TagName string `json:"tagName,optional"` |
| 102 | - Category string `json:"category,optional"` | 105 | + CategoryId int64 `json:"categoryId,optional"` |
| 103 | Remark string `json:"remark,optional"` | 106 | Remark string `json:"remark,optional"` |
| 104 | } | 107 | } |
| 105 | TagListResponse { | 108 | TagListResponse { |
| @@ -111,9 +114,11 @@ type ( | @@ -111,9 +114,11 @@ type ( | ||
| 111 | Image string `json:"image"` | 114 | Image string `json:"image"` |
| 112 | Name string `json:"name"` // 标签名称 | 115 | Name string `json:"name"` // 标签名称 |
| 113 | Category string `json:"category"` // 标签分类 | 116 | Category string `json:"category"` // 标签分类 |
| 117 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
| 114 | Remark string `json:"remark"` // 备注 | 118 | Remark string `json:"remark"` // 备注 |
| 115 | CreatedAt int64 `json:"createdAt"` | 119 | CreatedAt int64 `json:"createdAt"` |
| 116 | SortBy int `json:"sortBy,optional"` // 排序 | 120 | SortBy int `json:"sortBy,optional"` // 排序 |
| 121 | + Removeable bool `json:"removeable,optional"` // 可删除 | ||
| 117 | } | 122 | } |
| 118 | ) | 123 | ) |
| 119 | 124 | ||
| @@ -137,7 +142,8 @@ type ( | @@ -137,7 +142,8 @@ type ( | ||
| 137 | Options []TagOptions `json:"options"` | 142 | Options []TagOptions `json:"options"` |
| 138 | } | 143 | } |
| 139 | TagOptions { | 144 | TagOptions { |
| 140 | - Label string `json:"label"` // 分组名称 | 145 | + Value int64 `json:"value"` // 分类ID |
| 146 | + Label string `json:"label"` // 分类名称 | ||
| 141 | Options []TagOptionValue `json:"options"` | 147 | Options []TagOptionValue `json:"options"` |
| 142 | } | 148 | } |
| 143 | TagOptionValue { | 149 | TagOptionValue { |
| @@ -25,6 +25,11 @@ type ArticleAuthor { | @@ -25,6 +25,11 @@ type ArticleAuthor { | ||
| 25 | Company string `json:"company"` // 公司 | 25 | Company string `json:"company"` // 公司 |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | +type Operator { | ||
| 29 | + Id int64 `json:"id,string"`// 人员id | ||
| 30 | + Name string `json:"name"` // 人员的名字 | ||
| 31 | +} | ||
| 32 | + | ||
| 28 | //小程序端创建发布文章 | 33 | //小程序端创建发布文章 |
| 29 | type ( | 34 | type ( |
| 30 | MiniArticleCreateRequest { | 35 | MiniArticleCreateRequest { |
| @@ -431,11 +436,14 @@ type ( | @@ -431,11 +436,14 @@ type ( | ||
| 431 | Author string `json:"author"` //发布人 | 436 | Author string `json:"author"` //发布人 |
| 432 | Images []string `json:"images"` //图片 | 437 | Images []string `json:"images"` //图片 |
| 433 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 438 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 439 | + UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期 | ||
| 434 | CountLove int `json:"countLove"` //点赞数量 | 440 | CountLove int `json:"countLove"` //点赞数量 |
| 435 | CountComment int `json:"countComment"` //评论数量 | 441 | CountComment int `json:"countComment"` //评论数量 |
| 436 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 442 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 437 | Tags []string `json:"tags"` //标签 | 443 | Tags []string `json:"tags"` //标签 |
| 438 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 444 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 445 | + Operator Operator `json:"operator"` //运营操作人 | ||
| 446 | + Source int `json:"source"` //来源[1用户发布、2运营发布] | ||
| 439 | } | 447 | } |
| 440 | ) | 448 | ) |
| 441 | // 管理后台编辑文章 | 449 | // 管理后台编辑文章 |
| @@ -469,6 +477,45 @@ type ( | @@ -469,6 +477,45 @@ type ( | ||
| 469 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 477 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 470 | } | 478 | } |
| 471 | ) | 479 | ) |
| 480 | +// 管理后台新增文章 | ||
| 481 | +type ( | ||
| 482 | + SystemArticleCreateRequest { | ||
| 483 | + Title string `json:"title"` //标题 | ||
| 484 | + Content string `json:"content"` //文章的文本内容 | ||
| 485 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 486 | + Images []string `json:"images,optional"` //图片 | ||
| 487 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 488 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 489 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 490 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 491 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 492 | + ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | ||
| 493 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 494 | + } | ||
| 495 | + SystemArticleCreateResponse { | ||
| 496 | + Id int64 `json:"id"` //id | ||
| 497 | + Title string `json:"title"` //标题 | ||
| 498 | + Content string `json:"content"` //文章的文本内容 | ||
| 499 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
| 500 | + Images []string `json:"images,optional"` //图片 | ||
| 501 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 502 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 503 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 504 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 505 | + MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | ||
| 506 | + } | ||
| 507 | +) | ||
| 508 | +//管理后台删除文章 | ||
| 509 | +type ( | ||
| 510 | + SystemArticleDeleteRequest { | ||
| 511 | + Id int64 `json:"id"` //id | ||
| 512 | + } | ||
| 513 | + SystemArticleDeleteResponse { | ||
| 514 | + Id int64 `json:"id"` //id | ||
| 515 | + Title string `json:"title"` //标题 | ||
| 516 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
| 517 | + } | ||
| 518 | +) | ||
| 472 | // 管理后台编辑历史列表 | 519 | // 管理后台编辑历史列表 |
| 473 | type ( | 520 | type ( |
| 474 | //历史 | 521 | //历史 |
| @@ -579,3 +626,170 @@ type ( | @@ -579,3 +626,170 @@ type ( | ||
| 579 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | 626 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] |
| 580 | } | 627 | } |
| 581 | ) | 628 | ) |
| 629 | + | ||
| 630 | +//后台新增文章草稿 | ||
| 631 | +type ( | ||
| 632 | + SystemArticleDraftCreateRequest { | ||
| 633 | + Title string `json:"title"` //标题 | ||
| 634 | + Content string `json:"content"` //文章的文本内容 | ||
| 635 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 636 | + Images []string `json:"images,optional"` //图片 | ||
| 637 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 638 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 639 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 640 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 641 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 642 | + Tags []int64 `json:"tags"` // 标签 | ||
| 643 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 644 | + } | ||
| 645 | + SystemArticleDraftCreateResponse { | ||
| 646 | + Id int64 `json:"id"` //ID | ||
| 647 | + Title string `json:"title"` //标题 | ||
| 648 | + Content string `json:"content"` //文章的文本内容 | ||
| 649 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 650 | + Images []string `json:"images,optional"` //图片 | ||
| 651 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 652 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 653 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 654 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 655 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 656 | + Tags []int64 `json:"tags"` // 标签 | ||
| 657 | + } | ||
| 658 | +) | ||
| 659 | + | ||
| 660 | +//后台编辑文章草稿 | ||
| 661 | +type ( | ||
| 662 | + SystemArticleDraftUpdateRequest { | ||
| 663 | + Id int64 `json:"id"` // ID | ||
| 664 | + Title string `json:"title"` //标题 | ||
| 665 | + Content string `json:"content"` //文章的文本内容 | ||
| 666 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 667 | + Images []string `json:"images,optional"` //图片 | ||
| 668 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 669 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 670 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 671 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 672 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 673 | + Tags []int64 `json:"tags"` // 标签 | ||
| 674 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 675 | + } | ||
| 676 | + SystemArticleDraftUpdateResponse { | ||
| 677 | + Id int64 `json:"id"` //ID | ||
| 678 | + Title string `json:"title"` //标题 | ||
| 679 | + Content string `json:"content"` //文章的文本内容 | ||
| 680 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 681 | + Images []string `json:"images,optional"` //图片 | ||
| 682 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 683 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 684 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 685 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 686 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 687 | + Tags []int64 `json:"tags"` // 标签 | ||
| 688 | + } | ||
| 689 | +) | ||
| 690 | + | ||
| 691 | +//管理后台文章草稿列表 | ||
| 692 | +type ( | ||
| 693 | + SystemArticleDraftSearchRequest { | ||
| 694 | + Page int `json:"page"` //页码 | ||
| 695 | + Size int `json:"size"` //每页行数 | ||
| 696 | + CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传) | ||
| 697 | + Title string `json:"title,optional"` //标题 | ||
| 698 | + Operator string `json:"operator,optional"` //编辑人 | ||
| 699 | + BeginTime int64 `json:"beginTime,optional"`//开始时间 | ||
| 700 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 701 | + } | ||
| 702 | + SystemArticleDraftSearchResponse { | ||
| 703 | + Total int `json:"total"` | ||
| 704 | + List []SystemArticleDraftSearch `json:"list"` | ||
| 705 | + } | ||
| 706 | + SystemArticleDraftSearch { | ||
| 707 | + Id int64 `json:"id"` //ID | ||
| 708 | + Title string `json:"title"` //标题 | ||
| 709 | + Images []string `json:"images"` //图片 | ||
| 710 | + Operator string `json:"operator"` //操作人 | ||
| 711 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 712 | + Author string `json:"author"` //发布人 | ||
| 713 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 | ||
| 714 | + } | ||
| 715 | +) | ||
| 716 | + | ||
| 717 | +//管理后台删除草稿 | ||
| 718 | +type ( | ||
| 719 | + SystemArticleDraftDeleteRequest { | ||
| 720 | + Id int64 `json:"id"` //ID | ||
| 721 | + } | ||
| 722 | + SystemArticleDraftDeleteResponse { | ||
| 723 | + Id int64 `json:"id"` //ID | ||
| 724 | + Title string `json:"title"` //标题 | ||
| 725 | + Content string `json:"content"` //文章的文本内容 | ||
| 726 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 727 | + Images []string `json:"images,optional"` //图片 | ||
| 728 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 729 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 730 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 731 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 732 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 733 | + Tags []int64 `json:"tags"` // 标签 | ||
| 734 | + } | ||
| 735 | +) | ||
| 736 | + | ||
| 737 | +//管理后台获取草稿 | ||
| 738 | +type ( | ||
| 739 | + SystemArticleDraftGetRequest { | ||
| 740 | + Id int64 `path:"id"` //id | ||
| 741 | + CompanyId int64 `path:",optional"` //公司ID(前端不传) | ||
| 742 | + } | ||
| 743 | + SystemArticleDraftGetResponse { | ||
| 744 | + Id int64 `json:"id"` //ID | ||
| 745 | + Title string `json:"title"` //标题 | ||
| 746 | + Content string `json:"content"` //文章的文本内容 | ||
| 747 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 748 | + Images []string `json:"images,optional"` //图片 | ||
| 749 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 750 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 751 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 752 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 753 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 754 | + Tags []int64 `json:"tags"` // 标签 | ||
| 755 | + } | ||
| 756 | +) | ||
| 757 | + | ||
| 758 | +//管理后台已删除列表 | ||
| 759 | +type ( | ||
| 760 | + SystemArticleSearchDeletedRequest { | ||
| 761 | + Page int `json:"page"` //页码 | ||
| 762 | + Size int `json:"size"` //每页行数 | ||
| 763 | + Title string `json:"title,optional"` //标题 | ||
| 764 | + Author int64 `json:"author,optional"` //发布人 | ||
| 765 | + DeletedType int `json:"deletedType,optional"`//类型 1-运营删除 2-用户删除 | ||
| 766 | + BeginTime int64 `json:"beginTime,optional"`//开始时间 | ||
| 767 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 768 | + } | ||
| 769 | + SystemArticleSearchDeletedResponse { | ||
| 770 | + Total int `json:"total"` | ||
| 771 | + List []SystemArticleSearchDeletedItem `json:"list"` | ||
| 772 | + } | ||
| 773 | + SystemArticleSearchDeletedItem { | ||
| 774 | + Id int64 `json:"id"` //ID | ||
| 775 | + Title string `json:"title"` //标题 | ||
| 776 | + Images []string `json:"images"` //图片 | ||
| 777 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 778 | + Author string `json:"author"` //发布人 | ||
| 779 | + Source int `json:"source"` //来源 1-用户发布 2-运营发布 | ||
| 780 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
| 781 | + DeletedAt int64 `json:"deletedAt"` //删除时间 | ||
| 782 | + } | ||
| 783 | +) | ||
| 784 | + | ||
| 785 | +//管理后台已删除文章恢复 | ||
| 786 | +type ( | ||
| 787 | + SystemArticleDeletedRestoreRequest { | ||
| 788 | + Id int64 `json:"id"` //ID | ||
| 789 | + } | ||
| 790 | + SystemArticleDeletedRestoreResponse { | ||
| 791 | + Id int64 `json:"id"` //ID | ||
| 792 | + Title string `json:"title"` //标题 | ||
| 793 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 794 | + } | ||
| 795 | +) |
| @@ -41,6 +41,10 @@ service Core { | @@ -41,6 +41,10 @@ service Core { | ||
| 41 | jwt : SystemAuth | 41 | jwt : SystemAuth |
| 42 | ) | 42 | ) |
| 43 | service Core { | 43 | service Core { |
| 44 | + @doc "公司可见开关" | ||
| 45 | + @handler systemCompanyVisibleSwitch | ||
| 46 | + post /system/company/visible_switch(CompanyVisibleSwitchRequest) returns (CompanyVisibleSwitchResponse) | ||
| 47 | + | ||
| 44 | @doc "公司搜索" | 48 | @doc "公司搜索" |
| 45 | @handler systemCompanySearch | 49 | @handler systemCompanySearch |
| 46 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) | 50 | post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) |
| @@ -70,6 +74,13 @@ type ( | @@ -70,6 +74,13 @@ type ( | ||
| 70 | Logo string `json:"logo,omitempty"` // 公司LOGO | 74 | Logo string `json:"logo,omitempty"` // 公司LOGO |
| 71 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) | 75 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) |
| 72 | } | 76 | } |
| 77 | + | ||
| 78 | + CompanyVisibleSwitchRequest{ | ||
| 79 | + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索 | ||
| 80 | + } | ||
| 81 | + CompanyVisibleSwitchResponse{ | ||
| 82 | + | ||
| 83 | + } | ||
| 73 | ) | 84 | ) |
| 74 | 85 | ||
| 75 | // 公司职位搜索 | 86 | // 公司职位搜索 |
| @@ -2,7 +2,7 @@ Name: discuss | @@ -2,7 +2,7 @@ Name: discuss | ||
| 2 | Host: 0.0.0.0 | 2 | Host: 0.0.0.0 |
| 3 | Port: 8081 | 3 | Port: 8081 |
| 4 | Verbose: false | 4 | Verbose: false |
| 5 | -Migrate: false | 5 | +Migrate: true |
| 6 | Timeout: 30000 | 6 | Timeout: 30000 |
| 7 | # CertFile: ./key/fjmaimaimai.com_bundle.crt | 7 | # CertFile: ./key/fjmaimaimai.com_bundle.crt |
| 8 | # KeyFile: ./key/fjmaimaimai.com.key | 8 | # KeyFile: ./key/fjmaimaimai.com.key |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleSearchDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleSearchDeletedRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemArticleSearchDeletedLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleSearchDeleted(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDraftCreateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemCreateArticleDraftLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemCreateArticleDraft(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemCreateArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleCreateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemCreateArticleLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemCreateArticle(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemDeleteArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDraftDeleteRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemDeleteArticleDraftLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemDeleteArticleDraft(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemDeleteArticleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDeleteRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemDeleteArticleLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemDeleteArticle(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemGetArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDraftGetRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemGetArticleDraftLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemGetArticleDraft(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemRestoreArticleDeletedHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDeletedRestoreRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemRestoreArticleDeletedLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemRestoreArticleDeleted(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 6 | + "net/http" | ||
| 7 | + | ||
| 8 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +func SystemSearchArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 16 | + var req types.SystemArticleDraftSearchRequest | ||
| 17 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 19 | + return | ||
| 20 | + } | ||
| 21 | + userToken := contextdata.GetUserTokenFromCtx(r.Context()) | ||
| 22 | + req.CompanyId = userToken.CompanyId | ||
| 23 | + l := article.NewSystemSearchArticleDraftLogic(r.Context(), svcCtx) | ||
| 24 | + resp, err := l.SystemSearchArticleDraft(&req) | ||
| 25 | + result.HttpResult(r, w, resp, err) | ||
| 26 | + } | ||
| 27 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.SystemArticleDraftUpdateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := article.NewSystemUpdateArticleDraftLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemUpdateArticleDraft(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package company | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/company" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func SystemCompanyVisibleSwitchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.CompanyVisibleSwitchRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := company.NewSystemCompanyVisibleSwitchLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.SystemCompanyVisibleSwitch(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 445 | []rest.Route{ | 445 | []rest.Route{ |
| 446 | { | 446 | { |
| 447 | Method: http.MethodPost, | 447 | Method: http.MethodPost, |
| 448 | + Path: "/system/company/visible_switch", | ||
| 449 | + Handler: company.SystemCompanyVisibleSwitchHandler(serverCtx), | ||
| 450 | + }, | ||
| 451 | + { | ||
| 452 | + Method: http.MethodPost, | ||
| 448 | Path: "/system/company/search", | 453 | Path: "/system/company/search", |
| 449 | Handler: company.SystemCompanySearchHandler(serverCtx), | 454 | Handler: company.SystemCompanySearchHandler(serverCtx), |
| 450 | }, | 455 | }, |
| @@ -598,6 +603,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -598,6 +603,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 598 | Path: "/article/restore", | 603 | Path: "/article/restore", |
| 599 | Handler: article.SystemArticleRestoreHandler(serverCtx), | 604 | Handler: article.SystemArticleRestoreHandler(serverCtx), |
| 600 | }, | 605 | }, |
| 606 | + { | ||
| 607 | + Method: http.MethodDelete, | ||
| 608 | + Path: "/article", | ||
| 609 | + Handler: article.SystemDeleteArticleHandler(serverCtx), | ||
| 610 | + }, | ||
| 611 | + { | ||
| 612 | + Method: http.MethodPost, | ||
| 613 | + Path: "/article", | ||
| 614 | + Handler: article.SystemCreateArticleHandler(serverCtx), | ||
| 615 | + }, | ||
| 616 | + { | ||
| 617 | + Method: http.MethodPost, | ||
| 618 | + Path: "/article/draft", | ||
| 619 | + Handler: article.SystemCreateArticleDraftHandler(serverCtx), | ||
| 620 | + }, | ||
| 621 | + { | ||
| 622 | + Method: http.MethodPut, | ||
| 623 | + Path: "/article/draft", | ||
| 624 | + Handler: article.SystemUpdateArticleDraftHandler(serverCtx), | ||
| 625 | + }, | ||
| 626 | + { | ||
| 627 | + Method: http.MethodPost, | ||
| 628 | + Path: "/article/draft/search", | ||
| 629 | + Handler: article.SystemSearchArticleDraftHandler(serverCtx), | ||
| 630 | + }, | ||
| 631 | + { | ||
| 632 | + Method: http.MethodDelete, | ||
| 633 | + Path: "/article/draft", | ||
| 634 | + Handler: article.SystemDeleteArticleDraftHandler(serverCtx), | ||
| 635 | + }, | ||
| 636 | + { | ||
| 637 | + Method: http.MethodGet, | ||
| 638 | + Path: "/article/draft/:id", | ||
| 639 | + Handler: article.SystemGetArticleDraftHandler(serverCtx), | ||
| 640 | + }, | ||
| 641 | + { | ||
| 642 | + Method: http.MethodPost, | ||
| 643 | + Path: "/article/deleted/list", | ||
| 644 | + Handler: article.SystemArticleSearchDeletedHandler(serverCtx), | ||
| 645 | + }, | ||
| 646 | + { | ||
| 647 | + Method: http.MethodPut, | ||
| 648 | + Path: "/article/deleted/restore", | ||
| 649 | + Handler: article.SystemRestoreArticleDeletedHandler(serverCtx), | ||
| 650 | + }, | ||
| 601 | }..., | 651 | }..., |
| 602 | ), | 652 | ), |
| 603 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 653 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| @@ -678,4 +728,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -678,4 +728,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 678 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 728 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 679 | rest.WithPrefix("/v1"), | 729 | rest.WithPrefix("/v1"), |
| 680 | ) | 730 | ) |
| 731 | + | ||
| 732 | + server.AddRoutes( | ||
| 733 | + rest.WithMiddlewares( | ||
| 734 | + []rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest}, | ||
| 735 | + []rest.Route{ | ||
| 736 | + { | ||
| 737 | + Method: http.MethodGet, | ||
| 738 | + Path: "/article_category/:id", | ||
| 739 | + Handler: tags.ArticleCategoryGetHandler(serverCtx), | ||
| 740 | + }, | ||
| 741 | + { | ||
| 742 | + Method: http.MethodPost, | ||
| 743 | + Path: "/article_category", | ||
| 744 | + Handler: tags.ArticleCategorySaveHandler(serverCtx), | ||
| 745 | + }, | ||
| 746 | + { | ||
| 747 | + Method: http.MethodDelete, | ||
| 748 | + Path: "/article_category/:id", | ||
| 749 | + Handler: tags.ArticleCategoryDeleteHandler(serverCtx), | ||
| 750 | + }, | ||
| 751 | + { | ||
| 752 | + Method: http.MethodPut, | ||
| 753 | + Path: "/article_category/:id", | ||
| 754 | + Handler: tags.ArticleCategoryUpdateHandler(serverCtx), | ||
| 755 | + }, | ||
| 756 | + { | ||
| 757 | + Method: http.MethodPost, | ||
| 758 | + Path: "/article_category/search", | ||
| 759 | + Handler: tags.ArticleCategorySearchHandler(serverCtx), | ||
| 760 | + }, | ||
| 761 | + { | ||
| 762 | + Method: http.MethodGet, | ||
| 763 | + Path: "/article_category/options", | ||
| 764 | + Handler: tags.ArticleCategoryOptionsHandler(serverCtx), | ||
| 765 | + }, | ||
| 766 | + }..., | ||
| 767 | + ), | ||
| 768 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
| 769 | + rest.WithPrefix("/v1/system"), | ||
| 770 | + ) | ||
| 771 | + | ||
| 772 | + server.AddRoutes( | ||
| 773 | + []rest.Route{ | ||
| 774 | + { | ||
| 775 | + Method: http.MethodGet, | ||
| 776 | + Path: "/article_category/init", | ||
| 777 | + Handler: tags.ArticleCategoryInitHandler(serverCtx), | ||
| 778 | + }, | ||
| 779 | + }, | ||
| 780 | + rest.WithPrefix("/v1/system"), | ||
| 781 | + ) | ||
| 681 | } | 782 | } |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategoryDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ArticleCategoryDeleteRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategoryDeleteLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategoryDelete(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategoryGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ArticleCategoryGetRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategoryGetLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategoryGet(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +func ArticleCategoryInitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 12 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 13 | + l := tags.NewArticleCategoryInitLogic(r.Context(), svcCtx) | ||
| 14 | + err := l.ArticleCategoryInit() | ||
| 15 | + if err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + } else { | ||
| 18 | + httpx.Ok(w) | ||
| 19 | + } | ||
| 20 | + } | ||
| 21 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategoryOptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.CategoryOptionsRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategoryOptionsLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategoryOptions(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategorySaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ArticleCategorySaveRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategorySaveLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategorySave(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategorySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ArticleCategorySearchRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategorySearchLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategorySearch(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "net/http" | ||
| 5 | + | ||
| 6 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +func ArticleCategoryUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 13 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 14 | + var req types.ArticleCategoryUpdateRequest | ||
| 15 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 16 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 17 | + return | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + l := tags.NewArticleCategoryUpdateLogic(r.Context(), svcCtx) | ||
| 21 | + resp, err := l.ArticleCategoryUpdate(&req) | ||
| 22 | + if err != nil { | ||
| 23 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 24 | + } else { | ||
| 25 | + httpx.OkJsonCtx(r.Context(), w, resp) | ||
| 26 | + } | ||
| 27 | + } | ||
| 28 | +} |
| @@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | @@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | ||
| 47 | countDataMap[val.TagId] = val | 47 | countDataMap[val.TagId] = val |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | - tagCategory := []string{} | ||
| 51 | - tagCount := []types.ArticleTagCount{} | 50 | + _, categoryList, _ := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions().MustWithKV("enable", 1)) |
| 51 | + tagCount := make([]types.ArticleTagCount, 0) | ||
| 52 | + tagCategory := domain.Values(categoryList, func(item *domain.ArticleCategory) string { | ||
| 53 | + return item.Name | ||
| 54 | + }) | ||
| 55 | + categoryMap := lo.KeyBy(categoryList, func(item *domain.ArticleCategory) int64 { | ||
| 56 | + return item.Id | ||
| 57 | + }) | ||
| 52 | for _, val := range allTags { | 58 | for _, val := range allTags { |
| 53 | - tagCategory = append(tagCategory, val.Category) | ||
| 54 | m := types.ArticleTagCount{ | 59 | m := types.ArticleTagCount{ |
| 55 | TagCategory: val.Category, | 60 | TagCategory: val.Category, |
| 56 | TagId: val.Id, | 61 | TagId: val.Id, |
| @@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | @@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) | ||
| 65 | m.TotalArticle = count.TotalArticle | 70 | m.TotalArticle = count.TotalArticle |
| 66 | m.ReadArticle = count.ReadArticle | 71 | m.ReadArticle = count.ReadArticle |
| 67 | } | 72 | } |
| 73 | + if v, ok := categoryMap[val.CategoryId]; ok { | ||
| 74 | + m.TagCategory = v.Name | ||
| 75 | + } else { | ||
| 76 | + continue | ||
| 77 | + } | ||
| 68 | tagCount = append(tagCount, m) | 78 | tagCount = append(tagCount, m) |
| 69 | } | 79 | } |
| 70 | - tagCategory = lo.Uniq(tagCategory) | ||
| 71 | resp = &types.MiniHomePageResponse{ | 80 | resp = &types.MiniHomePageResponse{ |
| 72 | TagCategory: tagCategory, | 81 | TagCategory: tagCategory, |
| 73 | Tags: tagCount, | 82 | Tags: tagCount, |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemArticleSearchDeletedLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | + conn transaction.Conn | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewSystemArticleSearchDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleSearchDeletedLogic { | ||
| 25 | + return &SystemArticleSearchDeletedLogic{ | ||
| 26 | + Logger: logx.WithContext(ctx), | ||
| 27 | + ctx: ctx, | ||
| 28 | + svcCtx: svcCtx, | ||
| 29 | + conn: svcCtx.DefaultDBConn(), | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemArticleSearchDeletedLogic) SystemArticleSearchDeleted(req *types.SystemArticleSearchDeletedRequest) (resp *types.SystemArticleSearchDeletedResponse, err error) { | ||
| 34 | + queryOptions := domain.NewQueryOptions(). | ||
| 35 | + WithOffsetLimit(req.Page, req.Size). | ||
| 36 | + WithKV("isDel", 1). | ||
| 37 | + WithKV("title", req.Title). | ||
| 38 | + WithKV("authorId", req.Author). | ||
| 39 | + WithKV("beginDeletedAt", req.BeginTime). | ||
| 40 | + WithKV("endDeletedAt", req.EndTime). | ||
| 41 | + WithKV("deletedType", req.DeletedType). | ||
| 42 | + WithKV("orderMode", "deletedAt descending") | ||
| 43 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 44 | + total, articles, err := l.svcCtx.ArticleRepository.Find(l.ctx, l.conn, userToken.CompanyId, queryOptions) | ||
| 45 | + if err != nil { | ||
| 46 | + return nil, xerr.NewErrMsgErr("搜索已删除列表异常", err) | ||
| 47 | + } | ||
| 48 | + resp = &types.SystemArticleSearchDeletedResponse{ | ||
| 49 | + Total: int(total), | ||
| 50 | + List: make([]types.SystemArticleSearchDeletedItem, 0), | ||
| 51 | + } | ||
| 52 | + authorIds := make([]int64, 0) | ||
| 53 | + lo.ForEach(articles, func(item *domain.Article, index int) { | ||
| 54 | + authorIds = append(authorIds, item.AuthorId) | ||
| 55 | + }) | ||
| 56 | + //查询用户数据,重新赋值更新用户名称 | ||
| 57 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
| 58 | + lo.ForEach(articles, func(item *domain.Article, index int) { | ||
| 59 | + //图片 | ||
| 60 | + images := make([]string, 0) | ||
| 61 | + lo.ForEach(item.Images, func(img domain.Image, n int) { | ||
| 62 | + images = append(images, img.Url) | ||
| 63 | + }) | ||
| 64 | + //发布人 | ||
| 65 | + author := item.Author.Name | ||
| 66 | + for _, user := range users { | ||
| 67 | + if user.Id == item.AuthorId { | ||
| 68 | + author = user.Name | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + resp.List = append(resp.List, types.SystemArticleSearchDeletedItem{ | ||
| 72 | + Id: item.Id, | ||
| 73 | + Title: item.Title, | ||
| 74 | + Images: images, | ||
| 75 | + AuthorId: item.AuthorId, | ||
| 76 | + Author: author, | ||
| 77 | + Source: item.Source, | ||
| 78 | + DeletedType: item.DeletedType, | ||
| 79 | + DeletedAt: item.DeletedAt, | ||
| 80 | + }) | ||
| 81 | + }) | ||
| 82 | + return | ||
| 83 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 11 | + "strconv" | ||
| 12 | + | ||
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 15 | + | ||
| 16 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 17 | +) | ||
| 18 | + | ||
| 19 | +type SystemCreateArticleDraftLogic struct { | ||
| 20 | + logx.Logger | ||
| 21 | + ctx context.Context | ||
| 22 | + svcCtx *svc.ServiceContext | ||
| 23 | + conn transaction.Conn | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func NewSystemCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleDraftLogic { | ||
| 27 | + return &SystemCreateArticleDraftLogic{ | ||
| 28 | + Logger: logx.WithContext(ctx), | ||
| 29 | + ctx: ctx, | ||
| 30 | + svcCtx: svcCtx, | ||
| 31 | + conn: svcCtx.DefaultDBConn(), | ||
| 32 | + } | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (l *SystemCreateArticleDraftLogic) SystemCreateArticleDraft(req *types.SystemArticleDraftCreateRequest) (resp *types.SystemArticleDraftCreateResponse, err error) { | ||
| 36 | + // 检查发布人 | ||
| 37 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId) | ||
| 38 | + if err != nil { | ||
| 39 | + return nil, xerr.NewErrMsgErr("创建草稿失败", err) | ||
| 40 | + } | ||
| 41 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
| 42 | + if err != nil { | ||
| 43 | + return nil, xerr.NewErrMsgErr("创建草稿失败", err) | ||
| 44 | + } | ||
| 45 | + //图片 | ||
| 46 | + images, err := getImages(req.Images) | ||
| 47 | + if err != nil { | ||
| 48 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 49 | + } | ||
| 50 | + //视频 | ||
| 51 | + videos, err := getVideos(req.Videos) | ||
| 52 | + if err != nil { | ||
| 53 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 54 | + } | ||
| 55 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 56 | + // 获取当前用户信息 | ||
| 57 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
| 58 | + if err != nil { | ||
| 59 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 60 | + } | ||
| 61 | + articleDraft := &domain.ArticleDraftOperation{ | ||
| 62 | + CompanyId: companyInfo.Id, | ||
| 63 | + AuthorId: req.AuthorId, | ||
| 64 | + Title: req.Title, | ||
| 65 | + Content: req.Content, | ||
| 66 | + Images: images, | ||
| 67 | + Videos: videos, | ||
| 68 | + TargetUser: domain.ArticleTarget(req.TargetUser), | ||
| 69 | + WhoRead: req.WhoRead, | ||
| 70 | + WhoReview: req.WhoReview, | ||
| 71 | + MatchUrl: req.MatchUrl, | ||
| 72 | + Source: domain.ArticleSourceOperator, | ||
| 73 | + Operator: domain.Operator{ | ||
| 74 | + Id: userToken.UserId, | ||
| 75 | + Name: userMe.User.NickName, | ||
| 76 | + }, | ||
| 77 | + Tags: req.Tags, | ||
| 78 | + } | ||
| 79 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
| 80 | + _, err := l.svcCtx.ArticleDraftOperationRepository.Insert(ctx, conn, articleDraft) | ||
| 81 | + if err != nil { | ||
| 82 | + return err | ||
| 83 | + } | ||
| 84 | + return nil | ||
| 85 | + }, true) | ||
| 86 | + resp = &types.SystemArticleDraftCreateResponse{ | ||
| 87 | + Id: articleDraft.Id, | ||
| 88 | + Title: articleDraft.Title, | ||
| 89 | + Content: articleDraft.Content, | ||
| 90 | + AuthorId: articleDraft.AuthorId, | ||
| 91 | + Images: req.Images, | ||
| 92 | + Videos: req.Videos, | ||
| 93 | + TargetUser: req.TargetUser, | ||
| 94 | + WhoRead: req.WhoRead, | ||
| 95 | + WhoReview: req.WhoReview, | ||
| 96 | + MatchUrl: req.MatchUrl, | ||
| 97 | + Tags: req.Tags, | ||
| 98 | + } | ||
| 99 | + return | ||
| 100 | +} | ||
| 101 | + | ||
| 102 | +// getImages 获取图片信息 | ||
| 103 | +func getImages(imgs []string) ([]domain.Image, error) { | ||
| 104 | + // 获取图片的尺寸大小 | ||
| 105 | + images := make([]domain.Image, 0) | ||
| 106 | + if len(imgs) <= 0 { | ||
| 107 | + return images, nil | ||
| 108 | + } | ||
| 109 | + for _, val := range imgs { | ||
| 110 | + fInfo, err := oss.GetImageInfo(val) | ||
| 111 | + if err != nil { | ||
| 112 | + return images, xerr.NewErrMsg("获取图片失败") | ||
| 113 | + } | ||
| 114 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 115 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 116 | + images = append(images, domain.Image{ | ||
| 117 | + Url: val, | ||
| 118 | + Width: w, | ||
| 119 | + Height: h, | ||
| 120 | + }) | ||
| 121 | + } | ||
| 122 | + return images, nil | ||
| 123 | +} | ||
| 124 | + | ||
| 125 | +// getVideos 获取视频信息 | ||
| 126 | +func getVideos(list []types.Video) ([]domain.Video, error) { | ||
| 127 | + videos := make([]domain.Video, 0) | ||
| 128 | + if len(list) <= 0 { | ||
| 129 | + return videos, nil | ||
| 130 | + } | ||
| 131 | + if len(list) > 0 { | ||
| 132 | + for _, item := range list { | ||
| 133 | + cover, w, h, err := oss.GetVideoCover(item.Url) | ||
| 134 | + if err != nil { | ||
| 135 | + return videos, xerr.NewErrMsg("获取视频信息失败") | ||
| 136 | + } | ||
| 137 | + videos = append(videos, domain.Video{ | ||
| 138 | + Url: item.Url, | ||
| 139 | + Cover: cover, | ||
| 140 | + Width: w, | ||
| 141 | + Height: h, | ||
| 142 | + }) | ||
| 143 | + } | ||
| 144 | + } | ||
| 145 | + return videos, nil | ||
| 146 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/pkg/errors" | ||
| 6 | + "github.com/samber/lo" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 13 | + "strconv" | ||
| 14 | + "strings" | ||
| 15 | + "unicode/utf8" | ||
| 16 | + | ||
| 17 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 18 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 19 | + | ||
| 20 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 21 | +) | ||
| 22 | + | ||
| 23 | +type SystemCreateArticleLogic struct { | ||
| 24 | + logx.Logger | ||
| 25 | + ctx context.Context | ||
| 26 | + svcCtx *svc.ServiceContext | ||
| 27 | + conn transaction.Conn | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func NewSystemCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCreateArticleLogic { | ||
| 31 | + return &SystemCreateArticleLogic{ | ||
| 32 | + Logger: logx.WithContext(ctx), | ||
| 33 | + ctx: ctx, | ||
| 34 | + svcCtx: svcCtx, | ||
| 35 | + conn: svcCtx.DefaultDBConn(), | ||
| 36 | + } | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleCreateRequest) (resp *types.SystemArticleCreateResponse, err error) { | ||
| 40 | + err = l.validate(req) | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 43 | + } | ||
| 44 | + // 检查发布人 | ||
| 45 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, req.AuthorId) | ||
| 46 | + if err != nil { | ||
| 47 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 48 | + } | ||
| 49 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, l.conn, author.CompanyId) | ||
| 50 | + if err != nil { | ||
| 51 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 52 | + } | ||
| 53 | + //文章作者 | ||
| 54 | + articleAuthor := domain.UserSimple{ | ||
| 55 | + Id: author.Id, | ||
| 56 | + Name: author.Name, | ||
| 57 | + Avatar: author.Avatar, | ||
| 58 | + Position: author.Position, | ||
| 59 | + Company: companyInfo.Name, | ||
| 60 | + CompanyId: author.CompanyId, | ||
| 61 | + } | ||
| 62 | + //图片 | ||
| 63 | + images, err := l.getImages(req) | ||
| 64 | + if err != nil { | ||
| 65 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 66 | + } | ||
| 67 | + //视频 | ||
| 68 | + videos, err := l.getVideos(req) | ||
| 69 | + if err != nil { | ||
| 70 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 71 | + } | ||
| 72 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 73 | + // 获取当前用户信息 | ||
| 74 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
| 75 | + if err != nil { | ||
| 76 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 77 | + } | ||
| 78 | + article := &domain.Article{ | ||
| 79 | + CompanyId: companyInfo.Id, | ||
| 80 | + AuthorId: req.AuthorId, | ||
| 81 | + Author: articleAuthor, | ||
| 82 | + Title: req.Title, | ||
| 83 | + Images: images, | ||
| 84 | + Videos: videos, | ||
| 85 | + WhoRead: make([]int64, 0), | ||
| 86 | + WhoReview: make([]int64, 0), | ||
| 87 | + Location: domain.Location{}, | ||
| 88 | + TargetUser: domain.ArticleTarget(req.TargetUser), | ||
| 89 | + Show: domain.ArticleShowEnable, | ||
| 90 | + Tags: make([]int64, 0), | ||
| 91 | + MatchUrl: make(map[string]string), | ||
| 92 | + Source: domain.ArticleSourceOperator, | ||
| 93 | + Operator: domain.Operator{ | ||
| 94 | + Id: userToken.UserId, | ||
| 95 | + Name: userMe.User.NickName, | ||
| 96 | + }, | ||
| 97 | + } | ||
| 98 | + if len(req.MatchUrl) > 0 { | ||
| 99 | + article.MatchUrl = req.MatchUrl | ||
| 100 | + } | ||
| 101 | + //检查文章可被哪些人查看 | ||
| 102 | + whoRead, err := l.validateAndGetWhoRead(req, article) | ||
| 103 | + if err != nil { | ||
| 104 | + return nil, err | ||
| 105 | + } | ||
| 106 | + //检查文章可被哪些人评论 | ||
| 107 | + whoReview := []int64{} | ||
| 108 | + if len(req.WhoReview) > 0 { | ||
| 109 | + whoReview = lo.Uniq(req.WhoReview) | ||
| 110 | + } | ||
| 111 | + //验证可评论 | ||
| 112 | + if err = l.validateWhoReview(whoRead, whoReview, article); err != nil { | ||
| 113 | + return nil, err | ||
| 114 | + } | ||
| 115 | + article.WhoRead = whoRead | ||
| 116 | + article.WhoReview = whoReview | ||
| 117 | + sections := l.getSections(req, article) | ||
| 118 | + //设置内容摘要 | ||
| 119 | + article.SetSummary(sections) | ||
| 120 | + //草稿ID | ||
| 121 | + if req.ArticleDraftId > 0 { | ||
| 122 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.ArticleDraftId) | ||
| 123 | + if err != nil { | ||
| 124 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
| 125 | + } | ||
| 126 | + if articleDraft.CompanyId != userToken.CompanyId { | ||
| 127 | + return nil, xerr.NewErrMsg("您没有权限") | ||
| 128 | + } | ||
| 129 | + } | ||
| 130 | + //保存数据 | ||
| 131 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
| 132 | + _, err = l.svcCtx.ArticleRepository.Insert(ctx, conn, article) | ||
| 133 | + if err != nil { | ||
| 134 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
| 135 | + } | ||
| 136 | + for i := range sections { | ||
| 137 | + sections[i].ArticleId = article.Id | ||
| 138 | + _, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, conn, sections[i]) | ||
| 139 | + if err != nil { | ||
| 140 | + return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + // 生成 备份数据 | ||
| 144 | + var backupData domain.ArticleBackup | ||
| 145 | + backupData.MakeBackup(articleAuthor, article, sections, "原始版本") | ||
| 146 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, &backupData) | ||
| 147 | + if err != nil { | ||
| 148 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
| 149 | + } | ||
| 150 | + //删除草稿 | ||
| 151 | + if req.ArticleDraftId > 0 { | ||
| 152 | + _, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, conn, &domain.ArticleDraftOperation{Id: req.ArticleDraftId}) | ||
| 153 | + if err != nil { | ||
| 154 | + return xerr.NewErrMsg("删除草稿失败") | ||
| 155 | + } | ||
| 156 | + } | ||
| 157 | + return nil | ||
| 158 | + }, true) | ||
| 159 | + if err != nil { | ||
| 160 | + return nil, xerr.NewErrMsgErr("创建文章失败", err) | ||
| 161 | + } | ||
| 162 | + resp = &types.SystemArticleCreateResponse{ | ||
| 163 | + Id: article.Id, | ||
| 164 | + Title: article.Title, | ||
| 165 | + Content: req.Content, | ||
| 166 | + AuthorId: req.AuthorId, | ||
| 167 | + Images: req.Images, | ||
| 168 | + Videos: req.Videos, | ||
| 169 | + TargetUser: req.TargetUser, | ||
| 170 | + WhoRead: whoRead, | ||
| 171 | + WhoReview: whoReview, | ||
| 172 | + } | ||
| 173 | + return | ||
| 174 | +} | ||
| 175 | + | ||
| 176 | +// validate 验证 | ||
| 177 | +func (l *SystemCreateArticleLogic) validate(req *types.SystemArticleCreateRequest) error { | ||
| 178 | + //文章标题 | ||
| 179 | + if utf8.RuneCountInString(req.Title) > 64 { | ||
| 180 | + return errors.New("标题最多只能输入64字") | ||
| 181 | + } | ||
| 182 | + //文章内容 | ||
| 183 | + if utf8.RuneCountInString(req.Content) > 1000 { | ||
| 184 | + return errors.New("内容最多只能输入1000字") | ||
| 185 | + } | ||
| 186 | + //图片 | ||
| 187 | + if len(req.Images) > 9 { | ||
| 188 | + return errors.New("图片数量最多9张") | ||
| 189 | + } | ||
| 190 | + return nil | ||
| 191 | +} | ||
| 192 | + | ||
| 193 | +// getImages 获取图片信息 | ||
| 194 | +func (l *SystemCreateArticleLogic) getImages(req *types.SystemArticleCreateRequest) ([]domain.Image, error) { | ||
| 195 | + // 获取图片的尺寸大小 | ||
| 196 | + images := make([]domain.Image, 0) | ||
| 197 | + for _, val := range req.Images { | ||
| 198 | + fInfo, err := oss.GetImageInfo(val) | ||
| 199 | + if err != nil { | ||
| 200 | + return images, xerr.NewErrMsg("获取图片失败") | ||
| 201 | + } | ||
| 202 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 203 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 204 | + images = append(images, domain.Image{ | ||
| 205 | + Url: val, | ||
| 206 | + Width: w, | ||
| 207 | + Height: h, | ||
| 208 | + }) | ||
| 209 | + } | ||
| 210 | + return images, nil | ||
| 211 | +} | ||
| 212 | + | ||
| 213 | +// getVideo 获取视频信息 | ||
| 214 | +func (l *SystemCreateArticleLogic) getVideos(req *types.SystemArticleCreateRequest) ([]domain.Video, error) { | ||
| 215 | + videos := make([]domain.Video, 0) | ||
| 216 | + if len(req.Videos) > 0 { | ||
| 217 | + for _, item := range req.Videos { | ||
| 218 | + cover, w, h, err := oss.GetVideoCover(item.Url) | ||
| 219 | + if err != nil { | ||
| 220 | + return videos, xerr.NewErrMsg("获取视频信息失败") | ||
| 221 | + } | ||
| 222 | + videos = append(videos, domain.Video{ | ||
| 223 | + Url: item.Url, | ||
| 224 | + Cover: cover, | ||
| 225 | + Width: w, | ||
| 226 | + Height: h, | ||
| 227 | + }) | ||
| 228 | + } | ||
| 229 | + } | ||
| 230 | + return videos, nil | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +// validateAndGetWhoRead 验证并获取可阅读 | ||
| 234 | +func (l *SystemCreateArticleLogic) validateAndGetWhoRead(req *types.SystemArticleCreateRequest, article *domain.Article) ([]int64, error) { | ||
| 235 | + whoRead := make([]int64, 0) | ||
| 236 | + if len(req.WhoRead) > 0 { | ||
| 237 | + whoRead = lo.Uniq(req.WhoRead) | ||
| 238 | + var u *domain.User | ||
| 239 | + var err error | ||
| 240 | + for _, val := range whoRead { | ||
| 241 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val) | ||
| 242 | + if err != nil { | ||
| 243 | + return whoRead, xerr.NewErrMsgErr("文章可查看人设置错误", err) | ||
| 244 | + } | ||
| 245 | + if u.CompanyId != article.CompanyId { | ||
| 246 | + return whoRead, xerr.NewErrMsg("文章可查看人设置错误") | ||
| 247 | + } | ||
| 248 | + } | ||
| 249 | + } | ||
| 250 | + return whoRead, nil | ||
| 251 | +} | ||
| 252 | + | ||
| 253 | +// validateWhoReview 验证可评论 | ||
| 254 | +func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview []int64, article *domain.Article) error { | ||
| 255 | + //有指定可查看人的情况 | ||
| 256 | + if len(whoRead) > 0 { | ||
| 257 | + if len(whoReview) > 0 { | ||
| 258 | + // 检查 whoRead 是否 完全包含 whoReview | ||
| 259 | + ok := lo.Every(whoRead, whoReview) | ||
| 260 | + if !ok { | ||
| 261 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + if len(whoReview) == 0 { | ||
| 265 | + //有指定可查看人 ,但未指定可评论人 | ||
| 266 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
| 267 | + } | ||
| 268 | + } | ||
| 269 | + //没有指定可查看人的情况 | ||
| 270 | + if len(whoRead) == 0 { | ||
| 271 | + if len(whoReview) > 0 { | ||
| 272 | + // 未指定可查看人(全员可看),有指定可评论人, | ||
| 273 | + var u *domain.User | ||
| 274 | + var err error | ||
| 275 | + for _, val := range whoReview { | ||
| 276 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, l.conn, val) | ||
| 277 | + if err != nil { | ||
| 278 | + return xerr.NewErrMsgErr("文章可评论人设置错误", err) | ||
| 279 | + } | ||
| 280 | + if u.CompanyId != article.CompanyId { | ||
| 281 | + return xerr.NewErrMsg("文章可评论人设置错误") | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + } | ||
| 286 | + return nil | ||
| 287 | +} | ||
| 288 | + | ||
| 289 | +// getSections 文章内容 | ||
| 290 | +func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection { | ||
| 291 | + articleSections := make([]*domain.ArticleSection, 0) | ||
| 292 | + sortBy := 1 | ||
| 293 | + sections := strings.Split(req.Content, "\n") | ||
| 294 | + lo.ForEach(sections, func(item string, index int) { | ||
| 295 | + section := domain.ArticleSection{ | ||
| 296 | + CompanyId: article.CompanyId, | ||
| 297 | + Version: article.Version, | ||
| 298 | + ArticleId: article.Id, | ||
| 299 | + Content: item, | ||
| 300 | + SortBy: sortBy, | ||
| 301 | + } | ||
| 302 | + articleSections = append(articleSections, §ion) | ||
| 303 | + sortBy++ | ||
| 304 | + }) | ||
| 305 | + return articleSections | ||
| 306 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemDeleteArticleDraftLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | + conn transaction.Conn | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewSystemDeleteArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleDraftLogic { | ||
| 25 | + return &SystemDeleteArticleDraftLogic{ | ||
| 26 | + Logger: logx.WithContext(ctx), | ||
| 27 | + ctx: ctx, | ||
| 28 | + svcCtx: svcCtx, | ||
| 29 | + conn: svcCtx.DefaultDBConn(), | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemDeleteArticleDraftLogic) SystemDeleteArticleDraft(req *types.SystemArticleDraftDeleteRequest) (resp *types.SystemArticleDraftDeleteResponse, err error) { | ||
| 34 | + // 草稿数据 | ||
| 35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
| 36 | + if err != nil { | ||
| 37 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
| 38 | + } | ||
| 39 | + //操作人 | ||
| 40 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 41 | + if userToken.CompanyId != articleDraft.CompanyId { | ||
| 42 | + return nil, xerr.NewErrMsg("您没有权限删除") | ||
| 43 | + } | ||
| 44 | + _, err = l.svcCtx.ArticleDraftOperationRepository.Delete(l.ctx, l.conn, articleDraft) | ||
| 45 | + if err != nil { | ||
| 46 | + return nil, xerr.NewErrMsg("删除草稿失败") | ||
| 47 | + } | ||
| 48 | + //图片 | ||
| 49 | + images := make([]string, 0) | ||
| 50 | + lo.ForEach(articleDraft.Images, func(img domain.Image, n int) { | ||
| 51 | + images = append(images, img.Url) | ||
| 52 | + }) | ||
| 53 | + //视频 | ||
| 54 | + videos := make([]types.Video, 0) | ||
| 55 | + lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) { | ||
| 56 | + videos = append(videos, types.Video{ | ||
| 57 | + Url: video.Url, | ||
| 58 | + Cover: video.Cover, | ||
| 59 | + Width: video.Width, | ||
| 60 | + Height: video.Height, | ||
| 61 | + }) | ||
| 62 | + }) | ||
| 63 | + resp = &types.SystemArticleDraftDeleteResponse{ | ||
| 64 | + Id: articleDraft.Id, | ||
| 65 | + Title: articleDraft.Title, | ||
| 66 | + Content: articleDraft.Content, | ||
| 67 | + AuthorId: articleDraft.AuthorId, | ||
| 68 | + Images: images, | ||
| 69 | + Videos: videos, | ||
| 70 | + TargetUser: int(articleDraft.TargetUser), | ||
| 71 | + WhoRead: articleDraft.WhoRead, | ||
| 72 | + WhoReview: articleDraft.WhoReview, | ||
| 73 | + MatchUrl: articleDraft.MatchUrl, | ||
| 74 | + Tags: articleDraft.Tags, | ||
| 75 | + } | ||
| 76 | + return | ||
| 77 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemDeleteArticleLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | + conn transaction.Conn | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewSystemDeleteArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemDeleteArticleLogic { | ||
| 24 | + return &SystemDeleteArticleLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + conn: svcCtx.DefaultDBConn(), | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (l *SystemDeleteArticleLogic) SystemDeleteArticle(req *types.SystemArticleDeleteRequest) (resp *types.SystemArticleDeleteResponse, err error) { | ||
| 33 | + // 文章数据 | ||
| 34 | + article, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, l.conn, req.Id) | ||
| 35 | + if err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
| 37 | + } | ||
| 38 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 39 | + if userToken.CompanyId != article.CompanyId { | ||
| 40 | + return nil, xerr.NewErrMsg("您没有权限") | ||
| 41 | + } | ||
| 42 | + article.DeletedType = domain.ArticleDeletedTypeOperator | ||
| 43 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
| 44 | + //更新删除类型 | ||
| 45 | + _, err = l.svcCtx.ArticleRepository.Update(l.ctx, conn, article) | ||
| 46 | + if err != nil { | ||
| 47 | + return err | ||
| 48 | + } | ||
| 49 | + _, err = l.svcCtx.ArticleRepository.Delete(l.ctx, l.conn, article) | ||
| 50 | + if err != nil { | ||
| 51 | + return err | ||
| 52 | + } | ||
| 53 | + return nil | ||
| 54 | + }, true) | ||
| 55 | + if err != nil { | ||
| 56 | + return nil, xerr.NewErrMsgErr("删除失败", err) | ||
| 57 | + } | ||
| 58 | + resp = &types.SystemArticleDeleteResponse{ | ||
| 59 | + Id: article.Id, | ||
| 60 | + Title: article.Title, | ||
| 61 | + AuthorId: article.AuthorId, | ||
| 62 | + } | ||
| 63 | + return | ||
| 64 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemGetArticleDraftLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | + conn transaction.Conn | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewSystemGetArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemGetArticleDraftLogic { | ||
| 25 | + return &SystemGetArticleDraftLogic{ | ||
| 26 | + Logger: logx.WithContext(ctx), | ||
| 27 | + ctx: ctx, | ||
| 28 | + svcCtx: svcCtx, | ||
| 29 | + conn: svcCtx.DefaultDBConn(), | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemGetArticleDraftLogic) SystemGetArticleDraft(req *types.SystemArticleDraftGetRequest) (resp *types.SystemArticleDraftGetResponse, err error) { | ||
| 34 | + // 草稿数据 | ||
| 35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
| 36 | + if err != nil { | ||
| 37 | + return nil, xerr.NewErrMsg("草稿不存在") | ||
| 38 | + } | ||
| 39 | + //操作人 | ||
| 40 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 41 | + //不同公司不能获取数据 | ||
| 42 | + if userToken.CompanyId != articleDraft.CompanyId { | ||
| 43 | + return nil, xerr.NewErrMsg("您没有权限查看该数据") | ||
| 44 | + } | ||
| 45 | + //图片 | ||
| 46 | + images := make([]string, 0) | ||
| 47 | + lo.ForEach(articleDraft.Images, func(img domain.Image, n int) { | ||
| 48 | + images = append(images, img.Url) | ||
| 49 | + }) | ||
| 50 | + //视频 | ||
| 51 | + videos := make([]types.Video, 0) | ||
| 52 | + lo.ForEach(articleDraft.Videos, func(video domain.Video, n int) { | ||
| 53 | + videos = append(videos, types.Video{ | ||
| 54 | + Url: video.Url, | ||
| 55 | + Cover: video.Cover, | ||
| 56 | + Width: video.Width, | ||
| 57 | + Height: video.Height, | ||
| 58 | + }) | ||
| 59 | + }) | ||
| 60 | + resp = &types.SystemArticleDraftGetResponse{ | ||
| 61 | + Id: articleDraft.Id, | ||
| 62 | + Title: articleDraft.Title, | ||
| 63 | + Content: articleDraft.Content, | ||
| 64 | + AuthorId: articleDraft.AuthorId, | ||
| 65 | + Images: images, | ||
| 66 | + Videos: videos, | ||
| 67 | + TargetUser: int(articleDraft.TargetUser), | ||
| 68 | + WhoRead: articleDraft.WhoRead, | ||
| 69 | + WhoReview: articleDraft.WhoReview, | ||
| 70 | + MatchUrl: articleDraft.MatchUrl, | ||
| 71 | + Tags: articleDraft.Tags, | ||
| 72 | + } | ||
| 73 | + return | ||
| 74 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SystemRestoreArticleDeletedLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | + conn transaction.Conn | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemRestoreArticleDeletedLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemRestoreArticleDeletedLogic { | ||
| 22 | + return &SystemRestoreArticleDeletedLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + conn: svcCtx.DefaultDBConn(), | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemRestoreArticleDeletedLogic) SystemRestoreArticleDeleted(req *types.SystemArticleDeletedRestoreRequest) (resp *types.SystemArticleDeletedRestoreResponse, err error) { | ||
| 31 | + // 文章数据 | ||
| 32 | + article, err := l.svcCtx.ArticleRepository.FindOneWithUnscoped(l.ctx, l.conn, req.Id) | ||
| 33 | + if err != nil { | ||
| 34 | + return nil, xerr.NewErrMsgErr("帖子不存在", err) | ||
| 35 | + } | ||
| 36 | + _, err = l.svcCtx.ArticleRepository.Restore(l.ctx, l.conn, article) | ||
| 37 | + if err != nil { | ||
| 38 | + return nil, xerr.NewErrMsg("恢复帖子失败") | ||
| 39 | + } | ||
| 40 | + resp = &types.SystemArticleDeletedRestoreResponse{ | ||
| 41 | + Id: article.Id, | ||
| 42 | + Title: article.Title, | ||
| 43 | + AuthorId: article.AuthorId, | ||
| 44 | + } | ||
| 45 | + return | ||
| 46 | +} |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemSearchArticleDraftLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | + conn transaction.Conn | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewSystemSearchArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemSearchArticleDraftLogic { | ||
| 24 | + return &SystemSearchArticleDraftLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + conn: svcCtx.DefaultDBConn(), | ||
| 29 | + } | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +func (l *SystemSearchArticleDraftLogic) SystemSearchArticleDraft(req *types.SystemArticleDraftSearchRequest) (resp *types.SystemArticleDraftSearchResponse, err error) { | ||
| 33 | + queryOptions := domain.NewQueryOptions(). | ||
| 34 | + WithOffsetLimit(req.Page, req.Size). | ||
| 35 | + WithKV("companyId", req.CompanyId). | ||
| 36 | + WithKV("title", req.Title). | ||
| 37 | + WithKV("operator", req.Operator). | ||
| 38 | + WithKV("beginTime", req.BeginTime). | ||
| 39 | + WithKV("endTime", req.EndTime) | ||
| 40 | + total, articleDrafts, err := l.svcCtx.ArticleDraftOperationRepository.Find(l.ctx, l.conn, queryOptions) | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, xerr.NewErrMsgErr("搜索草稿异常", err) | ||
| 43 | + } | ||
| 44 | + resp = &types.SystemArticleDraftSearchResponse{ | ||
| 45 | + Total: int(total), | ||
| 46 | + List: make([]types.SystemArticleDraftSearch, 0), | ||
| 47 | + } | ||
| 48 | + authorIds := make([]int64, 0) | ||
| 49 | + lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) { | ||
| 50 | + authorIds = append(authorIds, item.AuthorId) | ||
| 51 | + }) | ||
| 52 | + //查询用户数据,重新赋值更新用户名称 | ||
| 53 | + _, users, _ := l.svcCtx.UserRepository.Find(l.ctx, l.conn, domain.NewQueryOptions().WithFindOnly().WithKV("ids", authorIds)) | ||
| 54 | + lo.ForEach(articleDrafts, func(item *domain.ArticleDraftOperation, index int) { | ||
| 55 | + //图片 | ||
| 56 | + images := make([]string, 0) | ||
| 57 | + lo.ForEach(item.Images, func(img domain.Image, n int) { | ||
| 58 | + images = append(images, img.Url) | ||
| 59 | + }) | ||
| 60 | + //发布人 | ||
| 61 | + author := "" | ||
| 62 | + for _, user := range users { | ||
| 63 | + if user.Id == item.AuthorId { | ||
| 64 | + author = user.Name | ||
| 65 | + } | ||
| 66 | + } | ||
| 67 | + resp.List = append(resp.List, types.SystemArticleDraftSearch{ | ||
| 68 | + Id: item.Id, | ||
| 69 | + Title: item.Title, | ||
| 70 | + Images: images, | ||
| 71 | + Operator: item.Operator.Name, | ||
| 72 | + AuthorId: item.AuthorId, | ||
| 73 | + Author: author, | ||
| 74 | + UpdatedAt: item.UpdatedAt, | ||
| 75 | + }) | ||
| 76 | + }) | ||
| 77 | + return | ||
| 78 | +} |
| @@ -82,11 +82,17 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | @@ -82,11 +82,17 @@ func (l *SystemSearchArticleLogic) SystemSearchArticle(req *types.SystemArticleS | ||
| 82 | Author: author, | 82 | Author: author, |
| 83 | Images: images, | 83 | Images: images, |
| 84 | CreatedAt: item.CreatedAt, | 84 | CreatedAt: item.CreatedAt, |
| 85 | + UpdatedAt: item.UpdatedAt, | ||
| 85 | CountLove: item.CountLove, | 86 | CountLove: item.CountLove, |
| 86 | CountComment: item.CountComment, | 87 | CountComment: item.CountComment, |
| 87 | Show: int(item.Show), | 88 | Show: int(item.Show), |
| 88 | Tags: articleTags, | 89 | Tags: articleTags, |
| 89 | TargetUser: int(item.TargetUser), | 90 | TargetUser: int(item.TargetUser), |
| 91 | + Source: item.Source, | ||
| 92 | + Operator: types.Operator{ | ||
| 93 | + Id: item.Operator.Id, | ||
| 94 | + Name: item.Operator.Name, | ||
| 95 | + }, | ||
| 90 | }) | 96 | }) |
| 91 | }) | 97 | }) |
| 92 | return | 98 | return |
| 1 | +package article | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type SystemUpdateArticleDraftLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | + conn transaction.Conn | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewSystemUpdateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemUpdateArticleDraftLogic { | ||
| 25 | + return &SystemUpdateArticleDraftLogic{ | ||
| 26 | + Logger: logx.WithContext(ctx), | ||
| 27 | + ctx: ctx, | ||
| 28 | + svcCtx: svcCtx, | ||
| 29 | + conn: svcCtx.DefaultDBConn(), | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemUpdateArticleDraftLogic) SystemUpdateArticleDraft(req *types.SystemArticleDraftUpdateRequest) (resp *types.SystemArticleDraftUpdateResponse, err error) { | ||
| 34 | + // 草稿数据 | ||
| 35 | + articleDraft, err := l.svcCtx.ArticleDraftOperationRepository.FindOne(l.ctx, l.conn, req.Id) | ||
| 36 | + if err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("草稿不存在", err) | ||
| 38 | + } | ||
| 39 | + articleDraft.Title = req.Title | ||
| 40 | + articleDraft.Content = req.Content | ||
| 41 | + articleDraft.AuthorId = req.AuthorId | ||
| 42 | + articleDraft.TargetUser = domain.ArticleTarget(req.TargetUser) | ||
| 43 | + articleDraft.WhoRead = req.WhoRead | ||
| 44 | + articleDraft.WhoReview = req.WhoReview | ||
| 45 | + articleDraft.Tags = req.Tags | ||
| 46 | + articleDraft.Source = domain.ArticleSourceOperator | ||
| 47 | + articleDraft.MatchUrl = req.MatchUrl | ||
| 48 | + //图片 | ||
| 49 | + images, err := getImages(req.Images) | ||
| 50 | + if err != nil { | ||
| 51 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 52 | + } | ||
| 53 | + articleDraft.Images = images | ||
| 54 | + //视频 | ||
| 55 | + videos, err := getVideos(req.Videos) | ||
| 56 | + if err != nil { | ||
| 57 | + return nil, xerr.NewErrMsg(err.Error()) | ||
| 58 | + } | ||
| 59 | + articleDraft.Videos = videos | ||
| 60 | + //操作人 | ||
| 61 | + userToken := contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 62 | + // 获取当前用户信息 | ||
| 63 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
| 64 | + if err != nil { | ||
| 65 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 66 | + } | ||
| 67 | + articleDraft.Operator = domain.Operator{ | ||
| 68 | + Id: userToken.UserId, | ||
| 69 | + Name: userMe.User.NickName, | ||
| 70 | + } | ||
| 71 | + err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, conn transaction.Conn) error { | ||
| 72 | + _, err := l.svcCtx.ArticleDraftOperationRepository.Update(ctx, conn, articleDraft) | ||
| 73 | + if err != nil { | ||
| 74 | + return err | ||
| 75 | + } | ||
| 76 | + return nil | ||
| 77 | + }, true) | ||
| 78 | + if err != nil { | ||
| 79 | + return nil, xerr.NewErrMsg("保存草稿失败") | ||
| 80 | + } | ||
| 81 | + resp = &types.SystemArticleDraftUpdateResponse{ | ||
| 82 | + Id: articleDraft.Id, | ||
| 83 | + Title: articleDraft.Title, | ||
| 84 | + Content: articleDraft.Content, | ||
| 85 | + AuthorId: articleDraft.AuthorId, | ||
| 86 | + Images: req.Images, | ||
| 87 | + Videos: req.Videos, | ||
| 88 | + TargetUser: int(articleDraft.TargetUser), | ||
| 89 | + WhoRead: articleDraft.WhoRead, | ||
| 90 | + WhoReview: articleDraft.WhoReview, | ||
| 91 | + MatchUrl: articleDraft.MatchUrl, | ||
| 92 | + Tags: articleDraft.Tags, | ||
| 93 | + } | ||
| 94 | + return | ||
| 95 | +} |
| @@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan | @@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan | ||
| 91 | if lo.Contains(companyJoiningList, company.Id) { | 91 | if lo.Contains(companyJoiningList, company.Id) { |
| 92 | company.JoinedFlag = 0 | 92 | company.JoinedFlag = 0 |
| 93 | } | 93 | } |
| 94 | + // 过滤掉不可见且未加入的企业。 | ||
| 95 | + if company.JoinedFlag != 1 && item.Visible == 0 { | ||
| 96 | + return | ||
| 97 | + } | ||
| 94 | resp.List = append(resp.List, company) | 98 | resp.List = append(resp.List, company) |
| 95 | }) | 99 | }) |
| 96 | resp.Total = total | 100 | resp.Total = total |
| @@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque | @@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque | ||
| 38 | if req.Code != "" { | 38 | if req.Code != "" { |
| 39 | queryOptions.WithKV("code", req.Code) | 39 | queryOptions.WithKV("code", req.Code) |
| 40 | } | 40 | } |
| 41 | + queryOptions.MustWithKV("visible", 1) | ||
| 41 | total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) | 42 | total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) |
| 42 | if err != nil { | 43 | if err != nil { |
| 43 | return nil, xerr.NewErrMsgErr("公司列表获取失败", err) | 44 | return nil, xerr.NewErrMsgErr("公司列表获取失败", err) |
| 1 | +package company | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemCompanyVisibleSwitchLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemCompanyVisibleSwitchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCompanyVisibleSwitchLogic { | ||
| 23 | + return &SystemCompanyVisibleSwitchLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemCompanyVisibleSwitchLogic) SystemCompanyVisibleSwitch(req *types.CompanyVisibleSwitchRequest) (resp *types.CompanyVisibleSwitchResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + company *domain.Company | ||
| 34 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + ) | ||
| 36 | + if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsg("设置失败") | ||
| 38 | + } | ||
| 39 | + company.Visible = lo.Ternary(req.Visible, 1, 0) | ||
| 40 | + if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil { | ||
| 41 | + return nil, xerr.NewErrMsg("设置失败") | ||
| 42 | + } | ||
| 43 | + resp = &types.CompanyVisibleSwitchResponse{} | ||
| 44 | + return | ||
| 45 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 8 | + | ||
| 9 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +type ArticleCategoryDeleteLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewArticleCategoryDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryDeleteLogic { | ||
| 19 | + return &ArticleCategoryDeleteLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *ArticleCategoryDeleteLogic) ArticleCategoryDelete(req *types.ArticleCategoryDeleteRequest) (resp *types.ArticleCategoryDeleteResponse, err error) { | ||
| 27 | + // todo: add your logic here and delete this line | ||
| 28 | + | ||
| 29 | + return | ||
| 30 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type ArticleCategoryGetLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewArticleCategoryGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryGetLogic { | ||
| 21 | + return &ArticleCategoryGetLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *ArticleCategoryGetLogic) ArticleCategoryGet(req *types.ArticleCategoryGetRequest) (resp *types.ArticleCategoryGetResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dm *domain.ArticleCategory | ||
| 32 | + ) | ||
| 33 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 34 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 35 | + } | ||
| 36 | + resp = &types.ArticleCategoryGetResponse{ | ||
| 37 | + ArticleCategory: NewTypesArticleCategory(dm), | ||
| 38 | + } | ||
| 39 | + return | ||
| 40 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type ArticleCategoryInitLogic struct { | ||
| 14 | + logx.Logger | ||
| 15 | + ctx context.Context | ||
| 16 | + svcCtx *svc.ServiceContext | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func NewArticleCategoryInitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryInitLogic { | ||
| 20 | + return &ArticleCategoryInitLogic{ | ||
| 21 | + Logger: logx.WithContext(ctx), | ||
| 22 | + ctx: ctx, | ||
| 23 | + svcCtx: svcCtx, | ||
| 24 | + } | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (l *ArticleCategoryInitLogic) ArticleCategoryInit() error { | ||
| 28 | + var ( | ||
| 29 | + conn = l.svcCtx.DefaultDBConn() | ||
| 30 | + companyList []*domain.Company | ||
| 31 | + categoryList = []*domain.ArticleCategory{ | ||
| 32 | + { | ||
| 33 | + Name: "机会风险", | ||
| 34 | + SortBy: 1, | ||
| 35 | + Enable: 1, | ||
| 36 | + Other: "", | ||
| 37 | + }, | ||
| 38 | + { | ||
| 39 | + Name: "紧急重要", | ||
| 40 | + SortBy: 2, | ||
| 41 | + Enable: 2, | ||
| 42 | + Other: "", | ||
| 43 | + }, | ||
| 44 | + } | ||
| 45 | + dm *domain.ArticleCategory | ||
| 46 | + err error | ||
| 47 | + ) | ||
| 48 | + | ||
| 49 | + _, companyList, _ = l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions()) | ||
| 50 | + for _, company := range companyList { | ||
| 51 | + for _, category := range categoryList { | ||
| 52 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, company.Id, category.Name); err == nil && dm != nil { | ||
| 53 | + continue | ||
| 54 | + } | ||
| 55 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 56 | + articleCategory := &domain.ArticleCategory{ | ||
| 57 | + Name: category.Name, | ||
| 58 | + SortBy: category.SortBy, | ||
| 59 | + Enable: category.Enable, | ||
| 60 | + Other: category.Other, | ||
| 61 | + CompanyId: company.Id, | ||
| 62 | + } | ||
| 63 | + articleCategory, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, articleCategory) | ||
| 64 | + if err != nil { | ||
| 65 | + return err | ||
| 66 | + } | ||
| 67 | + _, tagList, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, company.Id, domain.NewQueryOptions().WithKV("category", articleCategory.Name)) | ||
| 68 | + for _, tag := range tagList { | ||
| 69 | + if tag.CategoryId != 0 { | ||
| 70 | + continue | ||
| 71 | + } | ||
| 72 | + tag.CategoryId = articleCategory.Id | ||
| 73 | + if _, err = l.svcCtx.ArticleTagRepository.UpdateWithVersion(l.ctx, conn, tag); err != nil { | ||
| 74 | + break | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + logx.Info(fmt.Sprintf("初始化 公司:%v(%d) 标签分类:%v(%d) 标签数:%v", company.Name, company.Id, articleCategory.Name, articleCategory.Id, len(tagList))) | ||
| 78 | + return err | ||
| 79 | + }, true); err != nil { | ||
| 80 | + return xerr.NewErrMsg("保存失败") | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + return nil | ||
| 85 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type ArticleCategoryOptionsLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewArticleCategoryOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryOptionsLogic { | ||
| 21 | + return &ArticleCategoryOptionsLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *ArticleCategoryOptionsLogic) ArticleCategoryOptions(req *types.CategoryOptionsRequest) (resp *types.CategoryOptionsResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dms []*domain.ArticleCategory | ||
| 32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 33 | + ) | ||
| 34 | + | ||
| 35 | + queryOptions := domain.NewQueryOptions().WithKV("enable", 1) | ||
| 36 | + | ||
| 37 | + _, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions) | ||
| 38 | + list := make([]types.CategoryOptions, 0) | ||
| 39 | + for _, item := range dms { | ||
| 40 | + list = append(list, types.CategoryOptions{ | ||
| 41 | + Label: item.Name, | ||
| 42 | + Value: item.Id, | ||
| 43 | + }) | ||
| 44 | + } | ||
| 45 | + resp = &types.CategoryOptionsResponse{ | ||
| 46 | + Options: list, | ||
| 47 | + } | ||
| 48 | + return | ||
| 49 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type ArticleCategorySaveLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewArticleCategorySaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySaveLogic { | ||
| 24 | + return &ArticleCategorySaveLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (l *ArticleCategorySaveLogic) ArticleCategorySave(req *types.ArticleCategorySaveRequest) (resp *types.ArticleCategorySaveResponse, err error) { | ||
| 32 | + var ( | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + dm *domain.ArticleCategory | ||
| 35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + ) | ||
| 37 | + // 唯一判断 | ||
| 38 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dm != nil { | ||
| 39 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dm.Name)) | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + dm = NewDomainArticleCategory(req.ArticleCategory) | ||
| 43 | + dm.CompanyId = userToken.CompanyId | ||
| 44 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 45 | + dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm) | ||
| 46 | + return err | ||
| 47 | + }, true); err != nil { | ||
| 48 | + return nil, xerr.NewErrMsg("保存失败") | ||
| 49 | + } | ||
| 50 | + resp = &types.ArticleCategorySaveResponse{} | ||
| 51 | + return | ||
| 52 | +} | ||
| 53 | +func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory { | ||
| 54 | + return &domain.ArticleCategory{ | ||
| 55 | + Name: item.Name, | ||
| 56 | + Enable: item.Enable, | ||
| 57 | + SortBy: item.SortBy, | ||
| 58 | + Other: item.Other, | ||
| 59 | + } | ||
| 60 | +} | ||
| 61 | + | ||
| 62 | +func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem { | ||
| 63 | + return types.ArticleCategoryItem{ | ||
| 64 | + Id: item.Id, | ||
| 65 | + Name: item.Name, | ||
| 66 | + Enable: item.Enable, | ||
| 67 | + SortBy: item.SortBy, | ||
| 68 | + Other: item.Other, | ||
| 69 | + } | ||
| 70 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 7 | + | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type ArticleCategorySearchLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewArticleCategorySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySearchLogic { | ||
| 21 | + return &ArticleCategorySearchLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *ArticleCategorySearchLogic) ArticleCategorySearch(req *types.ArticleCategorySearchRequest) (resp *types.ArticleCategorySearchResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dms []*domain.ArticleCategory | ||
| 32 | + total int64 | ||
| 33 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 34 | + ) | ||
| 35 | + | ||
| 36 | + queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | ||
| 37 | + | ||
| 38 | + total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions) | ||
| 39 | + list := make([]types.ArticleCategoryItem, 0) | ||
| 40 | + for _, item := range dms { | ||
| 41 | + list = append(list, NewTypesArticleCategory(item)) | ||
| 42 | + } | ||
| 43 | + resp = &types.ArticleCategorySearchResponse{ | ||
| 44 | + List: list, | ||
| 45 | + Total: total, | ||
| 46 | + } | ||
| 47 | + return | ||
| 48 | +} |
| 1 | +package tags | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 10 | + | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 12 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 13 | + | ||
| 14 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 15 | +) | ||
| 16 | + | ||
| 17 | +type ArticleCategoryUpdateLogic struct { | ||
| 18 | + logx.Logger | ||
| 19 | + ctx context.Context | ||
| 20 | + svcCtx *svc.ServiceContext | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +func NewArticleCategoryUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryUpdateLogic { | ||
| 24 | + return &ArticleCategoryUpdateLogic{ | ||
| 25 | + Logger: logx.WithContext(ctx), | ||
| 26 | + ctx: ctx, | ||
| 27 | + svcCtx: svcCtx, | ||
| 28 | + } | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (l *ArticleCategoryUpdateLogic) ArticleCategoryUpdate(req *types.ArticleCategoryUpdateRequest) (resp *types.ArticleCategoryUpdateResponse, err error) { | ||
| 32 | + var ( | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + dm *domain.ArticleCategory | ||
| 35 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 36 | + ) | ||
| 37 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 38 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 39 | + } | ||
| 40 | + // 不可编辑判断 | ||
| 41 | + if dm.Name != req.ArticleCategory.Name { | ||
| 42 | + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dm != nil { | ||
| 43 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dm.Name)) | ||
| 44 | + } | ||
| 45 | + } | ||
| 46 | + // 赋值 | ||
| 47 | + dm.Name = req.ArticleCategory.Name | ||
| 48 | + dm.SortBy = req.ArticleCategory.SortBy | ||
| 49 | + dm.Enable = req.ArticleCategory.Enable | ||
| 50 | + dm.Other = req.ArticleCategory.Other | ||
| 51 | + // 更新 | ||
| 52 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 53 | + dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 54 | + return err | ||
| 55 | + }, true); err != nil { | ||
| 56 | + return nil, xerr.NewErrMsg("更新失败") | ||
| 57 | + } | ||
| 58 | + resp = &types.ArticleCategoryUpdateResponse{} | ||
| 59 | + return | ||
| 60 | +} |
| @@ -30,18 +30,24 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | @@ -30,18 +30,24 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT | ||
| 30 | 30 | ||
| 31 | // 创建标签 | 31 | // 创建标签 |
| 32 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { | 32 | func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { |
| 33 | - var conn = l.svcCtx.DefaultDBConn() | 33 | + var ( |
| 34 | + conn = l.svcCtx.DefaultDBConn() | ||
| 35 | + articleCategory *domain.ArticleCategory | ||
| 36 | + ) | ||
| 37 | + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil { | ||
| 38 | + return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 39 | + } | ||
| 34 | //检查重复 | 40 | //检查重复 |
| 35 | cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ | 41 | cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ |
| 36 | "name": req.Name, | 42 | "name": req.Name, |
| 37 | - "category": req.Category, | 43 | + "categoryId": req.CategoryId, |
| 38 | "countOnly": true, | 44 | "countOnly": true, |
| 39 | }) | 45 | }) |
| 40 | if err != nil { | 46 | if err != nil { |
| 41 | return nil, xerr.NewErrMsgErr("添加标签失败", err) | 47 | return nil, xerr.NewErrMsgErr("添加标签失败", err) |
| 42 | } | 48 | } |
| 43 | if cnt > 0 { | 49 | if cnt > 0 { |
| 44 | - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) | 50 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name)) |
| 45 | } | 51 | } |
| 46 | 52 | ||
| 47 | newTag := &domain.ArticleTag{ | 53 | newTag := &domain.ArticleTag{ |
| @@ -53,15 +59,17 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | @@ -53,15 +59,17 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag | ||
| 53 | Version: 0, | 59 | Version: 0, |
| 54 | Image: domain.Image{}, | 60 | Image: domain.Image{}, |
| 55 | Name: req.Name, | 61 | Name: req.Name, |
| 56 | - Category: req.Category, | 62 | + Category: articleCategory.Name, |
| 63 | + CategoryId: articleCategory.Id, | ||
| 57 | Remark: req.Remark, | 64 | Remark: req.Remark, |
| 58 | Other: req.Other, | 65 | Other: req.Other, |
| 59 | SortBy: int64(req.SortBy), | 66 | SortBy: int64(req.SortBy), |
| 67 | + DataFrom: 1, | ||
| 60 | } | 68 | } |
| 61 | - err = newTag.SetCategory(req.Category) | ||
| 62 | - if err != nil { | ||
| 63 | - return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 64 | - } | 69 | + //err = newTag.SetCategory(req.Category) |
| 70 | + //if err != nil { | ||
| 71 | + // return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 72 | + //} | ||
| 65 | if len(req.Image) > 0 { | 73 | if len(req.Image) > 0 { |
| 66 | //获取图片的尺寸大小 | 74 | //获取图片的尺寸大小 |
| 67 | fInfo, _ := oss.GetImageInfo(req.Image) | 75 | fInfo, _ := oss.GetImageInfo(req.Image) |
| @@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag | @@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag | ||
| 33 | if oldTag.CompanyId != req.CompanyId { | 33 | if oldTag.CompanyId != req.CompanyId { |
| 34 | return nil, xerr.NewErrMsg("删除标签失败") | 34 | return nil, xerr.NewErrMsg("删除标签失败") |
| 35 | } | 35 | } |
| 36 | + if oldTag.DataFrom == 0 { | ||
| 37 | + return nil, xerr.NewErrMsg("系统标签不可删除") | ||
| 38 | + } | ||
| 36 | _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) | 39 | _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) |
| 37 | if err != nil { | 40 | if err != nil { |
| 38 | return nil, xerr.NewErrMsg("删除标签失败") | 41 | return nil, xerr.NewErrMsg("删除标签失败") |
| @@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | @@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo | ||
| 30 | 30 | ||
| 31 | // 编辑标签 | 31 | // 编辑标签 |
| 32 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { | 32 | func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { |
| 33 | - var conn = l.svcCtx.DefaultDBConn() | 33 | + var ( |
| 34 | + conn = l.svcCtx.DefaultDBConn() | ||
| 35 | + articleCategory *domain.ArticleCategory | ||
| 36 | + ) | ||
| 34 | //检查重复 | 37 | //检查重复 |
| 35 | queryOptions := domain.NewQueryOptions(). | 38 | queryOptions := domain.NewQueryOptions(). |
| 36 | WithFindOnly(). | 39 | WithFindOnly(). |
| 37 | MustWithKV("name", req.Name). | 40 | MustWithKV("name", req.Name). |
| 38 | - MustWithKV("category", req.Category). | 41 | + MustWithKV("categoryId", req.CategoryId). |
| 39 | WithOffsetLimit(1, 1) | 42 | WithOffsetLimit(1, 1) |
| 40 | - | 43 | + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil { |
| 44 | + return nil, xerr.NewErrMsgErr("标签分类不存在失败", err) | ||
| 45 | + } | ||
| 41 | _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) | 46 | _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) |
| 42 | if err != nil { | 47 | if err != nil { |
| 43 | return nil, xerr.NewErrMsgErr("修改标签失败", err) | 48 | return nil, xerr.NewErrMsgErr("修改标签失败", err) |
| 44 | } | 49 | } |
| 45 | if len(tagList) > 0 { | 50 | if len(tagList) > 0 { |
| 46 | if tagList[0].Id != req.Id { | 51 | if tagList[0].Id != req.Id { |
| 47 | - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) | 52 | + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name)) |
| 48 | } | 53 | } |
| 49 | } | 54 | } |
| 50 | oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) | 55 | oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) |
| @@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | @@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe | ||
| 66 | Height: h, | 71 | Height: h, |
| 67 | } | 72 | } |
| 68 | } | 73 | } |
| 69 | - oldTag.Category = req.Category | ||
| 70 | oldTag.Name = req.Name | 74 | oldTag.Name = req.Name |
| 71 | oldTag.Remark = req.Remark | 75 | oldTag.Remark = req.Remark |
| 72 | oldTag.Other = req.Other | 76 | oldTag.Other = req.Other |
| 73 | oldTag.SortBy = int64(req.SortBy) | 77 | oldTag.SortBy = int64(req.SortBy) |
| 74 | - err = oldTag.SetCategory(req.Category) | ||
| 75 | - if err != nil { | ||
| 76 | - return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 77 | - } | 78 | + oldTag.CategoryId = articleCategory.Id |
| 79 | + oldTag.Category = articleCategory.Name | ||
| 80 | + //err = oldTag.SetCategory(req.Category) | ||
| 81 | + //if err != nil { | ||
| 82 | + // return nil, xerr.NewErrMsgErr("添加标签失败", err) | ||
| 83 | + //} | ||
| 78 | oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) | 84 | oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) |
| 79 | if err != nil { | 85 | if err != nil { |
| 80 | return nil, xerr.NewErrMsgErr("添加标签失败", err) | 86 | return nil, xerr.NewErrMsgErr("添加标签失败", err) |
| @@ -39,6 +39,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon | @@ -39,6 +39,7 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon | ||
| 39 | Image: oldTag.Image.Url, | 39 | Image: oldTag.Image.Url, |
| 40 | Name: oldTag.Name, | 40 | Name: oldTag.Name, |
| 41 | Category: oldTag.Category, | 41 | Category: oldTag.Category, |
| 42 | + CategoryId: oldTag.CategoryId, | ||
| 42 | Remark: oldTag.Remark, | 43 | Remark: oldTag.Remark, |
| 43 | Other: oldTag.Other, | 44 | Other: oldTag.Other, |
| 44 | SortBy: int(oldTag.SortBy), | 45 | SortBy: int(oldTag.SortBy), |
| @@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT | @@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT | ||
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { | 26 | func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { |
| 27 | - var conn = l.svcCtx.DefaultDBConn() | 27 | + var ( |
| 28 | + conn = l.svcCtx.DefaultDBConn() | ||
| 29 | + categoryMap = make(map[int64]*domain.ArticleCategory) | ||
| 30 | + ) | ||
| 28 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) | 31 | queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) |
| 29 | 32 | ||
| 30 | - if len(req.Category) > 0 { | ||
| 31 | - queryOptions = queryOptions.MustWithKV("category", "%"+req.Category+"%") | 33 | + if req.CategoryId > 0 { |
| 34 | + queryOptions = queryOptions.MustWithKV("categoryId", req.CategoryId) | ||
| 32 | } | 35 | } |
| 33 | if len(req.TagName) > 0 { | 36 | if len(req.TagName) > 0 { |
| 34 | queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%") | 37 | queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%") |
| @@ -51,9 +54,14 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi | @@ -51,9 +54,14 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi | ||
| 51 | Image: tagList[i].Image.Url, | 54 | Image: tagList[i].Image.Url, |
| 52 | Name: tagList[i].Name, | 55 | Name: tagList[i].Name, |
| 53 | Category: tagList[i].Category, | 56 | Category: tagList[i].Category, |
| 57 | + CategoryId: tagList[i].CategoryId, | ||
| 54 | Remark: tagList[i].Remark, | 58 | Remark: tagList[i].Remark, |
| 55 | CreatedAt: tagList[i].CreatedAt, | 59 | CreatedAt: tagList[i].CreatedAt, |
| 56 | SortBy: int(tagList[i].SortBy), | 60 | SortBy: int(tagList[i].SortBy), |
| 61 | + Removeable: tagList[i].DataFrom != 0, | ||
| 62 | + } | ||
| 63 | + if category, _ := domain.LazyLoad(categoryMap, l.ctx, conn, tagList[i].CategoryId, l.svcCtx.ArticleCategoryRepository.FindOne); category != nil { | ||
| 64 | + resp.List[i].Category = category.Name | ||
| 57 | } | 65 | } |
| 58 | } | 66 | } |
| 59 | return resp, nil | 67 | return resp, nil |
| @@ -3,6 +3,7 @@ package user | @@ -3,6 +3,7 @@ package user | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | "strconv" | 7 | "strconv" |
| 7 | 8 | ||
| 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| @@ -109,11 +110,23 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | @@ -109,11 +110,23 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
| 109 | // 初始设置文章标签 | 110 | // 初始设置文章标签 |
| 110 | queryOption := domain.NewQueryOptions().WithCountOnly() | 111 | queryOption := domain.NewQueryOptions().WithCountOnly() |
| 111 | conn := l.svcCtx.DefaultDBConn() | 112 | conn := l.svcCtx.DefaultDBConn() |
| 112 | - cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption) | ||
| 113 | - if err != nil { | ||
| 114 | - return xerr.NewErrMsgErr("初始话公司数据失败", err) | 113 | + categoryList := []*domain.ArticleCategory{ |
| 114 | + { | ||
| 115 | + Name: "机会风险", | ||
| 116 | + SortBy: 1, | ||
| 117 | + Enable: 1, | ||
| 118 | + Other: "", | ||
| 119 | + CompanyId: companyId, | ||
| 120 | + }, | ||
| 121 | + { | ||
| 122 | + Name: "紧急重要", | ||
| 123 | + SortBy: 2, | ||
| 124 | + Enable: 1, | ||
| 125 | + Other: "", | ||
| 126 | + CompanyId: companyId, | ||
| 127 | + }, | ||
| 115 | } | 128 | } |
| 116 | - if cnt == 0 { | 129 | + |
| 117 | articleTags := []*domain.ArticleTag{ | 130 | articleTags := []*domain.ArticleTag{ |
| 118 | { | 131 | { |
| 119 | Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0}, | 132 | Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0}, |
| @@ -168,11 +181,37 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | @@ -168,11 +181,37 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { | ||
| 168 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, | 181 | Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13, |
| 169 | }, | 182 | }, |
| 170 | } | 183 | } |
| 184 | + | ||
| 185 | + cnt, _, err := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, companyId, queryOption) | ||
| 186 | + if cnt == 0 { | ||
| 187 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 188 | + for _, category := range categoryList { | ||
| 189 | + category, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, category) | ||
| 190 | + if err != nil { | ||
| 191 | + return err | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + cnt, _, err = l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption) | ||
| 195 | + if err != nil { | ||
| 196 | + return xerr.NewErrMsgErr("初始话公司数据失败", err) | ||
| 197 | + } | ||
| 198 | + for _, tag := range articleTags { | ||
| 199 | + for _, category := range categoryList { | ||
| 200 | + if category.Name == tag.Category { | ||
| 201 | + tag.CategoryId = category.Id | ||
| 202 | + } | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + if cnt == 0 { | ||
| 171 | err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags) | 206 | err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags) |
| 172 | if err != nil { | 207 | if err != nil { |
| 173 | return xerr.NewErrMsgErr("初始话公司数据失败", err) | 208 | return xerr.NewErrMsgErr("初始话公司数据失败", err) |
| 174 | } | 209 | } |
| 175 | } | 210 | } |
| 176 | - | 211 | + return nil |
| 212 | + }, true); err != nil { | ||
| 213 | + return xerr.NewErrMsgErr("初始话公司数据失败", err) | ||
| 214 | + } | ||
| 215 | + } | ||
| 177 | return nil | 216 | return nil |
| 178 | } | 217 | } |
| @@ -33,7 +33,9 @@ type ServiceContext struct { | @@ -33,7 +33,9 @@ type ServiceContext struct { | ||
| 33 | ArticleRepository domain.ArticleRepository | 33 | ArticleRepository domain.ArticleRepository |
| 34 | ArticleSectionRepository domain.ArticleSectionRepository | 34 | ArticleSectionRepository domain.ArticleSectionRepository |
| 35 | ArticleTagRepository domain.ArticleTagRepository | 35 | ArticleTagRepository domain.ArticleTagRepository |
| 36 | + ArticleCategoryRepository domain.ArticleCategoryRepository | ||
| 36 | ArticleAndTagRepository domain.ArticleAndTagRepository | 37 | ArticleAndTagRepository domain.ArticleAndTagRepository |
| 38 | + ArticleDraftOperationRepository domain.ArticleDraftOperationRepository | ||
| 37 | 39 | ||
| 38 | CompanyRepository domain.CompanyRepository | 40 | CompanyRepository domain.CompanyRepository |
| 39 | DepartmentRepository domain.DepartmentRepository | 41 | DepartmentRepository domain.DepartmentRepository |
| @@ -351,10 +351,10 @@ type TagCreateRequest struct { | @@ -351,10 +351,10 @@ type TagCreateRequest struct { | ||
| 351 | CompanyId int64 `json:",optional"` | 351 | CompanyId int64 `json:",optional"` |
| 352 | Image string `json:"image"` | 352 | Image string `json:"image"` |
| 353 | Name string `json:"name"` // 标签名称 | 353 | Name string `json:"name"` // 标签名称 |
| 354 | - Category string `json:"category"` // 标签分类 | ||
| 355 | Remark string `json:"remark,optional"` // 备注 | 354 | Remark string `json:"remark,optional"` // 备注 |
| 356 | Other string `json:"other,optional"` | 355 | Other string `json:"other,optional"` |
| 357 | SortBy int `json:"sortBy,optional"` //排序 | 356 | SortBy int `json:"sortBy,optional"` //排序 |
| 357 | + CategoryId int64 `json:"categoryId"` // 标签Id | ||
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | type TagCreateResponse struct { | 360 | type TagCreateResponse struct { |
| @@ -366,7 +366,7 @@ type TagEditRequest struct { | @@ -366,7 +366,7 @@ type TagEditRequest struct { | ||
| 366 | CompanyId int64 `json:",optional"` | 366 | CompanyId int64 `json:",optional"` |
| 367 | Image string `json:"image"` | 367 | Image string `json:"image"` |
| 368 | Name string `json:"name"` // 标签名称 | 368 | Name string `json:"name"` // 标签名称 |
| 369 | - Category string `json:"category"` // 标签分类 | 369 | + CategoryId int64 `json:"categoryId"` // 标签Id |
| 370 | Remark string `json:"remark,optional"` // 备注 | 370 | Remark string `json:"remark,optional"` // 备注 |
| 371 | Other string `json:"other,optional"` | 371 | Other string `json:"other,optional"` |
| 372 | SortBy int `json:"sortBy,optional"` // 排序 | 372 | SortBy int `json:"sortBy,optional"` // 排序 |
| @@ -386,6 +386,7 @@ type TagGetResponse struct { | @@ -386,6 +386,7 @@ type TagGetResponse struct { | ||
| 386 | Image string `json:"image"` | 386 | Image string `json:"image"` |
| 387 | Name string `json:"name"` // 标签名称 | 387 | Name string `json:"name"` // 标签名称 |
| 388 | Category string `json:"category"` // 标签分类 | 388 | Category string `json:"category"` // 标签分类 |
| 389 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
| 389 | Remark string `json:"remark"` // 备注 | 390 | Remark string `json:"remark"` // 备注 |
| 390 | Other string `json:"other"` | 391 | Other string `json:"other"` |
| 391 | SortBy int `json:"sortBy,optional"` // 排序 | 392 | SortBy int `json:"sortBy,optional"` // 排序 |
| @@ -396,7 +397,7 @@ type TagListRequest struct { | @@ -396,7 +397,7 @@ type TagListRequest struct { | ||
| 396 | Size int `json:"size"` | 397 | Size int `json:"size"` |
| 397 | CompanyId int64 `json:",optional"` | 398 | CompanyId int64 `json:",optional"` |
| 398 | TagName string `json:"tagName,optional"` | 399 | TagName string `json:"tagName,optional"` |
| 399 | - Category string `json:"category,optional"` | 400 | + CategoryId int64 `json:"categoryId,optional"` |
| 400 | Remark string `json:"remark,optional"` | 401 | Remark string `json:"remark,optional"` |
| 401 | } | 402 | } |
| 402 | 403 | ||
| @@ -410,9 +411,11 @@ type TagItem struct { | @@ -410,9 +411,11 @@ type TagItem struct { | ||
| 410 | Image string `json:"image"` | 411 | Image string `json:"image"` |
| 411 | Name string `json:"name"` // 标签名称 | 412 | Name string `json:"name"` // 标签名称 |
| 412 | Category string `json:"category"` // 标签分类 | 413 | Category string `json:"category"` // 标签分类 |
| 414 | + CategoryId int64 `json:"categoryId"` // 标签分类Id | ||
| 413 | Remark string `json:"remark"` // 备注 | 415 | Remark string `json:"remark"` // 备注 |
| 414 | CreatedAt int64 `json:"createdAt"` | 416 | CreatedAt int64 `json:"createdAt"` |
| 415 | SortBy int `json:"sortBy,optional"` // 排序 | 417 | SortBy int `json:"sortBy,optional"` // 排序 |
| 418 | + Removeable bool `json:"removeable,optional"` // 可删除 | ||
| 416 | } | 419 | } |
| 417 | 420 | ||
| 418 | type TagDeleteRequest struct { | 421 | type TagDeleteRequest struct { |
| @@ -433,7 +436,8 @@ type TagOptionsResponse struct { | @@ -433,7 +436,8 @@ type TagOptionsResponse struct { | ||
| 433 | } | 436 | } |
| 434 | 437 | ||
| 435 | type TagOptions struct { | 438 | type TagOptions struct { |
| 436 | - Label string `json:"label"` // 分组名称 | 439 | + Value int64 `json:"value"` // 分类ID |
| 440 | + Label string `json:"label"` // 分类名称 | ||
| 437 | Options []TagOptionValue `json:"options"` | 441 | Options []TagOptionValue `json:"options"` |
| 438 | } | 442 | } |
| 439 | 443 | ||
| @@ -862,6 +866,13 @@ type Company struct { | @@ -862,6 +866,13 @@ type Company struct { | ||
| 862 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) | 866 | JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) |
| 863 | } | 867 | } |
| 864 | 868 | ||
| 869 | +type CompanyVisibleSwitchRequest struct { | ||
| 870 | + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索 | ||
| 871 | +} | ||
| 872 | + | ||
| 873 | +type CompanyVisibleSwitchResponse struct { | ||
| 874 | +} | ||
| 875 | + | ||
| 865 | type CompanyPositionsSearchRequest struct { | 876 | type CompanyPositionsSearchRequest struct { |
| 866 | } | 877 | } |
| 867 | 878 | ||
| @@ -895,6 +906,11 @@ type ArticleAuthor struct { | @@ -895,6 +906,11 @@ type ArticleAuthor struct { | ||
| 895 | Company string `json:"company"` // 公司 | 906 | Company string `json:"company"` // 公司 |
| 896 | } | 907 | } |
| 897 | 908 | ||
| 909 | +type Operator struct { | ||
| 910 | + Id int64 `json:"id,string"` // 人员id | ||
| 911 | + Name string `json:"name"` // 人员的名字 | ||
| 912 | +} | ||
| 913 | + | ||
| 898 | type MiniArticleCreateRequest struct { | 914 | type MiniArticleCreateRequest struct { |
| 899 | Title string `json:"title"` //标题 | 915 | Title string `json:"title"` //标题 |
| 900 | Section []string `json:"section"` //文章的文本内容 | 916 | Section []string `json:"section"` //文章的文本内容 |
| @@ -1263,11 +1279,14 @@ type SystemArticleSearch struct { | @@ -1263,11 +1279,14 @@ type SystemArticleSearch struct { | ||
| 1263 | Author string `json:"author"` //发布人 | 1279 | Author string `json:"author"` //发布人 |
| 1264 | Images []string `json:"images"` //图片 | 1280 | Images []string `json:"images"` //图片 |
| 1265 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 | 1281 | CreatedAt int64 `json:"createdAt"` //文章的创建日期 |
| 1282 | + UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期 | ||
| 1266 | CountLove int `json:"countLove"` //点赞数量 | 1283 | CountLove int `json:"countLove"` //点赞数量 |
| 1267 | CountComment int `json:"countComment"` //评论数量 | 1284 | CountComment int `json:"countComment"` //评论数量 |
| 1268 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] | 1285 | Show int `json:"show"` //是否隐藏 [0显示、1不显示] |
| 1269 | Tags []string `json:"tags"` //标签 | 1286 | Tags []string `json:"tags"` //标签 |
| 1270 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1287 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 1288 | + Operator Operator `json:"operator"` //运营操作人 | ||
| 1289 | + Source int `json:"source"` //来源[1用户发布、2运营发布] | ||
| 1271 | } | 1290 | } |
| 1272 | 1291 | ||
| 1273 | type SystemArticleUpdateRequest struct { | 1292 | type SystemArticleUpdateRequest struct { |
| @@ -1299,6 +1318,43 @@ type SystemArticleUpdateResponse struct { | @@ -1299,6 +1318,43 @@ type SystemArticleUpdateResponse struct { | ||
| 1299 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] | 1318 | TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] |
| 1300 | } | 1319 | } |
| 1301 | 1320 | ||
| 1321 | +type SystemArticleCreateRequest struct { | ||
| 1322 | + Title string `json:"title"` //标题 | ||
| 1323 | + Content string `json:"content"` //文章的文本内容 | ||
| 1324 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1325 | + Images []string `json:"images,optional"` //图片 | ||
| 1326 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1327 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1328 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1329 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1330 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1331 | + ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | ||
| 1332 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 1333 | +} | ||
| 1334 | + | ||
| 1335 | +type SystemArticleCreateResponse struct { | ||
| 1336 | + Id int64 `json:"id"` //id | ||
| 1337 | + Title string `json:"title"` //标题 | ||
| 1338 | + Content string `json:"content"` //文章的文本内容 | ||
| 1339 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
| 1340 | + Images []string `json:"images,optional"` //图片 | ||
| 1341 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1342 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1343 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1344 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1345 | + MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | ||
| 1346 | +} | ||
| 1347 | + | ||
| 1348 | +type SystemArticleDeleteRequest struct { | ||
| 1349 | + Id int64 `json:"id"` //id | ||
| 1350 | +} | ||
| 1351 | + | ||
| 1352 | +type SystemArticleDeleteResponse struct { | ||
| 1353 | + Id int64 `json:"id"` //id | ||
| 1354 | + Title string `json:"title"` //标题 | ||
| 1355 | + AuthorId int64 `json:"authorId,optional"` //发布人id | ||
| 1356 | +} | ||
| 1357 | + | ||
| 1302 | type SystemArticleHistoryRequest struct { | 1358 | type SystemArticleHistoryRequest struct { |
| 1303 | ArticleId int64 `json:"articleId"` //文章ID | 1359 | ArticleId int64 `json:"articleId"` //文章ID |
| 1304 | Author string `json:"author,optional"` //发布人 | 1360 | Author string `json:"author,optional"` //发布人 |
| @@ -1401,6 +1457,161 @@ type MiniSearchArticleItem struct { | @@ -1401,6 +1457,161 @@ type MiniSearchArticleItem struct { | ||
| 1401 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] | 1457 | MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] |
| 1402 | } | 1458 | } |
| 1403 | 1459 | ||
| 1460 | +type SystemArticleDraftCreateRequest struct { | ||
| 1461 | + Title string `json:"title"` //标题 | ||
| 1462 | + Content string `json:"content"` //文章的文本内容 | ||
| 1463 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1464 | + Images []string `json:"images,optional"` //图片 | ||
| 1465 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1466 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1467 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1468 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1469 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1470 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1471 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 1472 | +} | ||
| 1473 | + | ||
| 1474 | +type SystemArticleDraftCreateResponse struct { | ||
| 1475 | + Id int64 `json:"id"` //ID | ||
| 1476 | + Title string `json:"title"` //标题 | ||
| 1477 | + Content string `json:"content"` //文章的文本内容 | ||
| 1478 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1479 | + Images []string `json:"images,optional"` //图片 | ||
| 1480 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1481 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1482 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1483 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1484 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1485 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1486 | +} | ||
| 1487 | + | ||
| 1488 | +type SystemArticleDraftUpdateRequest struct { | ||
| 1489 | + Id int64 `json:"id"` // ID | ||
| 1490 | + Title string `json:"title"` //标题 | ||
| 1491 | + Content string `json:"content"` //文章的文本内容 | ||
| 1492 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1493 | + Images []string `json:"images,optional"` //图片 | ||
| 1494 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1495 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1496 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1497 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1498 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1499 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1500 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 1501 | +} | ||
| 1502 | + | ||
| 1503 | +type SystemArticleDraftUpdateResponse struct { | ||
| 1504 | + Id int64 `json:"id"` //ID | ||
| 1505 | + Title string `json:"title"` //标题 | ||
| 1506 | + Content string `json:"content"` //文章的文本内容 | ||
| 1507 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1508 | + Images []string `json:"images,optional"` //图片 | ||
| 1509 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1510 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1511 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1512 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1513 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1514 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1515 | +} | ||
| 1516 | + | ||
| 1517 | +type SystemArticleDraftSearchRequest struct { | ||
| 1518 | + Page int `json:"page"` //页码 | ||
| 1519 | + Size int `json:"size"` //每页行数 | ||
| 1520 | + CompanyId int64 `json:"companyId,optional"` //公司ID(前端不传) | ||
| 1521 | + Title string `json:"title,optional"` //标题 | ||
| 1522 | + Operator string `json:"operator,optional"` //编辑人 | ||
| 1523 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 | ||
| 1524 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 1525 | +} | ||
| 1526 | + | ||
| 1527 | +type SystemArticleDraftSearchResponse struct { | ||
| 1528 | + Total int `json:"total"` | ||
| 1529 | + List []SystemArticleDraftSearch `json:"list"` | ||
| 1530 | +} | ||
| 1531 | + | ||
| 1532 | +type SystemArticleDraftSearch struct { | ||
| 1533 | + Id int64 `json:"id"` //ID | ||
| 1534 | + Title string `json:"title"` //标题 | ||
| 1535 | + Images []string `json:"images"` //图片 | ||
| 1536 | + Operator string `json:"operator"` //操作人 | ||
| 1537 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1538 | + Author string `json:"author"` //发布人 | ||
| 1539 | + UpdatedAt int64 `json:"updatedAt"` //编辑时间 | ||
| 1540 | +} | ||
| 1541 | + | ||
| 1542 | +type SystemArticleDraftDeleteRequest struct { | ||
| 1543 | + Id int64 `json:"id"` //ID | ||
| 1544 | +} | ||
| 1545 | + | ||
| 1546 | +type SystemArticleDraftDeleteResponse struct { | ||
| 1547 | + Id int64 `json:"id"` //ID | ||
| 1548 | + Title string `json:"title"` //标题 | ||
| 1549 | + Content string `json:"content"` //文章的文本内容 | ||
| 1550 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1551 | + Images []string `json:"images,optional"` //图片 | ||
| 1552 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1553 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1554 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1555 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1556 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1557 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1558 | +} | ||
| 1559 | + | ||
| 1560 | +type SystemArticleDraftGetRequest struct { | ||
| 1561 | + Id int64 `path:"id"` //id | ||
| 1562 | + CompanyId int64 `path:",optional"` //公司ID(前端不传) | ||
| 1563 | +} | ||
| 1564 | + | ||
| 1565 | +type SystemArticleDraftGetResponse struct { | ||
| 1566 | + Id int64 `json:"id"` //ID | ||
| 1567 | + Title string `json:"title"` //标题 | ||
| 1568 | + Content string `json:"content"` //文章的文本内容 | ||
| 1569 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1570 | + Images []string `json:"images,optional"` //图片 | ||
| 1571 | + Videos []Video `json:"video,optional"` // 视频 | ||
| 1572 | + TargetUser int `json:"targetUser"` // 分发方式 [0分发给所有人、1分发给指定的人] | ||
| 1573 | + WhoRead []int64 `json:"whoRead,optional"` //谁可查看 | ||
| 1574 | + WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | ||
| 1575 | + MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | ||
| 1576 | + Tags []int64 `json:"tags"` // 标签 | ||
| 1577 | +} | ||
| 1578 | + | ||
| 1579 | +type SystemArticleSearchDeletedRequest struct { | ||
| 1580 | + Page int `json:"page"` //页码 | ||
| 1581 | + Size int `json:"size"` //每页行数 | ||
| 1582 | + Title string `json:"title,optional"` //标题 | ||
| 1583 | + Author int64 `json:"author,optional"` //发布人 | ||
| 1584 | + DeletedType int `json:"deletedType,optional"` //类型 1-运营删除 2-用户删除 | ||
| 1585 | + BeginTime int64 `json:"beginTime,optional"` //开始时间 | ||
| 1586 | + EndTime int64 `json:"endTime,optional"` //结束时间 | ||
| 1587 | +} | ||
| 1588 | + | ||
| 1589 | +type SystemArticleSearchDeletedResponse struct { | ||
| 1590 | + Total int `json:"total"` | ||
| 1591 | + List []SystemArticleSearchDeletedItem `json:"list"` | ||
| 1592 | +} | ||
| 1593 | + | ||
| 1594 | +type SystemArticleSearchDeletedItem struct { | ||
| 1595 | + Id int64 `json:"id"` //ID | ||
| 1596 | + Title string `json:"title"` //标题 | ||
| 1597 | + Images []string `json:"images"` //图片 | ||
| 1598 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1599 | + Author string `json:"author"` //发布人 | ||
| 1600 | + Source int `json:"source"` //来源 1-用户发布 2-运营发布 | ||
| 1601 | + DeletedType int `json:"deletedType"` //类型 1-运营删除 2-用户删除 | ||
| 1602 | + DeletedAt int64 `json:"deletedAt"` //删除时间 | ||
| 1603 | +} | ||
| 1604 | + | ||
| 1605 | +type SystemArticleDeletedRestoreRequest struct { | ||
| 1606 | + Id int64 `json:"id"` //ID | ||
| 1607 | +} | ||
| 1608 | + | ||
| 1609 | +type SystemArticleDeletedRestoreResponse struct { | ||
| 1610 | + Id int64 `json:"id"` //ID | ||
| 1611 | + Title string `json:"title"` //标题 | ||
| 1612 | + AuthorId int64 `json:"authorId"` //发布人id | ||
| 1613 | +} | ||
| 1614 | + | ||
| 1404 | type RoleGetRequest struct { | 1615 | type RoleGetRequest struct { |
| 1405 | Id int64 `path:"id"` | 1616 | Id int64 `path:"id"` |
| 1406 | } | 1617 | } |
| @@ -1494,3 +1705,70 @@ type DepartmentListResponse struct { | @@ -1494,3 +1705,70 @@ type DepartmentListResponse struct { | ||
| 1494 | List []Department `json:"list"` | 1705 | List []Department `json:"list"` |
| 1495 | Total int64 `json:"total"` | 1706 | Total int64 `json:"total"` |
| 1496 | } | 1707 | } |
| 1708 | + | ||
| 1709 | +type ArticleCategoryGetRequest struct { | ||
| 1710 | + Id int64 `path:"id"` | ||
| 1711 | +} | ||
| 1712 | + | ||
| 1713 | +type ArticleCategoryGetResponse struct { | ||
| 1714 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 1715 | +} | ||
| 1716 | + | ||
| 1717 | +type ArticleCategorySaveRequest struct { | ||
| 1718 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 1719 | +} | ||
| 1720 | + | ||
| 1721 | +type ArticleCategorySaveResponse struct { | ||
| 1722 | +} | ||
| 1723 | + | ||
| 1724 | +type ArticleCategoryDeleteRequest struct { | ||
| 1725 | + Id int64 `path:"id"` | ||
| 1726 | +} | ||
| 1727 | + | ||
| 1728 | +type ArticleCategoryDeleteResponse struct { | ||
| 1729 | +} | ||
| 1730 | + | ||
| 1731 | +type ArticleCategoryUpdateRequest struct { | ||
| 1732 | + Id int64 `path:"id"` | ||
| 1733 | + ArticleCategory ArticleCategoryItem `json:"category"` | ||
| 1734 | +} | ||
| 1735 | + | ||
| 1736 | +type ArticleCategoryUpdateResponse struct { | ||
| 1737 | +} | ||
| 1738 | + | ||
| 1739 | +type ArticleCategorySearchRequest struct { | ||
| 1740 | + Page int `json:"page"` | ||
| 1741 | + Size int `json:"size"` | ||
| 1742 | +} | ||
| 1743 | + | ||
| 1744 | +type ArticleCategorySearchResponse struct { | ||
| 1745 | + List []ArticleCategoryItem `json:"list"` | ||
| 1746 | + Total int64 `json:"total"` | ||
| 1747 | +} | ||
| 1748 | + | ||
| 1749 | +type ArticleCategoryItem struct { | ||
| 1750 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
| 1751 | + CompanyId int64 `json:"companyId,optional,omitempty"` | ||
| 1752 | + Name string `json:"name"` | ||
| 1753 | + SortBy int `json:"sortBy,optional,omitempty"` // 排序 | ||
| 1754 | + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | ||
| 1755 | + Other string `json:"other,optional,omitempty"` // 其他备注说明 | ||
| 1756 | +} | ||
| 1757 | + | ||
| 1758 | +type CategoryOptionsRequest struct { | ||
| 1759 | + CompanyId int64 `path:",optional"` // 公司ID | ||
| 1760 | +} | ||
| 1761 | + | ||
| 1762 | +type CategoryOptionsResponse struct { | ||
| 1763 | + Options []CategoryOptions `json:"options"` | ||
| 1764 | +} | ||
| 1765 | + | ||
| 1766 | +type CategoryOptions struct { | ||
| 1767 | + Value int64 `json:"value"` // 分类ID | ||
| 1768 | + Label string `json:"label"` // 分组名称 | ||
| 1769 | +} | ||
| 1770 | + | ||
| 1771 | +type CategoryOptionValue struct { | ||
| 1772 | + Label string `json:"label"` // 名称 | ||
| 1773 | + Value int64 `json:"value"` // 分类ID | ||
| 1774 | +} |
cmd/discuss/doc/dsl/api/article_category.api
0 → 100644
| 1 | + | ||
| 2 | +syntax = "v1" | ||
| 3 | + | ||
| 4 | +info( | ||
| 5 | + title: "xx实例" | ||
| 6 | + desc: "xx实例" | ||
| 7 | + author: "author" | ||
| 8 | + email: "email" | ||
| 9 | + version: "v1" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +@server( | ||
| 13 | + prefix: article_category/v1 | ||
| 14 | + group: article_category | ||
| 15 | + jwt: JwtAuth | ||
| 16 | +) | ||
| 17 | +service Core { | ||
| 18 | + @doc "详情" | ||
| 19 | + @handler article_categoryGet | ||
| 20 | + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse) | ||
| 21 | + @doc "保存" | ||
| 22 | + @handler article_categorySave | ||
| 23 | + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse) | ||
| 24 | + @doc "删除" | ||
| 25 | + @handler article_categoryDelete | ||
| 26 | + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse) | ||
| 27 | + @doc "更新" | ||
| 28 | + @handler article_categoryUpdate | ||
| 29 | + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse) | ||
| 30 | + @doc "搜索" | ||
| 31 | + @handler article_categorySearch | ||
| 32 | + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +type ( | ||
| 36 | + ArticleCategoryGetRequest { | ||
| 37 | + Id int64 `path:"id"` | ||
| 38 | + } | ||
| 39 | + ArticleCategoryGetResponse struct{ | ||
| 40 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + ArticleCategorySaveRequest struct{ | ||
| 44 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
| 45 | + } | ||
| 46 | + ArticleCategorySaveResponse struct{} | ||
| 47 | + | ||
| 48 | + ArticleCategoryDeleteRequest struct{ | ||
| 49 | + Id int64 `path:"id"` | ||
| 50 | + } | ||
| 51 | + ArticleCategoryDeleteResponse struct{} | ||
| 52 | + | ||
| 53 | + ArticleCategoryUpdateRequest struct{ | ||
| 54 | + Id int64 `path:"id"` | ||
| 55 | + ArticleCategory ArticleCategoryItem `json:"article_category"` | ||
| 56 | + } | ||
| 57 | + ArticleCategoryUpdateResponse struct{} | ||
| 58 | + | ||
| 59 | + ArticleCategorySearchRequest struct{ | ||
| 60 | + Page int `json:"page"` | ||
| 61 | + Size int `json:"size"` | ||
| 62 | + } | ||
| 63 | + ArticleCategorySearchResponse{ | ||
| 64 | + List []ArticleCategoryItem `json:"list"` | ||
| 65 | + Total int64 `json:"total"` | ||
| 66 | + } | ||
| 67 | + ArticleCategoryItem struct{ | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | +) | ||
| 71 | + | ||
| 72 | +// logic CRUD | ||
| 73 | +// Save | ||
| 74 | + //var ( | ||
| 75 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 76 | + // dm *domain.ArticleCategory | ||
| 77 | + //) | ||
| 78 | + //// 唯一判断 | ||
| 79 | + | ||
| 80 | + //dm = NewDomainArticleCategory(req.ArticleCategory) | ||
| 81 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 82 | + // dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm) | ||
| 83 | + // return err | ||
| 84 | + //}, true); err != nil { | ||
| 85 | + // return nil, xerr.NewErrMsg("保存失败") | ||
| 86 | + //} | ||
| 87 | + ////resp = &types.ArticleCategorySaveResponse{} | ||
| 88 | + //return | ||
| 89 | + | ||
| 90 | +//func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory { | ||
| 91 | +// return &domain.ArticleCategory{ | ||
| 92 | + | ||
| 93 | +// } | ||
| 94 | +//} | ||
| 95 | +// | ||
| 96 | +//func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem { | ||
| 97 | +// return types.ArticleCategoryItem{ | ||
| 98 | +// Id: item.Id, | ||
| 99 | +// } | ||
| 100 | +//} | ||
| 101 | + | ||
| 102 | +// Get | ||
| 103 | + //var ( | ||
| 104 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 105 | + // dm *domain.ArticleCategory | ||
| 106 | + //) | ||
| 107 | + //// 货号唯一 | ||
| 108 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 109 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 110 | + //} | ||
| 111 | + //resp = &types.ArticleCategoryGetResponse{ | ||
| 112 | + // ArticleCategory: NewTypesArticleCategory(dm), | ||
| 113 | + //} | ||
| 114 | + //return | ||
| 115 | + | ||
| 116 | +// Delete | ||
| 117 | + //var ( | ||
| 118 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 119 | + // dm *domain.ArticleCategory | ||
| 120 | + //) | ||
| 121 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 122 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 123 | + //} | ||
| 124 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 125 | + // if dm, err = l.svcCtx.ArticleCategoryRepository.Delete(l.ctx, conn, dm); err != nil { | ||
| 126 | + // return err | ||
| 127 | + // } | ||
| 128 | + // return nil | ||
| 129 | + //}, true); err != nil { | ||
| 130 | + // return nil, xerr.NewErrMsgErr("移除失败", err) | ||
| 131 | + //} | ||
| 132 | + //return | ||
| 133 | + | ||
| 134 | +// Search | ||
| 135 | + //var ( | ||
| 136 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 137 | + // dms []*domain.ArticleCategory | ||
| 138 | + // total int64 | ||
| 139 | + //) | ||
| 140 | + // | ||
| 141 | + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | ||
| 142 | + // WithKV("", "") | ||
| 143 | + | ||
| 144 | + //total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, queryOptions) | ||
| 145 | + //list := make([]types.ArticleCategoryItem, 0) | ||
| 146 | + //for i := range dms { | ||
| 147 | + // list = append(list, NewTypesArticleCategory(dms[i])) | ||
| 148 | + //} | ||
| 149 | + //resp = &types.ArticleCategorySearchResponse{ | ||
| 150 | + // List: list, | ||
| 151 | + // Total: total, | ||
| 152 | + //} | ||
| 153 | + //return | ||
| 154 | + | ||
| 155 | +// Update | ||
| 156 | + //var ( | ||
| 157 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 158 | + // dm *domain.ArticleCategory | ||
| 159 | + //) | ||
| 160 | + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 161 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 162 | + //} | ||
| 163 | + //// 不可编辑判断 | ||
| 164 | + | ||
| 165 | + //// 赋值 | ||
| 166 | + | ||
| 167 | + //// 更新 | ||
| 168 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 169 | + // dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 170 | + // return err | ||
| 171 | + //}, true); err != nil { | ||
| 172 | + // return nil, xerr.NewErrMsg("更新失败") | ||
| 173 | + //} | ||
| 174 | + //resp = &types.ArticleCategoryUpdateResponse{} | ||
| 175 | + //return |
| 1 | + | ||
| 2 | +syntax = "v1" | ||
| 3 | + | ||
| 4 | +info( | ||
| 5 | + title: "xx实例" | ||
| 6 | + desc: "xx实例" | ||
| 7 | + author: "author" | ||
| 8 | + email: "email" | ||
| 9 | + version: "v1" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +@server( | ||
| 13 | + prefix: article_draft_operation/v1 | ||
| 14 | + group: article_draft_operation | ||
| 15 | + jwt: JwtAuth | ||
| 16 | +) | ||
| 17 | +service Core { | ||
| 18 | + @handler getArticleDraftOperation | ||
| 19 | + post /article_draft_operation/:id (ArticleDraftOperationGetRequest) returns (ArticleDraftOperationGetResponse) | ||
| 20 | + @handler saveArticleDraftOperation | ||
| 21 | + post /article_draft_operation (ArticleDraftOperationSaveRequest) returns (ArticleDraftOperationSaveResponse) | ||
| 22 | + @handler deleteArticleDraftOperation | ||
| 23 | + delete /article_draft_operation/:id (ArticleDraftOperationDeleteRequest) returns (ArticleDraftOperationDeleteResponse) | ||
| 24 | + @handler updateArticleDraftOperation | ||
| 25 | + put /article_draft_operation/:id (ArticleDraftOperationUpdateRequest) returns (ArticleDraftOperationUpdateResponse) | ||
| 26 | + @handler searchArticleDraftOperation | ||
| 27 | + post /article_draft_operation/search (ArticleDraftOperationSearchRequest) returns (ArticleDraftOperationSearchResponse) | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +type ( | ||
| 31 | + ArticleDraftOperationGetRequest { | ||
| 32 | + Id int64 `path:"id"` | ||
| 33 | + } | ||
| 34 | + ArticleDraftOperationGetResponse struct{ | ||
| 35 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + ArticleDraftOperationSaveRequest struct{ | ||
| 39 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
| 40 | + } | ||
| 41 | + ArticleDraftOperationSaveResponse struct{} | ||
| 42 | + | ||
| 43 | + ArticleDraftOperationDeleteRequest struct{ | ||
| 44 | + Id int64 `path:"id"` | ||
| 45 | + } | ||
| 46 | + ArticleDraftOperationDeleteResponse struct{} | ||
| 47 | + | ||
| 48 | + ArticleDraftOperationUpdateRequest struct{ | ||
| 49 | + Id int64 `path:"id"` | ||
| 50 | + ArticleDraftOperation ArticleDraftOperationItem `json:"article_draft_operation"` | ||
| 51 | + } | ||
| 52 | + ArticleDraftOperationUpdateResponse struct{} | ||
| 53 | + | ||
| 54 | + ArticleDraftOperationSearchRequest struct{ | ||
| 55 | + Page int `json:"page"` | ||
| 56 | + Size int `json:"size"` | ||
| 57 | + } | ||
| 58 | + ArticleDraftOperationSearchResponse{ | ||
| 59 | + List []ArticleDraftOperationItem `json:"list"` | ||
| 60 | + Total int64 `json:"total"` | ||
| 61 | + } | ||
| 62 | + ArticleDraftOperationItem struct{ | ||
| 63 | + | ||
| 64 | + } | ||
| 65 | +) |
| 1 | + | ||
| 2 | +syntax = "proto3"; | ||
| 3 | + | ||
| 4 | +option go_package ="./pb"; | ||
| 5 | + | ||
| 6 | +package pb; | ||
| 7 | + | ||
| 8 | +message ArticleCategoryGetReq { | ||
| 9 | + int64 Id = 1; | ||
| 10 | +} | ||
| 11 | +message ArticleCategoryGetResp{ | ||
| 12 | + ArticleCategoryItem User = 1; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +message ArticleCategorySaveReq { | ||
| 16 | + | ||
| 17 | +} | ||
| 18 | +message ArticleCategorySaveResp{ | ||
| 19 | + | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +message ArticleCategoryDeleteReq { | ||
| 23 | + int64 Id = 1; | ||
| 24 | +} | ||
| 25 | +message ArticleCategoryDeleteResp{ | ||
| 26 | + | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +message ArticleCategoryUpdateReq { | ||
| 30 | + int64 Id = 1; | ||
| 31 | +} | ||
| 32 | +message ArticleCategoryUpdateResp{ | ||
| 33 | + | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +message ArticleCategorySearchReq { | ||
| 37 | + int64 PageNumber = 1; | ||
| 38 | + int64 PageSize = 2; | ||
| 39 | +} | ||
| 40 | +message ArticleCategorySearchResp{ | ||
| 41 | + repeated ArticleCategoryItem List =1; | ||
| 42 | + int64 Total =2; | ||
| 43 | +} | ||
| 44 | +message ArticleCategoryItem { | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +service ArticleCategoryService { | ||
| 49 | + rpc ArticleCategoryGet(ArticleCategoryGetReq) returns(ArticleCategoryGetResp); | ||
| 50 | + rpc ArticleCategorySave(ArticleCategorySaveReq) returns(ArticleCategorySaveResp); | ||
| 51 | + rpc ArticleCategoryDelete(ArticleCategoryDeleteReq) returns(ArticleCategoryDeleteResp); | ||
| 52 | + rpc ArticleCategoryUpdate(ArticleCategoryUpdateReq) returns(ArticleCategoryUpdateResp); | ||
| 53 | + rpc ArticleCategorySearch(ArticleCategorySearchReq) returns(ArticleCategorySearchResp); | ||
| 54 | +} |
| 1 | + | ||
| 2 | +syntax = "proto3"; | ||
| 3 | + | ||
| 4 | +option go_package ="./pb"; | ||
| 5 | + | ||
| 6 | +package pb; | ||
| 7 | + | ||
| 8 | +message ArticleDraftOperationGetReq { | ||
| 9 | + int64 Id = 1; | ||
| 10 | +} | ||
| 11 | +message ArticleDraftOperationGetResp{ | ||
| 12 | + ArticleDraftOperationItem User = 1; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +message ArticleDraftOperationSaveReq { | ||
| 16 | + | ||
| 17 | +} | ||
| 18 | +message ArticleDraftOperationSaveResp{ | ||
| 19 | + | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +message ArticleDraftOperationDeleteReq { | ||
| 23 | + int64 Id = 1; | ||
| 24 | +} | ||
| 25 | +message ArticleDraftOperationDeleteResp{ | ||
| 26 | + | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +message ArticleDraftOperationUpdateReq { | ||
| 30 | + int64 Id = 1; | ||
| 31 | +} | ||
| 32 | +message ArticleDraftOperationUpdateResp{ | ||
| 33 | + | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +message ArticleDraftOperationSearchReq { | ||
| 37 | + int64 PageNumber = 1; | ||
| 38 | + int64 PageSize = 2; | ||
| 39 | +} | ||
| 40 | +message ArticleDraftOperationSearchResp{ | ||
| 41 | + repeated ArticleDraftOperationItem List =1; | ||
| 42 | + int64 Total =2; | ||
| 43 | +} | ||
| 44 | +message ArticleDraftOperationItem { | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +service ArticleDraftOperationService { | ||
| 49 | + rpc ArticleDraftOperationGet(ArticleDraftOperationGetReq) returns(ArticleDraftOperationGetResp); | ||
| 50 | + rpc ArticleDraftOperationSave(ArticleDraftOperationSaveReq) returns(ArticleDraftOperationSaveResp); | ||
| 51 | + rpc ArticleDraftOperationDelete(ArticleDraftOperationDeleteReq) returns(ArticleDraftOperationDeleteResp); | ||
| 52 | + rpc ArticleDraftOperationUpdate(ArticleDraftOperationUpdateReq) returns(ArticleDraftOperationUpdateResp); | ||
| 53 | + rpc ArticleDraftOperationSearch(ArticleDraftOperationSearchReq) returns(ArticleDraftOperationSearchResp); | ||
| 54 | +} |
| @@ -7,23 +7,25 @@ import ( | @@ -7,23 +7,25 @@ import ( | ||
| 7 | 7 | ||
| 8 | func Migrate(db *gorm.DB) { | 8 | func Migrate(db *gorm.DB) { |
| 9 | modelsList := []interface{}{ | 9 | modelsList := []interface{}{ |
| 10 | - &models.Article{}, | ||
| 11 | - &models.ArticleSection{}, | ||
| 12 | - &models.ArticleBackup{}, | ||
| 13 | - &models.ArticleDraft{}, | ||
| 14 | - &models.ArticleComment{}, | ||
| 15 | - &models.ArticleTag{}, | ||
| 16 | - &models.UserLoveFlag{}, | ||
| 17 | - &models.UserReadArticle{}, | ||
| 18 | - &models.User{}, | ||
| 19 | - &models.UserRole{}, | ||
| 20 | - &models.Role{}, | ||
| 21 | - &models.Company{}, | ||
| 22 | - &models.UserFollow{}, | ||
| 23 | - &models.MessageSystem{}, | ||
| 24 | - &models.MessageBusiness{}, | ||
| 25 | - &models.Department{}, | ||
| 26 | - &models.ArticleAndTag{}, | 10 | + //&models.Article{}, |
| 11 | + //&models.ArticleSection{}, | ||
| 12 | + //&models.ArticleBackup{}, | ||
| 13 | + //&models.ArticleDraft{}, | ||
| 14 | + //&models.ArticleComment{}, | ||
| 15 | + //&models.ArticleTag{}, | ||
| 16 | + //&models.UserLoveFlag{}, | ||
| 17 | + //&models.UserReadArticle{}, | ||
| 18 | + //&models.User{}, | ||
| 19 | + //&models.UserRole{}, | ||
| 20 | + //&models.Role{}, | ||
| 21 | + //&models.Company{}, | ||
| 22 | + //&models.UserFollow{}, | ||
| 23 | + //&models.MessageSystem{}, | ||
| 24 | + //&models.MessageBusiness{}, | ||
| 25 | + //&models.Department{}, | ||
| 26 | + //&models.ArticleAndTag{}, | ||
| 27 | + &models.ArticleDraftOperation{}, | ||
| 28 | + &models.ArticleCategory{}, | ||
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | db.AutoMigrate(modelsList...) | 31 | db.AutoMigrate(modelsList...) |
| @@ -2,11 +2,10 @@ package models | @@ -2,11 +2,10 @@ package models | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "fmt" | 4 | "fmt" |
| 5 | - "time" | ||
| 6 | - | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 5 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| 8 | "gorm.io/gorm" | 6 | "gorm.io/gorm" |
| 9 | "gorm.io/plugin/soft_delete" | 7 | "gorm.io/plugin/soft_delete" |
| 8 | + "time" | ||
| 10 | ) | 9 | ) |
| 11 | 10 | ||
| 12 | type Article struct { | 11 | type Article struct { |
| @@ -33,6 +32,9 @@ type Article struct { | @@ -33,6 +32,9 @@ type Article struct { | ||
| 33 | Show int // 评论的展示状态(1显示、2不显示) | 32 | Show int // 评论的展示状态(1显示、2不显示) |
| 34 | Summary string // 内容概要 | 33 | Summary string // 内容概要 |
| 35 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | 34 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 |
| 35 | + Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布 | ||
| 36 | + Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人 | ||
| 37 | + DeletedType int `json:"deletedType"` // 删除类型 1-运营删除 2-用户删除 | ||
| 36 | } | 38 | } |
| 37 | 39 | ||
| 38 | func (m *Article) TableName() string { | 40 | func (m *Article) TableName() string { |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gorm.io/gorm" | ||
| 7 | + "gorm.io/plugin/soft_delete" | ||
| 8 | + "time" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +type ArticleCategory struct { | ||
| 12 | + Id int64 // 唯一标识 | ||
| 13 | + CompanyId int64 | ||
| 14 | + Name string | ||
| 15 | + SortBy int | ||
| 16 | + Enable int | ||
| 17 | + Other string | ||
| 18 | + CreatedAt int64 | ||
| 19 | + UpdatedAt int64 | ||
| 20 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
| 21 | + DeletedAt int64 | ||
| 22 | + Version int | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +func (m *ArticleCategory) TableName() string { | ||
| 26 | + return "article_category" | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (m *ArticleCategory) BeforeCreate(tx *gorm.DB) (err error) { | ||
| 30 | + m.CreatedAt = time.Now().Unix() | ||
| 31 | + m.UpdatedAt = time.Now().Unix() | ||
| 32 | + return | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (m *ArticleCategory) BeforeUpdate(tx *gorm.DB) (err error) { | ||
| 36 | + m.UpdatedAt = time.Now().Unix() | ||
| 37 | + return | ||
| 38 | +} | ||
| 39 | + | ||
| 40 | +func (m *ArticleCategory) CacheKeyFunc() string { | ||
| 41 | + if m.Id == 0 { | ||
| 42 | + return "" | ||
| 43 | + } | ||
| 44 | + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
| 45 | +} | ||
| 46 | + | ||
| 47 | +func (m *ArticleCategory) CacheKeyFuncByObject(obj interface{}) string { | ||
| 48 | + if v, ok := obj.(*ArticleCategory); ok { | ||
| 49 | + return v.CacheKeyFunc() | ||
| 50 | + } | ||
| 51 | + return "" | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +func (m *ArticleCategory) CachePrimaryKeyFunc() string { | ||
| 55 | + if len("") == 0 { | ||
| 56 | + return "" | ||
| 57 | + } | ||
| 58 | + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
| 59 | +} |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gorm.io/gorm" | ||
| 7 | + "gorm.io/plugin/soft_delete" | ||
| 8 | + "time" | ||
| 9 | +) | ||
| 10 | + | ||
| 11 | +// ArticleDraftOperation 运营草稿 | ||
| 12 | +type ArticleDraftOperation struct { | ||
| 13 | + Id int64 `gorm:"primaryKey"` // 唯一标识 | ||
| 14 | + CompanyId int64 `gorm:"comment:公司ID"` // 公司ID | ||
| 15 | + AuthorId int64 `gorm:"comment:发布人ID"` // 发布人 | ||
| 16 | + Title string `gorm:"comment:标题"` // 文章标题 | ||
| 17 | + Content string `json:"content"` // 文章内容 | ||
| 18 | + Images []domain.Image `gorm:"type:jsonb;serializer:json"` // 图片 | ||
| 19 | + Videos []domain.Video `gorm:"type:jsonb;serializer:json"` // 视频 | ||
| 20 | + TargetUser domain.ArticleTarget `gorm:"comment:分发方式 0所有人 1指定人"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 21 | + WhoRead []int64 `gorm:"type:jsonb;serializer:json"` // 谁可以看 | ||
| 22 | + WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | ||
| 23 | + Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签 | ||
| 24 | + MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | ||
| 25 | + Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布 | ||
| 26 | + Operator domain.Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人 | ||
| 27 | + Version int `gorm:"comment:版本号"` // 版本号 | ||
| 28 | + CreatedAt int64 `gorm:"comment:创建时间"` // 创建时间 | ||
| 29 | + UpdatedAt int64 `gorm:"comment:编辑时间"` // 编辑时间 | ||
| 30 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` // 删除标记 | ||
| 31 | + DeletedAt int64 `gorm:"comment:删除时间"` // 删除时间 | ||
| 32 | +} | ||
| 33 | + | ||
| 34 | +func (m *ArticleDraftOperation) TableName() string { | ||
| 35 | + return "article_draft_operation" | ||
| 36 | +} | ||
| 37 | + | ||
| 38 | +func (m *ArticleDraftOperation) BeforeCreate(tx *gorm.DB) (err error) { | ||
| 39 | + nowTime := time.Now().Unix() | ||
| 40 | + m.CreatedAt = nowTime | ||
| 41 | + m.UpdatedAt = nowTime | ||
| 42 | + return | ||
| 43 | +} | ||
| 44 | + | ||
| 45 | +func (m *ArticleDraftOperation) BeforeUpdate(tx *gorm.DB) (err error) { | ||
| 46 | + m.UpdatedAt = time.Now().Unix() | ||
| 47 | + m.Version += 1 | ||
| 48 | + return | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +func (m *ArticleDraftOperation) CacheKeyFunc() string { | ||
| 52 | + if m.Id == 0 { | ||
| 53 | + return "" | ||
| 54 | + } | ||
| 55 | + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +func (m *ArticleDraftOperation) CacheKeyFuncByObject(obj interface{}) string { | ||
| 59 | + if v, ok := obj.(*ArticleDraftOperation); ok { | ||
| 60 | + return v.CacheKeyFunc() | ||
| 61 | + } | ||
| 62 | + return "" | ||
| 63 | +} | ||
| 64 | + | ||
| 65 | +func (m *ArticleDraftOperation) CachePrimaryKeyFunc() string { | ||
| 66 | + if len("") == 0 { | ||
| 67 | + return "" | ||
| 68 | + } | ||
| 69 | + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
| 70 | +} |
| @@ -24,6 +24,8 @@ type ArticleTag struct { | @@ -24,6 +24,8 @@ type ArticleTag struct { | ||
| 24 | Category string // 标签分类 | 24 | Category string // 标签分类 |
| 25 | SortBy int64 // 顺序 | 25 | SortBy int64 // 顺序 |
| 26 | Other string // 其他 | 26 | Other string // 其他 |
| 27 | + CategoryId int64 // 标签分类ID | ||
| 28 | + DataFrom int // 来源 0:系统初始化 1:用户自动添加(可删除) | ||
| 27 | } | 29 | } |
| 28 | 30 | ||
| 29 | func (m *ArticleTag) TableName() string { | 31 | func (m *ArticleTag) TableName() string { |
| @@ -12,7 +12,7 @@ type Company struct { | @@ -12,7 +12,7 @@ type Company struct { | ||
| 12 | Name string // 名称 | 12 | Name string // 名称 |
| 13 | Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字) | 13 | Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字) |
| 14 | Logo string // 公司LOGO | 14 | Logo string // 公司LOGO |
| 15 | - | 15 | + Visible int |
| 16 | CreatedAt int64 | 16 | CreatedAt int64 |
| 17 | UpdatedAt int64 | 17 | UpdatedAt int64 |
| 18 | DeletedAt int64 | 18 | DeletedAt int64 |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/jinzhu/copier" | ||
| 6 | + "github.com/pkg/errors" | ||
| 7 | + "github.com/tiptok/gocomm/pkg/cache" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 11 | + "gorm.io/gorm" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type ArticleCategoryRepository struct { | ||
| 15 | + *cache.CachedRepository | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func (repository *ArticleCategoryRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
| 19 | + var ( | ||
| 20 | + err error | ||
| 21 | + m = &models.ArticleCategory{} | ||
| 22 | + tx = conn.DB() | ||
| 23 | + ) | ||
| 24 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 25 | + return nil, err | ||
| 26 | + } | ||
| 27 | + if tx = tx.Model(m).Save(m); tx.Error != nil { | ||
| 28 | + return nil, tx.Error | ||
| 29 | + } | ||
| 30 | + dm.Id = m.Id | ||
| 31 | + return repository.ModelToDomainModel(m) | ||
| 32 | + | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (repository *ArticleCategoryRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
| 36 | + var ( | ||
| 37 | + err error | ||
| 38 | + m *models.ArticleCategory | ||
| 39 | + tx = conn.DB() | ||
| 40 | + ) | ||
| 41 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 42 | + return nil, err | ||
| 43 | + } | ||
| 44 | + queryFunc := func() (interface{}, error) { | ||
| 45 | + tx = tx.Model(m).Updates(m) | ||
| 46 | + return nil, tx.Error | ||
| 47 | + } | ||
| 48 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 49 | + return nil, err | ||
| 50 | + } | ||
| 51 | + return repository.ModelToDomainModel(m) | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +func (repository *ArticleCategoryRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
| 55 | + var ( | ||
| 56 | + err error | ||
| 57 | + m *models.ArticleCategory | ||
| 58 | + tx = transaction.DB() | ||
| 59 | + ) | ||
| 60 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 61 | + return nil, err | ||
| 62 | + } | ||
| 63 | + oldVersion := dm.Version | ||
| 64 | + m.Version += 1 | ||
| 65 | + queryFunc := func() (interface{}, error) { | ||
| 66 | + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m) | ||
| 67 | + if tx.RowsAffected == 0 { | ||
| 68 | + return nil, domain.ErrUpdateFail | ||
| 69 | + } | ||
| 70 | + return nil, tx.Error | ||
| 71 | + } | ||
| 72 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 73 | + return nil, err | ||
| 74 | + } | ||
| 75 | + return repository.ModelToDomainModel(m) | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +func (repository *ArticleCategoryRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) { | ||
| 79 | + var ( | ||
| 80 | + tx = conn.DB() | ||
| 81 | + m = &models.ArticleCategory{Id: dm.Identify().(int64)} | ||
| 82 | + ) | ||
| 83 | + queryFunc := func() (interface{}, error) { | ||
| 84 | + tx = tx.Where("id = ?", m.Id).Delete(m) | ||
| 85 | + return m, tx.Error | ||
| 86 | + } | ||
| 87 | + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 88 | + return dm, err | ||
| 89 | + } | ||
| 90 | + return repository.ModelToDomainModel(m) | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +func (repository *ArticleCategoryRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleCategory, error) { | ||
| 94 | + var ( | ||
| 95 | + err error | ||
| 96 | + tx = conn.DB() | ||
| 97 | + m = new(models.ArticleCategory) | ||
| 98 | + ) | ||
| 99 | + queryFunc := func() (interface{}, error) { | ||
| 100 | + tx = tx.Model(m).Where("id = ?", id).First(m) | ||
| 101 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
| 102 | + return nil, domain.ErrNotFound | ||
| 103 | + } | ||
| 104 | + return m, tx.Error | ||
| 105 | + } | ||
| 106 | + cacheModel := new(models.ArticleCategory) | ||
| 107 | + cacheModel.Id = id | ||
| 108 | + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil { | ||
| 109 | + return nil, err | ||
| 110 | + } | ||
| 111 | + return repository.ModelToDomainModel(m) | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +func (repository *ArticleCategoryRepository) FindOneByName(ctx context.Context, conn transaction.Conn, companyId int64, name string) (*domain.ArticleCategory, error) { | ||
| 115 | + var ( | ||
| 116 | + err error | ||
| 117 | + tx = conn.DB() | ||
| 118 | + m = new(models.ArticleCategory) | ||
| 119 | + ) | ||
| 120 | + queryFunc := func() (interface{}, error) { | ||
| 121 | + tx = tx.Model(m).Where("company_id = ?", companyId).Where("name = ?", name).First(m) | ||
| 122 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
| 123 | + return nil, domain.ErrNotFound | ||
| 124 | + } | ||
| 125 | + return m, tx.Error | ||
| 126 | + } | ||
| 127 | + if _, err = repository.Query(queryFunc); err != nil { | ||
| 128 | + return nil, err | ||
| 129 | + } | ||
| 130 | + return repository.ModelToDomainModel(m) | ||
| 131 | +} | ||
| 132 | + | ||
| 133 | +func (repository *ArticleCategoryRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.ArticleCategory, error) { | ||
| 134 | + var ( | ||
| 135 | + tx = conn.DB() | ||
| 136 | + ms []*models.ArticleCategory | ||
| 137 | + dms = make([]*domain.ArticleCategory, 0) | ||
| 138 | + total int64 | ||
| 139 | + ) | ||
| 140 | + queryFunc := func() (interface{}, error) { | ||
| 141 | + tx = tx.Model(&ms).Where("company_id = ?", companyId) | ||
| 142 | + if v, ok := queryOptions["enable"]; ok { | ||
| 143 | + tx.Where("enable = ?", v) | ||
| 144 | + } | ||
| 145 | + tx.Order("sort_by asc").Order("id asc") | ||
| 146 | + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
| 147 | + return dms, tx.Error | ||
| 148 | + } | ||
| 149 | + return dms, nil | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + if _, err := repository.Query(queryFunc); err != nil { | ||
| 153 | + return 0, nil, err | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + for _, item := range ms { | ||
| 157 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
| 158 | + return 0, dms, err | ||
| 159 | + } else { | ||
| 160 | + dms = append(dms, dm) | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + return total, dms, nil | ||
| 164 | +} | ||
| 165 | + | ||
| 166 | +func (repository *ArticleCategoryRepository) ModelToDomainModel(from *models.ArticleCategory) (*domain.ArticleCategory, error) { | ||
| 167 | + to := &domain.ArticleCategory{} | ||
| 168 | + err := copier.Copy(to, from) | ||
| 169 | + return to, err | ||
| 170 | +} | ||
| 171 | + | ||
| 172 | +func (repository *ArticleCategoryRepository) DomainModelToModel(from *domain.ArticleCategory) (*models.ArticleCategory, error) { | ||
| 173 | + to := &models.ArticleCategory{} | ||
| 174 | + err := copier.Copy(to, from) | ||
| 175 | + return to, err | ||
| 176 | +} | ||
| 177 | + | ||
| 178 | +func NewArticleCategoryRepository(cache *cache.CachedRepository) domain.ArticleCategoryRepository { | ||
| 179 | + return &ArticleCategoryRepository{CachedRepository: cache} | ||
| 180 | +} |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/jinzhu/copier" | ||
| 6 | + "github.com/pkg/errors" | ||
| 7 | + "github.com/tiptok/gocomm/pkg/cache" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 11 | + "gorm.io/gorm" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type ArticleDraftOperationRepository struct { | ||
| 15 | + *cache.CachedRepository | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func (repository *ArticleDraftOperationRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) { | ||
| 19 | + var ( | ||
| 20 | + err error | ||
| 21 | + m = &models.ArticleDraftOperation{} | ||
| 22 | + tx = conn.DB() | ||
| 23 | + ) | ||
| 24 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 25 | + return nil, err | ||
| 26 | + } | ||
| 27 | + if tx = tx.Model(m).Save(m); tx.Error != nil { | ||
| 28 | + return nil, tx.Error | ||
| 29 | + } | ||
| 30 | + dm.Id = m.Id | ||
| 31 | + return repository.ModelToDomainModel(m) | ||
| 32 | + | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (repository *ArticleDraftOperationRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) { | ||
| 36 | + var ( | ||
| 37 | + err error | ||
| 38 | + m *models.ArticleDraftOperation | ||
| 39 | + tx = conn.DB() | ||
| 40 | + ) | ||
| 41 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 42 | + return nil, err | ||
| 43 | + } | ||
| 44 | + queryFunc := func() (interface{}, error) { | ||
| 45 | + tx = tx.Model(m).Updates(m) | ||
| 46 | + return nil, tx.Error | ||
| 47 | + } | ||
| 48 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 49 | + return nil, err | ||
| 50 | + } | ||
| 51 | + return repository.ModelToDomainModel(m) | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +func (repository *ArticleDraftOperationRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) { | ||
| 55 | + var ( | ||
| 56 | + err error | ||
| 57 | + m *models.ArticleDraftOperation | ||
| 58 | + tx = transaction.DB() | ||
| 59 | + ) | ||
| 60 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 61 | + return nil, err | ||
| 62 | + } | ||
| 63 | + oldVersion := dm.Version | ||
| 64 | + m.Version += 1 | ||
| 65 | + queryFunc := func() (interface{}, error) { | ||
| 66 | + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m) | ||
| 67 | + if tx.RowsAffected == 0 { | ||
| 68 | + return nil, domain.ErrUpdateFail | ||
| 69 | + } | ||
| 70 | + return nil, tx.Error | ||
| 71 | + } | ||
| 72 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 73 | + return nil, err | ||
| 74 | + } | ||
| 75 | + return repository.ModelToDomainModel(m) | ||
| 76 | +} | ||
| 77 | + | ||
| 78 | +func (repository *ArticleDraftOperationRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) { | ||
| 79 | + var ( | ||
| 80 | + tx = conn.DB() | ||
| 81 | + m = &models.ArticleDraftOperation{Id: dm.Identify().(int64)} | ||
| 82 | + ) | ||
| 83 | + queryFunc := func() (interface{}, error) { | ||
| 84 | + tx = tx.Where("id = ?", m.Id).Delete(m) | ||
| 85 | + return m, tx.Error | ||
| 86 | + } | ||
| 87 | + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 88 | + return dm, err | ||
| 89 | + } | ||
| 90 | + return repository.ModelToDomainModel(m) | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +func (repository *ArticleDraftOperationRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleDraftOperation, error) { | ||
| 94 | + var ( | ||
| 95 | + err error | ||
| 96 | + tx = conn.DB() | ||
| 97 | + m = new(models.ArticleDraftOperation) | ||
| 98 | + ) | ||
| 99 | + queryFunc := func() (interface{}, error) { | ||
| 100 | + tx = tx.Model(m).Where("id = ?", id).First(m) | ||
| 101 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
| 102 | + return nil, domain.ErrNotFound | ||
| 103 | + } | ||
| 104 | + return m, tx.Error | ||
| 105 | + } | ||
| 106 | + cacheModel := new(models.ArticleDraftOperation) | ||
| 107 | + cacheModel.Id = id | ||
| 108 | + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil { | ||
| 109 | + return nil, err | ||
| 110 | + } | ||
| 111 | + return repository.ModelToDomainModel(m) | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +func (repository *ArticleDraftOperationRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.ArticleDraftOperation, error) { | ||
| 115 | + var ( | ||
| 116 | + tx = conn.DB() | ||
| 117 | + ms []*models.ArticleDraftOperation | ||
| 118 | + dms = make([]*domain.ArticleDraftOperation, 0) | ||
| 119 | + total int64 | ||
| 120 | + ) | ||
| 121 | + queryFunc := func() (interface{}, error) { | ||
| 122 | + tx = tx.Model(&ms).Order("updated_at desc") | ||
| 123 | + //标题 | ||
| 124 | + if v, ok := queryOptions["title"]; ok { | ||
| 125 | + tx = tx.Where("title like ?", "%"+v.(string)+"%") | ||
| 126 | + } | ||
| 127 | + //公司ID | ||
| 128 | + if v, ok := queryOptions["companyId"]; ok { | ||
| 129 | + tx = tx.Where("company_id = ?", v) | ||
| 130 | + } | ||
| 131 | + //最近修改时间 | ||
| 132 | + if v, ok := queryOptions["beginTime"]; ok { | ||
| 133 | + tx = tx.Where("updated_at >= ?", v) | ||
| 134 | + } | ||
| 135 | + if v, ok := queryOptions["endTime"]; ok { | ||
| 136 | + tx = tx.Where("updated_at <= ?", v) | ||
| 137 | + } | ||
| 138 | + //操作人 | ||
| 139 | + if v, ok := queryOptions["operator"]; ok { | ||
| 140 | + tx = tx.Where(`"operator" ->> 'name' like ?`, "%"+v.(string)+"%") | ||
| 141 | + } | ||
| 142 | + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
| 143 | + return dms, tx.Error | ||
| 144 | + } | ||
| 145 | + return dms, nil | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + if _, err := repository.Query(queryFunc); err != nil { | ||
| 149 | + return 0, nil, err | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + for _, item := range ms { | ||
| 153 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
| 154 | + return 0, dms, err | ||
| 155 | + } else { | ||
| 156 | + dms = append(dms, dm) | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + return total, dms, nil | ||
| 160 | +} | ||
| 161 | + | ||
| 162 | +func (repository *ArticleDraftOperationRepository) ModelToDomainModel(from *models.ArticleDraftOperation) (*domain.ArticleDraftOperation, error) { | ||
| 163 | + to := &domain.ArticleDraftOperation{} | ||
| 164 | + err := copier.Copy(to, from) | ||
| 165 | + return to, err | ||
| 166 | +} | ||
| 167 | + | ||
| 168 | +func (repository *ArticleDraftOperationRepository) DomainModelToModel(from *domain.ArticleDraftOperation) (*models.ArticleDraftOperation, error) { | ||
| 169 | + to := &models.ArticleDraftOperation{} | ||
| 170 | + err := copier.Copy(to, from) | ||
| 171 | + return to, err | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +func NewArticleDraftOperationRepository(cache *cache.CachedRepository) domain.ArticleDraftOperationRepository { | ||
| 175 | + return &ArticleDraftOperationRepository{CachedRepository: cache} | ||
| 176 | +} |
| @@ -3,6 +3,7 @@ package repository | @@ -3,6 +3,7 @@ package repository | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | + "gorm.io/plugin/soft_delete" | ||
| 6 | "strings" | 7 | "strings" |
| 7 | 8 | ||
| 8 | "github.com/pkg/errors" | 9 | "github.com/pkg/errors" |
| @@ -53,6 +54,28 @@ func (repository *ArticleRepository) Update(ctx context.Context, conn transactio | @@ -53,6 +54,28 @@ func (repository *ArticleRepository) Update(ctx context.Context, conn transactio | ||
| 53 | return repository.ModelToDomainModel(m) | 54 | return repository.ModelToDomainModel(m) |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 57 | +func (repository *ArticleRepository) Restore(ctx context.Context, conn transaction.Conn, dm *domain.Article) (*domain.Article, error) { | ||
| 58 | + var ( | ||
| 59 | + err error | ||
| 60 | + m *models.Article | ||
| 61 | + tx = conn.DB() | ||
| 62 | + ) | ||
| 63 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 64 | + return nil, err | ||
| 65 | + } | ||
| 66 | + m.DeletedAt = 0 | ||
| 67 | + m.IsDel = soft_delete.DeletedAt(soft_delete.FlagActived) | ||
| 68 | + m.DeletedType = 0 | ||
| 69 | + queryFunc := func() (interface{}, error) { | ||
| 70 | + tx = tx.Model(m).Unscoped().Select("*").Updates(m) | ||
| 71 | + return nil, tx.Error | ||
| 72 | + } | ||
| 73 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 74 | + return nil, err | ||
| 75 | + } | ||
| 76 | + return repository.ModelToDomainModel(m) | ||
| 77 | +} | ||
| 78 | + | ||
| 56 | func (repository *ArticleRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.Article) (*domain.Article, error) { | 79 | func (repository *ArticleRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.Article) (*domain.Article, error) { |
| 57 | var ( | 80 | var ( |
| 58 | err error | 81 | err error |
| @@ -113,6 +136,27 @@ func (repository *ArticleRepository) FindOne(ctx context.Context, conn transacti | @@ -113,6 +136,27 @@ func (repository *ArticleRepository) FindOne(ctx context.Context, conn transacti | ||
| 113 | return repository.ModelToDomainModel(m) | 136 | return repository.ModelToDomainModel(m) |
| 114 | } | 137 | } |
| 115 | 138 | ||
| 139 | +func (repository *ArticleRepository) FindOneWithUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*domain.Article, error) { | ||
| 140 | + var ( | ||
| 141 | + err error | ||
| 142 | + tx = conn.DB() | ||
| 143 | + m = new(models.Article) | ||
| 144 | + ) | ||
| 145 | + queryFunc := func() (interface{}, error) { | ||
| 146 | + tx = tx.Model(m).Unscoped().Where("id = ?", id).First(m) | ||
| 147 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
| 148 | + return nil, domain.ErrNotFound | ||
| 149 | + } | ||
| 150 | + return m, tx.Error | ||
| 151 | + } | ||
| 152 | + cacheModel := new(models.Article) | ||
| 153 | + cacheModel.Id = id | ||
| 154 | + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil { | ||
| 155 | + return nil, err | ||
| 156 | + } | ||
| 157 | + return repository.ModelToDomainModel(m) | ||
| 158 | +} | ||
| 159 | + | ||
| 116 | func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.Article, error) { | 160 | func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.Article, error) { |
| 117 | var ( | 161 | var ( |
| 118 | tx = conn.DB() | 162 | tx = conn.DB() |
| @@ -133,6 +177,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -133,6 +177,8 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 133 | tx = tx.Order("count_love asc") | 177 | tx = tx.Order("count_love asc") |
| 134 | case "countLove descending": | 178 | case "countLove descending": |
| 135 | tx = tx.Order("count_love desc") | 179 | tx = tx.Order("count_love desc") |
| 180 | + case "deletedAt descending": | ||
| 181 | + tx = tx.Order("deleted_at desc") | ||
| 136 | default: | 182 | default: |
| 137 | tx = tx.Order("created_at desc") | 183 | tx = tx.Order("created_at desc") |
| 138 | } | 184 | } |
| @@ -154,6 +200,20 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | @@ -154,6 +200,20 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction. | ||
| 154 | if v, ok := queryOptions["authorId"]; ok { | 200 | if v, ok := queryOptions["authorId"]; ok { |
| 155 | tx = tx.Where("author_id=?", v) | 201 | tx = tx.Where("author_id=?", v) |
| 156 | } | 202 | } |
| 203 | + if v, ok := queryOptions["deletedType"]; ok { | ||
| 204 | + tx = tx.Where("deleted_type = ?", v) | ||
| 205 | + } | ||
| 206 | + //删除 | ||
| 207 | + if v, ok := queryOptions["isDel"]; ok { | ||
| 208 | + tx = tx.Unscoped().Where("is_del = ?", v) | ||
| 209 | + } | ||
| 210 | + //删除时间 | ||
| 211 | + if v, ok := queryOptions["beginDeletedAt"]; ok { | ||
| 212 | + tx = tx.Where("deleted_at >= ?", v) | ||
| 213 | + } | ||
| 214 | + if v, ok := queryOptions["endDeletedAt"]; ok { | ||
| 215 | + tx = tx.Where("deleted_at < ?", v) | ||
| 216 | + } | ||
| 157 | if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 { | 217 | if v, ok := queryOptions["tags"]; ok && len(v.([]int64)) > 0 { |
| 158 | values := make([]string, 0) | 218 | values := make([]string, 0) |
| 159 | for _, item := range v.([]int64) { | 219 | for _, item := range v.([]int64) { |
| @@ -384,6 +444,9 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | @@ -384,6 +444,9 @@ func (repository *ArticleRepository) ModelToDomainModel(from *models.Article) (* | ||
| 384 | Summary: from.Summary, | 444 | Summary: from.Summary, |
| 385 | MatchUrl: from.MatchUrl, | 445 | MatchUrl: from.MatchUrl, |
| 386 | Videos: from.Videos, | 446 | Videos: from.Videos, |
| 447 | + Source: from.Source, | ||
| 448 | + Operator: from.Operator, | ||
| 449 | + DeletedType: from.DeletedType, | ||
| 387 | } | 450 | } |
| 388 | return to, nil | 451 | return to, nil |
| 389 | } | 452 | } |
| @@ -413,6 +476,9 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | @@ -413,6 +476,9 @@ func (repository *ArticleRepository) DomainModelToModel(from *domain.Article) (* | ||
| 413 | Summary: from.Summary, | 476 | Summary: from.Summary, |
| 414 | MatchUrl: from.MatchUrl, | 477 | MatchUrl: from.MatchUrl, |
| 415 | Videos: from.Videos, | 478 | Videos: from.Videos, |
| 479 | + Source: from.Source, | ||
| 480 | + Operator: from.Operator, | ||
| 481 | + DeletedType: from.DeletedType, | ||
| 416 | } | 482 | } |
| 417 | // err := copier.Copy(to, from) | 483 | // err := copier.Copy(to, from) |
| 418 | return to, nil | 484 | return to, nil |
| @@ -152,6 +152,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | @@ -152,6 +152,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti | ||
| 152 | if v, ok := queryOptions["category"]; ok { | 152 | if v, ok := queryOptions["category"]; ok { |
| 153 | tx = tx.Where("category like ?", v) | 153 | tx = tx.Where("category like ?", v) |
| 154 | } | 154 | } |
| 155 | + if v, ok := queryOptions["categoryId"]; ok { | ||
| 156 | + tx = tx.Where("category_id = ?", v) | ||
| 157 | + } | ||
| 155 | if v, ok := queryOptions["ids"]; ok { | 158 | if v, ok := queryOptions["ids"]; ok { |
| 156 | tx = tx.Where("id in (?)", v) | 159 | tx = tx.Where("id in (?)", v) |
| 157 | } | 160 | } |
| @@ -144,6 +144,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | @@ -144,6 +144,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. | ||
| 144 | if v, ok := queryOptions["ids"]; ok { | 144 | if v, ok := queryOptions["ids"]; ok { |
| 145 | tx.Where("id in (?)", v) | 145 | tx.Where("id in (?)", v) |
| 146 | } | 146 | } |
| 147 | + if v, ok := queryOptions["visible"]; ok { | ||
| 148 | + tx.Where("visible = ?", v) | ||
| 149 | + } | ||
| 147 | if v, ok := queryOptions["excludeIds"]; ok { | 150 | if v, ok := queryOptions["excludeIds"]; ok { |
| 148 | tx.Where("id not in (?)", v) | 151 | tx.Where("id not in (?)", v) |
| 149 | } | 152 | } |
| @@ -31,6 +31,9 @@ type Article struct { | @@ -31,6 +31,9 @@ type Article struct { | ||
| 31 | Tags []int64 `json:"tags"` // 定性标签 | 31 | Tags []int64 `json:"tags"` // 定性标签 |
| 32 | Summary string `json:"summary"` // 内容概要 | 32 | Summary string `json:"summary"` // 内容概要 |
| 33 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 33 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 34 | + Source int `gorm:"default:1"` // 来源 1-用户发布 2-运营发布 | ||
| 35 | + Operator Operator `gorm:"type:jsonb;serializer:json"` // 运营操作人 | ||
| 36 | + DeletedType int `json:"deletedType"` // 删除类型 1-运营删除 2-用户删除 | ||
| 34 | // ...more | 37 | // ...more |
| 35 | } | 38 | } |
| 36 | 39 | ||
| @@ -38,8 +41,10 @@ type ArticleRepository interface { | @@ -38,8 +41,10 @@ type ArticleRepository interface { | ||
| 38 | Insert(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) | 41 | Insert(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) |
| 39 | Update(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) | 42 | Update(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) |
| 40 | Delete(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) | 43 | Delete(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) |
| 44 | + Restore(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) | ||
| 41 | UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) | 45 | UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *Article) (*Article, error) |
| 42 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Article, error) | 46 | FindOne(ctx context.Context, conn transaction.Conn, id int64) (*Article, error) |
| 47 | + FindOneWithUnscoped(ctx context.Context, conn transaction.Conn, id int64) (*Article, error) | ||
| 43 | Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*Article, error) | 48 | Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*Article, error) |
| 44 | FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) | 49 | FindAuthorsLatestFirstArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) |
| 45 | FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) | 50 | FindAuthorsLatestFirstUnreadArticle(ctx context.Context, conn transaction.Conn, companyId int64, authors []int64, whoRead int64, limit int) (int64, []*Article, error) |
| @@ -65,6 +70,12 @@ type ArticleTarget int | @@ -65,6 +70,12 @@ type ArticleTarget int | ||
| 65 | const ( | 70 | const ( |
| 66 | ArticleTargetAll ArticleTarget = 0 //内容分发给所有人 | 71 | ArticleTargetAll ArticleTarget = 0 //内容分发给所有人 |
| 67 | ArticleTargetLimit ArticleTarget = 1 //分发给指定的人 | 72 | ArticleTargetLimit ArticleTarget = 1 //分发给指定的人 |
| 73 | + | ||
| 74 | + ArticleSourceUser int = 1 //文章来源 用户发布 | ||
| 75 | + ArticleSourceOperator int = 2 //文章来源 运营发布 | ||
| 76 | + | ||
| 77 | + ArticleDeletedTypeOperator int = 1 // 文章删除类型 运营删除 | ||
| 78 | + ArticleDeletedTypeUser int = 2 // 文章删除类型 用户删除 | ||
| 68 | ) | 79 | ) |
| 69 | 80 | ||
| 70 | func (a ArticleTarget) Named() string { | 81 | func (a ArticleTarget) Named() string { |
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | +) | ||
| 7 | + | ||
| 8 | +type ArticleCategory struct { | ||
| 9 | + Id int64 // 唯一标识 | ||
| 10 | + CompanyId int64 `json:"companyId"` | ||
| 11 | + Name string `json:"name"` | ||
| 12 | + SortBy int `json:"sortBy"` // 排序 | ||
| 13 | + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用 | ||
| 14 | + Other string `json:"other"` // 其他备注说明 | ||
| 15 | + CreatedAt int64 `json:"createdAt,omitempty"` | ||
| 16 | + UpdatedAt int64 `json:"updatedAt,omitempty"` | ||
| 17 | + DeletedAt int64 `json:"deletedAt,omitempty"` | ||
| 18 | + Version int `json:"version,omitempty"` | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +type ArticleCategoryRepository interface { | ||
| 22 | + Insert(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error) | ||
| 23 | + Update(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error) | ||
| 24 | + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error) | ||
| 25 | + Delete(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error) | ||
| 26 | + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleCategory, error) | ||
| 27 | + FindOneByName(ctx context.Context, conn transaction.Conn, companyId int64, name string) (*ArticleCategory, error) | ||
| 28 | + Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*ArticleCategory, error) | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (m *ArticleCategory) Identify() interface{} { | ||
| 32 | + if m.Id == 0 { | ||
| 33 | + return nil | ||
| 34 | + } | ||
| 35 | + return m.Id | ||
| 36 | +} |
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gorm.io/plugin/soft_delete" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +// ArticleDraftOperation 运营草稿 | ||
| 10 | +type ArticleDraftOperation struct { | ||
| 11 | + Id int64 `json:"id"` // 唯一标识 | ||
| 12 | + CompanyId int64 `json:"companyId,string"` // 公司ID | ||
| 13 | + AuthorId int64 `json:"authorId"` // 发布人 | ||
| 14 | + Title string `json:"title"` // 文章标题 | ||
| 15 | + Content string `json:"content"` // 文章内容 | ||
| 16 | + Images []Image `json:"images"` // 图片 | ||
| 17 | + Videos []Video `json:"videos"` // 视频 | ||
| 18 | + TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 19 | + WhoRead []int64 `json:"whoRead"` // 谁可以看 | ||
| 20 | + WhoReview []int64 `json:"whoReview"` // 评论人 | ||
| 21 | + Tags []int64 `json:"tags"` //定性标签 | ||
| 22 | + MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | ||
| 23 | + Source int `json:"source"` // 来源 1-用户发布 2-运营发布 | ||
| 24 | + Operator Operator `json:"operator"` // 运营操作人 | ||
| 25 | + Version int `json:"version,omitempty"` // 版本号 | ||
| 26 | + CreatedAt int64 `json:"createdAt,omitempty"` // 创建时间 | ||
| 27 | + UpdatedAt int64 `json:"updatedAt,omitempty"` // 编辑时间 | ||
| 28 | + IsDel soft_delete.DeletedAt `json:"isDel,omitempty"` // 删除标记 | ||
| 29 | + DeletedAt int64 `json:"deletedAt,omitempty"` // 删除时间 | ||
| 30 | +} | ||
| 31 | + | ||
| 32 | +type ArticleDraftOperationRepository interface { | ||
| 33 | + Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error) | ||
| 34 | + Update(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error) | ||
| 35 | + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error) | ||
| 36 | + Delete(ctx context.Context, conn transaction.Conn, dm *ArticleDraftOperation) (*ArticleDraftOperation, error) | ||
| 37 | + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleDraftOperation, error) | ||
| 38 | + Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleDraftOperation, error) | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +func (m *ArticleDraftOperation) Identify() interface{} { | ||
| 42 | + if m.Id == 0 { | ||
| 43 | + return nil | ||
| 44 | + } | ||
| 45 | + return m.Id | ||
| 46 | +} |
| @@ -19,6 +19,8 @@ type ArticleTag struct { | @@ -19,6 +19,8 @@ type ArticleTag struct { | ||
| 19 | Image Image `json:"image"` // 图片 | 19 | Image Image `json:"image"` // 图片 |
| 20 | Name string `json:"name"` // 标签名称 | 20 | Name string `json:"name"` // 标签名称 |
| 21 | Category string `json:"category"` // 标签分类 [紧急重要]、[机会风险] | 21 | Category string `json:"category"` // 标签分类 [紧急重要]、[机会风险] |
| 22 | + CategoryId int64 `json:"categoryId"` // 标签分类ID | ||
| 23 | + DataFrom int `json:"dataFrom"` // 来源 0:系统初始化 1:用户自动添加(可删除) | ||
| 22 | Remark string `json:"remark"` // 备注 | 24 | Remark string `json:"remark"` // 备注 |
| 23 | SortBy int64 `json:"sortBy"` // 顺序 | 25 | SortBy int64 `json:"sortBy"` // 顺序 |
| 24 | Other string `json:"other"` // | 26 | Other string `json:"other"` // |
| @@ -10,7 +10,7 @@ type Company struct { | @@ -10,7 +10,7 @@ type Company struct { | ||
| 10 | Name string `json:"name,omitempty"` // 名称 | 10 | Name string `json:"name,omitempty"` // 名称 |
| 11 | Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字) | 11 | Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字) |
| 12 | Logo string `json:"logo,omitempty"` // 公司LOGO | 12 | Logo string `json:"logo,omitempty"` // 公司LOGO |
| 13 | - | 13 | + Visible int `json:"visible,omitempty"` // 可见的 1:可见 0:不可见 |
| 14 | CreatedAt int64 `json:"createdAt,omitempty"` | 14 | CreatedAt int64 `json:"createdAt,omitempty"` |
| 15 | UpdatedAt int64 `json:"updatedAt,omitempty"` | 15 | UpdatedAt int64 `json:"updatedAt,omitempty"` |
| 16 | DeletedAt int64 `json:"deletedAt,omitempty"` | 16 | DeletedAt int64 `json:"deletedAt,omitempty"` |
| @@ -45,10 +45,8 @@ type UserSimple struct { | @@ -45,10 +45,8 @@ type UserSimple struct { | ||
| 45 | CompanyId int64 `json:"companyId"` | 45 | CompanyId int64 `json:"companyId"` |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | -// 记录数据的操作人 | ||
| 49 | -// type Operator struct { | ||
| 50 | -// From string `json:"from"` // 操作来源 | ||
| 51 | -// Id int `json:"id"` // 人员id | ||
| 52 | -// Name string `json:"name"` // 人员名字 | ||
| 53 | -// UpdatedAt int64 `json:"updatedAt"` // 时间 | ||
| 54 | -// } | 48 | +// 运营操作人 |
| 49 | +type Operator struct { | ||
| 50 | + Id int64 `json:"id,string"` // 人员id | ||
| 51 | + Name string `json:"name"` // 人员名字 | ||
| 52 | +} |
| @@ -27,3 +27,13 @@ CREATE TABLE `user_follow` ( | @@ -27,3 +27,13 @@ CREATE TABLE `user_follow` ( | ||
| 27 | `id` int(0) NOT NULL COMMENT '唯一标识', | 27 | `id` int(0) NOT NULL COMMENT '唯一标识', |
| 28 | PRIMARY KEY (`id`) USING BTREE | 28 | PRIMARY KEY (`id`) USING BTREE |
| 29 | ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; | 29 | ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; |
| 30 | + | ||
| 31 | +CREATE TABLE `article_draft_operation` ( | ||
| 32 | + `id` int(0) NOT NULL COMMENT '唯一标识', | ||
| 33 | + PRIMARY KEY (`id`) USING BTREE | ||
| 34 | +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; | ||
| 35 | + | ||
| 36 | +CREATE TABLE `article_category` ( | ||
| 37 | + `id` int(0) NOT NULL COMMENT '唯一标识', | ||
| 38 | + PRIMARY KEY (`id`) USING BTREE | ||
| 39 | +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; |
deploy/database/v1.0.2 升级脚本.sql
0 → 100644
-
请 注册 或 登录 后发表评论