作者 yangfu

标签分类修改

正在显示 36 个修改的文件 包含 3500 行增加66 行删除
@@ -1748,6 +1748,58 @@ @@ -1748,6 +1748,58 @@
1748 } 1748 }
1749 }, 1749 },
1750 "v1/system/article": { 1750 "v1/system/article": {
  1751 + "delete": {
  1752 + "summary": "管理后台删除文章",
  1753 + "operationId": "SystemDeleteArticle",
  1754 + "responses": {
  1755 + "200": {
  1756 + "description": "A successful response.",
  1757 + "schema": {
  1758 + "$ref": "#/definitions/SystemArticleDeleteResponse"
  1759 + }
  1760 + }
  1761 + },
  1762 + "parameters": [
  1763 + {
  1764 + "name": "body",
  1765 + "in": "body",
  1766 + "required": true,
  1767 + "schema": {
  1768 + "$ref": "#/definitions/SystemArticleDeleteRequest"
  1769 + }
  1770 + }
  1771 + ],
  1772 + "requestBody": {},
  1773 + "tags": [
  1774 + "article"
  1775 + ]
  1776 + },
  1777 + "post": {
  1778 + "summary": "管理后台新增文章",
  1779 + "operationId": "SystemCreateArticle",
  1780 + "responses": {
  1781 + "200": {
  1782 + "description": "A successful response.",
  1783 + "schema": {
  1784 + "$ref": "#/definitions/SystemArticleCreateResponse"
  1785 + }
  1786 + }
  1787 + },
  1788 + "parameters": [
  1789 + {
  1790 + "name": "body",
  1791 + "in": "body",
  1792 + "required": true,
  1793 + "schema": {
  1794 + "$ref": "#/definitions/SystemArticleCreateRequest"
  1795 + }
  1796 + }
  1797 + ],
  1798 + "requestBody": {},
  1799 + "tags": [
  1800 + "article"
  1801 + ]
  1802 + },
1751 "put": { 1803 "put": {
1752 "summary": "管理后台编辑帖子", 1804 "summary": "管理后台编辑帖子",
1753 "operationId": "SystemUpdateArticle", 1805 "operationId": "SystemUpdateArticle",
@@ -1776,6 +1828,196 @@ @@ -1776,6 +1828,196 @@
1776 ] 1828 ]
1777 } 1829 }
1778 }, 1830 },
  1831 + "v1/system/article/deleted/list": {
  1832 + "post": {
  1833 + "summary": "管理后台已删除列表",
  1834 + "operationId": "SystemArticleSearchDeleted",
  1835 + "responses": {
  1836 + "200": {
  1837 + "description": "A successful response.",
  1838 + "schema": {
  1839 + "$ref": "#/definitions/SystemArticleSearchDeletedResponse"
  1840 + }
  1841 + }
  1842 + },
  1843 + "parameters": [
  1844 + {
  1845 + "name": "body",
  1846 + "in": "body",
  1847 + "required": true,
  1848 + "schema": {
  1849 + "$ref": "#/definitions/SystemArticleSearchDeletedRequest"
  1850 + }
  1851 + }
  1852 + ],
  1853 + "requestBody": {},
  1854 + "tags": [
  1855 + "article"
  1856 + ]
  1857 + }
  1858 + },
  1859 + "v1/system/article/deleted/restore": {
  1860 + "put": {
  1861 + "summary": "管理后台文章删除恢复",
  1862 + "operationId": "SystemRestoreArticleDeleted",
  1863 + "responses": {
  1864 + "200": {
  1865 + "description": "A successful response.",
  1866 + "schema": {
  1867 + "$ref": "#/definitions/SystemArticleDeletedRestoreResponse"
  1868 + }
  1869 + }
  1870 + },
  1871 + "parameters": [
  1872 + {
  1873 + "name": "body",
  1874 + "in": "body",
  1875 + "required": true,
  1876 + "schema": {
  1877 + "$ref": "#/definitions/SystemArticleDeletedRestoreRequest"
  1878 + }
  1879 + }
  1880 + ],
  1881 + "requestBody": {},
  1882 + "tags": [
  1883 + "article"
  1884 + ]
  1885 + }
  1886 + },
  1887 + "v1/system/article/draft": {
  1888 + "delete": {
  1889 + "summary": "管理后台删除草稿",
  1890 + "operationId": "SystemDeleteArticleDraft",
  1891 + "responses": {
  1892 + "200": {
  1893 + "description": "A successful response.",
  1894 + "schema": {
  1895 + "$ref": "#/definitions/SystemArticleDraftDeleteResponse"
  1896 + }
  1897 + }
  1898 + },
  1899 + "parameters": [
  1900 + {
  1901 + "name": "body",
  1902 + "in": "body",
  1903 + "required": true,
  1904 + "schema": {
  1905 + "$ref": "#/definitions/SystemArticleDraftDeleteRequest"
  1906 + }
  1907 + }
  1908 + ],
  1909 + "requestBody": {},
  1910 + "tags": [
  1911 + "article"
  1912 + ]
  1913 + },
  1914 + "post": {
  1915 + "summary": "管理后台新增草稿",
  1916 + "operationId": "SystemCreateArticleDraft",
  1917 + "responses": {
  1918 + "200": {
  1919 + "description": "A successful response.",
  1920 + "schema": {
  1921 + "$ref": "#/definitions/SystemArticleDraftCreateResponse"
  1922 + }
  1923 + }
  1924 + },
  1925 + "parameters": [
  1926 + {
  1927 + "name": "body",
  1928 + "in": "body",
  1929 + "required": true,
  1930 + "schema": {
  1931 + "$ref": "#/definitions/SystemArticleDraftCreateRequest"
  1932 + }
  1933 + }
  1934 + ],
  1935 + "requestBody": {},
  1936 + "tags": [
  1937 + "article"
  1938 + ]
  1939 + },
  1940 + "put": {
  1941 + "summary": "管理后台编辑草稿",
  1942 + "operationId": "SystemUpdateArticleDraft",
  1943 + "responses": {
  1944 + "200": {
  1945 + "description": "A successful response.",
  1946 + "schema": {
  1947 + "$ref": "#/definitions/SystemArticleDraftUpdateResponse"
  1948 + }
  1949 + }
  1950 + },
  1951 + "parameters": [
  1952 + {
  1953 + "name": "body",
  1954 + "in": "body",
  1955 + "required": true,
  1956 + "schema": {
  1957 + "$ref": "#/definitions/SystemArticleDraftUpdateRequest"
  1958 + }
  1959 + }
  1960 + ],
  1961 + "requestBody": {},
  1962 + "tags": [
  1963 + "article"
  1964 + ]
  1965 + }
  1966 + },
  1967 + "v1/system/article/draft/search": {
  1968 + "post": {
  1969 + "summary": "管理后台草稿列表",
  1970 + "operationId": "SystemSearchArticleDraft",
  1971 + "responses": {
  1972 + "200": {
  1973 + "description": "A successful response.",
  1974 + "schema": {
  1975 + "$ref": "#/definitions/SystemArticleDraftSearchResponse"
  1976 + }
  1977 + }
  1978 + },
  1979 + "parameters": [
  1980 + {
  1981 + "name": "body",
  1982 + "in": "body",
  1983 + "required": true,
  1984 + "schema": {
  1985 + "$ref": "#/definitions/SystemArticleDraftSearchRequest"
  1986 + }
  1987 + }
  1988 + ],
  1989 + "requestBody": {},
  1990 + "tags": [
  1991 + "article"
  1992 + ]
  1993 + }
  1994 + },
  1995 + "v1/system/article/draft/{id}": {
  1996 + "get": {
  1997 + "summary": "管理后台获取草稿",
  1998 + "operationId": "SystemGetArticleDraft",
  1999 + "responses": {
  2000 + "200": {
  2001 + "description": "A successful response.",
  2002 + "schema": {
  2003 + "$ref": "#/definitions/SystemArticleDraftGetResponse"
  2004 + }
  2005 + }
  2006 + },
  2007 + "parameters": [
  2008 + {
  2009 + "name": "id",
  2010 + "in": "path",
  2011 + "required": true,
  2012 + "type": "string"
  2013 + }
  2014 + ],
  2015 + "requestBody": {},
  2016 + "tags": [
  2017 + "article"
  2018 + ]
  2019 + }
  2020 + },
1779 "v1/system/article/history": { 2021 "v1/system/article/history": {
1780 "post": { 2022 "post": {
1781 "summary": "管理后台编辑历史", 2023 "summary": "管理后台编辑历史",
@@ -6650,6 +6892,25 @@ @@ -6650,6 +6892,25 @@
6650 "comment" 6892 "comment"
6651 ] 6893 ]
6652 }, 6894 },
  6895 + "Operator": {
  6896 + "type": "object",
  6897 + "properties": {
  6898 + "id": {
  6899 + "type": "integer",
  6900 + "format": "int64",
  6901 + "description": " 人员id"
  6902 + },
  6903 + "name": {
  6904 + "type": "string",
  6905 + "description": " 人员的名字"
  6906 + }
  6907 + },
  6908 + "title": "Operator",
  6909 + "required": [
  6910 + "id",
  6911 + "name"
  6912 + ]
  6913 + },
6653 "Position": { 6914 "Position": {
6654 "type": "object", 6915 "type": "object",
6655 "properties": { 6916 "properties": {
@@ -7234,42 +7495,887 @@ @@ -7234,42 +7495,887 @@
7234 "list" 7495 "list"
7235 ] 7496 ]
7236 }, 7497 },
7237 - "SystemArticleGetHistoryRequest": {  
7238 - "type": "object",  
7239 - "properties": {  
7240 - "id": {  
7241 - "type": "integer",  
7242 - "format": "int64",  
7243 - "description": "id"  
7244 - },  
7245 - "": {  
7246 - "type": "integer",  
7247 - "format": "int64"  
7248 - }  
7249 - },  
7250 - "title": "SystemArticleGetHistoryRequest",  
7251 - "required": [  
7252 - "id"  
7253 - ]  
7254 - },  
7255 - "SystemArticleGetHistoryResponse": { 7498 + "SystemArticleCreateRequest": {
7256 "type": "object", 7499 "type": "object",
7257 "properties": { 7500 "properties": {
7258 - "id": {  
7259 - "type": "integer",  
7260 - "format": "int64",  
7261 - "description": " id"  
7262 - },  
7263 - "articleId": {  
7264 - "type": "integer",  
7265 - "format": "int64",  
7266 - "description": " 文章ID"  
7267 - },  
7268 "title": { 7501 "title": {
7269 "type": "string", 7502 "type": "string",
7270 - "description": " 标题" 7503 + "description": "标题"
7271 }, 7504 },
7272 - "createdAt": { 7505 + "content": {
  7506 + "type": "string",
  7507 + "description": "文章的文本内容"
  7508 + },
  7509 + "authorId": {
  7510 + "type": "integer",
  7511 + "format": "int64",
  7512 + "description": "发布人id"
  7513 + },
  7514 + "images": {
  7515 + "type": "array",
  7516 + "items": {
  7517 + "type": "string"
  7518 + },
  7519 + "description": "图片"
  7520 + },
  7521 + "video": {
  7522 + "type": "array",
  7523 + "items": {
  7524 + "$ref": "#/definitions/Video"
  7525 + },
  7526 + "description": " 视频"
  7527 + },
  7528 + "targetUser": {
  7529 + "type": "integer",
  7530 + "format": "int32",
  7531 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  7532 + },
  7533 + "whoRead": {
  7534 + "type": "array",
  7535 + "items": {
  7536 + "type": "integer",
  7537 + "format": "int64"
  7538 + },
  7539 + "description": "谁可查看"
  7540 + },
  7541 + "whoReview": {
  7542 + "type": "array",
  7543 + "items": {
  7544 + "type": "integer",
  7545 + "format": "int64"
  7546 + },
  7547 + "description": "谁可评论"
  7548 + },
  7549 + "matchUrl": {
  7550 + "type": "object",
  7551 + "description": " 匹配文章内容中的url文本"
  7552 + },
  7553 + "articleDraftId": {
  7554 + "type": "integer",
  7555 + "format": "int64",
  7556 + "description": " 草稿ID"
  7557 + },
  7558 + "AccessToken": {
  7559 + "type": "string",
  7560 + "description": " 授权token"
  7561 + }
  7562 + },
  7563 + "title": "SystemArticleCreateRequest",
  7564 + "required": [
  7565 + "title",
  7566 + "content",
  7567 + "authorId",
  7568 + "targetUser",
  7569 + "articleDraftId",
  7570 + "x-mmm-accesstoken"
  7571 + ]
  7572 + },
  7573 + "SystemArticleCreateResponse": {
  7574 + "type": "object",
  7575 + "properties": {
  7576 + "id": {
  7577 + "type": "integer",
  7578 + "format": "int64",
  7579 + "description": "id"
  7580 + },
  7581 + "title": {
  7582 + "type": "string",
  7583 + "description": "标题"
  7584 + },
  7585 + "content": {
  7586 + "type": "string",
  7587 + "description": "文章的文本内容"
  7588 + },
  7589 + "authorId": {
  7590 + "type": "integer",
  7591 + "format": "int64",
  7592 + "description": "发布人id"
  7593 + },
  7594 + "images": {
  7595 + "type": "array",
  7596 + "items": {
  7597 + "type": "string"
  7598 + },
  7599 + "description": "图片"
  7600 + },
  7601 + "video": {
  7602 + "type": "array",
  7603 + "items": {
  7604 + "$ref": "#/definitions/Video"
  7605 + },
  7606 + "description": " 视频"
  7607 + },
  7608 + "targetUser": {
  7609 + "type": "integer",
  7610 + "format": "int32",
  7611 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  7612 + },
  7613 + "whoRead": {
  7614 + "type": "array",
  7615 + "items": {
  7616 + "type": "integer",
  7617 + "format": "int64"
  7618 + },
  7619 + "description": "谁可查看"
  7620 + },
  7621 + "whoReview": {
  7622 + "type": "array",
  7623 + "items": {
  7624 + "type": "integer",
  7625 + "format": "int64"
  7626 + },
  7627 + "description": "谁可评论"
  7628 + },
  7629 + "matchUrl": {
  7630 + "type": "object",
  7631 + "description": " 匹配文章内容中的url文本"
  7632 + }
  7633 + },
  7634 + "title": "SystemArticleCreateResponse",
  7635 + "required": [
  7636 + "id",
  7637 + "title",
  7638 + "content",
  7639 + "targetUser",
  7640 + "matchUrl"
  7641 + ]
  7642 + },
  7643 + "SystemArticleDeleteRequest": {
  7644 + "type": "object",
  7645 + "properties": {
  7646 + "id": {
  7647 + "type": "integer",
  7648 + "format": "int64",
  7649 + "description": "id"
  7650 + }
  7651 + },
  7652 + "title": "SystemArticleDeleteRequest",
  7653 + "required": [
  7654 + "id"
  7655 + ]
  7656 + },
  7657 + "SystemArticleDeleteResponse": {
  7658 + "type": "object",
  7659 + "properties": {
  7660 + "id": {
  7661 + "type": "integer",
  7662 + "format": "int64",
  7663 + "description": "id"
  7664 + },
  7665 + "title": {
  7666 + "type": "string",
  7667 + "description": "标题"
  7668 + },
  7669 + "authorId": {
  7670 + "type": "integer",
  7671 + "format": "int64",
  7672 + "description": "发布人id"
  7673 + }
  7674 + },
  7675 + "title": "SystemArticleDeleteResponse",
  7676 + "required": [
  7677 + "id",
  7678 + "title"
  7679 + ]
  7680 + },
  7681 + "SystemArticleDeletedRestoreRequest": {
  7682 + "type": "object",
  7683 + "properties": {
  7684 + "id": {
  7685 + "type": "integer",
  7686 + "format": "int64",
  7687 + "description": "ID"
  7688 + }
  7689 + },
  7690 + "title": "SystemArticleDeletedRestoreRequest",
  7691 + "required": [
  7692 + "id"
  7693 + ]
  7694 + },
  7695 + "SystemArticleDeletedRestoreResponse": {
  7696 + "type": "object",
  7697 + "properties": {
  7698 + "id": {
  7699 + "type": "integer",
  7700 + "format": "int64",
  7701 + "description": "ID"
  7702 + },
  7703 + "title": {
  7704 + "type": "string",
  7705 + "description": "标题"
  7706 + },
  7707 + "authorId": {
  7708 + "type": "integer",
  7709 + "format": "int64",
  7710 + "description": "发布人id"
  7711 + }
  7712 + },
  7713 + "title": "SystemArticleDeletedRestoreResponse",
  7714 + "required": [
  7715 + "id",
  7716 + "title",
  7717 + "authorId"
  7718 + ]
  7719 + },
  7720 + "SystemArticleDraftCreateRequest": {
  7721 + "type": "object",
  7722 + "properties": {
  7723 + "title": {
  7724 + "type": "string",
  7725 + "description": "标题"
  7726 + },
  7727 + "content": {
  7728 + "type": "string",
  7729 + "description": "文章的文本内容"
  7730 + },
  7731 + "authorId": {
  7732 + "type": "integer",
  7733 + "format": "int64",
  7734 + "description": "发布人id"
  7735 + },
  7736 + "images": {
  7737 + "type": "array",
  7738 + "items": {
  7739 + "type": "string"
  7740 + },
  7741 + "description": "图片"
  7742 + },
  7743 + "video": {
  7744 + "type": "array",
  7745 + "items": {
  7746 + "$ref": "#/definitions/Video"
  7747 + },
  7748 + "description": " 视频"
  7749 + },
  7750 + "targetUser": {
  7751 + "type": "integer",
  7752 + "format": "int32",
  7753 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  7754 + },
  7755 + "whoRead": {
  7756 + "type": "array",
  7757 + "items": {
  7758 + "type": "integer",
  7759 + "format": "int64"
  7760 + },
  7761 + "description": "谁可查看"
  7762 + },
  7763 + "whoReview": {
  7764 + "type": "array",
  7765 + "items": {
  7766 + "type": "integer",
  7767 + "format": "int64"
  7768 + },
  7769 + "description": "谁可评论"
  7770 + },
  7771 + "matchUrl": {
  7772 + "type": "object",
  7773 + "description": " 匹配文章内容中的url文本"
  7774 + },
  7775 + "tags": {
  7776 + "type": "array",
  7777 + "items": {
  7778 + "type": "integer",
  7779 + "format": "int64"
  7780 + },
  7781 + "description": " 标签"
  7782 + },
  7783 + "AccessToken": {
  7784 + "type": "string",
  7785 + "description": " 授权token"
  7786 + }
  7787 + },
  7788 + "title": "SystemArticleDraftCreateRequest",
  7789 + "required": [
  7790 + "title",
  7791 + "content",
  7792 + "authorId",
  7793 + "targetUser",
  7794 + "tags",
  7795 + "x-mmm-accesstoken"
  7796 + ]
  7797 + },
  7798 + "SystemArticleDraftCreateResponse": {
  7799 + "type": "object",
  7800 + "properties": {
  7801 + "id": {
  7802 + "type": "integer",
  7803 + "format": "int64",
  7804 + "description": "ID"
  7805 + },
  7806 + "title": {
  7807 + "type": "string",
  7808 + "description": "标题"
  7809 + },
  7810 + "content": {
  7811 + "type": "string",
  7812 + "description": "文章的文本内容"
  7813 + },
  7814 + "authorId": {
  7815 + "type": "integer",
  7816 + "format": "int64",
  7817 + "description": "发布人id"
  7818 + },
  7819 + "images": {
  7820 + "type": "array",
  7821 + "items": {
  7822 + "type": "string"
  7823 + },
  7824 + "description": "图片"
  7825 + },
  7826 + "video": {
  7827 + "type": "array",
  7828 + "items": {
  7829 + "$ref": "#/definitions/Video"
  7830 + },
  7831 + "description": " 视频"
  7832 + },
  7833 + "targetUser": {
  7834 + "type": "integer",
  7835 + "format": "int32",
  7836 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  7837 + },
  7838 + "whoRead": {
  7839 + "type": "array",
  7840 + "items": {
  7841 + "type": "integer",
  7842 + "format": "int64"
  7843 + },
  7844 + "description": "谁可查看"
  7845 + },
  7846 + "whoReview": {
  7847 + "type": "array",
  7848 + "items": {
  7849 + "type": "integer",
  7850 + "format": "int64"
  7851 + },
  7852 + "description": "谁可评论"
  7853 + },
  7854 + "matchUrl": {
  7855 + "type": "object",
  7856 + "description": " 匹配文章内容中的url文本"
  7857 + },
  7858 + "tags": {
  7859 + "type": "array",
  7860 + "items": {
  7861 + "type": "integer",
  7862 + "format": "int64"
  7863 + },
  7864 + "description": " 标签"
  7865 + }
  7866 + },
  7867 + "title": "SystemArticleDraftCreateResponse",
  7868 + "required": [
  7869 + "id",
  7870 + "title",
  7871 + "content",
  7872 + "authorId",
  7873 + "targetUser",
  7874 + "tags"
  7875 + ]
  7876 + },
  7877 + "SystemArticleDraftDeleteRequest": {
  7878 + "type": "object",
  7879 + "properties": {
  7880 + "id": {
  7881 + "type": "integer",
  7882 + "format": "int64",
  7883 + "description": "ID"
  7884 + }
  7885 + },
  7886 + "title": "SystemArticleDraftDeleteRequest",
  7887 + "required": [
  7888 + "id"
  7889 + ]
  7890 + },
  7891 + "SystemArticleDraftDeleteResponse": {
  7892 + "type": "object",
  7893 + "properties": {
  7894 + "id": {
  7895 + "type": "integer",
  7896 + "format": "int64",
  7897 + "description": "ID"
  7898 + },
  7899 + "title": {
  7900 + "type": "string",
  7901 + "description": "标题"
  7902 + },
  7903 + "content": {
  7904 + "type": "string",
  7905 + "description": "文章的文本内容"
  7906 + },
  7907 + "authorId": {
  7908 + "type": "integer",
  7909 + "format": "int64",
  7910 + "description": "发布人id"
  7911 + },
  7912 + "images": {
  7913 + "type": "array",
  7914 + "items": {
  7915 + "type": "string"
  7916 + },
  7917 + "description": "图片"
  7918 + },
  7919 + "video": {
  7920 + "type": "array",
  7921 + "items": {
  7922 + "$ref": "#/definitions/Video"
  7923 + },
  7924 + "description": " 视频"
  7925 + },
  7926 + "targetUser": {
  7927 + "type": "integer",
  7928 + "format": "int32",
  7929 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  7930 + },
  7931 + "whoRead": {
  7932 + "type": "array",
  7933 + "items": {
  7934 + "type": "integer",
  7935 + "format": "int64"
  7936 + },
  7937 + "description": "谁可查看"
  7938 + },
  7939 + "whoReview": {
  7940 + "type": "array",
  7941 + "items": {
  7942 + "type": "integer",
  7943 + "format": "int64"
  7944 + },
  7945 + "description": "谁可评论"
  7946 + },
  7947 + "matchUrl": {
  7948 + "type": "object",
  7949 + "description": " 匹配文章内容中的url文本"
  7950 + },
  7951 + "tags": {
  7952 + "type": "array",
  7953 + "items": {
  7954 + "type": "integer",
  7955 + "format": "int64"
  7956 + },
  7957 + "description": " 标签"
  7958 + }
  7959 + },
  7960 + "title": "SystemArticleDraftDeleteResponse",
  7961 + "required": [
  7962 + "id",
  7963 + "title",
  7964 + "content",
  7965 + "authorId",
  7966 + "targetUser",
  7967 + "tags"
  7968 + ]
  7969 + },
  7970 + "SystemArticleDraftGetRequest": {
  7971 + "type": "object",
  7972 + "properties": {
  7973 + "id": {
  7974 + "type": "integer",
  7975 + "format": "int64",
  7976 + "description": "id"
  7977 + },
  7978 + "": {
  7979 + "type": "integer",
  7980 + "format": "int64",
  7981 + "description": "公司ID(前端不传)"
  7982 + }
  7983 + },
  7984 + "title": "SystemArticleDraftGetRequest",
  7985 + "required": [
  7986 + "id"
  7987 + ]
  7988 + },
  7989 + "SystemArticleDraftGetResponse": {
  7990 + "type": "object",
  7991 + "properties": {
  7992 + "id": {
  7993 + "type": "integer",
  7994 + "format": "int64",
  7995 + "description": "ID"
  7996 + },
  7997 + "title": {
  7998 + "type": "string",
  7999 + "description": "标题"
  8000 + },
  8001 + "content": {
  8002 + "type": "string",
  8003 + "description": "文章的文本内容"
  8004 + },
  8005 + "authorId": {
  8006 + "type": "integer",
  8007 + "format": "int64",
  8008 + "description": "发布人id"
  8009 + },
  8010 + "images": {
  8011 + "type": "array",
  8012 + "items": {
  8013 + "type": "string"
  8014 + },
  8015 + "description": "图片"
  8016 + },
  8017 + "video": {
  8018 + "type": "array",
  8019 + "items": {
  8020 + "$ref": "#/definitions/Video"
  8021 + },
  8022 + "description": " 视频"
  8023 + },
  8024 + "targetUser": {
  8025 + "type": "integer",
  8026 + "format": "int32",
  8027 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  8028 + },
  8029 + "whoRead": {
  8030 + "type": "array",
  8031 + "items": {
  8032 + "type": "integer",
  8033 + "format": "int64"
  8034 + },
  8035 + "description": "谁可查看"
  8036 + },
  8037 + "whoReview": {
  8038 + "type": "array",
  8039 + "items": {
  8040 + "type": "integer",
  8041 + "format": "int64"
  8042 + },
  8043 + "description": "谁可评论"
  8044 + },
  8045 + "matchUrl": {
  8046 + "type": "object",
  8047 + "description": " 匹配文章内容中的url文本"
  8048 + },
  8049 + "tags": {
  8050 + "type": "array",
  8051 + "items": {
  8052 + "type": "integer",
  8053 + "format": "int64"
  8054 + },
  8055 + "description": " 标签"
  8056 + }
  8057 + },
  8058 + "title": "SystemArticleDraftGetResponse",
  8059 + "required": [
  8060 + "id",
  8061 + "title",
  8062 + "content",
  8063 + "authorId",
  8064 + "targetUser",
  8065 + "tags"
  8066 + ]
  8067 + },
  8068 + "SystemArticleDraftSearch": {
  8069 + "type": "object",
  8070 + "properties": {
  8071 + "id": {
  8072 + "type": "integer",
  8073 + "format": "int64",
  8074 + "description": "ID"
  8075 + },
  8076 + "title": {
  8077 + "type": "string",
  8078 + "description": "标题"
  8079 + },
  8080 + "images": {
  8081 + "type": "array",
  8082 + "items": {
  8083 + "type": "string"
  8084 + },
  8085 + "description": "图片"
  8086 + },
  8087 + "operator": {
  8088 + "type": "string",
  8089 + "description": "操作人"
  8090 + },
  8091 + "authorId": {
  8092 + "type": "integer",
  8093 + "format": "int64",
  8094 + "description": "发布人id"
  8095 + },
  8096 + "author": {
  8097 + "type": "string",
  8098 + "description": "发布人"
  8099 + },
  8100 + "updatedAt": {
  8101 + "type": "integer",
  8102 + "format": "int64",
  8103 + "description": "编辑时间"
  8104 + }
  8105 + },
  8106 + "title": "SystemArticleDraftSearch",
  8107 + "required": [
  8108 + "id",
  8109 + "title",
  8110 + "images",
  8111 + "operator",
  8112 + "authorId",
  8113 + "author",
  8114 + "updatedAt"
  8115 + ]
  8116 + },
  8117 + "SystemArticleDraftSearchRequest": {
  8118 + "type": "object",
  8119 + "properties": {
  8120 + "page": {
  8121 + "type": "integer",
  8122 + "format": "int32",
  8123 + "description": "页码"
  8124 + },
  8125 + "size": {
  8126 + "type": "integer",
  8127 + "format": "int32",
  8128 + "description": "每页行数"
  8129 + },
  8130 + "companyId": {
  8131 + "type": "integer",
  8132 + "format": "int64",
  8133 + "description": "公司ID(前端不传)"
  8134 + },
  8135 + "title": {
  8136 + "type": "string",
  8137 + "description": "标题"
  8138 + },
  8139 + "operator": {
  8140 + "type": "string",
  8141 + "description": "编辑人"
  8142 + },
  8143 + "beginTime": {
  8144 + "type": "integer",
  8145 + "format": "int64",
  8146 + "description": "开始时间"
  8147 + },
  8148 + "endTime": {
  8149 + "type": "integer",
  8150 + "format": "int64",
  8151 + "description": "结束时间"
  8152 + }
  8153 + },
  8154 + "title": "SystemArticleDraftSearchRequest",
  8155 + "required": [
  8156 + "page",
  8157 + "size"
  8158 + ]
  8159 + },
  8160 + "SystemArticleDraftSearchResponse": {
  8161 + "type": "object",
  8162 + "properties": {
  8163 + "total": {
  8164 + "type": "integer",
  8165 + "format": "int32"
  8166 + },
  8167 + "list": {
  8168 + "type": "array",
  8169 + "items": {
  8170 + "$ref": "#/definitions/SystemArticleDraftSearch"
  8171 + }
  8172 + }
  8173 + },
  8174 + "title": "SystemArticleDraftSearchResponse",
  8175 + "required": [
  8176 + "total",
  8177 + "list"
  8178 + ]
  8179 + },
  8180 + "SystemArticleDraftUpdateRequest": {
  8181 + "type": "object",
  8182 + "properties": {
  8183 + "id": {
  8184 + "type": "integer",
  8185 + "format": "int64",
  8186 + "description": " ID"
  8187 + },
  8188 + "title": {
  8189 + "type": "string",
  8190 + "description": "标题"
  8191 + },
  8192 + "content": {
  8193 + "type": "string",
  8194 + "description": "文章的文本内容"
  8195 + },
  8196 + "authorId": {
  8197 + "type": "integer",
  8198 + "format": "int64",
  8199 + "description": "发布人id"
  8200 + },
  8201 + "images": {
  8202 + "type": "array",
  8203 + "items": {
  8204 + "type": "string"
  8205 + },
  8206 + "description": "图片"
  8207 + },
  8208 + "video": {
  8209 + "type": "array",
  8210 + "items": {
  8211 + "$ref": "#/definitions/Video"
  8212 + },
  8213 + "description": " 视频"
  8214 + },
  8215 + "targetUser": {
  8216 + "type": "integer",
  8217 + "format": "int32",
  8218 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  8219 + },
  8220 + "whoRead": {
  8221 + "type": "array",
  8222 + "items": {
  8223 + "type": "integer",
  8224 + "format": "int64"
  8225 + },
  8226 + "description": "谁可查看"
  8227 + },
  8228 + "whoReview": {
  8229 + "type": "array",
  8230 + "items": {
  8231 + "type": "integer",
  8232 + "format": "int64"
  8233 + },
  8234 + "description": "谁可评论"
  8235 + },
  8236 + "matchUrl": {
  8237 + "type": "object",
  8238 + "description": " 匹配文章内容中的url文本"
  8239 + },
  8240 + "tags": {
  8241 + "type": "array",
  8242 + "items": {
  8243 + "type": "integer",
  8244 + "format": "int64"
  8245 + },
  8246 + "description": " 标签"
  8247 + },
  8248 + "AccessToken": {
  8249 + "type": "string",
  8250 + "description": " 授权token"
  8251 + }
  8252 + },
  8253 + "title": "SystemArticleDraftUpdateRequest",
  8254 + "required": [
  8255 + "id",
  8256 + "title",
  8257 + "content",
  8258 + "authorId",
  8259 + "targetUser",
  8260 + "tags",
  8261 + "x-mmm-accesstoken"
  8262 + ]
  8263 + },
  8264 + "SystemArticleDraftUpdateResponse": {
  8265 + "type": "object",
  8266 + "properties": {
  8267 + "id": {
  8268 + "type": "integer",
  8269 + "format": "int64",
  8270 + "description": "ID"
  8271 + },
  8272 + "title": {
  8273 + "type": "string",
  8274 + "description": "标题"
  8275 + },
  8276 + "content": {
  8277 + "type": "string",
  8278 + "description": "文章的文本内容"
  8279 + },
  8280 + "authorId": {
  8281 + "type": "integer",
  8282 + "format": "int64",
  8283 + "description": "发布人id"
  8284 + },
  8285 + "images": {
  8286 + "type": "array",
  8287 + "items": {
  8288 + "type": "string"
  8289 + },
  8290 + "description": "图片"
  8291 + },
  8292 + "video": {
  8293 + "type": "array",
  8294 + "items": {
  8295 + "$ref": "#/definitions/Video"
  8296 + },
  8297 + "description": " 视频"
  8298 + },
  8299 + "targetUser": {
  8300 + "type": "integer",
  8301 + "format": "int32",
  8302 + "description": " 分发方式 [0分发给所有人、1分发给指定的人]"
  8303 + },
  8304 + "whoRead": {
  8305 + "type": "array",
  8306 + "items": {
  8307 + "type": "integer",
  8308 + "format": "int64"
  8309 + },
  8310 + "description": "谁可查看"
  8311 + },
  8312 + "whoReview": {
  8313 + "type": "array",
  8314 + "items": {
  8315 + "type": "integer",
  8316 + "format": "int64"
  8317 + },
  8318 + "description": "谁可评论"
  8319 + },
  8320 + "matchUrl": {
  8321 + "type": "object",
  8322 + "description": " 匹配文章内容中的url文本"
  8323 + },
  8324 + "tags": {
  8325 + "type": "array",
  8326 + "items": {
  8327 + "type": "integer",
  8328 + "format": "int64"
  8329 + },
  8330 + "description": " 标签"
  8331 + }
  8332 + },
  8333 + "title": "SystemArticleDraftUpdateResponse",
  8334 + "required": [
  8335 + "id",
  8336 + "title",
  8337 + "content",
  8338 + "authorId",
  8339 + "targetUser",
  8340 + "tags"
  8341 + ]
  8342 + },
  8343 + "SystemArticleGetHistoryRequest": {
  8344 + "type": "object",
  8345 + "properties": {
  8346 + "id": {
  8347 + "type": "integer",
  8348 + "format": "int64",
  8349 + "description": "id"
  8350 + },
  8351 + "": {
  8352 + "type": "integer",
  8353 + "format": "int64"
  8354 + }
  8355 + },
  8356 + "title": "SystemArticleGetHistoryRequest",
  8357 + "required": [
  8358 + "id"
  8359 + ]
  8360 + },
  8361 + "SystemArticleGetHistoryResponse": {
  8362 + "type": "object",
  8363 + "properties": {
  8364 + "id": {
  8365 + "type": "integer",
  8366 + "format": "int64",
  8367 + "description": " id"
  8368 + },
  8369 + "articleId": {
  8370 + "type": "integer",
  8371 + "format": "int64",
  8372 + "description": " 文章ID"
  8373 + },
  8374 + "title": {
  8375 + "type": "string",
  8376 + "description": " 标题"
  8377 + },
  8378 + "createdAt": {
7273 "type": "integer", 8379 "type": "integer",
7274 "format": "int64", 8380 "format": "int64",
7275 "description": " 文章的发布时间" 8381 "description": " 文章的发布时间"
@@ -7677,6 +8783,11 @@ @@ -7677,6 +8783,11 @@
7677 "format": "int64", 8783 "format": "int64",
7678 "description": "文章的创建日期" 8784 "description": "文章的创建日期"
7679 }, 8785 },
  8786 + "updatedAt": {
  8787 + "type": "integer",
  8788 + "format": "int64",
  8789 + "description": "文章的编辑日期"
  8790 + },
7680 "countLove": { 8791 "countLove": {
7681 "type": "integer", 8792 "type": "integer",
7682 "format": "int32", 8793 "format": "int32",
@@ -7703,6 +8814,15 @@ @@ -7703,6 +8814,15 @@
7703 "type": "integer", 8814 "type": "integer",
7704 "format": "int32", 8815 "format": "int32",
7705 "description": "分发方式 [0分发给所有人、1分发给指定的人]" 8816 "description": "分发方式 [0分发给所有人、1分发给指定的人]"
  8817 + },
  8818 + "operator": {
  8819 + "$ref": "#/definitions/Operator",
  8820 + "description": "运营操作人"
  8821 + },
  8822 + "source": {
  8823 + "type": "integer",
  8824 + "format": "int32",
  8825 + "description": "来源[1用户发布、2运营发布]"
7706 } 8826 }
7707 }, 8827 },
7708 "title": "SystemArticleSearch", 8828 "title": "SystemArticleSearch",
@@ -7713,11 +8833,134 @@ @@ -7713,11 +8833,134 @@
7713 "author", 8833 "author",
7714 "images", 8834 "images",
7715 "createdAt", 8835 "createdAt",
  8836 + "updatedAt",
7716 "countLove", 8837 "countLove",
7717 "countComment", 8838 "countComment",
7718 "show", 8839 "show",
7719 "tags", 8840 "tags",
7720 - "targetUser" 8841 + "targetUser",
  8842 + "operator",
  8843 + "source"
  8844 + ]
  8845 + },
  8846 + "SystemArticleSearchDeletedItem": {
  8847 + "type": "object",
  8848 + "properties": {
  8849 + "id": {
  8850 + "type": "integer",
  8851 + "format": "int64",
  8852 + "description": "ID"
  8853 + },
  8854 + "title": {
  8855 + "type": "string",
  8856 + "description": "标题"
  8857 + },
  8858 + "images": {
  8859 + "type": "array",
  8860 + "items": {
  8861 + "type": "string"
  8862 + },
  8863 + "description": "图片"
  8864 + },
  8865 + "authorId": {
  8866 + "type": "integer",
  8867 + "format": "int64",
  8868 + "description": "发布人id"
  8869 + },
  8870 + "author": {
  8871 + "type": "string",
  8872 + "description": "发布人"
  8873 + },
  8874 + "source": {
  8875 + "type": "integer",
  8876 + "format": "int32",
  8877 + "description": "来源 1-用户发布 2-运营发布"
  8878 + },
  8879 + "deletedType": {
  8880 + "type": "integer",
  8881 + "format": "int32",
  8882 + "description": "类型 1-运营删除 2-用户删除"
  8883 + },
  8884 + "deletedAt": {
  8885 + "type": "integer",
  8886 + "format": "int64",
  8887 + "description": "删除时间"
  8888 + }
  8889 + },
  8890 + "title": "SystemArticleSearchDeletedItem",
  8891 + "required": [
  8892 + "id",
  8893 + "title",
  8894 + "images",
  8895 + "authorId",
  8896 + "author",
  8897 + "source",
  8898 + "deletedType",
  8899 + "deletedAt"
  8900 + ]
  8901 + },
  8902 + "SystemArticleSearchDeletedRequest": {
  8903 + "type": "object",
  8904 + "properties": {
  8905 + "page": {
  8906 + "type": "integer",
  8907 + "format": "int32",
  8908 + "description": "页码"
  8909 + },
  8910 + "size": {
  8911 + "type": "integer",
  8912 + "format": "int32",
  8913 + "description": "每页行数"
  8914 + },
  8915 + "title": {
  8916 + "type": "string",
  8917 + "description": "标题"
  8918 + },
  8919 + "author": {
  8920 + "type": "integer",
  8921 + "format": "int64",
  8922 + "description": "发布人"
  8923 + },
  8924 + "deletedType": {
  8925 + "type": "integer",
  8926 + "format": "int32",
  8927 + "description": "类型 1-运营删除 2-用户删除"
  8928 + },
  8929 + "beginTime": {
  8930 + "type": "integer",
  8931 + "format": "int64",
  8932 + "description": "开始时间"
  8933 + },
  8934 + "endTime": {
  8935 + "type": "integer",
  8936 + "format": "int64",
  8937 + "description": "结束时间"
  8938 + }
  8939 + },
  8940 + "title": "SystemArticleSearchDeletedRequest",
  8941 + "required": [
  8942 + "page",
  8943 + "size"
  8944 + ]
  8945 + },
  8946 + "SystemArticleSearchDeletedResponse": {
  8947 + "type": "object",
  8948 + "properties": {
  8949 + "total": {
  8950 + "type": "integer",
  8951 + "format": "int32"
  8952 + },
  8953 + "list": {
  8954 + "type": "array",
  8955 + "items": {
  8956 + "$ref": "#/definitions/SystemArticleSearchDeletedItem"
  8957 + }
  8958 + }
  8959 + },
  8960 + "title": "SystemArticleSearchDeletedResponse",
  8961 + "required": [
  8962 + "total",
  8963 + "list"
7721 ] 8964 ]
7722 }, 8965 },
7723 "SystemArticleSearchMeRequest": { 8966 "SystemArticleSearchMeRequest": {
@@ -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 }
@@ -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 //历史
@@ -578,4 +625,171 @@ type ( @@ -578,4 +625,171 @@ type (
578 CreatedAt int64 `json:"createdAt"` 625 CreatedAt int64 `json:"createdAt"`
579 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] 626 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
580 } 627 }
  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 + }
581 ) 795 )
  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 +}
@@ -603,6 +603,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -603,6 +603,51 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
603 Path: "/article/restore", 603 Path: "/article/restore",
604 Handler: article.SystemArticleRestoreHandler(serverCtx), 604 Handler: article.SystemArticleRestoreHandler(serverCtx),
605 }, 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 + },
606 }..., 651 }...,
607 ), 652 ),
608 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 653 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  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, &section)
  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 +}
@@ -27,14 +27,15 @@ type ServiceContext struct { @@ -27,14 +27,15 @@ type ServiceContext struct {
27 DB *gorm.DB 27 DB *gorm.DB
28 Redis *redis.Redis 28 Redis *redis.Redis
29 29
30 - ArticleBackupRepository domain.ArticleBackupRepository  
31 - ArticleCommentRepository domain.ArticleCommentRepository  
32 - ArticleDraftRepository domain.ArticleDraftRepository  
33 - ArticleRepository domain.ArticleRepository  
34 - ArticleSectionRepository domain.ArticleSectionRepository  
35 - ArticleTagRepository domain.ArticleTagRepository  
36 - ArticleCategoryRepository domain.ArticleCategoryRepository  
37 - ArticleAndTagRepository domain.ArticleAndTagRepository 30 + ArticleBackupRepository domain.ArticleBackupRepository
  31 + ArticleCommentRepository domain.ArticleCommentRepository
  32 + ArticleDraftRepository domain.ArticleDraftRepository
  33 + ArticleRepository domain.ArticleRepository
  34 + ArticleSectionRepository domain.ArticleSectionRepository
  35 + ArticleTagRepository domain.ArticleTagRepository
  36 + ArticleCategoryRepository domain.ArticleCategoryRepository
  37 + ArticleAndTagRepository domain.ArticleAndTagRepository
  38 + ArticleDraftOperationRepository domain.ArticleDraftOperationRepository
38 39
39 CompanyRepository domain.CompanyRepository 40 CompanyRepository domain.CompanyRepository
40 DepartmentRepository domain.DepartmentRepository 41 DepartmentRepository domain.DepartmentRepository
@@ -99,7 +100,6 @@ func NewServiceContext(c config.Config) *ServiceContext { @@ -99,7 +100,6 @@ func NewServiceContext(c config.Config) *ServiceContext {
99 UserRepository: repository.NewUserRepository(cache.NewCachedRepository(mlCache)), 100 UserRepository: repository.NewUserRepository(cache.NewCachedRepository(mlCache)),
100 UserReadArticleRepository: repository.NewUserReadArticleRepository(cache.NewCachedRepository(mlCache)), 101 UserReadArticleRepository: repository.NewUserReadArticleRepository(cache.NewCachedRepository(mlCache)),
101 ArticleTagRepository: repository.NewArticleTagRepository(cache.NewCachedRepository(mlCache)), 102 ArticleTagRepository: repository.NewArticleTagRepository(cache.NewCachedRepository(mlCache)),
102 - ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)),  
103 UserRoleRepository: repository.NewUserRoleRepository(cache.NewCachedRepository(mlCache)), 103 UserRoleRepository: repository.NewUserRoleRepository(cache.NewCachedRepository(mlCache)),
104 } 104 }
105 } 105 }
@@ -906,6 +906,11 @@ type ArticleAuthor struct { @@ -906,6 +906,11 @@ type ArticleAuthor struct {
906 Company string `json:"company"` // 公司 906 Company string `json:"company"` // 公司
907 } 907 }
908 908
  909 +type Operator struct {
  910 + Id int64 `json:"id,string"` // 人员id
  911 + Name string `json:"name"` // 人员的名字
  912 +}
  913 +
909 type MiniArticleCreateRequest struct { 914 type MiniArticleCreateRequest struct {
910 Title string `json:"title"` //标题 915 Title string `json:"title"` //标题
911 Section []string `json:"section"` //文章的文本内容 916 Section []string `json:"section"` //文章的文本内容
@@ -1274,11 +1279,14 @@ type SystemArticleSearch struct { @@ -1274,11 +1279,14 @@ type SystemArticleSearch struct {
1274 Author string `json:"author"` //发布人 1279 Author string `json:"author"` //发布人
1275 Images []string `json:"images"` //图片 1280 Images []string `json:"images"` //图片
1276 CreatedAt int64 `json:"createdAt"` //文章的创建日期 1281 CreatedAt int64 `json:"createdAt"` //文章的创建日期
  1282 + UpdatedAt int64 `json:"updatedAt"` //文章的编辑日期
1277 CountLove int `json:"countLove"` //点赞数量 1283 CountLove int `json:"countLove"` //点赞数量
1278 CountComment int `json:"countComment"` //评论数量 1284 CountComment int `json:"countComment"` //评论数量
1279 Show int `json:"show"` //是否隐藏 [0显示、1不显示] 1285 Show int `json:"show"` //是否隐藏 [0显示、1不显示]
1280 Tags []string `json:"tags"` //标签 1286 Tags []string `json:"tags"` //标签
1281 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运营发布]
1282 } 1290 }
1283 1291
1284 type SystemArticleUpdateRequest struct { 1292 type SystemArticleUpdateRequest struct {
@@ -1310,6 +1318,43 @@ type SystemArticleUpdateResponse struct { @@ -1310,6 +1318,43 @@ type SystemArticleUpdateResponse struct {
1310 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人] 1318 TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
1311 } 1319 }
1312 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 +
1313 type SystemArticleHistoryRequest struct { 1358 type SystemArticleHistoryRequest struct {
1314 ArticleId int64 `json:"articleId"` //文章ID 1359 ArticleId int64 `json:"articleId"` //文章ID
1315 Author string `json:"author,optional"` //发布人 1360 Author string `json:"author,optional"` //发布人
@@ -1412,6 +1457,161 @@ type MiniSearchArticleItem struct { @@ -1412,6 +1457,161 @@ type MiniSearchArticleItem struct {
1412 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读] 1457 MeReadFlag int `json:"meReadFlag"` //已读标识 [0:未读] [1:已读]
1413 } 1458 }
1414 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 +
1415 type RoleGetRequest struct { 1615 type RoleGetRequest struct {
1416 Id int64 `path:"id"` 1616 Id int64 `path:"id"`
1417 } 1617 }
  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 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 +}
@@ -24,6 +24,7 @@ func Migrate(db *gorm.DB) { @@ -24,6 +24,7 @@ func Migrate(db *gorm.DB) {
24 //&models.MessageBusiness{}, 24 //&models.MessageBusiness{},
25 //&models.Department{}, 25 //&models.Department{},
26 //&models.ArticleAndTag{}, 26 //&models.ArticleAndTag{},
  27 + &models.ArticleDraftOperation{},
27 &models.ArticleCategory{}, 28 &models.ArticleCategory{},
28 } 29 }
29 30
@@ -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 +// 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 +}
  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
@@ -15,22 +15,25 @@ type Article struct { @@ -15,22 +15,25 @@ type Article struct {
15 UpdatedAt int64 `json:"updatedAt,omitempty"` 15 UpdatedAt int64 `json:"updatedAt,omitempty"`
16 DeletedAt int64 `json:"deletedAt,omitempty"` 16 DeletedAt int64 `json:"deletedAt,omitempty"`
17 Version int `json:"version,omitempty"` 17 Version int `json:"version,omitempty"`
18 - AuthorId int64 `json:"authorId"` // 发布人  
19 - Author UserSimple `json:"author"` // 发布人  
20 - Title string `json:"title"` // 文章标题  
21 - Images []Image `json:"images"` // 图片  
22 - Videos []Video `json:"videos"` // 视频  
23 - WhoRead []int64 `json:"whoRead"` // 谁可以看  
24 - WhoReview []int64 `json:"whoReview"` // 评论人  
25 - Location Location `json:"location"` // 坐标  
26 - TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人  
27 - CountLove int `json:"countLove"` // 点赞数量  
28 - CountComment int `json:"countComment"` // 评论数量  
29 - CountRead int `json:"countRead"` // 浏览数量  
30 - Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)  
31 - Tags []int64 `json:"tags"` // 定性标签  
32 - Summary string `json:"summary"` // 内容概要  
33 - MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 18 + AuthorId int64 `json:"authorId"` // 发布人
  19 + Author UserSimple `json:"author"` // 发布人
  20 + Title string `json:"title"` // 文章标题
  21 + Images []Image `json:"images"` // 图片
  22 + Videos []Video `json:"videos"` // 视频
  23 + WhoRead []int64 `json:"whoRead"` // 谁可以看
  24 + WhoReview []int64 `json:"whoReview"` // 评论人
  25 + Location Location `json:"location"` // 坐标
  26 + TargetUser ArticleTarget `json:"targetUser"` // 分发方式 0 分发给所有人 1 分发给指定的人
  27 + CountLove int `json:"countLove"` // 点赞数量
  28 + CountComment int `json:"countComment"` // 评论数量
  29 + CountRead int `json:"countRead"` // 浏览数量
  30 + Show ArticleShow `json:"show"` // 评论的展示状态(1显示,2不显示、)
  31 + Tags []int64 `json:"tags"` // 定性标签
  32 + Summary string `json:"summary"` // 内容概要
  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 + "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 +}
@@ -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 +}
@@ -28,6 +28,11 @@ CREATE TABLE `user_follow` ( @@ -28,6 +28,11 @@ CREATE TABLE `user_follow` (
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 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 +
31 CREATE TABLE `article_category` ( 36 CREATE TABLE `article_category` (
32 `id` int(0) NOT NULL COMMENT '唯一标识', 37 `id` int(0) NOT NULL COMMENT '唯一标识',
33 PRIMARY KEY (`id`) USING BTREE 38 PRIMARY KEY (`id`) USING BTREE