作者 yangfu

标签分类修改

正在显示 48 个修改的文件 包含 2306 行增加225 行删除
@@ -9,4 +9,5 @@ import "core/company.api" @@ -9,4 +9,5 @@ import "core/company.api"
9 import "core/article_type.api" 9 import "core/article_type.api"
10 import "core/article.api" 10 import "core/article.api"
11 import "core/role.api" 11 import "core/role.api"
12 -import "core/department.api"  
  12 +import "core/department.api"
  13 +import "core/article_category.api"
@@ -333,6 +333,32 @@ @@ -333,6 +333,32 @@
333 ] 333 ]
334 } 334 }
335 }, 335 },
  336 + "v1/mini/article_backup/{id}": {
  337 + "get": {
  338 + "summary": "小程序获取文章的编辑记录",
  339 + "operationId": "MiniGetArticleBackup",
  340 + "responses": {
  341 + "200": {
  342 + "description": "A successful response.",
  343 + "schema": {
  344 + "$ref": "#/definitions/MiniGetArticleBackupResponse"
  345 + }
  346 + }
  347 + },
  348 + "parameters": [
  349 + {
  350 + "name": "id",
  351 + "in": "path",
  352 + "required": true,
  353 + "type": "string"
  354 + }
  355 + ],
  356 + "requestBody": {},
  357 + "tags": [
  358 + "article"
  359 + ]
  360 + }
  361 + },
336 "v1/mini/article_comment": { 362 "v1/mini/article_comment": {
337 "post": { 363 "post": {
338 "summary": "小程序填写文章的评论", 364 "summary": "小程序填写文章的评论",
@@ -766,7 +792,7 @@ @@ -766,7 +792,7 @@
766 "v1/mini/homepage/user_beliked": { 792 "v1/mini/homepage/user_beliked": {
767 "post": { 793 "post": {
768 "summary": "个人主页-获赞的列表", 794 "summary": "个人主页-获赞的列表",
769 - "operationId": "miniHomepageUserBeliked", 795 + "operationId": "miniHomepageUserBeLiked",
770 "responses": { 796 "responses": {
771 "200": { 797 "200": {
772 "description": "A successful response.", 798 "description": "A successful response.",
@@ -1915,6 +1941,170 @@ @@ -1915,6 +1941,170 @@
1915 ] 1941 ]
1916 } 1942 }
1917 }, 1943 },
  1944 + "v1/system/article_category": {
  1945 + "post": {
  1946 + "summary": "标签分类保存",
  1947 + "operationId": "articleCategorySave",
  1948 + "responses": {
  1949 + "200": {
  1950 + "description": "A successful response.",
  1951 + "schema": {
  1952 + "$ref": "#/definitions/ArticleCategorySaveResponse"
  1953 + }
  1954 + }
  1955 + },
  1956 + "parameters": [
  1957 + {
  1958 + "name": "body",
  1959 + "in": "body",
  1960 + "required": true,
  1961 + "schema": {
  1962 + "$ref": "#/definitions/ArticleCategorySaveRequest"
  1963 + }
  1964 + }
  1965 + ],
  1966 + "requestBody": {},
  1967 + "tags": [
  1968 + "tags"
  1969 + ]
  1970 + }
  1971 + },
  1972 + "v1/system/article_category/options": {
  1973 + "get": {
  1974 + "summary": "标签分类下拉列表",
  1975 + "operationId": "articleCategoryOptions",
  1976 + "responses": {
  1977 + "200": {
  1978 + "description": "A successful response.",
  1979 + "schema": {
  1980 + "$ref": "#/definitions/CategoryOptionsResponse"
  1981 + }
  1982 + }
  1983 + },
  1984 + "requestBody": {},
  1985 + "tags": [
  1986 + "tags"
  1987 + ]
  1988 + }
  1989 + },
  1990 + "v1/system/article_category/search": {
  1991 + "post": {
  1992 + "summary": "标签分类搜索",
  1993 + "operationId": "articleCategorySearch",
  1994 + "responses": {
  1995 + "200": {
  1996 + "description": "A successful response.",
  1997 + "schema": {
  1998 + "$ref": "#/definitions/ArticleCategorySearchResponse"
  1999 + }
  2000 + }
  2001 + },
  2002 + "parameters": [
  2003 + {
  2004 + "name": "body",
  2005 + "in": "body",
  2006 + "required": true,
  2007 + "schema": {
  2008 + "$ref": "#/definitions/ArticleCategorySearchRequest"
  2009 + }
  2010 + }
  2011 + ],
  2012 + "requestBody": {},
  2013 + "tags": [
  2014 + "tags"
  2015 + ]
  2016 + }
  2017 + },
  2018 + "v1/system/article_category/{id}": {
  2019 + "get": {
  2020 + "summary": "标签分类详情",
  2021 + "operationId": "articleCategoryGet",
  2022 + "responses": {
  2023 + "200": {
  2024 + "description": "A successful response.",
  2025 + "schema": {
  2026 + "$ref": "#/definitions/ArticleCategoryGetResponse"
  2027 + }
  2028 + }
  2029 + },
  2030 + "parameters": [
  2031 + {
  2032 + "name": "id",
  2033 + "in": "path",
  2034 + "required": true,
  2035 + "type": "string"
  2036 + }
  2037 + ],
  2038 + "requestBody": {},
  2039 + "tags": [
  2040 + "tags"
  2041 + ]
  2042 + },
  2043 + "delete": {
  2044 + "summary": "标签分类删除",
  2045 + "operationId": "articleCategoryDelete",
  2046 + "responses": {
  2047 + "200": {
  2048 + "description": "A successful response.",
  2049 + "schema": {
  2050 + "$ref": "#/definitions/ArticleCategoryDeleteResponse"
  2051 + }
  2052 + }
  2053 + },
  2054 + "parameters": [
  2055 + {
  2056 + "name": "id",
  2057 + "in": "path",
  2058 + "required": true,
  2059 + "type": "string"
  2060 + },
  2061 + {
  2062 + "name": "body",
  2063 + "in": "body",
  2064 + "required": true,
  2065 + "schema": {
  2066 + "$ref": "#/definitions/ArticleCategoryDeleteRequest"
  2067 + }
  2068 + }
  2069 + ],
  2070 + "requestBody": {},
  2071 + "tags": [
  2072 + "tags"
  2073 + ]
  2074 + },
  2075 + "put": {
  2076 + "summary": "标签分类更新",
  2077 + "operationId": "articleCategoryUpdate",
  2078 + "responses": {
  2079 + "200": {
  2080 + "description": "A successful response.",
  2081 + "schema": {
  2082 + "$ref": "#/definitions/ArticleCategoryUpdateResponse"
  2083 + }
  2084 + }
  2085 + },
  2086 + "parameters": [
  2087 + {
  2088 + "name": "id",
  2089 + "in": "path",
  2090 + "required": true,
  2091 + "type": "string"
  2092 + },
  2093 + {
  2094 + "name": "body",
  2095 + "in": "body",
  2096 + "required": true,
  2097 + "schema": {
  2098 + "$ref": "#/definitions/ArticleCategoryUpdateRequest"
  2099 + }
  2100 + }
  2101 + ],
  2102 + "requestBody": {},
  2103 + "tags": [
  2104 + "tags"
  2105 + ]
  2106 + }
  2107 + },
1918 "v1/system/article_comment/edit": { 2108 "v1/system/article_comment/edit": {
1919 "post": { 2109 "post": {
1920 "summary": "管理后台变更评论", 2110 "summary": "管理后台变更评论",
@@ -2323,6 +2513,34 @@ @@ -2323,6 +2513,34 @@
2323 ] 2513 ]
2324 } 2514 }
2325 }, 2515 },
  2516 + "v1/system/company/visible_switch": {
  2517 + "post": {
  2518 + "summary": "公司可见开关",
  2519 + "operationId": "systemCompanyVisibleSwitch",
  2520 + "responses": {
  2521 + "200": {
  2522 + "description": "A successful response.",
  2523 + "schema": {
  2524 + "$ref": "#/definitions/CompanyVisibleSwitchResponse"
  2525 + }
  2526 + }
  2527 + },
  2528 + "parameters": [
  2529 + {
  2530 + "name": "body",
  2531 + "in": "body",
  2532 + "required": true,
  2533 + "schema": {
  2534 + "$ref": "#/definitions/CompanyVisibleSwitchRequest"
  2535 + }
  2536 + }
  2537 + ],
  2538 + "requestBody": {},
  2539 + "tags": [
  2540 + "company"
  2541 + ]
  2542 + }
  2543 + },
2326 "v1/system/department/add": { 2544 "v1/system/department/add": {
2327 "post": { 2545 "post": {
2328 "summary": "部门-新增", 2546 "summary": "部门-新增",
@@ -2875,6 +3093,162 @@ @@ -2875,6 +3093,162 @@
2875 "company" 3093 "company"
2876 ] 3094 ]
2877 }, 3095 },
  3096 + "ArticleCategoryDeleteRequest": {
  3097 + "type": "object",
  3098 + "properties": {
  3099 + "id": {
  3100 + "type": "integer",
  3101 + "format": "int64"
  3102 + }
  3103 + },
  3104 + "title": "ArticleCategoryDeleteRequest",
  3105 + "required": [
  3106 + "id"
  3107 + ]
  3108 + },
  3109 + "ArticleCategoryDeleteResponse": {
  3110 + "type": "object",
  3111 + "title": "ArticleCategoryDeleteResponse"
  3112 + },
  3113 + "ArticleCategoryGetRequest": {
  3114 + "type": "object",
  3115 + "properties": {
  3116 + "id": {
  3117 + "type": "integer",
  3118 + "format": "int64"
  3119 + }
  3120 + },
  3121 + "title": "ArticleCategoryGetRequest",
  3122 + "required": [
  3123 + "id"
  3124 + ]
  3125 + },
  3126 + "ArticleCategoryGetResponse": {
  3127 + "type": "object",
  3128 + "properties": {
  3129 + "category": {
  3130 + "$ref": "#/definitions/ArticleCategoryItem"
  3131 + }
  3132 + },
  3133 + "title": "ArticleCategoryGetResponse",
  3134 + "required": [
  3135 + "category"
  3136 + ]
  3137 + },
  3138 + "ArticleCategoryItem": {
  3139 + "type": "object",
  3140 + "properties": {
  3141 + "id": {
  3142 + "type": "integer",
  3143 + "format": "int64",
  3144 + "description": " 唯一标识"
  3145 + },
  3146 + "companyId": {
  3147 + "type": "integer",
  3148 + "format": "int64"
  3149 + },
  3150 + "name": {
  3151 + "type": "string"
  3152 + },
  3153 + "sortBy": {
  3154 + "type": "integer",
  3155 + "format": "int32",
  3156 + "description": " 排序"
  3157 + },
  3158 + "enable": {
  3159 + "type": "integer",
  3160 + "format": "int32",
  3161 + "description": " 启用状态 1:启用 2:禁用"
  3162 + },
  3163 + "other": {
  3164 + "type": "string",
  3165 + "description": " 其他备注说明"
  3166 + }
  3167 + },
  3168 + "title": "ArticleCategoryItem",
  3169 + "required": [
  3170 + "companyId",
  3171 + "name",
  3172 + "sortBy",
  3173 + "enable",
  3174 + "other"
  3175 + ]
  3176 + },
  3177 + "ArticleCategorySaveRequest": {
  3178 + "type": "object",
  3179 + "properties": {
  3180 + "category": {
  3181 + "$ref": "#/definitions/ArticleCategoryItem"
  3182 + }
  3183 + },
  3184 + "title": "ArticleCategorySaveRequest",
  3185 + "required": [
  3186 + "category"
  3187 + ]
  3188 + },
  3189 + "ArticleCategorySaveResponse": {
  3190 + "type": "object",
  3191 + "title": "ArticleCategorySaveResponse"
  3192 + },
  3193 + "ArticleCategorySearchRequest": {
  3194 + "type": "object",
  3195 + "properties": {
  3196 + "page": {
  3197 + "type": "integer",
  3198 + "format": "int32"
  3199 + },
  3200 + "size": {
  3201 + "type": "integer",
  3202 + "format": "int32"
  3203 + }
  3204 + },
  3205 + "title": "ArticleCategorySearchRequest",
  3206 + "required": [
  3207 + "page",
  3208 + "size"
  3209 + ]
  3210 + },
  3211 + "ArticleCategorySearchResponse": {
  3212 + "type": "object",
  3213 + "properties": {
  3214 + "list": {
  3215 + "type": "array",
  3216 + "items": {
  3217 + "$ref": "#/definitions/ArticleCategoryItem"
  3218 + }
  3219 + },
  3220 + "total": {
  3221 + "type": "integer",
  3222 + "format": "int64"
  3223 + }
  3224 + },
  3225 + "title": "ArticleCategorySearchResponse",
  3226 + "required": [
  3227 + "list",
  3228 + "total"
  3229 + ]
  3230 + },
  3231 + "ArticleCategoryUpdateRequest": {
  3232 + "type": "object",
  3233 + "properties": {
  3234 + "id": {
  3235 + "type": "integer",
  3236 + "format": "int64"
  3237 + },
  3238 + "category": {
  3239 + "$ref": "#/definitions/ArticleCategoryItem"
  3240 + }
  3241 + },
  3242 + "title": "ArticleCategoryUpdateRequest",
  3243 + "required": [
  3244 + "id",
  3245 + "category"
  3246 + ]
  3247 + },
  3248 + "ArticleCategoryUpdateResponse": {
  3249 + "type": "object",
  3250 + "title": "ArticleCategoryUpdateResponse"
  3251 + },
2878 "ArticleCommentAndReply": { 3252 "ArticleCommentAndReply": {
2879 "type": "object", 3253 "type": "object",
2880 "properties": { 3254 "properties": {
@@ -3224,6 +3598,70 @@ @@ -3224,6 +3598,70 @@
3224 "code" 3598 "code"
3225 ] 3599 ]
3226 }, 3600 },
  3601 + "CategoryOptionValue": {
  3602 + "type": "object",
  3603 + "properties": {
  3604 + "label": {
  3605 + "type": "string",
  3606 + "description": " 名称"
  3607 + },
  3608 + "value": {
  3609 + "type": "integer",
  3610 + "format": "int64",
  3611 + "description": " 分类ID"
  3612 + }
  3613 + },
  3614 + "title": "CategoryOptionValue",
  3615 + "required": [
  3616 + "label",
  3617 + "value"
  3618 + ]
  3619 + },
  3620 + "CategoryOptions": {
  3621 + "type": "object",
  3622 + "properties": {
  3623 + "value": {
  3624 + "type": "integer",
  3625 + "format": "int64",
  3626 + "description": " 分类ID"
  3627 + },
  3628 + "label": {
  3629 + "type": "string",
  3630 + "description": " 分组名称"
  3631 + }
  3632 + },
  3633 + "title": "CategoryOptions",
  3634 + "required": [
  3635 + "value",
  3636 + "label"
  3637 + ]
  3638 + },
  3639 + "CategoryOptionsRequest": {
  3640 + "type": "object",
  3641 + "properties": {
  3642 + "": {
  3643 + "type": "integer",
  3644 + "format": "int64",
  3645 + "description": " 公司ID"
  3646 + }
  3647 + },
  3648 + "title": "CategoryOptionsRequest"
  3649 + },
  3650 + "CategoryOptionsResponse": {
  3651 + "type": "object",
  3652 + "properties": {
  3653 + "options": {
  3654 + "type": "array",
  3655 + "items": {
  3656 + "$ref": "#/definitions/CategoryOptions"
  3657 + }
  3658 + }
  3659 + },
  3660 + "title": "CategoryOptionsResponse",
  3661 + "required": [
  3662 + "options"
  3663 + ]
  3664 + },
3227 "CommentAtWho": { 3665 "CommentAtWho": {
3228 "type": "object", 3666 "type": "object",
3229 "properties": { 3667 "properties": {
@@ -3405,6 +3843,24 @@ @@ -3405,6 +3843,24 @@
3405 "total" 3843 "total"
3406 ] 3844 ]
3407 }, 3845 },
  3846 + "CompanyVisibleSwitchRequest": {
  3847 + "type": "object",
  3848 + "properties": {
  3849 + "visible": {
  3850 + "type": "boolean",
  3851 + "format": "boolean",
  3852 + "description": " 可见性 true:可被搜索 false:不可被搜索"
  3853 + }
  3854 + },
  3855 + "title": "CompanyVisibleSwitchRequest",
  3856 + "required": [
  3857 + "visible"
  3858 + ]
  3859 + },
  3860 + "CompanyVisibleSwitchResponse": {
  3861 + "type": "object",
  3862 + "title": "CompanyVisibleSwitchResponse"
  3863 + },
3408 "Department": { 3864 "Department": {
3409 "type": "object", 3865 "type": "object",
3410 "properties": { 3866 "properties": {
@@ -3808,12 +4264,31 @@ @@ -3808,12 +4264,31 @@
3808 "type": "string" 4264 "type": "string"
3809 } 4265 }
3810 }, 4266 },
  4267 + "videos": {
  4268 + "type": "array",
  4269 + "items": {
  4270 + "$ref": "#/definitions/Video"
  4271 + }
  4272 + },
  4273 + "changeField": {
  4274 + "type": "array",
  4275 + "items": {
  4276 + "type": "string"
  4277 + }
  4278 + },
3811 "createdAt": { 4279 "createdAt": {
3812 "type": "integer", 4280 "type": "integer",
3813 "format": "int64" 4281 "format": "int64"
3814 }, 4282 },
3815 "location": { 4283 "location": {
3816 "$ref": "#/definitions/Location" 4284 "$ref": "#/definitions/Location"
  4285 + },
  4286 + "action": {
  4287 + "type": "string"
  4288 + },
  4289 + "show": {
  4290 + "type": "integer",
  4291 + "format": "int32"
3817 } 4292 }
3818 }, 4293 },
3819 "title": "MiniArticleBackupItem", 4294 "title": "MiniArticleBackupItem",
@@ -3822,8 +4297,12 @@ @@ -3822,8 +4297,12 @@
3822 "title", 4297 "title",
3823 "content", 4298 "content",
3824 "images", 4299 "images",
  4300 + "videos",
  4301 + "changeField",
3825 "createdAt", 4302 "createdAt",
3826 - "location" 4303 + "location",
  4304 + "action",
  4305 + "show"
3827 ] 4306 ]
3828 }, 4307 },
3829 "MiniArticleBackupSearchRequest": { 4308 "MiniArticleBackupSearchRequest": {
@@ -4991,6 +5470,84 @@ @@ -4991,6 +5470,84 @@
4991 "type": "object", 5470 "type": "object",
4992 "title": "MiniEditUserInfoResponse" 5471 "title": "MiniEditUserInfoResponse"
4993 }, 5472 },
  5473 + "MiniGetArticleBackupRequest": {
  5474 + "type": "object",
  5475 + "properties": {
  5476 + "id": {
  5477 + "type": "integer",
  5478 + "format": "int64"
  5479 + },
  5480 + "": {
  5481 + "type": "integer",
  5482 + "format": "int64",
  5483 + "description": " 服务端自动获取"
  5484 + }
  5485 + },
  5486 + "title": "MiniGetArticleBackupRequest",
  5487 + "required": [
  5488 + "id"
  5489 + ]
  5490 + },
  5491 + "MiniGetArticleBackupResponse": {
  5492 + "type": "object",
  5493 + "properties": {
  5494 + "id": {
  5495 + "type": "integer",
  5496 + "format": "int64"
  5497 + },
  5498 + "title": {
  5499 + "type": "string"
  5500 + },
  5501 + "content": {
  5502 + "type": "string"
  5503 + },
  5504 + "images": {
  5505 + "type": "array",
  5506 + "items": {
  5507 + "type": "string"
  5508 + }
  5509 + },
  5510 + "videos": {
  5511 + "type": "array",
  5512 + "items": {
  5513 + "$ref": "#/definitions/Video"
  5514 + }
  5515 + },
  5516 + "changeField": {
  5517 + "type": "array",
  5518 + "items": {
  5519 + "type": "string"
  5520 + }
  5521 + },
  5522 + "createdAt": {
  5523 + "type": "integer",
  5524 + "format": "int64"
  5525 + },
  5526 + "location": {
  5527 + "$ref": "#/definitions/Location"
  5528 + },
  5529 + "action": {
  5530 + "type": "string"
  5531 + },
  5532 + "show": {
  5533 + "type": "integer",
  5534 + "format": "int32"
  5535 + }
  5536 + },
  5537 + "title": "MiniGetArticleBackupResponse",
  5538 + "required": [
  5539 + "id",
  5540 + "title",
  5541 + "content",
  5542 + "images",
  5543 + "videos",
  5544 + "changeField",
  5545 + "createdAt",
  5546 + "location",
  5547 + "action",
  5548 + "show"
  5549 + ]
  5550 + },
4994 "MiniGetArticleCommentRequest": { 5551 "MiniGetArticleCommentRequest": {
4995 "type": "object", 5552 "type": "object",
4996 "properties": { 5553 "properties": {
@@ -5114,6 +5671,9 @@ @@ -5114,6 +5671,9 @@
5114 "size": { 5671 "size": {
5115 "type": "integer", 5672 "type": "integer",
5116 "format": "int32" 5673 "format": "int32"
  5674 + },
  5675 + "name": {
  5676 + "type": "string"
5117 } 5677 }
5118 }, 5678 },
5119 "title": "MiniHomePageUserFollowerSearchRequest", 5679 "title": "MiniHomePageUserFollowerSearchRequest",
@@ -5210,10 +5770,14 @@ @@ -5210,10 +5770,14 @@
5210 "format": "int32", 5770 "format": "int32",
5211 "description": " 数量" 5771 "description": " 数量"
5212 }, 5772 },
5213 - "orderByHotScore": { 5773 + "orderByKey": {
5214 "type": "string", 5774 "type": "string",
5215 "default": "desc", 5775 "default": "desc",
5216 - "description": " 热度排序 升序 asc 降序 desc" 5776 + "description": " 按规则排序 (热度:HotScore All:时间排序 Time:时间排序)"
  5777 + },
  5778 + "orderByValue": {
  5779 + "type": "string",
  5780 + "description": " 排序值 升序 asc 降序 desc"
5217 }, 5781 },
5218 "keywords": { 5782 "keywords": {
5219 "type": "string", 5783 "type": "string",
@@ -5224,7 +5788,7 @@ @@ -5224,7 +5788,7 @@
5224 "format": "int64", 5788 "format": "int64",
5225 "description": " 开始时间" 5789 "description": " 开始时间"
5226 }, 5790 },
5227 - "beginTime": { 5791 + "endTime": {
5228 "type": "integer", 5792 "type": "integer",
5229 "format": "int64", 5793 "format": "int64",
5230 "description": " 结束时间" 5794 "description": " 结束时间"
@@ -5234,7 +5798,8 @@ @@ -5234,7 +5798,8 @@
5234 "required": [ 5798 "required": [
5235 "authorId", 5799 "authorId",
5236 "size", 5800 "size",
5237 - "orderByHotScore" 5801 + "orderByKey",
  5802 + "orderByValue"
5238 ] 5803 ]
5239 }, 5804 },
5240 "MiniHomepageUserNewsResposne": { 5805 "MiniHomepageUserNewsResposne": {
@@ -5250,12 +5815,17 @@ @@ -5250,12 +5815,17 @@
5250 "type": "integer", 5815 "type": "integer",
5251 "format": "int64", 5816 "format": "int64",
5252 "description": " 最后文章ID" 5817 "description": " 最后文章ID"
  5818 + },
  5819 + "total": {
  5820 + "type": "integer",
  5821 + "format": "int64"
5253 } 5822 }
5254 }, 5823 },
5255 "title": "MiniHomepageUserNewsResposne", 5824 "title": "MiniHomepageUserNewsResposne",
5256 "required": [ 5825 "required": [
5257 "list", 5826 "list",
5258 - "lastArticleId" 5827 + "lastArticleId",
  5828 + "total"
5259 ] 5829 ]
5260 }, 5830 },
5261 "MiniListArticleCommentRequest": { 5831 "MiniListArticleCommentRequest": {
@@ -7247,6 +7817,10 @@ @@ -7247,6 +7817,10 @@
7247 "type": "integer", 7817 "type": "integer",
7248 "format": "int32", 7818 "format": "int32",
7249 "description": "每页行数" 7819 "description": "每页行数"
  7820 + },
  7821 + "orderMode": {
  7822 + "type": "string",
  7823 + "description": "排序方式"
7250 } 7824 }
7251 }, 7825 },
7252 "title": "SystemArticleSearchRequest", 7826 "title": "SystemArticleSearchRequest",
@@ -7353,7 +7927,6 @@ @@ -7353,7 +7927,6 @@
7353 "title": "SystemArticleUpdateRequest", 7927 "title": "SystemArticleUpdateRequest",
7354 "required": [ 7928 "required": [
7355 "id", 7929 "id",
7356 - "template",  
7357 "section", 7930 "section",
7358 "title", 7931 "title",
7359 "images", 7932 "images",
@@ -8584,9 +9157,14 @@ @@ -8584,9 +9157,14 @@
8584 "TagOptions": { 9157 "TagOptions": {
8585 "type": "object", 9158 "type": "object",
8586 "properties": { 9159 "properties": {
  9160 + "value": {
  9161 + "type": "integer",
  9162 + "format": "int64",
  9163 + "description": " 分类ID"
  9164 + },
8587 "label": { 9165 "label": {
8588 "type": "string", 9166 "type": "string",
8589 - "description": " 分名称" 9167 + "description": " 分名称"
8590 }, 9168 },
8591 "options": { 9169 "options": {
8592 "type": "array", 9170 "type": "array",
@@ -8597,6 +9175,7 @@ @@ -8597,6 +9175,7 @@
8597 }, 9175 },
8598 "title": "TagOptions", 9176 "title": "TagOptions",
8599 "required": [ 9177 "required": [
  9178 + "value",
8600 "label", 9179 "label",
8601 "options" 9180 "options"
8602 ] 9181 ]
  1 +@server(
  2 + prefix: v1/system
  3 + group: tags
  4 + middleware: LoginStatusCheck,LogRequest
  5 + jwt: SystemAuth
  6 +)
  7 +service Core {
  8 + @doc "标签分类详情"
  9 + @handler articleCategoryGet
  10 + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse)
  11 + @doc "标签分类保存"
  12 + @handler articleCategorySave
  13 + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse)
  14 + @doc "标签分类删除"
  15 + @handler articleCategoryDelete
  16 + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse)
  17 + @doc "标签分类更新"
  18 + @handler articleCategoryUpdate
  19 + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse)
  20 + @doc "标签分类搜索"
  21 + @handler articleCategorySearch
  22 + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse)
  23 + @doc "标签分类下拉列表"
  24 + @handler articleCategoryOptions
  25 + get /article_category/options (CategoryOptionsRequest) returns (CategoryOptionsResponse)
  26 +}
  27 +
  28 +@server(
  29 + prefix: v1/system
  30 + group: tags
  31 +)
  32 +service Core {
  33 + @doc "标签分类初始化"
  34 + @handler articleCategoryInit
  35 + get /article_category/init
  36 +}
  37 +
  38 +type (
  39 + ArticleCategoryGetRequest {
  40 + Id int64 `path:"id"`
  41 + }
  42 + ArticleCategoryGetResponse struct{
  43 + ArticleCategory ArticleCategoryItem `json:"category"`
  44 + }
  45 +
  46 + ArticleCategorySaveRequest struct{
  47 + ArticleCategory ArticleCategoryItem `json:"category"`
  48 + }
  49 + ArticleCategorySaveResponse struct{}
  50 +
  51 + ArticleCategoryDeleteRequest struct{
  52 + Id int64 `path:"id"`
  53 + }
  54 + ArticleCategoryDeleteResponse struct{}
  55 +
  56 + ArticleCategoryUpdateRequest struct{
  57 + Id int64 `path:"id"`
  58 + ArticleCategory ArticleCategoryItem `json:"category"`
  59 + }
  60 + ArticleCategoryUpdateResponse struct{}
  61 +
  62 + ArticleCategorySearchRequest struct{
  63 + Page int `json:"page"`
  64 + Size int `json:"size"`
  65 + }
  66 + ArticleCategorySearchResponse{
  67 + List []ArticleCategoryItem `json:"list"`
  68 + Total int64 `json:"total"`
  69 + }
  70 + ArticleCategoryItem struct{
  71 + Id int64 `json:"id,optional"` // 唯一标识
  72 + CompanyId int64 `json:"companyId,optional,omitempty"`
  73 + Name string `json:"name"`
  74 + SortBy int `json:"sortBy,optional,omitempty"` // 排序
  75 + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
  76 + Other string `json:"other,optional,omitempty"` // 其他备注说明
  77 + }
  78 +)
  79 +
  80 +//标签下拉列表
  81 +type (
  82 + CategoryOptionsRequest {
  83 + CompanyId int64 `path:",optional"` // 公司ID
  84 + }
  85 + CategoryOptionsResponse {
  86 + Options []CategoryOptions `json:"options"`
  87 + }
  88 + CategoryOptions {
  89 + Value int64 `json:"value"` // 分类ID
  90 + Label string `json:"label"` // 分组名称
  91 + //Options []CategoryOptionValue `json:"options,omitempty"`
  92 + }
  93 + CategoryOptionValue {
  94 + Label string `json:"label"` // 名称
  95 + Value int64 `json:"value"` // 分类ID
  96 + }
  97 +)
@@ -46,10 +46,11 @@ type ( @@ -46,10 +46,11 @@ type (
46 CompanyId int64 `json:",optional"` 46 CompanyId int64 `json:",optional"`
47 Image string `json:"image"` 47 Image string `json:"image"`
48 Name string `json:"name"` // 标签名称 48 Name string `json:"name"` // 标签名称
49 - Category string `json:"category"` // 标签分类 49 + //Category string `json:"category"` // 标签分类
50 Remark string `json:"remark,optional"` // 备注 50 Remark string `json:"remark,optional"` // 备注
51 Other string `json:"other,optional"` 51 Other string `json:"other,optional"`
52 SortBy int `json:"sortBy,optional"` //排序 52 SortBy int `json:"sortBy,optional"` //排序
  53 + CategoryId int64 `json:"categoryId"` // 标签Id
53 } 54 }
54 55
55 TagCreateResponse { 56 TagCreateResponse {
@@ -64,7 +65,8 @@ type ( @@ -64,7 +65,8 @@ type (
64 CompanyId int64 `json:",optional"` 65 CompanyId int64 `json:",optional"`
65 Image string `json:"image"` 66 Image string `json:"image"`
66 Name string `json:"name"` // 标签名称 67 Name string `json:"name"` // 标签名称
67 - Category string `json:"category"` // 标签分类 68 + //Category string `json:"category"` // 标签分类
  69 + CategoryId int64 `json:"categoryId"` // 标签Id
68 Remark string `json:"remark,optional"` // 备注 70 Remark string `json:"remark,optional"` // 备注
69 Other string `json:"other,optional"` 71 Other string `json:"other,optional"`
70 SortBy int `json:"sortBy,optional"` // 排序 72 SortBy int `json:"sortBy,optional"` // 排序
@@ -86,6 +88,7 @@ type ( @@ -86,6 +88,7 @@ type (
86 Image string `json:"image"` 88 Image string `json:"image"`
87 Name string `json:"name"` // 标签名称 89 Name string `json:"name"` // 标签名称
88 Category string `json:"category"` // 标签分类 90 Category string `json:"category"` // 标签分类
  91 + CategoryId int64 `json:"categoryId"` // 标签分类Id
89 Remark string `json:"remark"` // 备注 92 Remark string `json:"remark"` // 备注
90 Other string `json:"other"` 93 Other string `json:"other"`
91 SortBy int `json:"sortBy,optional"` // 排序 94 SortBy int `json:"sortBy,optional"` // 排序
@@ -99,7 +102,7 @@ type ( @@ -99,7 +102,7 @@ type (
99 Size int `json:"size"` 102 Size int `json:"size"`
100 CompanyId int64 `json:",optional"` 103 CompanyId int64 `json:",optional"`
101 TagName string `json:"tagName,optional"` 104 TagName string `json:"tagName,optional"`
102 - Category string `json:"category,optional"` 105 + CategoryId int64 `json:"categoryId,optional"`
103 Remark string `json:"remark,optional"` 106 Remark string `json:"remark,optional"`
104 } 107 }
105 TagListResponse { 108 TagListResponse {
@@ -111,9 +114,11 @@ type ( @@ -111,9 +114,11 @@ type (
111 Image string `json:"image"` 114 Image string `json:"image"`
112 Name string `json:"name"` // 标签名称 115 Name string `json:"name"` // 标签名称
113 Category string `json:"category"` // 标签分类 116 Category string `json:"category"` // 标签分类
  117 + CategoryId int64 `json:"categoryId"` // 标签分类Id
114 Remark string `json:"remark"` // 备注 118 Remark string `json:"remark"` // 备注
115 CreatedAt int64 `json:"createdAt"` 119 CreatedAt int64 `json:"createdAt"`
116 SortBy int `json:"sortBy,optional"` // 排序 120 SortBy int `json:"sortBy,optional"` // 排序
  121 + Removeable bool `json:"removeable,optional"` // 可删除
117 } 122 }
118 ) 123 )
119 124
@@ -137,7 +142,8 @@ type ( @@ -137,7 +142,8 @@ type (
137 Options []TagOptions `json:"options"` 142 Options []TagOptions `json:"options"`
138 } 143 }
139 TagOptions { 144 TagOptions {
140 - Label string `json:"label"` // 分组名称 145 + Value int64 `json:"value"` // 分类ID
  146 + Label string `json:"label"` // 分类名称
141 Options []TagOptionValue `json:"options"` 147 Options []TagOptionValue `json:"options"`
142 } 148 }
143 TagOptionValue { 149 TagOptionValue {
@@ -41,6 +41,10 @@ service Core { @@ -41,6 +41,10 @@ service Core {
41 jwt : SystemAuth 41 jwt : SystemAuth
42 ) 42 )
43 service Core { 43 service Core {
  44 + @doc "公司可见开关"
  45 + @handler systemCompanyVisibleSwitch
  46 + post /system/company/visible_switch(CompanyVisibleSwitchRequest) returns (CompanyVisibleSwitchResponse)
  47 +
44 @doc "公司搜索" 48 @doc "公司搜索"
45 @handler systemCompanySearch 49 @handler systemCompanySearch
46 post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse) 50 post /system/company/search(CompanySearchRequest) returns (CompanySearchResponse)
@@ -70,6 +74,13 @@ type ( @@ -70,6 +74,13 @@ type (
70 Logo string `json:"logo,omitempty"` // 公司LOGO 74 Logo string `json:"logo,omitempty"` // 公司LOGO
71 JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) 75 JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入)
72 } 76 }
  77 +
  78 + CompanyVisibleSwitchRequest{
  79 + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索
  80 + }
  81 + CompanyVisibleSwitchResponse{
  82 +
  83 + }
73 ) 84 )
74 85
75 // 公司职位搜索 86 // 公司职位搜索
@@ -2,7 +2,7 @@ Name: discuss @@ -2,7 +2,7 @@ Name: discuss
2 Host: 0.0.0.0 2 Host: 0.0.0.0
3 Port: 8081 3 Port: 8081
4 Verbose: false 4 Verbose: false
5 -Migrate: false 5 +Migrate: true
6 Timeout: 30000 6 Timeout: 30000
7 # CertFile: ./key/fjmaimaimai.com_bundle.crt 7 # CertFile: ./key/fjmaimaimai.com_bundle.crt
8 # KeyFile: ./key/fjmaimaimai.com.key 8 # KeyFile: ./key/fjmaimaimai.com.key
  1 +package company
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/company"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func SystemCompanyVisibleSwitchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.CompanyVisibleSwitchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := company.NewSystemCompanyVisibleSwitchLogic(r.Context(), svcCtx)
  21 + resp, err := l.SystemCompanyVisibleSwitch(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
@@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -445,6 +445,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
445 []rest.Route{ 445 []rest.Route{
446 { 446 {
447 Method: http.MethodPost, 447 Method: http.MethodPost,
  448 + Path: "/system/company/visible_switch",
  449 + Handler: company.SystemCompanyVisibleSwitchHandler(serverCtx),
  450 + },
  451 + {
  452 + Method: http.MethodPost,
448 Path: "/system/company/search", 453 Path: "/system/company/search",
449 Handler: company.SystemCompanySearchHandler(serverCtx), 454 Handler: company.SystemCompanySearchHandler(serverCtx),
450 }, 455 },
@@ -678,4 +683,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { @@ -678,4 +683,55 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
678 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), 683 rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
679 rest.WithPrefix("/v1"), 684 rest.WithPrefix("/v1"),
680 ) 685 )
  686 +
  687 + server.AddRoutes(
  688 + rest.WithMiddlewares(
  689 + []rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest},
  690 + []rest.Route{
  691 + {
  692 + Method: http.MethodGet,
  693 + Path: "/article_category/:id",
  694 + Handler: tags.ArticleCategoryGetHandler(serverCtx),
  695 + },
  696 + {
  697 + Method: http.MethodPost,
  698 + Path: "/article_category",
  699 + Handler: tags.ArticleCategorySaveHandler(serverCtx),
  700 + },
  701 + {
  702 + Method: http.MethodDelete,
  703 + Path: "/article_category/:id",
  704 + Handler: tags.ArticleCategoryDeleteHandler(serverCtx),
  705 + },
  706 + {
  707 + Method: http.MethodPut,
  708 + Path: "/article_category/:id",
  709 + Handler: tags.ArticleCategoryUpdateHandler(serverCtx),
  710 + },
  711 + {
  712 + Method: http.MethodPost,
  713 + Path: "/article_category/search",
  714 + Handler: tags.ArticleCategorySearchHandler(serverCtx),
  715 + },
  716 + {
  717 + Method: http.MethodGet,
  718 + Path: "/article_category/options",
  719 + Handler: tags.ArticleCategoryOptionsHandler(serverCtx),
  720 + },
  721 + }...,
  722 + ),
  723 + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret),
  724 + rest.WithPrefix("/v1/system"),
  725 + )
  726 +
  727 + server.AddRoutes(
  728 + []rest.Route{
  729 + {
  730 + Method: http.MethodGet,
  731 + Path: "/article_category/init",
  732 + Handler: tags.ArticleCategoryInitHandler(serverCtx),
  733 + },
  734 + },
  735 + rest.WithPrefix("/v1/system"),
  736 + )
681 } 737 }
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategoryDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ArticleCategoryDeleteRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategoryDeleteLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategoryDelete(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategoryGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ArticleCategoryGetRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategoryGetLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategoryGet(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 +)
  10 +
  11 +func ArticleCategoryInitHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  12 + return func(w http.ResponseWriter, r *http.Request) {
  13 + l := tags.NewArticleCategoryInitLogic(r.Context(), svcCtx)
  14 + err := l.ArticleCategoryInit()
  15 + if err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + } else {
  18 + httpx.Ok(w)
  19 + }
  20 + }
  21 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategoryOptionsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.CategoryOptionsRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategoryOptionsLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategoryOptions(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategorySaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ArticleCategorySaveRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategorySaveLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategorySave(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategorySearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ArticleCategorySearchRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategorySearchLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategorySearch(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
  1 +package tags
  2 +
  3 +import (
  4 + "net/http"
  5 +
  6 + "github.com/zeromicro/go-zero/rest/httpx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/tags"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +)
  11 +
  12 +func ArticleCategoryUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
  13 + return func(w http.ResponseWriter, r *http.Request) {
  14 + var req types.ArticleCategoryUpdateRequest
  15 + if err := httpx.Parse(r, &req); err != nil {
  16 + httpx.ErrorCtx(r.Context(), w, err)
  17 + return
  18 + }
  19 +
  20 + l := tags.NewArticleCategoryUpdateLogic(r.Context(), svcCtx)
  21 + resp, err := l.ArticleCategoryUpdate(&req)
  22 + if err != nil {
  23 + httpx.ErrorCtx(r.Context(), w, err)
  24 + } else {
  25 + httpx.OkJsonCtx(r.Context(), w, resp)
  26 + }
  27 + }
  28 +}
@@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) @@ -47,10 +47,15 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest)
47 countDataMap[val.TagId] = val 47 countDataMap[val.TagId] = val
48 } 48 }
49 49
50 - tagCategory := []string{}  
51 - tagCount := []types.ArticleTagCount{} 50 + _, categoryList, _ := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, req.CompanyId, domain.NewQueryOptions().MustWithKV("enable", 1))
  51 + tagCount := make([]types.ArticleTagCount, 0)
  52 + tagCategory := domain.Values(categoryList, func(item *domain.ArticleCategory) string {
  53 + return item.Name
  54 + })
  55 + categoryMap := lo.KeyBy(categoryList, func(item *domain.ArticleCategory) int64 {
  56 + return item.Id
  57 + })
52 for _, val := range allTags { 58 for _, val := range allTags {
53 - tagCategory = append(tagCategory, val.Category)  
54 m := types.ArticleTagCount{ 59 m := types.ArticleTagCount{
55 TagCategory: val.Category, 60 TagCategory: val.Category,
56 TagId: val.Id, 61 TagId: val.Id,
@@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest) @@ -65,9 +70,13 @@ func (l *MiniShowHomePageLogic) MiniShowHomePage(req *types.MiniHomePageRequest)
65 m.TotalArticle = count.TotalArticle 70 m.TotalArticle = count.TotalArticle
66 m.ReadArticle = count.ReadArticle 71 m.ReadArticle = count.ReadArticle
67 } 72 }
  73 + if v, ok := categoryMap[val.CategoryId]; ok {
  74 + m.TagCategory = v.Name
  75 + } else {
  76 + continue
  77 + }
68 tagCount = append(tagCount, m) 78 tagCount = append(tagCount, m)
69 } 79 }
70 - tagCategory = lo.Uniq(tagCategory)  
71 resp = &types.MiniHomePageResponse{ 80 resp = &types.MiniHomePageResponse{
72 TagCategory: tagCategory, 81 TagCategory: tagCategory,
73 Tags: tagCount, 82 Tags: tagCount,
@@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan @@ -91,6 +91,10 @@ func (l *MiniCompanySearchJoinedLogic) MiniCompanySearchJoined(req *types.Compan
91 if lo.Contains(companyJoiningList, company.Id) { 91 if lo.Contains(companyJoiningList, company.Id) {
92 company.JoinedFlag = 0 92 company.JoinedFlag = 0
93 } 93 }
  94 + // 过滤掉不可见且未加入的企业。
  95 + if company.JoinedFlag != 1 && item.Visible == 0 {
  96 + return
  97 + }
94 resp.List = append(resp.List, company) 98 resp.List = append(resp.List, company)
95 }) 99 })
96 resp.Total = total 100 resp.Total = total
@@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque @@ -38,6 +38,7 @@ func (l *MiniCompanySearchLogic) MiniCompanySearch(req *types.CompanySearchReque
38 if req.Code != "" { 38 if req.Code != "" {
39 queryOptions.WithKV("code", req.Code) 39 queryOptions.WithKV("code", req.Code)
40 } 40 }
  41 + queryOptions.MustWithKV("visible", 1)
41 total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions) 42 total, companyList, err = l.svcCtx.CompanyRepository.Find(l.ctx, conn, queryOptions)
42 if err != nil { 43 if err != nil {
43 return nil, xerr.NewErrMsgErr("公司列表获取失败", err) 44 return nil, xerr.NewErrMsgErr("公司列表获取失败", err)
  1 +package company
  2 +
  3 +import (
  4 + "context"
  5 + "github.com/samber/lo"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  9 +
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  12 +
  13 + "github.com/zeromicro/go-zero/core/logx"
  14 +)
  15 +
  16 +type SystemCompanyVisibleSwitchLogic struct {
  17 + logx.Logger
  18 + ctx context.Context
  19 + svcCtx *svc.ServiceContext
  20 +}
  21 +
  22 +func NewSystemCompanyVisibleSwitchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemCompanyVisibleSwitchLogic {
  23 + return &SystemCompanyVisibleSwitchLogic{
  24 + Logger: logx.WithContext(ctx),
  25 + ctx: ctx,
  26 + svcCtx: svcCtx,
  27 + }
  28 +}
  29 +
  30 +func (l *SystemCompanyVisibleSwitchLogic) SystemCompanyVisibleSwitch(req *types.CompanyVisibleSwitchRequest) (resp *types.CompanyVisibleSwitchResponse, err error) {
  31 + var (
  32 + conn = l.svcCtx.DefaultDBConn()
  33 + company *domain.Company
  34 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  35 + )
  36 + if company, err = l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, userToken.CompanyId); err != nil {
  37 + return nil, xerr.NewErrMsg("设置失败")
  38 + }
  39 + company.Visible = lo.Ternary(req.Visible, 1, 0)
  40 + if company, err = l.svcCtx.CompanyRepository.UpdateWithVersion(l.ctx, conn, company); err != nil {
  41 + return nil, xerr.NewErrMsg("设置失败")
  42 + }
  43 + resp = &types.CompanyVisibleSwitchResponse{}
  44 + return
  45 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 +
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  8 +
  9 + "github.com/zeromicro/go-zero/core/logx"
  10 +)
  11 +
  12 +type ArticleCategoryDeleteLogic struct {
  13 + logx.Logger
  14 + ctx context.Context
  15 + svcCtx *svc.ServiceContext
  16 +}
  17 +
  18 +func NewArticleCategoryDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryDeleteLogic {
  19 + return &ArticleCategoryDeleteLogic{
  20 + Logger: logx.WithContext(ctx),
  21 + ctx: ctx,
  22 + svcCtx: svcCtx,
  23 + }
  24 +}
  25 +
  26 +func (l *ArticleCategoryDeleteLogic) ArticleCategoryDelete(req *types.ArticleCategoryDeleteRequest) (resp *types.ArticleCategoryDeleteResponse, err error) {
  27 + // todo: add your logic here and delete this line
  28 +
  29 + return
  30 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type ArticleCategoryGetLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewArticleCategoryGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryGetLogic {
  21 + return &ArticleCategoryGetLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *ArticleCategoryGetLogic) ArticleCategoryGet(req *types.ArticleCategoryGetRequest) (resp *types.ArticleCategoryGetResponse, err error) {
  29 + var (
  30 + conn = l.svcCtx.DefaultDBConn()
  31 + dm *domain.ArticleCategory
  32 + )
  33 + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  34 + return nil, xerr.NewErrMsgErr("不存在", err)
  35 + }
  36 + resp = &types.ArticleCategoryGetResponse{
  37 + ArticleCategory: NewTypesArticleCategory(dm),
  38 + }
  39 + return
  40 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "github.com/zeromicro/go-zero/core/logx"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  11 +)
  12 +
  13 +type ArticleCategoryInitLogic struct {
  14 + logx.Logger
  15 + ctx context.Context
  16 + svcCtx *svc.ServiceContext
  17 +}
  18 +
  19 +func NewArticleCategoryInitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryInitLogic {
  20 + return &ArticleCategoryInitLogic{
  21 + Logger: logx.WithContext(ctx),
  22 + ctx: ctx,
  23 + svcCtx: svcCtx,
  24 + }
  25 +}
  26 +
  27 +func (l *ArticleCategoryInitLogic) ArticleCategoryInit() error {
  28 + var (
  29 + conn = l.svcCtx.DefaultDBConn()
  30 + companyList []*domain.Company
  31 + categoryList = []*domain.ArticleCategory{
  32 + {
  33 + Name: "机会风险",
  34 + SortBy: 1,
  35 + Enable: 1,
  36 + Other: "",
  37 + },
  38 + {
  39 + Name: "紧急重要",
  40 + SortBy: 2,
  41 + Enable: 2,
  42 + Other: "",
  43 + },
  44 + }
  45 + dm *domain.ArticleCategory
  46 + err error
  47 + )
  48 +
  49 + _, companyList, _ = l.svcCtx.CompanyRepository.Find(l.ctx, conn, domain.NewQueryOptions())
  50 + for _, company := range companyList {
  51 + for _, category := range categoryList {
  52 + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, company.Id, category.Name); err == nil && dm != nil {
  53 + continue
  54 + }
  55 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  56 + articleCategory := &domain.ArticleCategory{
  57 + Name: category.Name,
  58 + SortBy: category.SortBy,
  59 + Enable: category.Enable,
  60 + Other: category.Other,
  61 + CompanyId: company.Id,
  62 + }
  63 + articleCategory, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, articleCategory)
  64 + if err != nil {
  65 + return err
  66 + }
  67 + _, tagList, _ := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, company.Id, domain.NewQueryOptions().WithKV("category", articleCategory.Name))
  68 + for _, tag := range tagList {
  69 + if tag.CategoryId != 0 {
  70 + continue
  71 + }
  72 + tag.CategoryId = articleCategory.Id
  73 + if _, err = l.svcCtx.ArticleTagRepository.UpdateWithVersion(l.ctx, conn, tag); err != nil {
  74 + break
  75 + }
  76 + }
  77 + logx.Info(fmt.Sprintf("初始化 公司:%v(%d) 标签分类:%v(%d) 标签数:%v", company.Name, company.Id, articleCategory.Name, articleCategory.Id, len(tagList)))
  78 + return err
  79 + }, true); err != nil {
  80 + return xerr.NewErrMsg("保存失败")
  81 + }
  82 + }
  83 + }
  84 + return nil
  85 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type ArticleCategoryOptionsLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewArticleCategoryOptionsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryOptionsLogic {
  21 + return &ArticleCategoryOptionsLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *ArticleCategoryOptionsLogic) ArticleCategoryOptions(req *types.CategoryOptionsRequest) (resp *types.CategoryOptionsResponse, err error) {
  29 + var (
  30 + conn = l.svcCtx.DefaultDBConn()
  31 + dms []*domain.ArticleCategory
  32 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  33 + )
  34 +
  35 + queryOptions := domain.NewQueryOptions().WithKV("enable", 1)
  36 +
  37 + _, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
  38 + list := make([]types.CategoryOptions, 0)
  39 + for _, item := range dms {
  40 + list = append(list, types.CategoryOptions{
  41 + Label: item.Name,
  42 + Value: item.Id,
  43 + })
  44 + }
  45 + resp = &types.CategoryOptionsResponse{
  46 + Options: list,
  47 + }
  48 + return
  49 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  13 +
  14 + "github.com/zeromicro/go-zero/core/logx"
  15 +)
  16 +
  17 +type ArticleCategorySaveLogic struct {
  18 + logx.Logger
  19 + ctx context.Context
  20 + svcCtx *svc.ServiceContext
  21 +}
  22 +
  23 +func NewArticleCategorySaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySaveLogic {
  24 + return &ArticleCategorySaveLogic{
  25 + Logger: logx.WithContext(ctx),
  26 + ctx: ctx,
  27 + svcCtx: svcCtx,
  28 + }
  29 +}
  30 +
  31 +func (l *ArticleCategorySaveLogic) ArticleCategorySave(req *types.ArticleCategorySaveRequest) (resp *types.ArticleCategorySaveResponse, err error) {
  32 + var (
  33 + conn = l.svcCtx.DefaultDBConn()
  34 + dm *domain.ArticleCategory
  35 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  36 + )
  37 + // 唯一判断
  38 + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dm != nil {
  39 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dm.Name))
  40 + }
  41 +
  42 + dm = NewDomainArticleCategory(req.ArticleCategory)
  43 + dm.CompanyId = userToken.CompanyId
  44 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  45 + dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm)
  46 + return err
  47 + }, true); err != nil {
  48 + return nil, xerr.NewErrMsg("保存失败")
  49 + }
  50 + resp = &types.ArticleCategorySaveResponse{}
  51 + return
  52 +}
  53 +func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory {
  54 + return &domain.ArticleCategory{
  55 + Name: item.Name,
  56 + Enable: item.Enable,
  57 + SortBy: item.SortBy,
  58 + Other: item.Other,
  59 + }
  60 +}
  61 +
  62 +func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem {
  63 + return types.ArticleCategoryItem{
  64 + Id: item.Id,
  65 + Name: item.Name,
  66 + Enable: item.Enable,
  67 + SortBy: item.SortBy,
  68 + Other: item.Other,
  69 + }
  70 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  7 +
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  10 +
  11 + "github.com/zeromicro/go-zero/core/logx"
  12 +)
  13 +
  14 +type ArticleCategorySearchLogic struct {
  15 + logx.Logger
  16 + ctx context.Context
  17 + svcCtx *svc.ServiceContext
  18 +}
  19 +
  20 +func NewArticleCategorySearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategorySearchLogic {
  21 + return &ArticleCategorySearchLogic{
  22 + Logger: logx.WithContext(ctx),
  23 + ctx: ctx,
  24 + svcCtx: svcCtx,
  25 + }
  26 +}
  27 +
  28 +func (l *ArticleCategorySearchLogic) ArticleCategorySearch(req *types.ArticleCategorySearchRequest) (resp *types.ArticleCategorySearchResponse, err error) {
  29 + var (
  30 + conn = l.svcCtx.DefaultDBConn()
  31 + dms []*domain.ArticleCategory
  32 + total int64
  33 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  34 + )
  35 +
  36 + queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
  37 +
  38 + total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, userToken.CompanyId, queryOptions)
  39 + list := make([]types.ArticleCategoryItem, 0)
  40 + for _, item := range dms {
  41 + list = append(list, NewTypesArticleCategory(item))
  42 + }
  43 + resp = &types.ArticleCategorySearchResponse{
  44 + List: list,
  45 + Total: total,
  46 + }
  47 + return
  48 +}
  1 +package tags
  2 +
  3 +import (
  4 + "context"
  5 + "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  7 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
  10 +
  11 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
  12 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
  13 +
  14 + "github.com/zeromicro/go-zero/core/logx"
  15 +)
  16 +
  17 +type ArticleCategoryUpdateLogic struct {
  18 + logx.Logger
  19 + ctx context.Context
  20 + svcCtx *svc.ServiceContext
  21 +}
  22 +
  23 +func NewArticleCategoryUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ArticleCategoryUpdateLogic {
  24 + return &ArticleCategoryUpdateLogic{
  25 + Logger: logx.WithContext(ctx),
  26 + ctx: ctx,
  27 + svcCtx: svcCtx,
  28 + }
  29 +}
  30 +
  31 +func (l *ArticleCategoryUpdateLogic) ArticleCategoryUpdate(req *types.ArticleCategoryUpdateRequest) (resp *types.ArticleCategoryUpdateResponse, err error) {
  32 + var (
  33 + conn = l.svcCtx.DefaultDBConn()
  34 + dm *domain.ArticleCategory
  35 + userToken = contextdata.GetUserTokenFromCtx(l.ctx)
  36 + )
  37 + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  38 + return nil, xerr.NewErrMsgErr("不存在", err)
  39 + }
  40 + // 不可编辑判断
  41 + if dm.Name != req.ArticleCategory.Name {
  42 + if dm, err = l.svcCtx.ArticleCategoryRepository.FindOneByName(l.ctx, conn, userToken.CompanyId, req.ArticleCategory.Name); err == nil && dm != nil {
  43 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在分类`%s`", dm.Name))
  44 + }
  45 + }
  46 + // 赋值
  47 + dm.Name = req.ArticleCategory.Name
  48 + dm.SortBy = req.ArticleCategory.SortBy
  49 + dm.Enable = req.ArticleCategory.Enable
  50 + dm.Other = req.ArticleCategory.Other
  51 + // 更新
  52 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  53 + dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm)
  54 + return err
  55 + }, true); err != nil {
  56 + return nil, xerr.NewErrMsg("更新失败")
  57 + }
  58 + resp = &types.ArticleCategoryUpdateResponse{}
  59 + return
  60 +}
@@ -30,38 +30,46 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT @@ -30,38 +30,46 @@ func NewCreateTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateT
30 30
31 // 创建标签 31 // 创建标签
32 func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) { 32 func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.TagCreateResponse, err error) {
33 - var conn = l.svcCtx.DefaultDBConn() 33 + var (
  34 + conn = l.svcCtx.DefaultDBConn()
  35 + articleCategory *domain.ArticleCategory
  36 + )
  37 + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil {
  38 + return nil, xerr.NewErrMsgErr("添加标签失败", err)
  39 + }
34 //检查重复 40 //检查重复
35 cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{ 41 cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, map[string]interface{}{
36 - "name": req.Name,  
37 - "category": req.Category,  
38 - "countOnly": true, 42 + "name": req.Name,
  43 + "categoryId": req.CategoryId,
  44 + "countOnly": true,
39 }) 45 })
40 if err != nil { 46 if err != nil {
41 return nil, xerr.NewErrMsgErr("添加标签失败", err) 47 return nil, xerr.NewErrMsgErr("添加标签失败", err)
42 } 48 }
43 if cnt > 0 { 49 if cnt > 0 {
44 - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) 50 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name))
45 } 51 }
46 52
47 newTag := &domain.ArticleTag{ 53 newTag := &domain.ArticleTag{
48 - Id: 0,  
49 - CompanyId: req.CompanyId,  
50 - CreatedAt: 0,  
51 - UpdatedAt: 0,  
52 - DeletedAt: 0,  
53 - Version: 0,  
54 - Image: domain.Image{},  
55 - Name: req.Name,  
56 - Category: req.Category,  
57 - Remark: req.Remark,  
58 - Other: req.Other,  
59 - SortBy: int64(req.SortBy),  
60 - }  
61 - err = newTag.SetCategory(req.Category)  
62 - if err != nil {  
63 - return nil, xerr.NewErrMsgErr("添加标签失败", err) 54 + Id: 0,
  55 + CompanyId: req.CompanyId,
  56 + CreatedAt: 0,
  57 + UpdatedAt: 0,
  58 + DeletedAt: 0,
  59 + Version: 0,
  60 + Image: domain.Image{},
  61 + Name: req.Name,
  62 + Category: articleCategory.Name,
  63 + CategoryId: articleCategory.Id,
  64 + Remark: req.Remark,
  65 + Other: req.Other,
  66 + SortBy: int64(req.SortBy),
  67 + DataFrom: 1,
64 } 68 }
  69 + //err = newTag.SetCategory(req.Category)
  70 + //if err != nil {
  71 + // return nil, xerr.NewErrMsgErr("添加标签失败", err)
  72 + //}
65 if len(req.Image) > 0 { 73 if len(req.Image) > 0 {
66 //获取图片的尺寸大小 74 //获取图片的尺寸大小
67 fInfo, _ := oss.GetImageInfo(req.Image) 75 fInfo, _ := oss.GetImageInfo(req.Image)
@@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag @@ -33,6 +33,9 @@ func (l *DeleteTagLogic) DeleteTag(req *types.TagDeleteRequest) (resp *types.Tag
33 if oldTag.CompanyId != req.CompanyId { 33 if oldTag.CompanyId != req.CompanyId {
34 return nil, xerr.NewErrMsg("删除标签失败") 34 return nil, xerr.NewErrMsg("删除标签失败")
35 } 35 }
  36 + if oldTag.DataFrom == 0 {
  37 + return nil, xerr.NewErrMsg("系统标签不可删除")
  38 + }
36 _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag) 39 _, err = l.svcCtx.ArticleTagRepository.Delete(l.ctx, conn, oldTag)
37 if err != nil { 40 if err != nil {
38 return nil, xerr.NewErrMsg("删除标签失败") 41 return nil, xerr.NewErrMsg("删除标签失败")
@@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo @@ -30,21 +30,26 @@ func NewEditTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EditTagLo
30 30
31 // 编辑标签 31 // 编辑标签
32 func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) { 32 func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditResponse, err error) {
33 - var conn = l.svcCtx.DefaultDBConn() 33 + var (
  34 + conn = l.svcCtx.DefaultDBConn()
  35 + articleCategory *domain.ArticleCategory
  36 + )
34 //检查重复 37 //检查重复
35 queryOptions := domain.NewQueryOptions(). 38 queryOptions := domain.NewQueryOptions().
36 WithFindOnly(). 39 WithFindOnly().
37 MustWithKV("name", req.Name). 40 MustWithKV("name", req.Name).
38 - MustWithKV("category", req.Category). 41 + MustWithKV("categoryId", req.CategoryId).
39 WithOffsetLimit(1, 1) 42 WithOffsetLimit(1, 1)
40 - 43 + if articleCategory, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.CategoryId); err != nil {
  44 + return nil, xerr.NewErrMsgErr("标签分类不存在失败", err)
  45 + }
41 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions) 46 _, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOptions)
42 if err != nil { 47 if err != nil {
43 return nil, xerr.NewErrMsgErr("修改标签失败", err) 48 return nil, xerr.NewErrMsgErr("修改标签失败", err)
44 } 49 }
45 if len(tagList) > 0 { 50 if len(tagList) > 0 {
46 if tagList[0].Id != req.Id { 51 if tagList[0].Id != req.Id {
47 - return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name)) 52 + return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", articleCategory.Name, req.Name))
48 } 53 }
49 } 54 }
50 oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id) 55 oldTag, err := l.svcCtx.ArticleTagRepository.FindOne(l.ctx, conn, req.Id)
@@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe @@ -66,15 +71,16 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
66 Height: h, 71 Height: h,
67 } 72 }
68 } 73 }
69 - oldTag.Category = req.Category  
70 oldTag.Name = req.Name 74 oldTag.Name = req.Name
71 oldTag.Remark = req.Remark 75 oldTag.Remark = req.Remark
72 oldTag.Other = req.Other 76 oldTag.Other = req.Other
73 oldTag.SortBy = int64(req.SortBy) 77 oldTag.SortBy = int64(req.SortBy)
74 - err = oldTag.SetCategory(req.Category)  
75 - if err != nil {  
76 - return nil, xerr.NewErrMsgErr("添加标签失败", err)  
77 - } 78 + oldTag.CategoryId = articleCategory.Id
  79 + oldTag.Category = articleCategory.Name
  80 + //err = oldTag.SetCategory(req.Category)
  81 + //if err != nil {
  82 + // return nil, xerr.NewErrMsgErr("添加标签失败", err)
  83 + //}
78 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag) 84 oldTag, err = l.svcCtx.ArticleTagRepository.Update(l.ctx, conn, oldTag)
79 if err != nil { 85 if err != nil {
80 return nil, xerr.NewErrMsgErr("添加标签失败", err) 86 return nil, xerr.NewErrMsgErr("添加标签失败", err)
@@ -35,13 +35,14 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon @@ -35,13 +35,14 @@ func (l *GetTagLogic) GetTag(req *types.TagGetRequest) (resp *types.TagGetRespon
35 return nil, xerr.NewErrMsg("获取标签失败") 35 return nil, xerr.NewErrMsg("获取标签失败")
36 } 36 }
37 resp = &types.TagGetResponse{ 37 resp = &types.TagGetResponse{
38 - Id: oldTag.Id,  
39 - Image: oldTag.Image.Url,  
40 - Name: oldTag.Name,  
41 - Category: oldTag.Category,  
42 - Remark: oldTag.Remark,  
43 - Other: oldTag.Other,  
44 - SortBy: int(oldTag.SortBy), 38 + Id: oldTag.Id,
  39 + Image: oldTag.Image.Url,
  40 + Name: oldTag.Name,
  41 + Category: oldTag.Category,
  42 + CategoryId: oldTag.CategoryId,
  43 + Remark: oldTag.Remark,
  44 + Other: oldTag.Other,
  45 + SortBy: int(oldTag.SortBy),
45 } 46 }
46 return 47 return
47 } 48 }
@@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT @@ -24,11 +24,14 @@ func NewSearchTagLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchT
24 } 24 }
25 25
26 func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) { 26 func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagListResponse, err error) {
27 - var conn = l.svcCtx.DefaultDBConn() 27 + var (
  28 + conn = l.svcCtx.DefaultDBConn()
  29 + categoryMap = make(map[int64]*domain.ArticleCategory)
  30 + )
28 queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size) 31 queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
29 32
30 - if len(req.Category) > 0 {  
31 - queryOptions = queryOptions.MustWithKV("category", "%"+req.Category+"%") 33 + if req.CategoryId > 0 {
  34 + queryOptions = queryOptions.MustWithKV("categoryId", req.CategoryId)
32 } 35 }
33 if len(req.TagName) > 0 { 36 if len(req.TagName) > 0 {
34 queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%") 37 queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%")
@@ -47,13 +50,18 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi @@ -47,13 +50,18 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
47 } 50 }
48 for i := range tagList { 51 for i := range tagList {
49 resp.List[i] = types.TagItem{ 52 resp.List[i] = types.TagItem{
50 - Id: tagList[i].Id,  
51 - Image: tagList[i].Image.Url,  
52 - Name: tagList[i].Name,  
53 - Category: tagList[i].Category,  
54 - Remark: tagList[i].Remark,  
55 - CreatedAt: tagList[i].CreatedAt,  
56 - SortBy: int(tagList[i].SortBy), 53 + Id: tagList[i].Id,
  54 + Image: tagList[i].Image.Url,
  55 + Name: tagList[i].Name,
  56 + Category: tagList[i].Category,
  57 + CategoryId: tagList[i].CategoryId,
  58 + Remark: tagList[i].Remark,
  59 + CreatedAt: tagList[i].CreatedAt,
  60 + SortBy: int(tagList[i].SortBy),
  61 + Removeable: tagList[i].DataFrom != 0,
  62 + }
  63 + if category, _ := domain.LazyLoad(categoryMap, l.ctx, conn, tagList[i].CategoryId, l.svcCtx.ArticleCategoryRepository.FindOne); category != nil {
  64 + resp.List[i].Category = category.Name
57 } 65 }
58 } 66 }
59 return resp, nil 67 return resp, nil
@@ -3,6 +3,7 @@ package user @@ -3,6 +3,7 @@ package user
3 import ( 3 import (
4 "context" 4 "context"
5 "fmt" 5 "fmt"
  6 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
6 "strconv" 7 "strconv"
7 8
8 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" 9 "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
@@ -109,70 +110,108 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error { @@ -109,70 +110,108 @@ func (l *SystemUserInfoLogic) initSystemData(companyId int64) error {
109 // 初始设置文章标签 110 // 初始设置文章标签
110 queryOption := domain.NewQueryOptions().WithCountOnly() 111 queryOption := domain.NewQueryOptions().WithCountOnly()
111 conn := l.svcCtx.DefaultDBConn() 112 conn := l.svcCtx.DefaultDBConn()
112 - cnt, _, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption)  
113 - if err != nil {  
114 - return xerr.NewErrMsgErr("初始话公司数据失败", err) 113 + categoryList := []*domain.ArticleCategory{
  114 + {
  115 + Name: "机会风险",
  116 + SortBy: 1,
  117 + Enable: 1,
  118 + Other: "",
  119 + CompanyId: companyId,
  120 + },
  121 + {
  122 + Name: "紧急重要",
  123 + SortBy: 2,
  124 + Enable: 1,
  125 + Other: "",
  126 + CompanyId: companyId,
  127 + },
  128 + }
  129 +
  130 + articleTags := []*domain.ArticleTag{
  131 + {
  132 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0},
  133 + Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1,
  134 + },
  135 + {
  136 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_04.png", Width: 0, Height: 0},
  137 + Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2,
  138 + },
  139 + {
  140 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_03.png", Width: 0, Height: 0},
  141 + Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3,
  142 + },
  143 + {
  144 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_02.png", Width: 0, Height: 0},
  145 + Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4,
  146 + },
  147 + {
  148 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_03.png", Width: 0, Height: 0},
  149 + Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5,
  150 + },
  151 + {
  152 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_02.png", Width: 0, Height: 0},
  153 + Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6,
  154 + },
  155 + {
  156 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_01.png", Width: 0, Height: 0},
  157 + Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7,
  158 + },
  159 + {
  160 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_04.png", Width: 0, Height: 0},
  161 + Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8,
  162 + },
  163 + {
  164 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_05.png", Width: 0, Height: 0},
  165 + Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9,
  166 + },
  167 + {
  168 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_06.png", Width: 0, Height: 0},
  169 + Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10,
  170 + },
  171 + {
  172 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_07.png", Width: 0, Height: 0},
  173 + Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11,
  174 + },
  175 + {
  176 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_08.png", Width: 0, Height: 0},
  177 + Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12,
  178 + },
  179 + {
  180 + Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_09.png", Width: 0, Height: 0},
  181 + Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13,
  182 + },
115 } 183 }
  184 +
  185 + cnt, _, err := l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, companyId, queryOption)
116 if cnt == 0 { 186 if cnt == 0 {
117 - articleTags := []*domain.ArticleTag{  
118 - {  
119 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_01.png", Width: 0, Height: 0},  
120 - Name: "紧急重要", Category: "紧急重要", Remark: "优先解决", SortBy: 1,  
121 - },  
122 - {  
123 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_04.png", Width: 0, Height: 0},  
124 - Name: "不紧急不重要", Category: "紧急重要", Remark: "给别人做", SortBy: 2,  
125 - },  
126 - {  
127 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_03.png", Width: 0, Height: 0},  
128 - Name: "紧急不重要", Category: "紧急重要", Remark: "有空再做", SortBy: 3,  
129 - },  
130 - {  
131 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_imp_02.png", Width: 0, Height: 0},  
132 - Name: "不紧急重要", Category: "紧急重要", Remark: "制定计划去做", SortBy: 4,  
133 - },  
134 - {  
135 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_03.png", Width: 0, Height: 0},  
136 - Name: "大机会高风险", Category: "机会风险", Remark: "谨慎考虑专项讨论", SortBy: 5,  
137 - },  
138 - {  
139 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_02.png", Width: 0, Height: 0},  
140 - Name: "大机会中风险", Category: "机会风险", Remark: "加大关注值得尝试", SortBy: 6,  
141 - },  
142 - {  
143 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_01.png", Width: 0, Height: 0},  
144 - Name: "大机会低风险", Category: "机会风险", Remark: "全员投入抓紧落实", SortBy: 7,  
145 - },  
146 - {  
147 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_04.png", Width: 0, Height: 0},  
148 - Name: "中机会高风险", Category: "机会风险", Remark: "专人跟踪成立项目", SortBy: 8,  
149 - },  
150 - {  
151 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_05.png", Width: 0, Height: 0},  
152 - Name: "中机会中风险", Category: "机会风险", Remark: "讨论落实", SortBy: 9,  
153 - },  
154 - {  
155 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_06.png", Width: 0, Height: 0},  
156 - Name: "中机会低风险", Category: "机会风险", Remark: "解决问题多手准备", SortBy: 10,  
157 - },  
158 - {  
159 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_07.png", Width: 0, Height: 0},  
160 - Name: "小机会高风险", Category: "机会风险", Remark: "有空看看", SortBy: 11,  
161 - },  
162 - {  
163 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_08.png", Width: 0, Height: 0},  
164 - Name: "小机会中风险", Category: "机会风险", Remark: "持续监控做好控制", SortBy: 12,  
165 - },  
166 - {  
167 - Id: 0, CompanyId: companyId, Image: domain.Image{Url: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/test/20231115/object/index_chance_09.png", Width: 0, Height: 0},  
168 - Name: "小机会低风险", Category: "机会风险", Remark: "全员警戒马上解决", SortBy: 13,  
169 - },  
170 - }  
171 - err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags)  
172 - if err != nil { 187 + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  188 + for _, category := range categoryList {
  189 + category, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, category)
  190 + if err != nil {
  191 + return err
  192 + }
  193 + }
  194 + cnt, _, err = l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, companyId, queryOption)
  195 + if err != nil {
  196 + return xerr.NewErrMsgErr("初始话公司数据失败", err)
  197 + }
  198 + for _, tag := range articleTags {
  199 + for _, category := range categoryList {
  200 + if category.Name == tag.Category {
  201 + tag.CategoryId = category.Id
  202 + }
  203 + }
  204 + }
  205 + if cnt == 0 {
  206 + err = l.svcCtx.ArticleTagRepository.CreateInBatches(l.ctx, conn, articleTags)
  207 + if err != nil {
  208 + return xerr.NewErrMsgErr("初始话公司数据失败", err)
  209 + }
  210 + }
  211 + return nil
  212 + }, true); err != nil {
173 return xerr.NewErrMsgErr("初始话公司数据失败", err) 213 return xerr.NewErrMsgErr("初始话公司数据失败", err)
174 } 214 }
175 } 215 }
176 -  
177 return nil 216 return nil
178 } 217 }
@@ -27,13 +27,14 @@ type ServiceContext struct { @@ -27,13 +27,14 @@ 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 - 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
37 38
38 CompanyRepository domain.CompanyRepository 39 CompanyRepository domain.CompanyRepository
39 DepartmentRepository domain.DepartmentRepository 40 DepartmentRepository domain.DepartmentRepository
@@ -98,6 +99,7 @@ func NewServiceContext(c config.Config) *ServiceContext { @@ -98,6 +99,7 @@ func NewServiceContext(c config.Config) *ServiceContext {
98 UserRepository: repository.NewUserRepository(cache.NewCachedRepository(mlCache)), 99 UserRepository: repository.NewUserRepository(cache.NewCachedRepository(mlCache)),
99 UserReadArticleRepository: repository.NewUserReadArticleRepository(cache.NewCachedRepository(mlCache)), 100 UserReadArticleRepository: repository.NewUserReadArticleRepository(cache.NewCachedRepository(mlCache)),
100 ArticleTagRepository: repository.NewArticleTagRepository(cache.NewCachedRepository(mlCache)), 101 ArticleTagRepository: repository.NewArticleTagRepository(cache.NewCachedRepository(mlCache)),
  102 + ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)),
101 UserRoleRepository: repository.NewUserRoleRepository(cache.NewCachedRepository(mlCache)), 103 UserRoleRepository: repository.NewUserRoleRepository(cache.NewCachedRepository(mlCache)),
102 } 104 }
103 } 105 }
@@ -348,13 +348,13 @@ type SimpleArticle struct { @@ -348,13 +348,13 @@ type SimpleArticle struct {
348 } 348 }
349 349
350 type TagCreateRequest struct { 350 type TagCreateRequest struct {
351 - CompanyId int64 `json:",optional"`  
352 - Image string `json:"image"`  
353 - Name string `json:"name"` // 标签名称  
354 - Category string `json:"category"` // 标签分类  
355 - Remark string `json:"remark,optional"` // 备注  
356 - Other string `json:"other,optional"`  
357 - SortBy int `json:"sortBy,optional"` //排序 351 + CompanyId int64 `json:",optional"`
  352 + Image string `json:"image"`
  353 + Name string `json:"name"` // 标签名称
  354 + Remark string `json:"remark,optional"` // 备注
  355 + Other string `json:"other,optional"`
  356 + SortBy int `json:"sortBy,optional"` //排序
  357 + CategoryId int64 `json:"categoryId"` // 标签Id
358 } 358 }
359 359
360 type TagCreateResponse struct { 360 type TagCreateResponse struct {
@@ -362,14 +362,14 @@ type TagCreateResponse struct { @@ -362,14 +362,14 @@ type TagCreateResponse struct {
362 } 362 }
363 363
364 type TagEditRequest struct { 364 type TagEditRequest struct {
365 - Id int64 `json:"id"`  
366 - CompanyId int64 `json:",optional"`  
367 - Image string `json:"image"`  
368 - Name string `json:"name"` // 标签名称  
369 - Category string `json:"category"` // 标签分类  
370 - Remark string `json:"remark,optional"` // 备注  
371 - Other string `json:"other,optional"`  
372 - SortBy int `json:"sortBy,optional"` // 排序 365 + Id int64 `json:"id"`
  366 + CompanyId int64 `json:",optional"`
  367 + Image string `json:"image"`
  368 + Name string `json:"name"` // 标签名称
  369 + CategoryId int64 `json:"categoryId"` // 标签Id
  370 + Remark string `json:"remark,optional"` // 备注
  371 + Other string `json:"other,optional"`
  372 + SortBy int `json:"sortBy,optional"` // 排序
373 } 373 }
374 374
375 type TagEditResponse struct { 375 type TagEditResponse struct {
@@ -382,22 +382,23 @@ type TagGetRequest struct { @@ -382,22 +382,23 @@ type TagGetRequest struct {
382 } 382 }
383 383
384 type TagGetResponse struct { 384 type TagGetResponse struct {
385 - Id int64 `json:"id"`  
386 - Image string `json:"image"`  
387 - Name string `json:"name"` // 标签名称  
388 - Category string `json:"category"` // 标签分类  
389 - Remark string `json:"remark"` // 备注  
390 - Other string `json:"other"`  
391 - SortBy int `json:"sortBy,optional"` // 排序 385 + Id int64 `json:"id"`
  386 + Image string `json:"image"`
  387 + Name string `json:"name"` // 标签名称
  388 + Category string `json:"category"` // 标签分类
  389 + CategoryId int64 `json:"categoryId"` // 标签分类Id
  390 + Remark string `json:"remark"` // 备注
  391 + Other string `json:"other"`
  392 + SortBy int `json:"sortBy,optional"` // 排序
392 } 393 }
393 394
394 type TagListRequest struct { 395 type TagListRequest struct {
395 - Page int `json:"page"`  
396 - Size int `json:"size"`  
397 - CompanyId int64 `json:",optional"`  
398 - TagName string `json:"tagName,optional"`  
399 - Category string `json:"category,optional"`  
400 - Remark string `json:"remark,optional"` 396 + Page int `json:"page"`
  397 + Size int `json:"size"`
  398 + CompanyId int64 `json:",optional"`
  399 + TagName string `json:"tagName,optional"`
  400 + CategoryId int64 `json:"categoryId,optional"`
  401 + Remark string `json:"remark,optional"`
401 } 402 }
402 403
403 type TagListResponse struct { 404 type TagListResponse struct {
@@ -406,13 +407,15 @@ type TagListResponse struct { @@ -406,13 +407,15 @@ type TagListResponse struct {
406 } 407 }
407 408
408 type TagItem struct { 409 type TagItem struct {
409 - Id int64 `json:"id"`  
410 - Image string `json:"image"`  
411 - Name string `json:"name"` // 标签名称  
412 - Category string `json:"category"` // 标签分类  
413 - Remark string `json:"remark"` // 备注  
414 - CreatedAt int64 `json:"createdAt"`  
415 - SortBy int `json:"sortBy,optional"` // 排序 410 + Id int64 `json:"id"`
  411 + Image string `json:"image"`
  412 + Name string `json:"name"` // 标签名称
  413 + Category string `json:"category"` // 标签分类
  414 + CategoryId int64 `json:"categoryId"` // 标签分类Id
  415 + Remark string `json:"remark"` // 备注
  416 + CreatedAt int64 `json:"createdAt"`
  417 + SortBy int `json:"sortBy,optional"` // 排序
  418 + Removeable bool `json:"removeable,optional"` // 可删除
416 } 419 }
417 420
418 type TagDeleteRequest struct { 421 type TagDeleteRequest struct {
@@ -433,7 +436,8 @@ type TagOptionsResponse struct { @@ -433,7 +436,8 @@ type TagOptionsResponse struct {
433 } 436 }
434 437
435 type TagOptions struct { 438 type TagOptions struct {
436 - Label string `json:"label"` // 分组名称 439 + Value int64 `json:"value"` // 分类ID
  440 + Label string `json:"label"` // 分类名称
437 Options []TagOptionValue `json:"options"` 441 Options []TagOptionValue `json:"options"`
438 } 442 }
439 443
@@ -862,6 +866,13 @@ type Company struct { @@ -862,6 +866,13 @@ type Company struct {
862 JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入) 866 JoinedFlag int `json:"joinedFlag"` // 已加入标识(1:已加入 其他:未加入)
863 } 867 }
864 868
  869 +type CompanyVisibleSwitchRequest struct {
  870 + Visible bool `json:"visible"` // 可见性 true:可被搜索 false:不可被搜索
  871 +}
  872 +
  873 +type CompanyVisibleSwitchResponse struct {
  874 +}
  875 +
865 type CompanyPositionsSearchRequest struct { 876 type CompanyPositionsSearchRequest struct {
866 } 877 }
867 878
@@ -1494,3 +1505,70 @@ type DepartmentListResponse struct { @@ -1494,3 +1505,70 @@ type DepartmentListResponse struct {
1494 List []Department `json:"list"` 1505 List []Department `json:"list"`
1495 Total int64 `json:"total"` 1506 Total int64 `json:"total"`
1496 } 1507 }
  1508 +
  1509 +type ArticleCategoryGetRequest struct {
  1510 + Id int64 `path:"id"`
  1511 +}
  1512 +
  1513 +type ArticleCategoryGetResponse struct {
  1514 + ArticleCategory ArticleCategoryItem `json:"category"`
  1515 +}
  1516 +
  1517 +type ArticleCategorySaveRequest struct {
  1518 + ArticleCategory ArticleCategoryItem `json:"category"`
  1519 +}
  1520 +
  1521 +type ArticleCategorySaveResponse struct {
  1522 +}
  1523 +
  1524 +type ArticleCategoryDeleteRequest struct {
  1525 + Id int64 `path:"id"`
  1526 +}
  1527 +
  1528 +type ArticleCategoryDeleteResponse struct {
  1529 +}
  1530 +
  1531 +type ArticleCategoryUpdateRequest struct {
  1532 + Id int64 `path:"id"`
  1533 + ArticleCategory ArticleCategoryItem `json:"category"`
  1534 +}
  1535 +
  1536 +type ArticleCategoryUpdateResponse struct {
  1537 +}
  1538 +
  1539 +type ArticleCategorySearchRequest struct {
  1540 + Page int `json:"page"`
  1541 + Size int `json:"size"`
  1542 +}
  1543 +
  1544 +type ArticleCategorySearchResponse struct {
  1545 + List []ArticleCategoryItem `json:"list"`
  1546 + Total int64 `json:"total"`
  1547 +}
  1548 +
  1549 +type ArticleCategoryItem struct {
  1550 + Id int64 `json:"id,optional"` // 唯一标识
  1551 + CompanyId int64 `json:"companyId,optional,omitempty"`
  1552 + Name string `json:"name"`
  1553 + SortBy int `json:"sortBy,optional,omitempty"` // 排序
  1554 + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
  1555 + Other string `json:"other,optional,omitempty"` // 其他备注说明
  1556 +}
  1557 +
  1558 +type CategoryOptionsRequest struct {
  1559 + CompanyId int64 `path:",optional"` // 公司ID
  1560 +}
  1561 +
  1562 +type CategoryOptionsResponse struct {
  1563 + Options []CategoryOptions `json:"options"`
  1564 +}
  1565 +
  1566 +type CategoryOptions struct {
  1567 + Value int64 `json:"value"` // 分类ID
  1568 + Label string `json:"label"` // 分组名称
  1569 +}
  1570 +
  1571 +type CategoryOptionValue struct {
  1572 + Label string `json:"label"` // 名称
  1573 + Value int64 `json:"value"` // 分类ID
  1574 +}
  1 +
  2 +syntax = "v1"
  3 +
  4 +info(
  5 + title: "xx实例"
  6 + desc: "xx实例"
  7 + author: "author"
  8 + email: "email"
  9 + version: "v1"
  10 +)
  11 +
  12 +@server(
  13 + prefix: article_category/v1
  14 + group: article_category
  15 + jwt: JwtAuth
  16 +)
  17 +service Core {
  18 + @doc "详情"
  19 + @handler article_categoryGet
  20 + get /article_category/:id (ArticleCategoryGetRequest) returns (ArticleCategoryGetResponse)
  21 + @doc "保存"
  22 + @handler article_categorySave
  23 + post /article_category (ArticleCategorySaveRequest) returns (ArticleCategorySaveResponse)
  24 + @doc "删除"
  25 + @handler article_categoryDelete
  26 + delete /article_category/:id (ArticleCategoryDeleteRequest) returns (ArticleCategoryDeleteResponse)
  27 + @doc "更新"
  28 + @handler article_categoryUpdate
  29 + put /article_category/:id (ArticleCategoryUpdateRequest) returns (ArticleCategoryUpdateResponse)
  30 + @doc "搜索"
  31 + @handler article_categorySearch
  32 + post /article_category/search (ArticleCategorySearchRequest) returns (ArticleCategorySearchResponse)
  33 +}
  34 +
  35 +type (
  36 + ArticleCategoryGetRequest {
  37 + Id int64 `path:"id"`
  38 + }
  39 + ArticleCategoryGetResponse struct{
  40 + ArticleCategory ArticleCategoryItem `json:"article_category"`
  41 + }
  42 +
  43 + ArticleCategorySaveRequest struct{
  44 + ArticleCategory ArticleCategoryItem `json:"article_category"`
  45 + }
  46 + ArticleCategorySaveResponse struct{}
  47 +
  48 + ArticleCategoryDeleteRequest struct{
  49 + Id int64 `path:"id"`
  50 + }
  51 + ArticleCategoryDeleteResponse struct{}
  52 +
  53 + ArticleCategoryUpdateRequest struct{
  54 + Id int64 `path:"id"`
  55 + ArticleCategory ArticleCategoryItem `json:"article_category"`
  56 + }
  57 + ArticleCategoryUpdateResponse struct{}
  58 +
  59 + ArticleCategorySearchRequest struct{
  60 + Page int `json:"page"`
  61 + Size int `json:"size"`
  62 + }
  63 + ArticleCategorySearchResponse{
  64 + List []ArticleCategoryItem `json:"list"`
  65 + Total int64 `json:"total"`
  66 + }
  67 + ArticleCategoryItem struct{
  68 +
  69 + }
  70 +)
  71 +
  72 +// logic CRUD
  73 +// Save
  74 + //var (
  75 + // conn = l.svcCtx.DefaultDBConn()
  76 + // dm *domain.ArticleCategory
  77 + //)
  78 + //// 唯一判断
  79 +
  80 + //dm = NewDomainArticleCategory(req.ArticleCategory)
  81 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  82 + // dm, err = l.svcCtx.ArticleCategoryRepository.Insert(l.ctx, conn, dm)
  83 + // return err
  84 + //}, true); err != nil {
  85 + // return nil, xerr.NewErrMsg("保存失败")
  86 + //}
  87 + ////resp = &types.ArticleCategorySaveResponse{}
  88 + //return
  89 +
  90 +//func NewDomainArticleCategory(item types.ArticleCategoryItem) *domain.ArticleCategory {
  91 +// return &domain.ArticleCategory{
  92 +
  93 +// }
  94 +//}
  95 +//
  96 +//func NewTypesArticleCategory(item *domain.ArticleCategory) types.ArticleCategoryItem {
  97 +// return types.ArticleCategoryItem{
  98 +// Id: item.Id,
  99 +// }
  100 +//}
  101 +
  102 +// Get
  103 + //var (
  104 + // conn = l.svcCtx.DefaultDBConn()
  105 + // dm *domain.ArticleCategory
  106 + //)
  107 + //// 货号唯一
  108 + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  109 + // return nil, xerr.NewErrMsgErr("不存在", err)
  110 + //}
  111 + //resp = &types.ArticleCategoryGetResponse{
  112 + // ArticleCategory: NewTypesArticleCategory(dm),
  113 + //}
  114 + //return
  115 +
  116 +// Delete
  117 + //var (
  118 + // conn = l.svcCtx.DefaultDBConn()
  119 + // dm *domain.ArticleCategory
  120 + //)
  121 + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  122 + // return nil, xerr.NewErrMsgErr("不存在", err)
  123 + //}
  124 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  125 + // if dm, err = l.svcCtx.ArticleCategoryRepository.Delete(l.ctx, conn, dm); err != nil {
  126 + // return err
  127 + // }
  128 + // return nil
  129 + //}, true); err != nil {
  130 + // return nil, xerr.NewErrMsgErr("移除失败", err)
  131 + //}
  132 + //return
  133 +
  134 +// Search
  135 + //var (
  136 + // conn = l.svcCtx.DefaultDBConn()
  137 + // dms []*domain.ArticleCategory
  138 + // total int64
  139 + //)
  140 + //
  141 + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
  142 + // WithKV("", "")
  143 +
  144 + //total, dms, err = l.svcCtx.ArticleCategoryRepository.Find(l.ctx, conn, queryOptions)
  145 + //list := make([]types.ArticleCategoryItem, 0)
  146 + //for i := range dms {
  147 + // list = append(list, NewTypesArticleCategory(dms[i]))
  148 + //}
  149 + //resp = &types.ArticleCategorySearchResponse{
  150 + // List: list,
  151 + // Total: total,
  152 + //}
  153 + //return
  154 +
  155 +// Update
  156 + //var (
  157 + // conn = l.svcCtx.DefaultDBConn()
  158 + // dm *domain.ArticleCategory
  159 + //)
  160 + //if dm, err = l.svcCtx.ArticleCategoryRepository.FindOne(l.ctx, conn, req.Id); err != nil {
  161 + // return nil, xerr.NewErrMsgErr("不存在", err)
  162 + //}
  163 + //// 不可编辑判断
  164 +
  165 + //// 赋值
  166 +
  167 + //// 更新
  168 + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error {
  169 + // dm, err = l.svcCtx.ArticleCategoryRepository.UpdateWithVersion(l.ctx, conn, dm)
  170 + // return err
  171 + //}, true); err != nil {
  172 + // return nil, xerr.NewErrMsg("更新失败")
  173 + //}
  174 + //resp = &types.ArticleCategoryUpdateResponse{}
  175 + //return
  1 +
  2 +syntax = "proto3";
  3 +
  4 +option go_package ="./pb";
  5 +
  6 +package pb;
  7 +
  8 +message ArticleCategoryGetReq {
  9 + int64 Id = 1;
  10 +}
  11 +message ArticleCategoryGetResp{
  12 + ArticleCategoryItem User = 1;
  13 +}
  14 +
  15 +message ArticleCategorySaveReq {
  16 +
  17 +}
  18 +message ArticleCategorySaveResp{
  19 +
  20 +}
  21 +
  22 +message ArticleCategoryDeleteReq {
  23 + int64 Id = 1;
  24 +}
  25 +message ArticleCategoryDeleteResp{
  26 +
  27 +}
  28 +
  29 +message ArticleCategoryUpdateReq {
  30 + int64 Id = 1;
  31 +}
  32 +message ArticleCategoryUpdateResp{
  33 +
  34 +}
  35 +
  36 +message ArticleCategorySearchReq {
  37 + int64 PageNumber = 1;
  38 + int64 PageSize = 2;
  39 +}
  40 +message ArticleCategorySearchResp{
  41 + repeated ArticleCategoryItem List =1;
  42 + int64 Total =2;
  43 +}
  44 +message ArticleCategoryItem {
  45 +
  46 +}
  47 +
  48 +service ArticleCategoryService {
  49 + rpc ArticleCategoryGet(ArticleCategoryGetReq) returns(ArticleCategoryGetResp);
  50 + rpc ArticleCategorySave(ArticleCategorySaveReq) returns(ArticleCategorySaveResp);
  51 + rpc ArticleCategoryDelete(ArticleCategoryDeleteReq) returns(ArticleCategoryDeleteResp);
  52 + rpc ArticleCategoryUpdate(ArticleCategoryUpdateReq) returns(ArticleCategoryUpdateResp);
  53 + rpc ArticleCategorySearch(ArticleCategorySearchReq) returns(ArticleCategorySearchResp);
  54 +}
@@ -7,23 +7,24 @@ import ( @@ -7,23 +7,24 @@ import (
7 7
8 func Migrate(db *gorm.DB) { 8 func Migrate(db *gorm.DB) {
9 modelsList := []interface{}{ 9 modelsList := []interface{}{
10 - &models.Article{},  
11 - &models.ArticleSection{},  
12 - &models.ArticleBackup{},  
13 - &models.ArticleDraft{},  
14 - &models.ArticleComment{},  
15 - &models.ArticleTag{},  
16 - &models.UserLoveFlag{},  
17 - &models.UserReadArticle{},  
18 - &models.User{},  
19 - &models.UserRole{},  
20 - &models.Role{},  
21 - &models.Company{},  
22 - &models.UserFollow{},  
23 - &models.MessageSystem{},  
24 - &models.MessageBusiness{},  
25 - &models.Department{},  
26 - &models.ArticleAndTag{}, 10 + //&models.Article{},
  11 + //&models.ArticleSection{},
  12 + //&models.ArticleBackup{},
  13 + //&models.ArticleDraft{},
  14 + //&models.ArticleComment{},
  15 + //&models.ArticleTag{},
  16 + //&models.UserLoveFlag{},
  17 + //&models.UserReadArticle{},
  18 + //&models.User{},
  19 + //&models.UserRole{},
  20 + //&models.Role{},
  21 + //&models.Company{},
  22 + //&models.UserFollow{},
  23 + //&models.MessageSystem{},
  24 + //&models.MessageBusiness{},
  25 + //&models.Department{},
  26 + //&models.ArticleAndTag{},
  27 + &models.ArticleCategory{},
27 } 28 }
28 29
29 db.AutoMigrate(modelsList...) 30 db.AutoMigrate(modelsList...)
  1 +package models
  2 +
  3 +import (
  4 + "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  6 + "gorm.io/gorm"
  7 + "gorm.io/plugin/soft_delete"
  8 + "time"
  9 +)
  10 +
  11 +type ArticleCategory struct {
  12 + Id int64 // 唯一标识
  13 + CompanyId int64
  14 + Name string
  15 + SortBy int
  16 + Enable int
  17 + Other string
  18 + CreatedAt int64
  19 + UpdatedAt int64
  20 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  21 + DeletedAt int64
  22 + Version int
  23 +}
  24 +
  25 +func (m *ArticleCategory) TableName() string {
  26 + return "article_category"
  27 +}
  28 +
  29 +func (m *ArticleCategory) BeforeCreate(tx *gorm.DB) (err error) {
  30 + m.CreatedAt = time.Now().Unix()
  31 + m.UpdatedAt = time.Now().Unix()
  32 + return
  33 +}
  34 +
  35 +func (m *ArticleCategory) BeforeUpdate(tx *gorm.DB) (err error) {
  36 + m.UpdatedAt = time.Now().Unix()
  37 + return
  38 +}
  39 +
  40 +func (m *ArticleCategory) CacheKeyFunc() string {
  41 + if m.Id == 0 {
  42 + return ""
  43 + }
  44 + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id)
  45 +}
  46 +
  47 +func (m *ArticleCategory) CacheKeyFuncByObject(obj interface{}) string {
  48 + if v, ok := obj.(*ArticleCategory); ok {
  49 + return v.CacheKeyFunc()
  50 + }
  51 + return ""
  52 +}
  53 +
  54 +func (m *ArticleCategory) CachePrimaryKeyFunc() string {
  55 + if len("") == 0 {
  56 + return ""
  57 + }
  58 + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key")
  59 +}
@@ -11,19 +11,21 @@ import ( @@ -11,19 +11,21 @@ import (
11 11
12 // 文章的所有标签 12 // 文章的所有标签
13 type ArticleTag struct { 13 type ArticleTag struct {
14 - Id int64 `gorm:"primaryKey"` // 唯一标识  
15 - CompanyId int64  
16 - CreatedAt int64  
17 - UpdatedAt int64  
18 - DeletedAt int64  
19 - IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`  
20 - Version int  
21 - Image domain.Image `gorm:"type:jsonb;serializer:json"` // 图片  
22 - Name string // 标签名称  
23 - Remark string // 备注  
24 - Category string // 标签分类  
25 - SortBy int64 // 顺序  
26 - Other string // 其他 14 + Id int64 `gorm:"primaryKey"` // 唯一标识
  15 + CompanyId int64
  16 + CreatedAt int64
  17 + UpdatedAt int64
  18 + DeletedAt int64
  19 + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
  20 + Version int
  21 + Image domain.Image `gorm:"type:jsonb;serializer:json"` // 图片
  22 + Name string // 标签名称
  23 + Remark string // 备注
  24 + Category string // 标签分类
  25 + SortBy int64 // 顺序
  26 + Other string // 其他
  27 + CategoryId int64 // 标签分类ID
  28 + DataFrom int // 来源 0:系统初始化 1:用户自动添加(可删除)
27 } 29 }
28 30
29 func (m *ArticleTag) TableName() string { 31 func (m *ArticleTag) TableName() string {
@@ -8,11 +8,11 @@ import ( @@ -8,11 +8,11 @@ import (
8 ) 8 )
9 9
10 type Company struct { 10 type Company struct {
11 - Id int64 // 唯一标识  
12 - Name string // 名称  
13 - Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字)  
14 - Logo string // 公司LOGO  
15 - 11 + Id int64 // 唯一标识
  12 + Name string // 名称
  13 + Code string `gorm:"uniqueIndex:idx_company_code"` // 编码(搜索使用,4位字母数字)
  14 + Logo string // 公司LOGO
  15 + Visible int
16 CreatedAt int64 16 CreatedAt int64
17 UpdatedAt int64 17 UpdatedAt int64
18 DeletedAt int64 18 DeletedAt int64
  1 +package repository
  2 +
  3 +import (
  4 + "context"
  5 + "github.com/jinzhu/copier"
  6 + "github.com/pkg/errors"
  7 + "github.com/tiptok/gocomm/pkg/cache"
  8 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models"
  9 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  10 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
  11 + "gorm.io/gorm"
  12 +)
  13 +
  14 +type ArticleCategoryRepository struct {
  15 + *cache.CachedRepository
  16 +}
  17 +
  18 +func (repository *ArticleCategoryRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) {
  19 + var (
  20 + err error
  21 + m = &models.ArticleCategory{}
  22 + tx = conn.DB()
  23 + )
  24 + if m, err = repository.DomainModelToModel(dm); err != nil {
  25 + return nil, err
  26 + }
  27 + if tx = tx.Model(m).Save(m); tx.Error != nil {
  28 + return nil, tx.Error
  29 + }
  30 + dm.Id = m.Id
  31 + return repository.ModelToDomainModel(m)
  32 +
  33 +}
  34 +
  35 +func (repository *ArticleCategoryRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) {
  36 + var (
  37 + err error
  38 + m *models.ArticleCategory
  39 + tx = conn.DB()
  40 + )
  41 + if m, err = repository.DomainModelToModel(dm); err != nil {
  42 + return nil, err
  43 + }
  44 + queryFunc := func() (interface{}, error) {
  45 + tx = tx.Model(m).Updates(m)
  46 + return nil, tx.Error
  47 + }
  48 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  49 + return nil, err
  50 + }
  51 + return repository.ModelToDomainModel(m)
  52 +}
  53 +
  54 +func (repository *ArticleCategoryRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) {
  55 + var (
  56 + err error
  57 + m *models.ArticleCategory
  58 + tx = transaction.DB()
  59 + )
  60 + if m, err = repository.DomainModelToModel(dm); err != nil {
  61 + return nil, err
  62 + }
  63 + oldVersion := dm.Version
  64 + m.Version += 1
  65 + queryFunc := func() (interface{}, error) {
  66 + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m)
  67 + if tx.RowsAffected == 0 {
  68 + return nil, domain.ErrUpdateFail
  69 + }
  70 + return nil, tx.Error
  71 + }
  72 + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  73 + return nil, err
  74 + }
  75 + return repository.ModelToDomainModel(m)
  76 +}
  77 +
  78 +func (repository *ArticleCategoryRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleCategory) (*domain.ArticleCategory, error) {
  79 + var (
  80 + tx = conn.DB()
  81 + m = &models.ArticleCategory{Id: dm.Identify().(int64)}
  82 + )
  83 + queryFunc := func() (interface{}, error) {
  84 + tx = tx.Where("id = ?", m.Id).Delete(m)
  85 + return m, tx.Error
  86 + }
  87 + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
  88 + return dm, err
  89 + }
  90 + return repository.ModelToDomainModel(m)
  91 +}
  92 +
  93 +func (repository *ArticleCategoryRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleCategory, error) {
  94 + var (
  95 + err error
  96 + tx = conn.DB()
  97 + m = new(models.ArticleCategory)
  98 + )
  99 + queryFunc := func() (interface{}, error) {
  100 + tx = tx.Model(m).Where("id = ?", id).First(m)
  101 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  102 + return nil, domain.ErrNotFound
  103 + }
  104 + return m, tx.Error
  105 + }
  106 + cacheModel := new(models.ArticleCategory)
  107 + cacheModel.Id = id
  108 + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil {
  109 + return nil, err
  110 + }
  111 + return repository.ModelToDomainModel(m)
  112 +}
  113 +
  114 +func (repository *ArticleCategoryRepository) FindOneByName(ctx context.Context, conn transaction.Conn, companyId int64, name string) (*domain.ArticleCategory, error) {
  115 + var (
  116 + err error
  117 + tx = conn.DB()
  118 + m = new(models.ArticleCategory)
  119 + )
  120 + queryFunc := func() (interface{}, error) {
  121 + tx = tx.Model(m).Where("company_id = ?", companyId).Where("name = ?", name).First(m)
  122 + if errors.Is(tx.Error, gorm.ErrRecordNotFound) {
  123 + return nil, domain.ErrNotFound
  124 + }
  125 + return m, tx.Error
  126 + }
  127 + if _, err = repository.Query(queryFunc); err != nil {
  128 + return nil, err
  129 + }
  130 + return repository.ModelToDomainModel(m)
  131 +}
  132 +
  133 +func (repository *ArticleCategoryRepository) Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*domain.ArticleCategory, error) {
  134 + var (
  135 + tx = conn.DB()
  136 + ms []*models.ArticleCategory
  137 + dms = make([]*domain.ArticleCategory, 0)
  138 + total int64
  139 + )
  140 + queryFunc := func() (interface{}, error) {
  141 + tx = tx.Model(&ms).Where("company_id = ?", companyId)
  142 + if v, ok := queryOptions["enable"]; ok {
  143 + tx.Where("enable = ?", v)
  144 + }
  145 + tx.Order("sort_by asc").Order("id asc")
  146 + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
  147 + return dms, tx.Error
  148 + }
  149 + return dms, nil
  150 + }
  151 +
  152 + if _, err := repository.Query(queryFunc); err != nil {
  153 + return 0, nil, err
  154 + }
  155 +
  156 + for _, item := range ms {
  157 + if dm, err := repository.ModelToDomainModel(item); err != nil {
  158 + return 0, dms, err
  159 + } else {
  160 + dms = append(dms, dm)
  161 + }
  162 + }
  163 + return total, dms, nil
  164 +}
  165 +
  166 +func (repository *ArticleCategoryRepository) ModelToDomainModel(from *models.ArticleCategory) (*domain.ArticleCategory, error) {
  167 + to := &domain.ArticleCategory{}
  168 + err := copier.Copy(to, from)
  169 + return to, err
  170 +}
  171 +
  172 +func (repository *ArticleCategoryRepository) DomainModelToModel(from *domain.ArticleCategory) (*models.ArticleCategory, error) {
  173 + to := &models.ArticleCategory{}
  174 + err := copier.Copy(to, from)
  175 + return to, err
  176 +}
  177 +
  178 +func NewArticleCategoryRepository(cache *cache.CachedRepository) domain.ArticleCategoryRepository {
  179 + return &ArticleCategoryRepository{CachedRepository: cache}
  180 +}
@@ -152,6 +152,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti @@ -152,6 +152,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti
152 if v, ok := queryOptions["category"]; ok { 152 if v, ok := queryOptions["category"]; ok {
153 tx = tx.Where("category like ?", v) 153 tx = tx.Where("category like ?", v)
154 } 154 }
  155 + if v, ok := queryOptions["categoryId"]; ok {
  156 + tx = tx.Where("category_id = ?", v)
  157 + }
155 if v, ok := queryOptions["ids"]; ok { 158 if v, ok := queryOptions["ids"]; ok {
156 tx = tx.Where("id in (?)", v) 159 tx = tx.Where("id in (?)", v)
157 } 160 }
@@ -144,6 +144,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction. @@ -144,6 +144,9 @@ func (repository *CompanyRepository) Find(ctx context.Context, conn transaction.
144 if v, ok := queryOptions["ids"]; ok { 144 if v, ok := queryOptions["ids"]; ok {
145 tx.Where("id in (?)", v) 145 tx.Where("id in (?)", v)
146 } 146 }
  147 + if v, ok := queryOptions["visible"]; ok {
  148 + tx.Where("visible = ?", v)
  149 + }
147 if v, ok := queryOptions["excludeIds"]; ok { 150 if v, ok := queryOptions["excludeIds"]; ok {
148 tx.Where("id not in (?)", v) 151 tx.Where("id not in (?)", v)
149 } 152 }
  1 +package domain
  2 +
  3 +import (
  4 + "context"
  5 + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
  6 +)
  7 +
  8 +type ArticleCategory struct {
  9 + Id int64 // 唯一标识
  10 + CompanyId int64 `json:"companyId"`
  11 + Name string `json:"name"`
  12 + SortBy int `json:"sortBy"` // 排序
  13 + Enable int `json:"enable,omitempty"` // 启用状态 1:启用 2:禁用
  14 + Other string `json:"other"` // 其他备注说明
  15 + CreatedAt int64 `json:"createdAt,omitempty"`
  16 + UpdatedAt int64 `json:"updatedAt,omitempty"`
  17 + DeletedAt int64 `json:"deletedAt,omitempty"`
  18 + Version int `json:"version,omitempty"`
  19 +}
  20 +
  21 +type ArticleCategoryRepository interface {
  22 + Insert(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error)
  23 + Update(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error)
  24 + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error)
  25 + Delete(ctx context.Context, conn transaction.Conn, dm *ArticleCategory) (*ArticleCategory, error)
  26 + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleCategory, error)
  27 + FindOneByName(ctx context.Context, conn transaction.Conn, companyId int64, name string) (*ArticleCategory, error)
  28 + Find(ctx context.Context, conn transaction.Conn, companyId int64, queryOptions map[string]interface{}) (int64, []*ArticleCategory, error)
  29 +}
  30 +
  31 +func (m *ArticleCategory) Identify() interface{} {
  32 + if m.Id == 0 {
  33 + return nil
  34 + }
  35 + return m.Id
  36 +}
@@ -10,18 +10,20 @@ import ( @@ -10,18 +10,20 @@ import (
10 // 文章全部的标签 10 // 文章全部的标签
11 11
12 type ArticleTag struct { 12 type ArticleTag struct {
13 - Id int64 `json:"id"`  
14 - CompanyId int64 `json:"companyId"`  
15 - CreatedAt int64 `json:"createdAt,omitempty"`  
16 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
17 - DeletedAt int64 `json:"deletedAt,omitempty"`  
18 - Version int `json:"version,omitempty"`  
19 - Image Image `json:"image"` // 图片  
20 - Name string `json:"name"` // 标签名称  
21 - Category string `json:"category"` // 标签分类 [紧急重要]、[机会风险]  
22 - Remark string `json:"remark"` // 备注  
23 - SortBy int64 `json:"sortBy"` // 顺序  
24 - Other string `json:"other"` // 13 + Id int64 `json:"id"`
  14 + CompanyId int64 `json:"companyId"`
  15 + CreatedAt int64 `json:"createdAt,omitempty"`
  16 + UpdatedAt int64 `json:"updatedAt,omitempty"`
  17 + DeletedAt int64 `json:"deletedAt,omitempty"`
  18 + Version int `json:"version,omitempty"`
  19 + Image Image `json:"image"` // 图片
  20 + Name string `json:"name"` // 标签名称
  21 + Category string `json:"category"` // 标签分类 [紧急重要]、[机会风险]
  22 + CategoryId int64 `json:"categoryId"` // 标签分类ID
  23 + DataFrom int `json:"dataFrom"` // 来源 0:系统初始化 1:用户自动添加(可删除)
  24 + Remark string `json:"remark"` // 备注
  25 + SortBy int64 `json:"sortBy"` // 顺序
  26 + Other string `json:"other"` //
25 } 27 }
26 28
27 type ArticleTagRepository interface { 29 type ArticleTagRepository interface {
@@ -6,15 +6,15 @@ import ( @@ -6,15 +6,15 @@ import (
6 ) 6 )
7 7
8 type Company struct { 8 type Company struct {
9 - Id int64 `json:"id,omitempty"` // 唯一标识  
10 - Name string `json:"name,omitempty"` // 名称  
11 - Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)  
12 - Logo string `json:"logo,omitempty"` // 公司LOGO  
13 -  
14 - CreatedAt int64 `json:"createdAt,omitempty"`  
15 - UpdatedAt int64 `json:"updatedAt,omitempty"`  
16 - DeletedAt int64 `json:"deletedAt,omitempty"`  
17 - Version int `json:"version,omitempty"` 9 + Id int64 `json:"id,omitempty"` // 唯一标识
  10 + Name string `json:"name,omitempty"` // 名称
  11 + Code string `json:"code,omitempty"` // 编码(搜索使用,4位字母数字)
  12 + Logo string `json:"logo,omitempty"` // 公司LOGO
  13 + Visible int `json:"visible,omitempty"` // 可见的 1:可见 0:不可见
  14 + CreatedAt int64 `json:"createdAt,omitempty"`
  15 + UpdatedAt int64 `json:"updatedAt,omitempty"`
  16 + DeletedAt int64 `json:"deletedAt,omitempty"`
  17 + Version int `json:"version,omitempty"`
18 } 18 }
19 19
20 type CompanyRepository interface { 20 type CompanyRepository interface {
@@ -26,4 +26,9 @@ CREATE TABLE `company` ( @@ -26,4 +26,9 @@ CREATE TABLE `company` (
26 CREATE TABLE `user_follow` ( 26 CREATE TABLE `user_follow` (
27 `id` int(0) NOT NULL COMMENT '唯一标识', 27 `id` int(0) NOT NULL COMMENT '唯一标识',
28 PRIMARY KEY (`id`) USING BTREE 28 PRIMARY KEY (`id`) USING BTREE
  29 +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
  30 +
  31 +CREATE TABLE `article_category` (
  32 + `id` int(0) NOT NULL COMMENT '唯一标识',
  33 + PRIMARY KEY (`id`) USING BTREE
29 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; 34 ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
  1 +-- 增加字段
  2 +alter table article_tag add column category_id int8;
  3 +alter table article_tag add column data_from int2;
  4 +alter table company add column visible int2;
  5 +
  6 +-- 更新数据
  7 +update article_tag set data_from = 0;
  8 +update company set visible = 0;