正在显示
54 个修改的文件
包含
3244 行增加
和
235 行删除
| @@ -12,3 +12,4 @@ import "core/role.api" | @@ -12,3 +12,4 @@ import "core/role.api" | ||
| 12 | import "core/department.api" | 12 | import "core/department.api" |
| 13 | import "core/article_category.api" | 13 | import "core/article_category.api" |
| 14 | import "core/article_security.api" | 14 | import "core/article_security.api" |
| 15 | +import "core/article_template.api" |
| @@ -789,6 +789,184 @@ | @@ -789,6 +789,184 @@ | ||
| 789 | ] | 789 | ] |
| 790 | } | 790 | } |
| 791 | }, | 791 | }, |
| 792 | + "v1/mini/article_template": { | ||
| 793 | + "post": { | ||
| 794 | + "summary": "模板管理-保存", | ||
| 795 | + "operationId": "miniArticleTemplateSave", | ||
| 796 | + "responses": { | ||
| 797 | + "200": { | ||
| 798 | + "description": "A successful response.", | ||
| 799 | + "schema": { | ||
| 800 | + "$ref": "#/definitions/ArticleTemplateSaveResponse" | ||
| 801 | + } | ||
| 802 | + } | ||
| 803 | + }, | ||
| 804 | + "parameters": [ | ||
| 805 | + { | ||
| 806 | + "name": "body", | ||
| 807 | + "in": "body", | ||
| 808 | + "required": true, | ||
| 809 | + "schema": { | ||
| 810 | + "$ref": "#/definitions/ArticleTemplateSaveRequest" | ||
| 811 | + } | ||
| 812 | + } | ||
| 813 | + ], | ||
| 814 | + "requestBody": {}, | ||
| 815 | + "tags": [ | ||
| 816 | + "template" | ||
| 817 | + ] | ||
| 818 | + } | ||
| 819 | + }, | ||
| 820 | + "v1/mini/article_template/search": { | ||
| 821 | + "post": { | ||
| 822 | + "summary": "模板搜索", | ||
| 823 | + "operationId": "miniArticleTemplateSearch", | ||
| 824 | + "responses": { | ||
| 825 | + "200": { | ||
| 826 | + "description": "A successful response.", | ||
| 827 | + "schema": { | ||
| 828 | + "$ref": "#/definitions/ArticleTemplateSearchResponse" | ||
| 829 | + } | ||
| 830 | + } | ||
| 831 | + }, | ||
| 832 | + "parameters": [ | ||
| 833 | + { | ||
| 834 | + "name": "body", | ||
| 835 | + "in": "body", | ||
| 836 | + "required": true, | ||
| 837 | + "schema": { | ||
| 838 | + "$ref": "#/definitions/ArticleTemplateSearchRequest" | ||
| 839 | + } | ||
| 840 | + } | ||
| 841 | + ], | ||
| 842 | + "requestBody": {}, | ||
| 843 | + "tags": [ | ||
| 844 | + "template" | ||
| 845 | + ] | ||
| 846 | + } | ||
| 847 | + }, | ||
| 848 | + "v1/mini/article_template/search-mine": { | ||
| 849 | + "post": { | ||
| 850 | + "summary": "我的模板搜索", | ||
| 851 | + "operationId": "miniArticleTemplateSearchMine", | ||
| 852 | + "responses": { | ||
| 853 | + "200": { | ||
| 854 | + "description": "A successful response.", | ||
| 855 | + "schema": { | ||
| 856 | + "$ref": "#/definitions/ArticleTemplateSearchResponse" | ||
| 857 | + } | ||
| 858 | + } | ||
| 859 | + }, | ||
| 860 | + "parameters": [ | ||
| 861 | + { | ||
| 862 | + "name": "body", | ||
| 863 | + "in": "body", | ||
| 864 | + "required": true, | ||
| 865 | + "schema": { | ||
| 866 | + "$ref": "#/definitions/ArticleTemplateSearchRequest" | ||
| 867 | + } | ||
| 868 | + } | ||
| 869 | + ], | ||
| 870 | + "requestBody": {}, | ||
| 871 | + "tags": [ | ||
| 872 | + "template" | ||
| 873 | + ] | ||
| 874 | + } | ||
| 875 | + }, | ||
| 876 | + "v1/mini/article_template/{id}": { | ||
| 877 | + "delete": { | ||
| 878 | + "summary": "模板管理-删除", | ||
| 879 | + "operationId": "miniArticleTemplateDelete", | ||
| 880 | + "responses": { | ||
| 881 | + "200": { | ||
| 882 | + "description": "A successful response.", | ||
| 883 | + "schema": { | ||
| 884 | + "$ref": "#/definitions/ArticleTemplateDeleteResponse" | ||
| 885 | + } | ||
| 886 | + } | ||
| 887 | + }, | ||
| 888 | + "parameters": [ | ||
| 889 | + { | ||
| 890 | + "name": "id", | ||
| 891 | + "in": "path", | ||
| 892 | + "required": true, | ||
| 893 | + "type": "string" | ||
| 894 | + }, | ||
| 895 | + { | ||
| 896 | + "name": "body", | ||
| 897 | + "in": "body", | ||
| 898 | + "required": true, | ||
| 899 | + "schema": { | ||
| 900 | + "$ref": "#/definitions/ArticleTemplateDeleteRequest" | ||
| 901 | + } | ||
| 902 | + } | ||
| 903 | + ], | ||
| 904 | + "requestBody": {}, | ||
| 905 | + "tags": [ | ||
| 906 | + "template" | ||
| 907 | + ] | ||
| 908 | + }, | ||
| 909 | + "put": { | ||
| 910 | + "summary": "模板管理-更新", | ||
| 911 | + "operationId": "miniArticleTemplateUpdate", | ||
| 912 | + "responses": { | ||
| 913 | + "200": { | ||
| 914 | + "description": "A successful response.", | ||
| 915 | + "schema": { | ||
| 916 | + "$ref": "#/definitions/ArticleTemplateUpdateResponse" | ||
| 917 | + } | ||
| 918 | + } | ||
| 919 | + }, | ||
| 920 | + "parameters": [ | ||
| 921 | + { | ||
| 922 | + "name": "id", | ||
| 923 | + "in": "path", | ||
| 924 | + "required": true, | ||
| 925 | + "type": "string" | ||
| 926 | + }, | ||
| 927 | + { | ||
| 928 | + "name": "body", | ||
| 929 | + "in": "body", | ||
| 930 | + "required": true, | ||
| 931 | + "schema": { | ||
| 932 | + "$ref": "#/definitions/ArticleTemplateUpdateRequest" | ||
| 933 | + } | ||
| 934 | + } | ||
| 935 | + ], | ||
| 936 | + "requestBody": {}, | ||
| 937 | + "tags": [ | ||
| 938 | + "template" | ||
| 939 | + ] | ||
| 940 | + } | ||
| 941 | + }, | ||
| 942 | + "v1/mini/article_template_class/search": { | ||
| 943 | + "post": { | ||
| 944 | + "summary": "模板分类搜索", | ||
| 945 | + "operationId": "miniArticleTemplateClassSearch", | ||
| 946 | + "responses": { | ||
| 947 | + "200": { | ||
| 948 | + "description": "A successful response.", | ||
| 949 | + "schema": { | ||
| 950 | + "$ref": "#/definitions/ArticleTemplateClassSearchResponse" | ||
| 951 | + } | ||
| 952 | + } | ||
| 953 | + }, | ||
| 954 | + "parameters": [ | ||
| 955 | + { | ||
| 956 | + "name": "body", | ||
| 957 | + "in": "body", | ||
| 958 | + "required": true, | ||
| 959 | + "schema": { | ||
| 960 | + "$ref": "#/definitions/ArticleTemplateClassSearchRequest" | ||
| 961 | + } | ||
| 962 | + } | ||
| 963 | + ], | ||
| 964 | + "requestBody": {}, | ||
| 965 | + "tags": [ | ||
| 966 | + "template" | ||
| 967 | + ] | ||
| 968 | + } | ||
| 969 | + }, | ||
| 792 | "v1/mini/company/search": { | 970 | "v1/mini/company/search": { |
| 793 | "post": { | 971 | "post": { |
| 794 | "summary": "公司搜索(公开的)", | 972 | "summary": "公司搜索(公开的)", |
| @@ -2968,15 +3146,15 @@ | @@ -2968,15 +3146,15 @@ | ||
| 2968 | ] | 3146 | ] |
| 2969 | } | 3147 | } |
| 2970 | }, | 3148 | }, |
| 2971 | - "v1/system/company/positions/search": { | 3149 | + "v1/system/article_template": { |
| 2972 | "post": { | 3150 | "post": { |
| 2973 | - "summary": "公司职位搜索", | ||
| 2974 | - "operationId": "systemCompanyPositionsSearch", | 3151 | + "summary": "模板管理-保存", |
| 3152 | + "operationId": "systemArticleTemplateSave", | ||
| 2975 | "responses": { | 3153 | "responses": { |
| 2976 | "200": { | 3154 | "200": { |
| 2977 | "description": "A successful response.", | 3155 | "description": "A successful response.", |
| 2978 | "schema": { | 3156 | "schema": { |
| 2979 | - "$ref": "#/definitions/CompanyPositionsSearchResponse" | 3157 | + "$ref": "#/definitions/ArticleTemplateSaveResponse" |
| 2980 | } | 3158 | } |
| 2981 | } | 3159 | } |
| 2982 | }, | 3160 | }, |
| @@ -2986,25 +3164,25 @@ | @@ -2986,25 +3164,25 @@ | ||
| 2986 | "in": "body", | 3164 | "in": "body", |
| 2987 | "required": true, | 3165 | "required": true, |
| 2988 | "schema": { | 3166 | "schema": { |
| 2989 | - "$ref": "#/definitions/CompanyPositionsSearchRequest" | 3167 | + "$ref": "#/definitions/ArticleTemplateSaveRequest" |
| 2990 | } | 3168 | } |
| 2991 | } | 3169 | } |
| 2992 | ], | 3170 | ], |
| 2993 | "requestBody": {}, | 3171 | "requestBody": {}, |
| 2994 | "tags": [ | 3172 | "tags": [ |
| 2995 | - "company" | 3173 | + "template" |
| 2996 | ] | 3174 | ] |
| 2997 | } | 3175 | } |
| 2998 | }, | 3176 | }, |
| 2999 | - "v1/system/company/search": { | ||
| 3000 | - "post": { | ||
| 3001 | - "summary": "公司搜索", | ||
| 3002 | - "operationId": "systemCompanySearch", | 3177 | + "v1/system/article_template/batch_delete": { |
| 3178 | + "delete": { | ||
| 3179 | + "summary": "模板管理-批量删除", | ||
| 3180 | + "operationId": "systemArticleTemplateBatchDelete", | ||
| 3003 | "responses": { | 3181 | "responses": { |
| 3004 | "200": { | 3182 | "200": { |
| 3005 | "description": "A successful response.", | 3183 | "description": "A successful response.", |
| 3006 | "schema": { | 3184 | "schema": { |
| 3007 | - "$ref": "#/definitions/CompanySearchResponse" | 3185 | + "$ref": "#/definitions/ArticleTemplateBatchResponse" |
| 3008 | } | 3186 | } |
| 3009 | } | 3187 | } |
| 3010 | }, | 3188 | }, |
| @@ -3014,25 +3192,25 @@ | @@ -3014,25 +3192,25 @@ | ||
| 3014 | "in": "body", | 3192 | "in": "body", |
| 3015 | "required": true, | 3193 | "required": true, |
| 3016 | "schema": { | 3194 | "schema": { |
| 3017 | - "$ref": "#/definitions/CompanySearchRequest" | 3195 | + "$ref": "#/definitions/ArticleTemplateBatchDeleteRequest" |
| 3018 | } | 3196 | } |
| 3019 | } | 3197 | } |
| 3020 | ], | 3198 | ], |
| 3021 | "requestBody": {}, | 3199 | "requestBody": {}, |
| 3022 | "tags": [ | 3200 | "tags": [ |
| 3023 | - "company" | 3201 | + "template" |
| 3024 | ] | 3202 | ] |
| 3025 | } | 3203 | } |
| 3026 | }, | 3204 | }, |
| 3027 | - "v1/system/company/visible_switch": { | 3205 | + "v1/system/article_template/search": { |
| 3028 | "post": { | 3206 | "post": { |
| 3029 | - "summary": "公司可见开关", | ||
| 3030 | - "operationId": "systemCompanyVisibleSwitch", | 3207 | + "summary": "模板管理-搜索", |
| 3208 | + "operationId": "systemArticleTemplateSearch", | ||
| 3031 | "responses": { | 3209 | "responses": { |
| 3032 | "200": { | 3210 | "200": { |
| 3033 | "description": "A successful response.", | 3211 | "description": "A successful response.", |
| 3034 | "schema": { | 3212 | "schema": { |
| 3035 | - "$ref": "#/definitions/CompanyVisibleSwitchResponse" | 3213 | + "$ref": "#/definitions/ArticleTemplateSearchResponse" |
| 3036 | } | 3214 | } |
| 3037 | } | 3215 | } |
| 3038 | }, | 3216 | }, |
| @@ -3042,81 +3220,81 @@ | @@ -3042,81 +3220,81 @@ | ||
| 3042 | "in": "body", | 3220 | "in": "body", |
| 3043 | "required": true, | 3221 | "required": true, |
| 3044 | "schema": { | 3222 | "schema": { |
| 3045 | - "$ref": "#/definitions/CompanyVisibleSwitchRequest" | 3223 | + "$ref": "#/definitions/ArticleTemplateSearchRequest" |
| 3046 | } | 3224 | } |
| 3047 | } | 3225 | } |
| 3048 | ], | 3226 | ], |
| 3049 | "requestBody": {}, | 3227 | "requestBody": {}, |
| 3050 | "tags": [ | 3228 | "tags": [ |
| 3051 | - "company" | 3229 | + "template" |
| 3052 | ] | 3230 | ] |
| 3053 | } | 3231 | } |
| 3054 | }, | 3232 | }, |
| 3055 | - "v1/system/department/add": { | ||
| 3056 | - "post": { | ||
| 3057 | - "summary": "部门-新增", | ||
| 3058 | - "operationId": "systemAdd", | 3233 | + "v1/system/article_template/{id}": { |
| 3234 | + "get": { | ||
| 3235 | + "summary": "模板管理-详情", | ||
| 3236 | + "operationId": "systemArticleTemplateGet", | ||
| 3059 | "responses": { | 3237 | "responses": { |
| 3060 | "200": { | 3238 | "200": { |
| 3061 | "description": "A successful response.", | 3239 | "description": "A successful response.", |
| 3062 | "schema": { | 3240 | "schema": { |
| 3063 | - "$ref": "#/definitions/DepartmentGetResponse" | 3241 | + "$ref": "#/definitions/ArticleTemplateGetResponse" |
| 3064 | } | 3242 | } |
| 3065 | } | 3243 | } |
| 3066 | }, | 3244 | }, |
| 3067 | "parameters": [ | 3245 | "parameters": [ |
| 3068 | { | 3246 | { |
| 3069 | - "name": "body", | ||
| 3070 | - "in": "body", | 3247 | + "name": "id", |
| 3248 | + "in": "path", | ||
| 3071 | "required": true, | 3249 | "required": true, |
| 3072 | - "schema": { | ||
| 3073 | - "$ref": "#/definitions/DepartmentAddRequest" | ||
| 3074 | - } | 3250 | + "type": "string" |
| 3075 | } | 3251 | } |
| 3076 | ], | 3252 | ], |
| 3077 | "requestBody": {}, | 3253 | "requestBody": {}, |
| 3078 | "tags": [ | 3254 | "tags": [ |
| 3079 | - "department" | 3255 | + "template" |
| 3080 | ] | 3256 | ] |
| 3081 | - } | ||
| 3082 | }, | 3257 | }, |
| 3083 | - "v1/system/department/list": { | ||
| 3084 | - "post": { | ||
| 3085 | - "summary": "部门列表", | ||
| 3086 | - "operationId": "systemList", | 3258 | + "delete": { |
| 3259 | + "summary": "模板管理-删除", | ||
| 3260 | + "operationId": "systemArticleTemplateDelete", | ||
| 3087 | "responses": { | 3261 | "responses": { |
| 3088 | "200": { | 3262 | "200": { |
| 3089 | "description": "A successful response.", | 3263 | "description": "A successful response.", |
| 3090 | "schema": { | 3264 | "schema": { |
| 3091 | - "$ref": "#/definitions/DepartmentListResponse" | 3265 | + "$ref": "#/definitions/ArticleTemplateDeleteResponse" |
| 3092 | } | 3266 | } |
| 3093 | } | 3267 | } |
| 3094 | }, | 3268 | }, |
| 3095 | "parameters": [ | 3269 | "parameters": [ |
| 3096 | { | 3270 | { |
| 3271 | + "name": "id", | ||
| 3272 | + "in": "path", | ||
| 3273 | + "required": true, | ||
| 3274 | + "type": "string" | ||
| 3275 | + }, | ||
| 3276 | + { | ||
| 3097 | "name": "body", | 3277 | "name": "body", |
| 3098 | "in": "body", | 3278 | "in": "body", |
| 3099 | "required": true, | 3279 | "required": true, |
| 3100 | "schema": { | 3280 | "schema": { |
| 3101 | - "$ref": "#/definitions/DepartmentListRequest" | 3281 | + "$ref": "#/definitions/ArticleTemplateDeleteRequest" |
| 3102 | } | 3282 | } |
| 3103 | } | 3283 | } |
| 3104 | ], | 3284 | ], |
| 3105 | "requestBody": {}, | 3285 | "requestBody": {}, |
| 3106 | "tags": [ | 3286 | "tags": [ |
| 3107 | - "department" | 3287 | + "template" |
| 3108 | ] | 3288 | ] |
| 3109 | - } | ||
| 3110 | }, | 3289 | }, |
| 3111 | - "v1/system/department/{id}": { | ||
| 3112 | - "get": { | ||
| 3113 | - "summary": "部门-详情", | ||
| 3114 | - "operationId": "systemGet", | 3290 | + "put": { |
| 3291 | + "summary": "模板管理-更新", | ||
| 3292 | + "operationId": "systemArticleTemplateUpdate", | ||
| 3115 | "responses": { | 3293 | "responses": { |
| 3116 | "200": { | 3294 | "200": { |
| 3117 | "description": "A successful response.", | 3295 | "description": "A successful response.", |
| 3118 | "schema": { | 3296 | "schema": { |
| 3119 | - "$ref": "#/definitions/DepartmentGetResponse" | 3297 | + "$ref": "#/definitions/ArticleTemplateUpdateResponse" |
| 3120 | } | 3298 | } |
| 3121 | } | 3299 | } |
| 3122 | }, | 3300 | }, |
| @@ -3126,87 +3304,87 @@ | @@ -3126,87 +3304,87 @@ | ||
| 3126 | "in": "path", | 3304 | "in": "path", |
| 3127 | "required": true, | 3305 | "required": true, |
| 3128 | "type": "string" | 3306 | "type": "string" |
| 3307 | + }, | ||
| 3308 | + { | ||
| 3309 | + "name": "body", | ||
| 3310 | + "in": "body", | ||
| 3311 | + "required": true, | ||
| 3312 | + "schema": { | ||
| 3313 | + "$ref": "#/definitions/ArticleTemplateUpdateRequest" | ||
| 3314 | + } | ||
| 3129 | } | 3315 | } |
| 3130 | ], | 3316 | ], |
| 3131 | "requestBody": {}, | 3317 | "requestBody": {}, |
| 3132 | "tags": [ | 3318 | "tags": [ |
| 3133 | - "department" | 3319 | + "template" |
| 3134 | ] | 3320 | ] |
| 3321 | + } | ||
| 3135 | }, | 3322 | }, |
| 3136 | - "delete": { | ||
| 3137 | - "summary": "部门-删除", | ||
| 3138 | - "operationId": "systemDelete", | 3323 | + "v1/system/article_template_class/search": { |
| 3324 | + "post": { | ||
| 3325 | + "summary": "模板管理-分类搜索", | ||
| 3326 | + "operationId": "systemArticleTemplateClassSearch", | ||
| 3139 | "responses": { | 3327 | "responses": { |
| 3140 | "200": { | 3328 | "200": { |
| 3141 | "description": "A successful response.", | 3329 | "description": "A successful response.", |
| 3142 | "schema": { | 3330 | "schema": { |
| 3143 | - "$ref": "#/definitions/DepartmentGetResponse" | 3331 | + "$ref": "#/definitions/ArticleTemplateClassSearchResponse" |
| 3144 | } | 3332 | } |
| 3145 | } | 3333 | } |
| 3146 | }, | 3334 | }, |
| 3147 | "parameters": [ | 3335 | "parameters": [ |
| 3148 | { | 3336 | { |
| 3149 | - "name": "id", | ||
| 3150 | - "in": "path", | ||
| 3151 | - "required": true, | ||
| 3152 | - "type": "string" | ||
| 3153 | - }, | ||
| 3154 | - { | ||
| 3155 | "name": "body", | 3337 | "name": "body", |
| 3156 | "in": "body", | 3338 | "in": "body", |
| 3157 | "required": true, | 3339 | "required": true, |
| 3158 | "schema": { | 3340 | "schema": { |
| 3159 | - "$ref": "#/definitions/DepartmentGetRequest" | 3341 | + "$ref": "#/definitions/ArticleTemplateClassSearchRequest" |
| 3160 | } | 3342 | } |
| 3161 | } | 3343 | } |
| 3162 | ], | 3344 | ], |
| 3163 | "requestBody": {}, | 3345 | "requestBody": {}, |
| 3164 | "tags": [ | 3346 | "tags": [ |
| 3165 | - "department" | 3347 | + "template" |
| 3166 | ] | 3348 | ] |
| 3349 | + } | ||
| 3167 | }, | 3350 | }, |
| 3168 | - "put": { | ||
| 3169 | - "summary": "部门-更新", | ||
| 3170 | - "operationId": "systemUpdate", | 3351 | + "v1/system/company/positions/search": { |
| 3352 | + "post": { | ||
| 3353 | + "summary": "公司职位搜索", | ||
| 3354 | + "operationId": "systemCompanyPositionsSearch", | ||
| 3171 | "responses": { | 3355 | "responses": { |
| 3172 | "200": { | 3356 | "200": { |
| 3173 | "description": "A successful response.", | 3357 | "description": "A successful response.", |
| 3174 | "schema": { | 3358 | "schema": { |
| 3175 | - "$ref": "#/definitions/DepartmentGetResponse" | 3359 | + "$ref": "#/definitions/CompanyPositionsSearchResponse" |
| 3176 | } | 3360 | } |
| 3177 | } | 3361 | } |
| 3178 | }, | 3362 | }, |
| 3179 | "parameters": [ | 3363 | "parameters": [ |
| 3180 | { | 3364 | { |
| 3181 | - "name": "id", | ||
| 3182 | - "in": "path", | ||
| 3183 | - "required": true, | ||
| 3184 | - "type": "string" | ||
| 3185 | - }, | ||
| 3186 | - { | ||
| 3187 | "name": "body", | 3365 | "name": "body", |
| 3188 | "in": "body", | 3366 | "in": "body", |
| 3189 | "required": true, | 3367 | "required": true, |
| 3190 | "schema": { | 3368 | "schema": { |
| 3191 | - "$ref": "#/definitions/DepartmentUpdateRequest" | 3369 | + "$ref": "#/definitions/CompanyPositionsSearchRequest" |
| 3192 | } | 3370 | } |
| 3193 | } | 3371 | } |
| 3194 | ], | 3372 | ], |
| 3195 | "requestBody": {}, | 3373 | "requestBody": {}, |
| 3196 | "tags": [ | 3374 | "tags": [ |
| 3197 | - "department" | 3375 | + "company" |
| 3198 | ] | 3376 | ] |
| 3199 | } | 3377 | } |
| 3200 | }, | 3378 | }, |
| 3201 | - "v1/system/role": { | 3379 | + "v1/system/company/search": { |
| 3202 | "post": { | 3380 | "post": { |
| 3203 | - "summary": "角色新增", | ||
| 3204 | - "operationId": "systemSaveRole", | 3381 | + "summary": "公司搜索", |
| 3382 | + "operationId": "systemCompanySearch", | ||
| 3205 | "responses": { | 3383 | "responses": { |
| 3206 | "200": { | 3384 | "200": { |
| 3207 | "description": "A successful response.", | 3385 | "description": "A successful response.", |
| 3208 | "schema": { | 3386 | "schema": { |
| 3209 | - "$ref": "#/definitions/RoleSaveResponse" | 3387 | + "$ref": "#/definitions/CompanySearchResponse" |
| 3210 | } | 3388 | } |
| 3211 | } | 3389 | } |
| 3212 | }, | 3390 | }, |
| @@ -3216,18 +3394,220 @@ | @@ -3216,18 +3394,220 @@ | ||
| 3216 | "in": "body", | 3394 | "in": "body", |
| 3217 | "required": true, | 3395 | "required": true, |
| 3218 | "schema": { | 3396 | "schema": { |
| 3219 | - "$ref": "#/definitions/RoleSaveRequest" | 3397 | + "$ref": "#/definitions/CompanySearchRequest" |
| 3220 | } | 3398 | } |
| 3221 | } | 3399 | } |
| 3222 | ], | 3400 | ], |
| 3223 | "requestBody": {}, | 3401 | "requestBody": {}, |
| 3224 | "tags": [ | 3402 | "tags": [ |
| 3225 | - "role" | 3403 | + "company" |
| 3226 | ] | 3404 | ] |
| 3227 | } | 3405 | } |
| 3228 | }, | 3406 | }, |
| 3229 | - "v1/system/role/auths": { | ||
| 3230 | - "get": { | 3407 | + "v1/system/company/visible_switch": { |
| 3408 | + "post": { | ||
| 3409 | + "summary": "公司可见开关", | ||
| 3410 | + "operationId": "systemCompanyVisibleSwitch", | ||
| 3411 | + "responses": { | ||
| 3412 | + "200": { | ||
| 3413 | + "description": "A successful response.", | ||
| 3414 | + "schema": { | ||
| 3415 | + "$ref": "#/definitions/CompanyVisibleSwitchResponse" | ||
| 3416 | + } | ||
| 3417 | + } | ||
| 3418 | + }, | ||
| 3419 | + "parameters": [ | ||
| 3420 | + { | ||
| 3421 | + "name": "body", | ||
| 3422 | + "in": "body", | ||
| 3423 | + "required": true, | ||
| 3424 | + "schema": { | ||
| 3425 | + "$ref": "#/definitions/CompanyVisibleSwitchRequest" | ||
| 3426 | + } | ||
| 3427 | + } | ||
| 3428 | + ], | ||
| 3429 | + "requestBody": {}, | ||
| 3430 | + "tags": [ | ||
| 3431 | + "company" | ||
| 3432 | + ] | ||
| 3433 | + } | ||
| 3434 | + }, | ||
| 3435 | + "v1/system/department/add": { | ||
| 3436 | + "post": { | ||
| 3437 | + "summary": "部门-新增", | ||
| 3438 | + "operationId": "systemAdd", | ||
| 3439 | + "responses": { | ||
| 3440 | + "200": { | ||
| 3441 | + "description": "A successful response.", | ||
| 3442 | + "schema": { | ||
| 3443 | + "$ref": "#/definitions/DepartmentGetResponse" | ||
| 3444 | + } | ||
| 3445 | + } | ||
| 3446 | + }, | ||
| 3447 | + "parameters": [ | ||
| 3448 | + { | ||
| 3449 | + "name": "body", | ||
| 3450 | + "in": "body", | ||
| 3451 | + "required": true, | ||
| 3452 | + "schema": { | ||
| 3453 | + "$ref": "#/definitions/DepartmentAddRequest" | ||
| 3454 | + } | ||
| 3455 | + } | ||
| 3456 | + ], | ||
| 3457 | + "requestBody": {}, | ||
| 3458 | + "tags": [ | ||
| 3459 | + "department" | ||
| 3460 | + ] | ||
| 3461 | + } | ||
| 3462 | + }, | ||
| 3463 | + "v1/system/department/list": { | ||
| 3464 | + "post": { | ||
| 3465 | + "summary": "部门列表", | ||
| 3466 | + "operationId": "systemList", | ||
| 3467 | + "responses": { | ||
| 3468 | + "200": { | ||
| 3469 | + "description": "A successful response.", | ||
| 3470 | + "schema": { | ||
| 3471 | + "$ref": "#/definitions/DepartmentListResponse" | ||
| 3472 | + } | ||
| 3473 | + } | ||
| 3474 | + }, | ||
| 3475 | + "parameters": [ | ||
| 3476 | + { | ||
| 3477 | + "name": "body", | ||
| 3478 | + "in": "body", | ||
| 3479 | + "required": true, | ||
| 3480 | + "schema": { | ||
| 3481 | + "$ref": "#/definitions/DepartmentListRequest" | ||
| 3482 | + } | ||
| 3483 | + } | ||
| 3484 | + ], | ||
| 3485 | + "requestBody": {}, | ||
| 3486 | + "tags": [ | ||
| 3487 | + "department" | ||
| 3488 | + ] | ||
| 3489 | + } | ||
| 3490 | + }, | ||
| 3491 | + "v1/system/department/{id}": { | ||
| 3492 | + "get": { | ||
| 3493 | + "summary": "部门-详情", | ||
| 3494 | + "operationId": "systemGet", | ||
| 3495 | + "responses": { | ||
| 3496 | + "200": { | ||
| 3497 | + "description": "A successful response.", | ||
| 3498 | + "schema": { | ||
| 3499 | + "$ref": "#/definitions/DepartmentGetResponse" | ||
| 3500 | + } | ||
| 3501 | + } | ||
| 3502 | + }, | ||
| 3503 | + "parameters": [ | ||
| 3504 | + { | ||
| 3505 | + "name": "id", | ||
| 3506 | + "in": "path", | ||
| 3507 | + "required": true, | ||
| 3508 | + "type": "string" | ||
| 3509 | + } | ||
| 3510 | + ], | ||
| 3511 | + "requestBody": {}, | ||
| 3512 | + "tags": [ | ||
| 3513 | + "department" | ||
| 3514 | + ] | ||
| 3515 | + }, | ||
| 3516 | + "delete": { | ||
| 3517 | + "summary": "部门-删除", | ||
| 3518 | + "operationId": "systemDelete", | ||
| 3519 | + "responses": { | ||
| 3520 | + "200": { | ||
| 3521 | + "description": "A successful response.", | ||
| 3522 | + "schema": { | ||
| 3523 | + "$ref": "#/definitions/DepartmentGetResponse" | ||
| 3524 | + } | ||
| 3525 | + } | ||
| 3526 | + }, | ||
| 3527 | + "parameters": [ | ||
| 3528 | + { | ||
| 3529 | + "name": "id", | ||
| 3530 | + "in": "path", | ||
| 3531 | + "required": true, | ||
| 3532 | + "type": "string" | ||
| 3533 | + }, | ||
| 3534 | + { | ||
| 3535 | + "name": "body", | ||
| 3536 | + "in": "body", | ||
| 3537 | + "required": true, | ||
| 3538 | + "schema": { | ||
| 3539 | + "$ref": "#/definitions/DepartmentGetRequest" | ||
| 3540 | + } | ||
| 3541 | + } | ||
| 3542 | + ], | ||
| 3543 | + "requestBody": {}, | ||
| 3544 | + "tags": [ | ||
| 3545 | + "department" | ||
| 3546 | + ] | ||
| 3547 | + }, | ||
| 3548 | + "put": { | ||
| 3549 | + "summary": "部门-更新", | ||
| 3550 | + "operationId": "systemUpdate", | ||
| 3551 | + "responses": { | ||
| 3552 | + "200": { | ||
| 3553 | + "description": "A successful response.", | ||
| 3554 | + "schema": { | ||
| 3555 | + "$ref": "#/definitions/DepartmentGetResponse" | ||
| 3556 | + } | ||
| 3557 | + } | ||
| 3558 | + }, | ||
| 3559 | + "parameters": [ | ||
| 3560 | + { | ||
| 3561 | + "name": "id", | ||
| 3562 | + "in": "path", | ||
| 3563 | + "required": true, | ||
| 3564 | + "type": "string" | ||
| 3565 | + }, | ||
| 3566 | + { | ||
| 3567 | + "name": "body", | ||
| 3568 | + "in": "body", | ||
| 3569 | + "required": true, | ||
| 3570 | + "schema": { | ||
| 3571 | + "$ref": "#/definitions/DepartmentUpdateRequest" | ||
| 3572 | + } | ||
| 3573 | + } | ||
| 3574 | + ], | ||
| 3575 | + "requestBody": {}, | ||
| 3576 | + "tags": [ | ||
| 3577 | + "department" | ||
| 3578 | + ] | ||
| 3579 | + } | ||
| 3580 | + }, | ||
| 3581 | + "v1/system/role": { | ||
| 3582 | + "post": { | ||
| 3583 | + "summary": "角色新增", | ||
| 3584 | + "operationId": "systemSaveRole", | ||
| 3585 | + "responses": { | ||
| 3586 | + "200": { | ||
| 3587 | + "description": "A successful response.", | ||
| 3588 | + "schema": { | ||
| 3589 | + "$ref": "#/definitions/RoleSaveResponse" | ||
| 3590 | + } | ||
| 3591 | + } | ||
| 3592 | + }, | ||
| 3593 | + "parameters": [ | ||
| 3594 | + { | ||
| 3595 | + "name": "body", | ||
| 3596 | + "in": "body", | ||
| 3597 | + "required": true, | ||
| 3598 | + "schema": { | ||
| 3599 | + "$ref": "#/definitions/RoleSaveRequest" | ||
| 3600 | + } | ||
| 3601 | + } | ||
| 3602 | + ], | ||
| 3603 | + "requestBody": {}, | ||
| 3604 | + "tags": [ | ||
| 3605 | + "role" | ||
| 3606 | + ] | ||
| 3607 | + } | ||
| 3608 | + }, | ||
| 3609 | + "v1/system/role/auths": { | ||
| 3610 | + "get": { | ||
| 3231 | "summary": "角色权限列表", | 3611 | "summary": "角色权限列表", |
| 3232 | "operationId": "systemGetRoleAuths", | 3612 | "operationId": "systemGetRoleAuths", |
| 3233 | "responses": { | 3613 | "responses": { |
| @@ -4080,231 +4460,518 @@ | @@ -4080,231 +4460,518 @@ | ||
| 4080 | "type": "string", | 4460 | "type": "string", |
| 4081 | "description": " 风控标签" | 4461 | "description": " 风控标签" |
| 4082 | }, | 4462 | }, |
| 4083 | - "prob": { | 4463 | + "prob": { |
| 4464 | + "type": "integer", | ||
| 4465 | + "format": "int32", | ||
| 4466 | + "description": " 分值" | ||
| 4467 | + }, | ||
| 4468 | + "suggest": { | ||
| 4469 | + "type": "string", | ||
| 4470 | + "description": " 建议 通过、风险、人工审核" | ||
| 4471 | + }, | ||
| 4472 | + "author": { | ||
| 4473 | + "type": "string", | ||
| 4474 | + "description": " 发布人" | ||
| 4475 | + }, | ||
| 4476 | + "releaseAt": { | ||
| 4477 | + "type": "integer", | ||
| 4478 | + "format": "int64", | ||
| 4479 | + "description": " 发布时间" | ||
| 4480 | + }, | ||
| 4481 | + "reviewStatus": { | ||
| 4482 | + "type": "integer", | ||
| 4483 | + "format": "int32", | ||
| 4484 | + "description": " 审核结果 1:待审核 2:通过 3:拒绝" | ||
| 4485 | + }, | ||
| 4486 | + "reviewer": { | ||
| 4487 | + "type": "string", | ||
| 4488 | + "description": " 审核人" | ||
| 4489 | + }, | ||
| 4490 | + "reviewAt": { | ||
| 4491 | + "type": "integer", | ||
| 4492 | + "format": "int64", | ||
| 4493 | + "description": " 审核时间(人工处置时间)" | ||
| 4494 | + }, | ||
| 4495 | + "checkList": { | ||
| 4496 | + "type": "array", | ||
| 4497 | + "items": { | ||
| 4498 | + "$ref": "#/definitions/CheckDetailItem" | ||
| 4499 | + }, | ||
| 4500 | + "description": " 检查列表" | ||
| 4501 | + } | ||
| 4502 | + }, | ||
| 4503 | + "title": "ArticleSecurityItem", | ||
| 4504 | + "required": [ | ||
| 4505 | + "id", | ||
| 4506 | + "contentKeyWords", | ||
| 4507 | + "content", | ||
| 4508 | + "label", | ||
| 4509 | + "prob", | ||
| 4510 | + "suggest", | ||
| 4511 | + "author", | ||
| 4512 | + "releaseAt", | ||
| 4513 | + "reviewStatus", | ||
| 4514 | + "reviewer", | ||
| 4515 | + "reviewAt", | ||
| 4516 | + "checkList" | ||
| 4517 | + ] | ||
| 4518 | + }, | ||
| 4519 | + "ArticleSecuritySearchRequest": { | ||
| 4520 | + "type": "object", | ||
| 4521 | + "properties": { | ||
| 4522 | + "page": { | ||
| 4523 | + "type": "integer", | ||
| 4524 | + "format": "int32" | ||
| 4525 | + }, | ||
| 4526 | + "size": { | ||
| 4527 | + "type": "integer", | ||
| 4528 | + "format": "int32" | ||
| 4529 | + }, | ||
| 4530 | + "reviewStatus": { | ||
| 4531 | + "type": "integer", | ||
| 4532 | + "format": "int32", | ||
| 4533 | + "description": " 审核结果 1:待审核 2:通过 3:拒绝" | ||
| 4534 | + }, | ||
| 4535 | + "suggest": { | ||
| 4536 | + "type": "string", | ||
| 4537 | + "description": " 建议 通过、风险、人工审核" | ||
| 4538 | + }, | ||
| 4539 | + "contentType": { | ||
| 4540 | + "type": "integer", | ||
| 4541 | + "format": "int32", | ||
| 4542 | + "description": " 内容类型 (1:文章 2:评论)" | ||
| 4543 | + }, | ||
| 4544 | + "authorName": { | ||
| 4545 | + "type": "string", | ||
| 4546 | + "description": " 作者名称" | ||
| 4547 | + }, | ||
| 4548 | + "beginTime": { | ||
| 4549 | + "type": "integer", | ||
| 4550 | + "format": "int64", | ||
| 4551 | + "description": " 开始时间" | ||
| 4552 | + }, | ||
| 4553 | + "endTime": { | ||
| 4554 | + "type": "integer", | ||
| 4555 | + "format": "int64", | ||
| 4556 | + "description": " 结束时间" | ||
| 4557 | + } | ||
| 4558 | + }, | ||
| 4559 | + "title": "ArticleSecuritySearchRequest", | ||
| 4560 | + "required": [ | ||
| 4561 | + "suggest", | ||
| 4562 | + "contentType", | ||
| 4563 | + "authorName", | ||
| 4564 | + "beginTime", | ||
| 4565 | + "endTime" | ||
| 4566 | + ] | ||
| 4567 | + }, | ||
| 4568 | + "ArticleSecuritySearchResponse": { | ||
| 4569 | + "type": "object", | ||
| 4570 | + "properties": { | ||
| 4571 | + "list": { | ||
| 4572 | + "type": "array", | ||
| 4573 | + "items": { | ||
| 4574 | + "$ref": "#/definitions/ArticleSecurityItem" | ||
| 4575 | + } | ||
| 4576 | + }, | ||
| 4577 | + "total": { | ||
| 4578 | + "type": "integer", | ||
| 4579 | + "format": "int64" | ||
| 4580 | + } | ||
| 4581 | + }, | ||
| 4582 | + "title": "ArticleSecuritySearchResponse", | ||
| 4583 | + "required": [ | ||
| 4584 | + "list", | ||
| 4585 | + "total" | ||
| 4586 | + ] | ||
| 4587 | + }, | ||
| 4588 | + "ArticleTagCount": { | ||
| 4589 | + "type": "object", | ||
| 4590 | + "properties": { | ||
| 4591 | + "tagCategory": { | ||
| 4592 | + "type": "string", | ||
| 4593 | + "description": " 标签分组" | ||
| 4594 | + }, | ||
| 4595 | + "tagId": { | ||
| 4596 | + "type": "integer", | ||
| 4597 | + "format": "int64", | ||
| 4598 | + "description": " 标签id" | ||
| 4599 | + }, | ||
| 4600 | + "tagImage": { | ||
| 4601 | + "type": "string", | ||
| 4602 | + "description": " 对应的图标" | ||
| 4603 | + }, | ||
| 4604 | + "tagName": { | ||
| 4605 | + "type": "string", | ||
| 4606 | + "description": " 标签名称" | ||
| 4607 | + }, | ||
| 4608 | + "tagRemark": { | ||
| 4609 | + "type": "string", | ||
| 4610 | + "description": " 标签备注" | ||
| 4611 | + }, | ||
| 4612 | + "totalArticle": { | ||
| 4613 | + "type": "integer", | ||
| 4614 | + "format": "int32", | ||
| 4615 | + "description": " 总的文章数量" | ||
| 4616 | + }, | ||
| 4617 | + "readArticle": { | ||
| 4618 | + "type": "integer", | ||
| 4619 | + "format": "int32", | ||
| 4620 | + "description": " 已读的标签数量" | ||
| 4621 | + }, | ||
| 4622 | + "sortBy": { | ||
| 4623 | + "type": "integer", | ||
| 4624 | + "format": "int32", | ||
| 4625 | + "description": " 排序" | ||
| 4626 | + } | ||
| 4627 | + }, | ||
| 4628 | + "title": "ArticleTagCount", | ||
| 4629 | + "required": [ | ||
| 4630 | + "tagCategory", | ||
| 4631 | + "tagId", | ||
| 4632 | + "tagImage", | ||
| 4633 | + "tagName", | ||
| 4634 | + "tagRemark", | ||
| 4635 | + "totalArticle", | ||
| 4636 | + "readArticle", | ||
| 4637 | + "sortBy" | ||
| 4638 | + ] | ||
| 4639 | + }, | ||
| 4640 | + "ArticleTagGroup": { | ||
| 4641 | + "type": "object", | ||
| 4642 | + "properties": { | ||
| 4643 | + "category": { | ||
| 4644 | + "type": "string" | ||
| 4645 | + }, | ||
| 4646 | + "tags": { | ||
| 4647 | + "type": "array", | ||
| 4648 | + "items": { | ||
| 4649 | + "$ref": "#/definitions/ArticleTagItem" | ||
| 4650 | + } | ||
| 4651 | + } | ||
| 4652 | + }, | ||
| 4653 | + "title": "ArticleTagGroup", | ||
| 4654 | + "required": [ | ||
| 4655 | + "category", | ||
| 4656 | + "tags" | ||
| 4657 | + ] | ||
| 4658 | + }, | ||
| 4659 | + "ArticleTagItem": { | ||
| 4660 | + "type": "object", | ||
| 4661 | + "properties": { | ||
| 4662 | + "id": { | ||
| 4663 | + "type": "integer", | ||
| 4664 | + "format": "int64" | ||
| 4665 | + }, | ||
| 4666 | + "category": { | ||
| 4667 | + "type": "string" | ||
| 4668 | + }, | ||
| 4669 | + "name": { | ||
| 4670 | + "type": "string" | ||
| 4671 | + }, | ||
| 4672 | + "image": { | ||
| 4673 | + "type": "string" | ||
| 4674 | + }, | ||
| 4675 | + "sortBy": { | ||
| 4676 | + "type": "integer", | ||
| 4677 | + "format": "int32" | ||
| 4678 | + } | ||
| 4679 | + }, | ||
| 4680 | + "title": "ArticleTagItem", | ||
| 4681 | + "required": [ | ||
| 4682 | + "id", | ||
| 4683 | + "category", | ||
| 4684 | + "name", | ||
| 4685 | + "image", | ||
| 4686 | + "sortBy" | ||
| 4687 | + ] | ||
| 4688 | + }, | ||
| 4689 | + "ArticleTemplateBatchDeleteRequest": { | ||
| 4690 | + "type": "object", | ||
| 4691 | + "properties": { | ||
| 4692 | + "ids": { | ||
| 4693 | + "type": "array", | ||
| 4694 | + "items": { | ||
| 4695 | + "type": "integer", | ||
| 4696 | + "format": "int64" | ||
| 4697 | + } | ||
| 4698 | + } | ||
| 4699 | + }, | ||
| 4700 | + "title": "ArticleTemplateBatchDeleteRequest", | ||
| 4701 | + "required": [ | ||
| 4702 | + "ids" | ||
| 4703 | + ] | ||
| 4704 | + }, | ||
| 4705 | + "ArticleTemplateBatchResponse": { | ||
| 4706 | + "type": "object", | ||
| 4707 | + "title": "ArticleTemplateBatchResponse" | ||
| 4708 | + }, | ||
| 4709 | + "ArticleTemplateClassItem": { | ||
| 4710 | + "type": "object", | ||
| 4711 | + "properties": { | ||
| 4712 | + "name": { | ||
| 4713 | + "type": "string", | ||
| 4714 | + "description": " 名称" | ||
| 4715 | + } | ||
| 4716 | + }, | ||
| 4717 | + "title": "ArticleTemplateClassItem", | ||
| 4718 | + "required": [ | ||
| 4719 | + "name" | ||
| 4720 | + ] | ||
| 4721 | + }, | ||
| 4722 | + "ArticleTemplateClassSearchRequest": { | ||
| 4723 | + "type": "object", | ||
| 4724 | + "properties": { | ||
| 4725 | + "page": { | ||
| 4726 | + "type": "integer", | ||
| 4727 | + "format": "int32" | ||
| 4728 | + }, | ||
| 4729 | + "size": { | ||
| 4730 | + "type": "integer", | ||
| 4731 | + "format": "int32" | ||
| 4732 | + }, | ||
| 4733 | + "name": { | ||
| 4734 | + "type": "string", | ||
| 4735 | + "description": " 模板名称" | ||
| 4736 | + } | ||
| 4737 | + }, | ||
| 4738 | + "title": "ArticleTemplateClassSearchRequest" | ||
| 4739 | + }, | ||
| 4740 | + "ArticleTemplateClassSearchResponse": { | ||
| 4741 | + "type": "object", | ||
| 4742 | + "properties": { | ||
| 4743 | + "list": { | ||
| 4744 | + "type": "array", | ||
| 4745 | + "items": { | ||
| 4746 | + "$ref": "#/definitions/ArticleTemplateClassItem" | ||
| 4747 | + } | ||
| 4748 | + }, | ||
| 4749 | + "total": { | ||
| 4750 | + "type": "integer", | ||
| 4751 | + "format": "int64" | ||
| 4752 | + } | ||
| 4753 | + }, | ||
| 4754 | + "title": "ArticleTemplateClassSearchResponse", | ||
| 4755 | + "required": [ | ||
| 4756 | + "list", | ||
| 4757 | + "total" | ||
| 4758 | + ] | ||
| 4759 | + }, | ||
| 4760 | + "ArticleTemplateDeleteRequest": { | ||
| 4761 | + "type": "object", | ||
| 4762 | + "properties": { | ||
| 4763 | + "id": { | ||
| 4764 | + "type": "integer", | ||
| 4765 | + "format": "int64" | ||
| 4766 | + } | ||
| 4767 | + }, | ||
| 4768 | + "title": "ArticleTemplateDeleteRequest", | ||
| 4769 | + "required": [ | ||
| 4770 | + "id" | ||
| 4771 | + ] | ||
| 4772 | + }, | ||
| 4773 | + "ArticleTemplateDeleteResponse": { | ||
| 4774 | + "type": "object", | ||
| 4775 | + "title": "ArticleTemplateDeleteResponse" | ||
| 4776 | + }, | ||
| 4777 | + "ArticleTemplateGetRequest": { | ||
| 4778 | + "type": "object", | ||
| 4779 | + "properties": { | ||
| 4780 | + "id": { | ||
| 4781 | + "type": "integer", | ||
| 4782 | + "format": "int64" | ||
| 4783 | + } | ||
| 4784 | + }, | ||
| 4785 | + "title": "ArticleTemplateGetRequest", | ||
| 4786 | + "required": [ | ||
| 4787 | + "id" | ||
| 4788 | + ] | ||
| 4789 | + }, | ||
| 4790 | + "ArticleTemplateGetResponse": { | ||
| 4791 | + "type": "object", | ||
| 4792 | + "properties": { | ||
| 4793 | + "item": { | ||
| 4794 | + "$ref": "#/definitions/ArticleTemplateItem" | ||
| 4795 | + } | ||
| 4796 | + }, | ||
| 4797 | + "title": "ArticleTemplateGetResponse", | ||
| 4798 | + "required": [ | ||
| 4799 | + "item" | ||
| 4800 | + ] | ||
| 4801 | + }, | ||
| 4802 | + "ArticleTemplateItem": { | ||
| 4803 | + "type": "object", | ||
| 4804 | + "properties": { | ||
| 4805 | + "id": { | ||
| 4084 | "type": "integer", | 4806 | "type": "integer", |
| 4085 | - "format": "int32", | ||
| 4086 | - "description": " 分值" | 4807 | + "format": "int64", |
| 4808 | + "description": " 唯一标识" | ||
| 4087 | }, | 4809 | }, |
| 4088 | - "suggest": { | 4810 | + "name": { |
| 4089 | "type": "string", | 4811 | "type": "string", |
| 4090 | - "description": " 建议 通过、风险、人工审核" | 4812 | + "description": " 模板名称" |
| 4091 | }, | 4813 | }, |
| 4092 | - "author": { | 4814 | + "templateClass": { |
| 4093 | "type": "string", | 4815 | "type": "string", |
| 4094 | - "description": " 发布人" | 4816 | + "description": " 模板分类" |
| 4095 | }, | 4817 | }, |
| 4096 | - "releaseAt": { | 4818 | + "paragraphs": { |
| 4819 | + "type": "array", | ||
| 4820 | + "items": { | ||
| 4821 | + "$ref": "#/definitions/Paragraph" | ||
| 4822 | + }, | ||
| 4823 | + "description": " 段落列表" | ||
| 4824 | + }, | ||
| 4825 | + "icon": { | ||
| 4097 | "type": "string", | 4826 | "type": "string", |
| 4098 | - "description": " 发布时间" | 4827 | + "description": " 图标地址" |
| 4099 | }, | 4828 | }, |
| 4100 | - "reviewStatus": { | 4829 | + "targetWhoRead": { |
| 4101 | "type": "integer", | 4830 | "type": "integer", |
| 4102 | "format": "int32", | 4831 | "format": "int32", |
| 4103 | - "description": " 审核结果 1:待审核 2:通过 3:拒绝" | ||
| 4104 | - }, | ||
| 4105 | - "reviewer": { | ||
| 4106 | - "type": "string", | ||
| 4107 | - "description": " 审核人" | 4832 | + "description": " 分发方式 0 分发给所有人 1 分发给指定的人" |
| 4108 | }, | 4833 | }, |
| 4109 | - "reviewAt": { | 4834 | + "targetWhoReview": { |
| 4110 | "type": "integer", | 4835 | "type": "integer", |
| 4111 | - "format": "int64", | ||
| 4112 | - "description": " 审核时间(人工处置时间)" | 4836 | + "format": "int32", |
| 4837 | + "description": " 分发方式 0 分发给所有人 1 分发给指定的人" | ||
| 4113 | }, | 4838 | }, |
| 4114 | - "checkList": { | 4839 | + "whoRead": { |
| 4115 | "type": "array", | 4840 | "type": "array", |
| 4116 | "items": { | 4841 | "items": { |
| 4117 | - "$ref": "#/definitions/CheckDetailItem" | ||
| 4118 | - }, | ||
| 4119 | - "description": " 检查列表" | ||
| 4120 | - } | 4842 | + "type": "integer", |
| 4843 | + "format": "int64" | ||
| 4121 | }, | 4844 | }, |
| 4122 | - "title": "ArticleSecurityItem", | ||
| 4123 | - "required": [ | ||
| 4124 | - "id", | ||
| 4125 | - "contentKeyWords", | ||
| 4126 | - "content", | ||
| 4127 | - "label", | ||
| 4128 | - "prob", | ||
| 4129 | - "suggest", | ||
| 4130 | - "author", | ||
| 4131 | - "releaseAt", | ||
| 4132 | - "reviewStatus", | ||
| 4133 | - "reviewer", | ||
| 4134 | - "reviewAt", | ||
| 4135 | - "checkList" | ||
| 4136 | - ] | 4845 | + "description": " 谁可以看" |
| 4137 | }, | 4846 | }, |
| 4138 | - "ArticleSecuritySearchRequest": { | ||
| 4139 | - "type": "object", | ||
| 4140 | - "properties": { | ||
| 4141 | - "page": { | 4847 | + "whoReview": { |
| 4848 | + "type": "array", | ||
| 4849 | + "items": { | ||
| 4142 | "type": "integer", | 4850 | "type": "integer", |
| 4143 | - "format": "int32" | 4851 | + "format": "int64" |
| 4144 | }, | 4852 | }, |
| 4145 | - "size": { | ||
| 4146 | - "type": "integer", | ||
| 4147 | - "format": "int32" | 4853 | + "description": " 查看、评论人" |
| 4148 | }, | 4854 | }, |
| 4149 | - "reviewStatus": { | ||
| 4150 | - "type": "integer", | ||
| 4151 | - "format": "int32", | ||
| 4152 | - "description": " 审核结果 1:待审核 2:通过 3:拒绝" | 4855 | + "whoReadInfo": { |
| 4856 | + "type": "array", | ||
| 4857 | + "items": { | ||
| 4858 | + "$ref": "#/definitions/TargetUser" | ||
| 4153 | }, | 4859 | }, |
| 4154 | - "suggest": { | ||
| 4155 | - "type": "string", | ||
| 4156 | - "description": " 建议 通过、风险、人工审核" | 4860 | + "description": " 谁可查看" |
| 4157 | }, | 4861 | }, |
| 4158 | - "contentType": { | ||
| 4159 | - "type": "integer", | ||
| 4160 | - "format": "int32", | ||
| 4161 | - "description": " 内容类型 (1:文章 2:评论)" | 4862 | + "whoReviewInfo": { |
| 4863 | + "type": "array", | ||
| 4864 | + "items": { | ||
| 4865 | + "$ref": "#/definitions/TargetUser" | ||
| 4162 | }, | 4866 | }, |
| 4163 | - "authorName": { | ||
| 4164 | - "type": "string", | ||
| 4165 | - "description": " 作者名称" | 4867 | + "description": " 谁可评论" |
| 4166 | }, | 4868 | }, |
| 4167 | - "beginTime": { | ||
| 4168 | - "type": "integer", | ||
| 4169 | - "format": "int64", | ||
| 4170 | - "description": " 开始时间" | 4869 | + "": { |
| 4870 | + "type": "string", | ||
| 4871 | + "description": " 操作人" | ||
| 4171 | }, | 4872 | }, |
| 4172 | - "endTime": { | 4873 | + "": { |
| 4173 | "type": "integer", | 4874 | "type": "integer", |
| 4174 | "format": "int64", | 4875 | "format": "int64", |
| 4175 | - "description": " 结束时间" | 4876 | + "description": " 更新时间戳" |
| 4176 | } | 4877 | } |
| 4177 | }, | 4878 | }, |
| 4178 | - "title": "ArticleSecuritySearchRequest", | 4879 | + "title": "ArticleTemplateItem", |
| 4179 | "required": [ | 4880 | "required": [ |
| 4180 | - "suggest", | ||
| 4181 | - "contentType", | ||
| 4182 | - "authorName", | ||
| 4183 | - "beginTime", | ||
| 4184 | - "endTime" | 4881 | + "name", |
| 4882 | + "templateClass", | ||
| 4883 | + "paragraphs", | ||
| 4884 | + "" | ||
| 4185 | ] | 4885 | ] |
| 4186 | }, | 4886 | }, |
| 4187 | - "ArticleSecuritySearchResponse": { | 4887 | + "ArticleTemplateSaveRequest": { |
| 4188 | "type": "object", | 4888 | "type": "object", |
| 4189 | "properties": { | 4889 | "properties": { |
| 4190 | - "list": { | ||
| 4191 | - "type": "array", | ||
| 4192 | - "items": { | ||
| 4193 | - "$ref": "#/definitions/ArticleSecurityItem" | ||
| 4194 | - } | 4890 | + "AccessToken": { |
| 4891 | + "type": "string", | ||
| 4892 | + "description": " 授权token" | ||
| 4195 | }, | 4893 | }, |
| 4196 | - "total": { | ||
| 4197 | - "type": "integer", | ||
| 4198 | - "format": "int64" | 4894 | + "item": { |
| 4895 | + "$ref": "#/definitions/ArticleTemplateItem" | ||
| 4199 | } | 4896 | } |
| 4200 | }, | 4897 | }, |
| 4201 | - "title": "ArticleSecuritySearchResponse", | 4898 | + "title": "ArticleTemplateSaveRequest", |
| 4202 | "required": [ | 4899 | "required": [ |
| 4203 | - "list", | ||
| 4204 | - "total" | 4900 | + "x-mmm-accesstoken", |
| 4901 | + "item" | ||
| 4205 | ] | 4902 | ] |
| 4206 | }, | 4903 | }, |
| 4207 | - "ArticleTagCount": { | 4904 | + "ArticleTemplateSaveResponse": { |
| 4208 | "type": "object", | 4905 | "type": "object", |
| 4209 | - "properties": { | ||
| 4210 | - "tagCategory": { | ||
| 4211 | - "type": "string", | ||
| 4212 | - "description": " 标签分组" | 4906 | + "title": "ArticleTemplateSaveResponse" |
| 4213 | }, | 4907 | }, |
| 4214 | - "tagId": { | 4908 | + "ArticleTemplateSearchRequest": { |
| 4909 | + "type": "object", | ||
| 4910 | + "properties": { | ||
| 4911 | + "page": { | ||
| 4215 | "type": "integer", | 4912 | "type": "integer", |
| 4216 | - "format": "int64", | ||
| 4217 | - "description": " 标签id" | 4913 | + "format": "int32" |
| 4218 | }, | 4914 | }, |
| 4219 | - "tagImage": { | ||
| 4220 | - "type": "string", | ||
| 4221 | - "description": " 对应的图标" | 4915 | + "size": { |
| 4916 | + "type": "integer", | ||
| 4917 | + "format": "int32" | ||
| 4222 | }, | 4918 | }, |
| 4223 | - "tagName": { | 4919 | + "name": { |
| 4224 | "type": "string", | 4920 | "type": "string", |
| 4225 | - "description": " 标签名称" | 4921 | + "description": " 模板名称" |
| 4226 | }, | 4922 | }, |
| 4227 | - "tagRemark": { | 4923 | + "templateClass": { |
| 4228 | "type": "string", | 4924 | "type": "string", |
| 4229 | - "description": " 标签备注" | 4925 | + "description": " 模板分类" |
| 4230 | }, | 4926 | }, |
| 4231 | - "totalArticle": { | ||
| 4232 | - "type": "integer", | ||
| 4233 | - "format": "int32", | ||
| 4234 | - "description": " 总的文章数量" | ||
| 4235 | - }, | ||
| 4236 | - "readArticle": { | ||
| 4237 | - "type": "integer", | ||
| 4238 | - "format": "int32", | ||
| 4239 | - "description": " 已读的标签数量" | ||
| 4240 | - }, | ||
| 4241 | - "sortBy": { | ||
| 4242 | - "type": "integer", | ||
| 4243 | - "format": "int32", | ||
| 4244 | - "description": " 排序" | 4927 | + "target": { |
| 4928 | + "$ref": "#/definitions/int", | ||
| 4929 | + "description": " 目标 0 全员 1 指定人" | ||
| 4245 | } | 4930 | } |
| 4246 | }, | 4931 | }, |
| 4247 | - "title": "ArticleTagCount", | ||
| 4248 | - "required": [ | ||
| 4249 | - "tagCategory", | ||
| 4250 | - "tagId", | ||
| 4251 | - "tagImage", | ||
| 4252 | - "tagName", | ||
| 4253 | - "tagRemark", | ||
| 4254 | - "totalArticle", | ||
| 4255 | - "readArticle", | ||
| 4256 | - "sortBy" | ||
| 4257 | - ] | 4932 | + "title": "ArticleTemplateSearchRequest" |
| 4258 | }, | 4933 | }, |
| 4259 | - "ArticleTagGroup": { | 4934 | + "ArticleTemplateSearchResponse": { |
| 4260 | "type": "object", | 4935 | "type": "object", |
| 4261 | "properties": { | 4936 | "properties": { |
| 4262 | - "category": { | ||
| 4263 | - "type": "string" | ||
| 4264 | - }, | ||
| 4265 | - "tags": { | 4937 | + "list": { |
| 4266 | "type": "array", | 4938 | "type": "array", |
| 4267 | "items": { | 4939 | "items": { |
| 4268 | - "$ref": "#/definitions/ArticleTagItem" | 4940 | + "$ref": "#/definitions/ArticleTemplateItem" |
| 4269 | } | 4941 | } |
| 4942 | + }, | ||
| 4943 | + "total": { | ||
| 4944 | + "type": "integer", | ||
| 4945 | + "format": "int64" | ||
| 4270 | } | 4946 | } |
| 4271 | }, | 4947 | }, |
| 4272 | - "title": "ArticleTagGroup", | 4948 | + "title": "ArticleTemplateSearchResponse", |
| 4273 | "required": [ | 4949 | "required": [ |
| 4274 | - "category", | ||
| 4275 | - "tags" | 4950 | + "list", |
| 4951 | + "total" | ||
| 4276 | ] | 4952 | ] |
| 4277 | }, | 4953 | }, |
| 4278 | - "ArticleTagItem": { | 4954 | + "ArticleTemplateUpdateRequest": { |
| 4279 | "type": "object", | 4955 | "type": "object", |
| 4280 | "properties": { | 4956 | "properties": { |
| 4281 | "id": { | 4957 | "id": { |
| 4282 | "type": "integer", | 4958 | "type": "integer", |
| 4283 | "format": "int64" | 4959 | "format": "int64" |
| 4284 | }, | 4960 | }, |
| 4285 | - "category": { | ||
| 4286 | - "type": "string" | ||
| 4287 | - }, | ||
| 4288 | - "name": { | ||
| 4289 | - "type": "string" | ||
| 4290 | - }, | ||
| 4291 | - "image": { | ||
| 4292 | - "type": "string" | ||
| 4293 | - }, | ||
| 4294 | - "sortBy": { | ||
| 4295 | - "type": "integer", | ||
| 4296 | - "format": "int32" | 4961 | + "item": { |
| 4962 | + "$ref": "#/definitions/ArticleTemplateItem" | ||
| 4297 | } | 4963 | } |
| 4298 | }, | 4964 | }, |
| 4299 | - "title": "ArticleTagItem", | 4965 | + "title": "ArticleTemplateUpdateRequest", |
| 4300 | "required": [ | 4966 | "required": [ |
| 4301 | "id", | 4967 | "id", |
| 4302 | - "category", | ||
| 4303 | - "name", | ||
| 4304 | - "image", | ||
| 4305 | - "sortBy" | 4968 | + "item" |
| 4306 | ] | 4969 | ] |
| 4307 | }, | 4970 | }, |
| 4971 | + "ArticleTemplateUpdateResponse": { | ||
| 4972 | + "type": "object", | ||
| 4973 | + "title": "ArticleTemplateUpdateResponse" | ||
| 4974 | + }, | ||
| 4308 | "Auth": { | 4975 | "Auth": { |
| 4309 | "type": "object", | 4976 | "type": "object", |
| 4310 | "properties": { | 4977 | "properties": { |
| @@ -7716,6 +8383,49 @@ | @@ -7716,6 +8383,49 @@ | ||
| 7716 | "name" | 8383 | "name" |
| 7717 | ] | 8384 | ] |
| 7718 | }, | 8385 | }, |
| 8386 | + "Paragraph": { | ||
| 8387 | + "type": "object", | ||
| 8388 | + "properties": { | ||
| 8389 | + "id": { | ||
| 8390 | + "type": "string", | ||
| 8391 | + "description": " 唯一标识" | ||
| 8392 | + }, | ||
| 8393 | + "title": { | ||
| 8394 | + "type": "string", | ||
| 8395 | + "description": " 标题" | ||
| 8396 | + }, | ||
| 8397 | + "prompt": { | ||
| 8398 | + "type": "string", | ||
| 8399 | + "description": " 文本提示" | ||
| 8400 | + }, | ||
| 8401 | + "required": { | ||
| 8402 | + "type": "boolean", | ||
| 8403 | + "format": "boolean", | ||
| 8404 | + "description": " 必填" | ||
| 8405 | + }, | ||
| 8406 | + "type": { | ||
| 8407 | + "type": "integer", | ||
| 8408 | + "format": "int32", | ||
| 8409 | + "description": " 段落类型 1:文本 2:图片" | ||
| 8410 | + }, | ||
| 8411 | + "text": { | ||
| 8412 | + "type": "string", | ||
| 8413 | + "description": " 文本内容" | ||
| 8414 | + }, | ||
| 8415 | + "images": { | ||
| 8416 | + "type": "array", | ||
| 8417 | + "items": { | ||
| 8418 | + "type": "string" | ||
| 8419 | + }, | ||
| 8420 | + "description": " 图片地址列表" | ||
| 8421 | + } | ||
| 8422 | + }, | ||
| 8423 | + "title": "Paragraph", | ||
| 8424 | + "required": [ | ||
| 8425 | + "text", | ||
| 8426 | + "images" | ||
| 8427 | + ] | ||
| 8428 | + }, | ||
| 7719 | "Position": { | 8429 | "Position": { |
| 7720 | "type": "object", | 8430 | "type": "object", |
| 7721 | "properties": { | 8431 | "properties": { |
| @@ -11304,6 +12014,23 @@ | @@ -11304,6 +12014,23 @@ | ||
| 11304 | "options" | 12014 | "options" |
| 11305 | ] | 12015 | ] |
| 11306 | }, | 12016 | }, |
| 12017 | + "TargetUser": { | ||
| 12018 | + "type": "object", | ||
| 12019 | + "properties": { | ||
| 12020 | + "id": { | ||
| 12021 | + "type": "integer", | ||
| 12022 | + "format": "int64" | ||
| 12023 | + }, | ||
| 12024 | + "name": { | ||
| 12025 | + "type": "string" | ||
| 12026 | + } | ||
| 12027 | + }, | ||
| 12028 | + "title": "TargetUser", | ||
| 12029 | + "required": [ | ||
| 12030 | + "id", | ||
| 12031 | + "name" | ||
| 12032 | + ] | ||
| 12033 | + }, | ||
| 11307 | "UserFollowItem": { | 12034 | "UserFollowItem": { |
| 11308 | "type": "object", | 12035 | "type": "object", |
| 11309 | "properties": { | 12036 | "properties": { |
| 1 | +@server( | ||
| 2 | + prefix: v1/system | ||
| 3 | + group: template | ||
| 4 | + middleware: LoginStatusCheck,LogRequest | ||
| 5 | + jwt: SystemAuth | ||
| 6 | +) | ||
| 7 | +service Core { | ||
| 8 | + @doc "模板管理-详情" | ||
| 9 | + @handler systemArticleTemplateGet | ||
| 10 | + get /article_template/:id (ArticleTemplateGetRequest) returns (ArticleTemplateGetResponse) | ||
| 11 | + @doc "模板管理-保存" | ||
| 12 | + @handler systemArticleTemplateSave | ||
| 13 | + post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse) | ||
| 14 | + @doc "模板管理-删除" | ||
| 15 | + @handler systemArticleTemplateDelete | ||
| 16 | + delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse) | ||
| 17 | + @doc "模板管理-批量删除" | ||
| 18 | + @handler systemArticleTemplateBatchDelete | ||
| 19 | + delete /article_template/batch_delete (ArticleTemplateBatchDeleteRequest) returns (ArticleTemplateBatchResponse) | ||
| 20 | + @doc "模板管理-更新" | ||
| 21 | + @handler systemArticleTemplateUpdate | ||
| 22 | + put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse) | ||
| 23 | + @doc "模板管理-搜索" | ||
| 24 | + @handler systemArticleTemplateSearch | ||
| 25 | + post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse) | ||
| 26 | + @doc "模板管理-分类搜索" | ||
| 27 | + @handler systemArticleTemplateClassSearch | ||
| 28 | + post /article_template_class/search (ArticleTemplateClassSearchRequest) returns (ArticleTemplateClassSearchResponse) | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +@server( | ||
| 32 | + prefix: v1/mini | ||
| 33 | + group: template | ||
| 34 | + middleware: LogRequest | ||
| 35 | + jwt: MiniAuth | ||
| 36 | +) | ||
| 37 | +service Core { | ||
| 38 | + @doc "模板搜索" | ||
| 39 | + @handler miniArticleTemplateSearch | ||
| 40 | + post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse) | ||
| 41 | + @doc "我的模板搜索" | ||
| 42 | + @handler miniArticleTemplateSearchMine | ||
| 43 | + post /article_template/search-mine (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse) | ||
| 44 | + @doc "模板分类搜索" | ||
| 45 | + @handler miniArticleTemplateClassSearch | ||
| 46 | + post /article_template_class/search (ArticleTemplateClassSearchRequest) returns (ArticleTemplateClassSearchResponse) | ||
| 47 | + @doc "模板管理-保存" | ||
| 48 | + @handler miniArticleTemplateSave | ||
| 49 | + post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse) | ||
| 50 | + @doc "模板管理-删除" | ||
| 51 | + @handler miniArticleTemplateDelete | ||
| 52 | + delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse) | ||
| 53 | + @doc "模板管理-更新" | ||
| 54 | + @handler miniArticleTemplateUpdate | ||
| 55 | + put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse) | ||
| 56 | +} | ||
| 57 | + | ||
| 58 | +type ( | ||
| 59 | + ArticleTemplateGetRequest { | ||
| 60 | + Id int64 `path:"id"` | ||
| 61 | + } | ||
| 62 | + ArticleTemplateGetResponse struct{ | ||
| 63 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + ArticleTemplateSaveRequest struct{ | ||
| 67 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 68 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 69 | + BelongTo int `json:"belongTo,optional,default=2"` // 模板属于: 1:企业 、2:个人 | ||
| 70 | + } | ||
| 71 | + ArticleTemplateSaveResponse struct{} | ||
| 72 | + | ||
| 73 | + ArticleTemplateDeleteRequest struct{ | ||
| 74 | + Id int64 `path:"id"` | ||
| 75 | + } | ||
| 76 | + ArticleTemplateDeleteResponse struct{} | ||
| 77 | + | ||
| 78 | + ArticleTemplateBatchDeleteRequest struct{ | ||
| 79 | + Ids []int64 `json:"ids"` | ||
| 80 | + } | ||
| 81 | + ArticleTemplateBatchResponse struct{ | ||
| 82 | + | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + ArticleTemplateUpdateRequest struct{ | ||
| 86 | + Id int64 `path:"id"` | ||
| 87 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 88 | + } | ||
| 89 | + ArticleTemplateUpdateResponse struct{} | ||
| 90 | + | ||
| 91 | + ArticleTemplateSearchRequest struct{ | ||
| 92 | + Page int `json:"page,optional"` | ||
| 93 | + Size int `json:"size,optional"` | ||
| 94 | + Name string `json:"name,optional"` // 模板名称 | ||
| 95 | + TemplateClass string `json:"templateClass,optional"` // 模板分类 | ||
| 96 | + Target *int `json:"target,optional"` // 目标 0 全员 1 指定人 | ||
| 97 | +// BelongTos []int `json:"belongTos,optional"` // 归属 | ||
| 98 | + CompanyId int64 `json:",optional"` // 属于企业时有值 | ||
| 99 | + UserId int64 `json:",optional"` // 属于个人时有值 | ||
| 100 | + } | ||
| 101 | + ArticleTemplateSearchResponse{ | ||
| 102 | + List []ArticleTemplateItem `json:"list"` | ||
| 103 | + Total int64 `json:"total"` | ||
| 104 | + } | ||
| 105 | + ArticleTemplateClassSearchRequest struct{ | ||
| 106 | + Page int `json:"page,optional"` | ||
| 107 | + Size int `json:"size,optional"` | ||
| 108 | + Name string `json:"name,optional"` // 模板名称 | ||
| 109 | + CompanyId int64 `json:",optional"` // 属于企业时有值 | ||
| 110 | + UserId int64 `json:",optional"` // 属于个人时有值 | ||
| 111 | + } | ||
| 112 | + ArticleTemplateClassSearchResponse{ | ||
| 113 | + List []ArticleTemplateClassItem `json:"list"` | ||
| 114 | + Total int64 `json:"total"` | ||
| 115 | + } | ||
| 116 | + ArticleTemplateClassItem struct{ | ||
| 117 | + Name string `json:"name"` // 名称 | ||
| 118 | + } | ||
| 119 | + ArticleTemplateItem struct{ | ||
| 120 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
| 121 | + //CompanyId int64 `json:",optional"` // 属于企业时有值 | ||
| 122 | + //UserId int64 `json:",optional"` // 属于个人时有值 | ||
| 123 | + //BelongTo int `json:"belongTo,optional"` // 模板属于: 1:企业 、2:个人 | ||
| 124 | + Name string `json:"name"` // 模板名称 | ||
| 125 | + TemplateClass string `json:"templateClass"` // 模板分类 | ||
| 126 | + Paragraphs []Paragraph `json:"paragraphs"` // 段落列表 | ||
| 127 | + Icon string `json:"icon,optional"` // 图标地址 | ||
| 128 | + TargetWhoRead int `json:"targetWhoRead,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 129 | + TargetWhoReview int `json:"targetWhoReview,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 130 | + WhoRead []int64 `json:"whoRead,optional"` // 谁可以看 | ||
| 131 | + WhoReview []int64 `json:"whoReview,optional"` // 查看、评论人 | ||
| 132 | + WhoReadInfo []TargetUser `json:"whoReadInfo,optional"` // 谁可查看 | ||
| 133 | + WhoReviewInfo []TargetUser `json:"whoReviewInfo,optional"` // 谁可评论 | ||
| 134 | + Operator string `json:"operator,omitempty,optional"` // 操作人 | ||
| 135 | + UpdatedAt int64 `json:"updatedAt,omitempty,optional"` // 更新时间戳 | ||
| 136 | + } | ||
| 137 | + Paragraph struct { | ||
| 138 | + ID string `json:"id,optional"` // 唯一标识 | ||
| 139 | + Title string `json:"title,optional"` // 标题 | ||
| 140 | + Prompt string `json:"prompt,optional"` // 文本提示 | ||
| 141 | + Required bool `json:"required,optional"` // 必填 | ||
| 142 | + Type int `json:"type,optional"` // 段落类型 1:文本 2:图片 | ||
| 143 | + | ||
| 144 | + Text string `json:"text,optional,omitempty"` // 文本内容 | ||
| 145 | + Images []string `json:"images,optional,omitempty"` // 图片地址列表 | ||
| 146 | + } | ||
| 147 | + TargetUser struct{ | ||
| 148 | + Id int64 `json:"id"` | ||
| 149 | + Name string `json:"name"` | ||
| 150 | + } | ||
| 151 | +) |
| @@ -41,6 +41,8 @@ type ( | @@ -41,6 +41,8 @@ type ( | ||
| 41 | WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | 41 | WhoReview []int64 `json:"whoReview,optional"` //谁可评论 |
| 42 | Location Location `json:"location,optional"` //定位坐标 | 42 | Location Location `json:"location,optional"` //定位坐标 |
| 43 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 43 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 44 | + | ||
| 45 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 44 | } | 46 | } |
| 45 | MiniArticleCreateResponse { | 47 | MiniArticleCreateResponse { |
| 46 | Id int64 `json:"id"` | 48 | Id int64 `json:"id"` |
| @@ -81,6 +83,9 @@ type ( | @@ -81,6 +83,9 @@ type ( | ||
| 81 | Content string `json:"content"` // 文本内容 | 83 | Content string `json:"content"` // 文本内容 |
| 82 | SortBy int `json:"sortBy"` // 排序 | 84 | SortBy int `json:"sortBy"` // 排序 |
| 83 | TotalComment int `json:"totalComment"` // 评论的数量 | 85 | TotalComment int `json:"totalComment"` // 评论的数量 |
| 86 | + Images []string `json:"images"` // 照片列表 | ||
| 87 | + ParagraphType int `json:"paragraphType"` // 段落类型 0:无样式 1:模板文本 2:模板图片 | ||
| 88 | + ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板 | ||
| 84 | } | 89 | } |
| 85 | ) | 90 | ) |
| 86 | 91 | ||
| @@ -261,6 +266,8 @@ type ( | @@ -261,6 +266,8 @@ type ( | ||
| 261 | WhoReview []int64 `json:"whoReview"` // 评论人 | 266 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 262 | Location Location `json:"location"` // 坐标 | 267 | Location Location `json:"location"` // 坐标 |
| 263 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 268 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 269 | + | ||
| 270 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 264 | } | 271 | } |
| 265 | 272 | ||
| 266 | MiniArticleDraftCreateResponse { | 273 | MiniArticleDraftCreateResponse { |
| @@ -282,6 +289,8 @@ type ( | @@ -282,6 +289,8 @@ type ( | ||
| 282 | WhoReview []int64 `json:"whoReview"` // 评论人 | 289 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 283 | Location Location `json:"location"` // 坐标 | 290 | Location Location `json:"location"` // 坐标 |
| 284 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 291 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 292 | + | ||
| 293 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 285 | } | 294 | } |
| 286 | 295 | ||
| 287 | MiniArticleDraftUpdateResponse { | 296 | MiniArticleDraftUpdateResponse { |
| @@ -519,6 +528,8 @@ type ( | @@ -519,6 +528,8 @@ type ( | ||
| 519 | MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | 528 | MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 |
| 520 | ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | 529 | ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID |
| 521 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token | 530 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token |
| 531 | + | ||
| 532 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 522 | } | 533 | } |
| 523 | SystemArticleCreateResponse { | 534 | SystemArticleCreateResponse { |
| 524 | Id int64 `json:"id"` //id | 535 | Id int64 `json:"id"` //id |
| @@ -13,6 +13,7 @@ import ( | @@ -13,6 +13,7 @@ import ( | ||
| 13 | role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role" | 13 | role "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/role" |
| 14 | secuirty "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/secuirty" | 14 | secuirty "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/secuirty" |
| 15 | tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags" | 15 | tags "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/tags" |
| 16 | + template "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/template" | ||
| 16 | user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user" | 17 | user "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/handler/user" |
| 17 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 18 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| 18 | 19 | ||
| @@ -835,4 +836,89 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | @@ -835,4 +836,89 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { | ||
| 835 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | 836 | rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), |
| 836 | rest.WithPrefix("/v1/system"), | 837 | rest.WithPrefix("/v1/system"), |
| 837 | ) | 838 | ) |
| 839 | + | ||
| 840 | + server.AddRoutes( | ||
| 841 | + rest.WithMiddlewares( | ||
| 842 | + []rest.Middleware{serverCtx.LoginStatusCheck, serverCtx.LogRequest}, | ||
| 843 | + []rest.Route{ | ||
| 844 | + { | ||
| 845 | + Method: http.MethodGet, | ||
| 846 | + Path: "/article_template/:id", | ||
| 847 | + Handler: template.SystemArticleTemplateGetHandler(serverCtx), | ||
| 848 | + }, | ||
| 849 | + { | ||
| 850 | + Method: http.MethodPost, | ||
| 851 | + Path: "/article_template", | ||
| 852 | + Handler: template.SystemArticleTemplateSaveHandler(serverCtx), | ||
| 853 | + }, | ||
| 854 | + { | ||
| 855 | + Method: http.MethodDelete, | ||
| 856 | + Path: "/article_template/:id", | ||
| 857 | + Handler: template.SystemArticleTemplateDeleteHandler(serverCtx), | ||
| 858 | + }, | ||
| 859 | + { | ||
| 860 | + Method: http.MethodDelete, | ||
| 861 | + Path: "/article_template/batch_delete", | ||
| 862 | + Handler: template.SystemArticleTemplateBatchDeleteHandler(serverCtx), | ||
| 863 | + }, | ||
| 864 | + { | ||
| 865 | + Method: http.MethodPut, | ||
| 866 | + Path: "/article_template/:id", | ||
| 867 | + Handler: template.SystemArticleTemplateUpdateHandler(serverCtx), | ||
| 868 | + }, | ||
| 869 | + { | ||
| 870 | + Method: http.MethodPost, | ||
| 871 | + Path: "/article_template/search", | ||
| 872 | + Handler: template.SystemArticleTemplateSearchHandler(serverCtx), | ||
| 873 | + }, | ||
| 874 | + { | ||
| 875 | + Method: http.MethodPost, | ||
| 876 | + Path: "/article_template_class/search", | ||
| 877 | + Handler: template.SystemArticleTemplateClassSearchHandler(serverCtx), | ||
| 878 | + }, | ||
| 879 | + }..., | ||
| 880 | + ), | ||
| 881 | + rest.WithJwt(serverCtx.Config.SystemAuth.AccessSecret), | ||
| 882 | + rest.WithPrefix("/v1/system"), | ||
| 883 | + ) | ||
| 884 | + | ||
| 885 | + server.AddRoutes( | ||
| 886 | + rest.WithMiddlewares( | ||
| 887 | + []rest.Middleware{serverCtx.LogRequest}, | ||
| 888 | + []rest.Route{ | ||
| 889 | + { | ||
| 890 | + Method: http.MethodPost, | ||
| 891 | + Path: "/article_template/search", | ||
| 892 | + Handler: template.MiniArticleTemplateSearchHandler(serverCtx), | ||
| 893 | + }, | ||
| 894 | + { | ||
| 895 | + Method: http.MethodPost, | ||
| 896 | + Path: "/article_template/search-mine", | ||
| 897 | + Handler: template.MiniArticleTemplateSearchMineHandler(serverCtx), | ||
| 898 | + }, | ||
| 899 | + { | ||
| 900 | + Method: http.MethodPost, | ||
| 901 | + Path: "/article_template_class/search", | ||
| 902 | + Handler: template.MiniArticleTemplateClassSearchHandler(serverCtx), | ||
| 903 | + }, | ||
| 904 | + { | ||
| 905 | + Method: http.MethodPost, | ||
| 906 | + Path: "/article_template", | ||
| 907 | + Handler: template.MiniArticleTemplateSaveHandler(serverCtx), | ||
| 908 | + }, | ||
| 909 | + { | ||
| 910 | + Method: http.MethodDelete, | ||
| 911 | + Path: "/article_template/:id", | ||
| 912 | + Handler: template.MiniArticleTemplateDeleteHandler(serverCtx), | ||
| 913 | + }, | ||
| 914 | + { | ||
| 915 | + Method: http.MethodPut, | ||
| 916 | + Path: "/article_template/:id", | ||
| 917 | + Handler: template.MiniArticleTemplateUpdateHandler(serverCtx), | ||
| 918 | + }, | ||
| 919 | + }..., | ||
| 920 | + ), | ||
| 921 | + rest.WithJwt(serverCtx.Config.MiniAuth.AccessSecret), | ||
| 922 | + rest.WithPrefix("/v1/mini"), | ||
| 923 | + ) | ||
| 838 | } | 924 | } |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateClassSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateClassSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateClassSearchLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateClassSearch(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateDeleteRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateDeleteLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateDelete(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateSaveRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateSaveLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateSave(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateSearchLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateSearch(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateSearchMineHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateSearchMineLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateSearchMine(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func MiniArticleTemplateUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateUpdateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewMiniArticleTemplateUpdateLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.MiniArticleTemplateUpdate(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
cmd/discuss/api/internal/handler/template/system_article_template_batch_delete_handler.go
0 → 100644
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateBatchDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateBatchDeleteRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateBatchDeleteLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateBatchDelete(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
cmd/discuss/api/internal/handler/template/system_article_template_class_search_handler.go
0 → 100644
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateClassSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateClassSearchRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateClassSearchLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateClassSearch(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateDeleteHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateDeleteRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateDeleteLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateDelete(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateGetHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateGetRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateGetLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateGet(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateSaveHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateSaveRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateSaveLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateSave(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 6 | + "net/http" | ||
| 7 | + | ||
| 8 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +func SystemArticleTemplateSearchHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 15 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 16 | + var req types.ArticleTemplateSearchRequest | ||
| 17 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 18 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 19 | + return | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + l := template.NewSystemArticleTemplateSearchLogic(r.Context(), svcCtx) | ||
| 23 | + userToken := contextdata.GetUserTokenFromCtx(r.Context()) | ||
| 24 | + req.CompanyId = userToken.CompanyId | ||
| 25 | + resp, err := l.SystemArticleTemplateSearch(&req) | ||
| 26 | + result.HttpResult(r, w, resp, err) | ||
| 27 | + } | ||
| 28 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result" | ||
| 5 | + "net/http" | ||
| 6 | + | ||
| 7 | + "github.com/zeromicro/go-zero/rest/httpx" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/template" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +func SystemArticleTemplateUpdateHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
| 14 | + return func(w http.ResponseWriter, r *http.Request) { | ||
| 15 | + var req types.ArticleTemplateUpdateRequest | ||
| 16 | + if err := httpx.Parse(r, &req); err != nil { | ||
| 17 | + httpx.ErrorCtx(r.Context(), w, err) | ||
| 18 | + return | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + l := template.NewSystemArticleTemplateUpdateLogic(r.Context(), svcCtx) | ||
| 22 | + resp, err := l.SystemArticleTemplateUpdate(&req) | ||
| 23 | + result.HttpResult(r, w, resp, err) | ||
| 24 | + } | ||
| 25 | +} |
| @@ -54,6 +54,7 @@ func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArti | @@ -54,6 +54,7 @@ func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArti | ||
| 54 | Descript: req.Location.Descript, | 54 | Descript: req.Location.Descript, |
| 55 | }, | 55 | }, |
| 56 | MatchUrl: map[string]string{}, | 56 | MatchUrl: map[string]string{}, |
| 57 | + Section: NewArticleSectionFromParagraphs(req.Paragraphs, req.CompanyId, 0), | ||
| 57 | } | 58 | } |
| 58 | for _, val := range req.Images { | 59 | for _, val := range req.Images { |
| 59 | newDraft.Images = append(newDraft.Images, domain.Image{ | 60 | newDraft.Images = append(newDraft.Images, domain.Image{ |
| @@ -129,6 +129,202 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | @@ -129,6 +129,202 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR | ||
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | //切分文章分段 | 131 | //切分文章分段 |
| 132 | + sectionList := NewArticleSectionFromParagraphs(req.Paragraphs, author.CompanyId, 0) | ||
| 133 | + //newStr := "" | ||
| 134 | + //for _, paragraph := range req.Paragraphs { | ||
| 135 | + // strList := []string{paragraph.Text} | ||
| 136 | + // // 无模板样式的 | ||
| 137 | + // if paragraph.Type == 0 { | ||
| 138 | + // strList = strings.Split(paragraph.Text, "\n") | ||
| 139 | + // } | ||
| 140 | + // for i2 := range strList { | ||
| 141 | + // newStr = template.HTMLEscapeString(strList[i2]) | ||
| 142 | + // newSection := domain.ArticleSection{ | ||
| 143 | + // Id: 0, | ||
| 144 | + // CompanyId: author.CompanyId, | ||
| 145 | + // ArticleId: 0, | ||
| 146 | + // Content: newStr, | ||
| 147 | + // SortBy: len(sectionList), | ||
| 148 | + // TotalComment: 0, | ||
| 149 | + // | ||
| 150 | + // Images: paragraph.Images, | ||
| 151 | + // ParagraphType: paragraph.Type, | ||
| 152 | + // ParagraphTemplate: core.NewDomainParagraph(paragraph), | ||
| 153 | + // } | ||
| 154 | + // sectionList = append(sectionList, &newSection) | ||
| 155 | + // } | ||
| 156 | + //} | ||
| 157 | + | ||
| 158 | + newArticle := &domain.Article{ | ||
| 159 | + Id: 0, | ||
| 160 | + CompanyId: author.CompanyId, | ||
| 161 | + AuthorId: author.Id, | ||
| 162 | + Author: articleAuthor, | ||
| 163 | + Title: req.Title, | ||
| 164 | + Images: images, | ||
| 165 | + WhoRead: whoRead, | ||
| 166 | + WhoReview: whoReview, | ||
| 167 | + Location: domain.Location{ | ||
| 168 | + Longitude: req.Location.Longitude, | ||
| 169 | + Latitude: req.Location.Latitude, | ||
| 170 | + Descript: req.Location.Descript, | ||
| 171 | + }, | ||
| 172 | + TargetUser: domain.ArticleTargetAll, | ||
| 173 | + CountLove: 0, | ||
| 174 | + CountComment: 0, | ||
| 175 | + CountRead: 0, | ||
| 176 | + Show: domain.ArticleShowEnable, | ||
| 177 | + Tags: []int64{}, | ||
| 178 | + MatchUrl: map[string]string{}, | ||
| 179 | + Videos: []domain.Video{}, | ||
| 180 | + } | ||
| 181 | + if len(whoRead) > 0 { | ||
| 182 | + newArticle.TargetUser = domain.ArticleTargetLimit | ||
| 183 | + } | ||
| 184 | + for k, v := range req.MatchUrl { | ||
| 185 | + newArticle.MatchUrl[k] = v | ||
| 186 | + } | ||
| 187 | + //设置内容概要 | ||
| 188 | + newArticle.SetSummary(sectionList) | ||
| 189 | + | ||
| 190 | + err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error { | ||
| 191 | + newArticle, err = l.svcCtx.ArticleRepository.Insert(ctx, c, newArticle) | ||
| 192 | + if err != nil { | ||
| 193 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + for i := range sectionList { | ||
| 197 | + sectionList[i].ArticleId = newArticle.Id | ||
| 198 | + _, err = l.svcCtx.ArticleSectionRepository.Insert(ctx, c, sectionList[i]) | ||
| 199 | + if err != nil { | ||
| 200 | + return xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 201 | + } | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + // 生成 备份数据 | ||
| 205 | + var backupData domain.ArticleBackup | ||
| 206 | + backupData.MakeBackup(articleAuthor, newArticle, sectionList, "原始版本") | ||
| 207 | + _, err = l.svcCtx.ArticleBackupRepository.Insert(l.ctx, conn, &backupData) | ||
| 208 | + if err != nil { | ||
| 209 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + //发送订阅消息 | ||
| 213 | + err = message.NewMiniSubscribeLogic(l.ctx, l.svcCtx).FollowArticle(conn, newArticle) | ||
| 214 | + if err != nil { | ||
| 215 | + return xerr.NewErrMsgErr("创建文章失败", err) | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + // 内容安全检查 | ||
| 219 | + if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, c, author, core.NewContentFromArticle(newArticle, sectionList)); err != nil { | ||
| 220 | + return err | ||
| 221 | + } | ||
| 222 | + return nil | ||
| 223 | + }, true) | ||
| 224 | + if err != nil { | ||
| 225 | + return nil, xerr.NewErrMsgErr("创建文章失败", err) | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + resp = &types.MiniArticleCreateResponse{ | ||
| 229 | + Id: newArticle.Id, | ||
| 230 | + } | ||
| 231 | + return | ||
| 232 | +} | ||
| 233 | + | ||
| 234 | +func (l *MiniCreateArticleLogic) MiniCreateArticleBak(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) { | ||
| 235 | + var conn = l.svcCtx.DefaultDBConn() | ||
| 236 | + err = l.validateTextLimit(req) | ||
| 237 | + if err != nil { | ||
| 238 | + return nil, err | ||
| 239 | + } | ||
| 240 | + // 检查发布人 | ||
| 241 | + author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId) | ||
| 242 | + if err != nil { | ||
| 243 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 244 | + } | ||
| 245 | + companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, author.CompanyId) | ||
| 246 | + if err != nil { | ||
| 247 | + return nil, xerr.NewErrMsgErr("创建文章内容失败", err) | ||
| 248 | + } | ||
| 249 | + articleAuthor := domain.UserSimple{ | ||
| 250 | + Id: author.Id, | ||
| 251 | + Name: author.Name, | ||
| 252 | + Avatar: author.Avatar, | ||
| 253 | + Position: author.Position, | ||
| 254 | + Company: companyInfo.Name, | ||
| 255 | + CompanyId: author.CompanyId, | ||
| 256 | + } | ||
| 257 | + if len(req.Images) > 9 { | ||
| 258 | + return nil, xerr.NewErrMsg("图片数量最多9张") | ||
| 259 | + } | ||
| 260 | + //获取图片的尺寸大小 | ||
| 261 | + images := []domain.Image{} | ||
| 262 | + for _, val := range req.Images { | ||
| 263 | + fInfo, _ := oss.GetImageInfo(val) | ||
| 264 | + w, _ := strconv.Atoi(fInfo.ImageWidth.Value) | ||
| 265 | + h, _ := strconv.Atoi(fInfo.ImageHeight.Value) | ||
| 266 | + images = append(images, domain.Image{ | ||
| 267 | + Url: val, | ||
| 268 | + Width: w, | ||
| 269 | + Height: h, | ||
| 270 | + }) | ||
| 271 | + } | ||
| 272 | + | ||
| 273 | + //检查文章可被哪些人查看 | ||
| 274 | + whoRead := []int64{} | ||
| 275 | + if len(req.WhoRead) > 0 { | ||
| 276 | + whoRead = lo.Uniq(req.WhoRead) | ||
| 277 | + var u *domain.User | ||
| 278 | + for _, val := range whoRead { | ||
| 279 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val) | ||
| 280 | + if err != nil { | ||
| 281 | + return nil, xerr.NewErrMsgErr("文章可查看人设置错误", err) | ||
| 282 | + } | ||
| 283 | + if u.CompanyId != author.CompanyId { | ||
| 284 | + return nil, xerr.NewErrMsg("文章可查看人设置错误") | ||
| 285 | + } | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | + //检查文章可被哪些人评论 | ||
| 289 | + whoReview := []int64{} | ||
| 290 | + if len(req.WhoReview) > 0 { | ||
| 291 | + whoReview = lo.Uniq(req.WhoReview) | ||
| 292 | + } | ||
| 293 | + //有指定可查看人的情况 | ||
| 294 | + if len(whoRead) > 0 { | ||
| 295 | + if len(whoReview) > 0 { | ||
| 296 | + // 检查 whoRead 是否 完全包含 whoReview | ||
| 297 | + ok := lo.Every(whoRead, whoReview) | ||
| 298 | + if !ok { | ||
| 299 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
| 300 | + } | ||
| 301 | + } | ||
| 302 | + if len(whoReview) == 0 { | ||
| 303 | + //有指定可查看人 ,但未指定可评论人 | ||
| 304 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + //没有指定可查看人的情况 | ||
| 308 | + if len(whoRead) == 0 { | ||
| 309 | + if len(whoReview) > 0 { | ||
| 310 | + // 未指定可查看人(全员可看),有指定可评论人, | ||
| 311 | + var u *domain.User | ||
| 312 | + for _, val := range whoReview { | ||
| 313 | + u, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, val) | ||
| 314 | + if err != nil { | ||
| 315 | + return nil, xerr.NewErrMsgErr("文章可评论人设置错误", err) | ||
| 316 | + } | ||
| 317 | + if u.CompanyId != author.CompanyId { | ||
| 318 | + return nil, xerr.NewErrMsg("文章可评论人设置错误") | ||
| 319 | + } | ||
| 320 | + } | ||
| 321 | + } | ||
| 322 | + // if len(whoReview) == 0 { | ||
| 323 | + // 未指定可查看人(全员可看),未指定可评论人 ,忽略判断 | ||
| 324 | + // } | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + //切分文章分段 | ||
| 132 | sectionList := []*domain.ArticleSection{} | 328 | sectionList := []*domain.ArticleSection{} |
| 133 | newStr := "" | 329 | newStr := "" |
| 134 | for i := range req.Section { | 330 | for i := range req.Section { |
| @@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core" | ||
| 5 | "sort" | 6 | "sort" |
| 6 | 7 | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" |
| @@ -106,6 +107,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | @@ -106,6 +107,9 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) ( | ||
| 106 | Content: val.Content, | 107 | Content: val.Content, |
| 107 | SortBy: val.SortBy, | 108 | SortBy: val.SortBy, |
| 108 | TotalComment: val.TotalComment, | 109 | TotalComment: val.TotalComment, |
| 110 | + Images: val.Images, | ||
| 111 | + ParagraphTemplate: core.NewTypesParagraph(val.ParagraphTemplate), | ||
| 112 | + ParagraphType: val.ParagraphType, | ||
| 109 | }) | 113 | }) |
| 110 | } | 114 | } |
| 111 | resp = &types.MiniArticleGetResponse{ | 115 | resp = &types.MiniArticleGetResponse{ |
| @@ -62,6 +62,7 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti | @@ -62,6 +62,7 @@ func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArti | ||
| 62 | for k, v := range req.MatchUrl { | 62 | for k, v := range req.MatchUrl { |
| 63 | draftInfo.MatchUrl[k] = v | 63 | draftInfo.MatchUrl[k] = v |
| 64 | } | 64 | } |
| 65 | + draftInfo.Section = NewArticleSectionFromParagraphs(req.Paragraphs, req.CompanyId, 0) | ||
| 65 | _, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo) | 66 | _, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo) |
| 66 | if err != nil { | 67 | if err != nil { |
| 67 | return nil, xerr.NewErrMsgErr("更新草稿失败", err) | 68 | return nil, xerr.NewErrMsgErr("更新草稿失败", err) |
| @@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
| 4 | "context" | 4 | "context" |
| 5 | "github.com/pkg/errors" | 5 | "github.com/pkg/errors" |
| 6 | "github.com/samber/lo" | 6 | "github.com/samber/lo" |
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core" | ||
| 7 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" | 8 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message" |
| 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/db/transaction" |
| 9 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" |
| @@ -11,6 +12,7 @@ import ( | @@ -11,6 +12,7 @@ import ( | ||
| 11 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" |
| 12 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" | 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss" |
| 13 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | 14 | "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" |
| 15 | + "html/template" | ||
| 14 | "strconv" | 16 | "strconv" |
| 15 | "strings" | 17 | "strings" |
| 16 | "unicode/utf8" | 18 | "unicode/utf8" |
| @@ -115,7 +117,7 @@ func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleC | @@ -115,7 +117,7 @@ func (l *SystemCreateArticleLogic) SystemCreateArticle(req *types.SystemArticleC | ||
| 115 | } | 117 | } |
| 116 | article.WhoRead = whoRead | 118 | article.WhoRead = whoRead |
| 117 | article.WhoReview = whoReview | 119 | article.WhoReview = whoReview |
| 118 | - sections := l.getSections(req, article) | 120 | + sections := NewArticleSectionFromParagraphs(req.Paragraphs, author.CompanyId, 0) //l.getSections(req, article) |
| 119 | //设置内容摘要 | 121 | //设置内容摘要 |
| 120 | article.SetSummary(sections) | 122 | article.SetSummary(sections) |
| 121 | //草稿ID | 123 | //草稿ID |
| @@ -296,17 +298,54 @@ func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview | @@ -296,17 +298,54 @@ func (l *SystemCreateArticleLogic) validateWhoReview(whoRead []int64, whoReview | ||
| 296 | func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection { | 298 | func (l *SystemCreateArticleLogic) getSections(req *types.SystemArticleCreateRequest, article *domain.Article) []*domain.ArticleSection { |
| 297 | articleSections := make([]*domain.ArticleSection, 0) | 299 | articleSections := make([]*domain.ArticleSection, 0) |
| 298 | sortBy := 1 | 300 | sortBy := 1 |
| 299 | - sections := strings.Split(req.Content, "\n") | ||
| 300 | - lo.ForEach(sections, func(item string, index int) { | 301 | + lo.ForEach(req.Paragraphs, func(paragraph types.Paragraph, index int) { |
| 301 | //去除空 | 302 | //去除空 |
| 302 | - item = strings.TrimSpace(item) | ||
| 303 | - if item != "" { | 303 | + strList := []string{paragraph.Text} |
| 304 | + // 无模板样式的 | ||
| 305 | + if paragraph.Type == 0 { | ||
| 306 | + strList = strings.Split(paragraph.Text, "\n") | ||
| 307 | + } | ||
| 308 | + for i2 := range strList { | ||
| 309 | + newStr := template.HTMLEscapeString(strList[i2]) | ||
| 304 | section := domain.ArticleSection{ | 310 | section := domain.ArticleSection{ |
| 305 | CompanyId: article.CompanyId, | 311 | CompanyId: article.CompanyId, |
| 306 | Version: article.Version, | 312 | Version: article.Version, |
| 307 | ArticleId: article.Id, | 313 | ArticleId: article.Id, |
| 308 | - Content: item, | 314 | + Content: newStr, |
| 309 | SortBy: sortBy, | 315 | SortBy: sortBy, |
| 316 | + | ||
| 317 | + Images: paragraph.Images, | ||
| 318 | + ParagraphType: paragraph.Type, | ||
| 319 | + ParagraphTemplate: core.NewDomainParagraph(paragraph), | ||
| 320 | + } | ||
| 321 | + articleSections = append(articleSections, §ion) | ||
| 322 | + sortBy++ | ||
| 323 | + } | ||
| 324 | + }) | ||
| 325 | + return articleSections | ||
| 326 | +} | ||
| 327 | + | ||
| 328 | +func NewArticleSectionFromParagraphs(paragraphs []types.Paragraph, companyId int64, articleId int64) []*domain.ArticleSection { | ||
| 329 | + articleSections := make([]*domain.ArticleSection, 0) | ||
| 330 | + sortBy := 1 | ||
| 331 | + lo.ForEach(paragraphs, func(paragraph types.Paragraph, index int) { | ||
| 332 | + //去除空 | ||
| 333 | + strList := []string{paragraph.Text} | ||
| 334 | + // 无模板样式的 | ||
| 335 | + if paragraph.Type == 0 { | ||
| 336 | + strList = strings.Split(paragraph.Text, "\n") | ||
| 337 | + } | ||
| 338 | + for i2 := range strList { | ||
| 339 | + newStr := template.HTMLEscapeString(strList[i2]) | ||
| 340 | + section := domain.ArticleSection{ | ||
| 341 | + CompanyId: companyId, | ||
| 342 | + ArticleId: articleId, | ||
| 343 | + Content: newStr, | ||
| 344 | + SortBy: sortBy, | ||
| 345 | + | ||
| 346 | + Images: paragraph.Images, | ||
| 347 | + ParagraphType: paragraph.Type, | ||
| 348 | + ParagraphTemplate: core.NewDomainParagraph(paragraph), | ||
| 310 | } | 349 | } |
| 311 | articleSections = append(articleSections, §ion) | 350 | articleSections = append(articleSections, §ion) |
| 312 | sortBy++ | 351 | sortBy++ |
| @@ -2,6 +2,7 @@ package article | @@ -2,6 +2,7 @@ package article | ||
| 2 | 2 | ||
| 3 | import ( | 3 | import ( |
| 4 | "context" | 4 | "context" |
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core" | ||
| 5 | "strconv" | 6 | "strconv" |
| 6 | "unicode/utf8" | 7 | "unicode/utf8" |
| 7 | 8 | ||
| @@ -139,6 +140,9 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | @@ -139,6 +140,9 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU | ||
| 139 | section.ArticleId = item.ArticleId | 140 | section.ArticleId = item.ArticleId |
| 140 | section.Version = item.Version | 141 | section.Version = item.Version |
| 141 | section.SortBy = item.SortBy | 142 | section.SortBy = item.SortBy |
| 143 | + section.Images = item.Images | ||
| 144 | + section.ParagraphType = item.ParagraphType | ||
| 145 | + section.ParagraphTemplate = item.ParagraphTemplate | ||
| 142 | section.CompanyId = item.CompanyId | 146 | section.CompanyId = item.CompanyId |
| 143 | _, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section) | 147 | _, err = l.svcCtx.ArticleSectionRepository.Update(ctx, c, section) |
| 144 | if err != nil { | 148 | if err != nil { |
| @@ -332,6 +336,9 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq | @@ -332,6 +336,9 @@ func (l *SystemUpdateArticleLogic) getSections(req *types.SystemArticleUpdateReq | ||
| 332 | ArticleId: article.Id, | 336 | ArticleId: article.Id, |
| 333 | Content: value, | 337 | Content: value, |
| 334 | SortBy: sortBy, | 338 | SortBy: sortBy, |
| 339 | + Images: item.Images, | ||
| 340 | + ParagraphType: item.ParagraphType, | ||
| 341 | + ParagraphTemplate: core.NewDomainParagraph(item.ParagraphTemplate), | ||
| 335 | } | 342 | } |
| 336 | if key == 0 { | 343 | if key == 0 { |
| 337 | section.Id = item.Id | 344 | section.Id = item.Id |
| 1 | +package core | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "github.com/google/uuid" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | +) | ||
| 8 | + | ||
| 9 | +func NewDomainParagraph(item types.Paragraph) domain.Paragraph { | ||
| 10 | + id := item.ID | ||
| 11 | + if item.ID == "" { | ||
| 12 | + idGen, _ := uuid.NewUUID() | ||
| 13 | + id = idGen.String() | ||
| 14 | + } | ||
| 15 | + return domain.Paragraph{ | ||
| 16 | + ID: id, | ||
| 17 | + Title: item.Title, | ||
| 18 | + Prompt: item.Prompt, | ||
| 19 | + Required: item.Required, | ||
| 20 | + Type: item.Type, | ||
| 21 | + } | ||
| 22 | +} | ||
| 23 | + | ||
| 24 | +func NewTypesParagraph(item domain.Paragraph) types.Paragraph { | ||
| 25 | + return types.Paragraph{ | ||
| 26 | + ID: item.ID, | ||
| 27 | + Title: item.Title, | ||
| 28 | + Prompt: item.Prompt, | ||
| 29 | + Required: item.Required, | ||
| 30 | + Type: item.Type, | ||
| 31 | + } | ||
| 32 | +} |
| 1 | +package template | ||
| 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 MiniArticleTemplateClassSearchLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewMiniArticleTemplateClassSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateClassSearchLogic { | ||
| 23 | + return &MiniArticleTemplateClassSearchLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *MiniArticleTemplateClassSearchLogic) MiniArticleTemplateClassSearch(req *types.ArticleTemplateClassSearchRequest) (resp *types.ArticleTemplateClassSearchResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + dms []*domain.ArticleTemplate | ||
| 34 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 35 | + user *domain.User | ||
| 36 | + ) | ||
| 37 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil { | ||
| 38 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 39 | + } | ||
| 40 | + // 企业有的类目 | ||
| 41 | + queryOptions := domain.NewQueryOptions().WithKV("name", req.Name). | ||
| 42 | + MustWithKV("companyId", userToken.CompanyId) | ||
| 43 | + _, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions) | ||
| 44 | + class := domain.Values(dms, func(item *domain.ArticleTemplate) string { | ||
| 45 | + return item.TemplateClass | ||
| 46 | + }) | ||
| 47 | + | ||
| 48 | + // 个人有的类目 | ||
| 49 | + queryOptions = domain.NewQueryOptions().WithKV("name", req.Name). | ||
| 50 | + MustWithKV("userId", user.Id) | ||
| 51 | + _, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions) | ||
| 52 | + class = append(class, domain.Values(dms, func(item *domain.ArticleTemplate) string { | ||
| 53 | + return item.TemplateClass | ||
| 54 | + })...) | ||
| 55 | + class = lo.Uniq(class) | ||
| 56 | + | ||
| 57 | + resp = &types.ArticleTemplateClassSearchResponse{ | ||
| 58 | + Total: int64(len(class)), | ||
| 59 | + } | ||
| 60 | + lo.ForEach(class, func(item string, index int) { | ||
| 61 | + resp.List = append(resp.List, types.ArticleTemplateClassItem{ | ||
| 62 | + Name: item, | ||
| 63 | + }) | ||
| 64 | + }) | ||
| 65 | + | ||
| 66 | + return | ||
| 67 | +} |
| 1 | +package template | ||
| 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 MiniArticleTemplateDeleteLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewMiniArticleTemplateDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateDeleteLogic { | ||
| 19 | + return &MiniArticleTemplateDeleteLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *MiniArticleTemplateDeleteLogic) MiniArticleTemplateDelete(req *types.ArticleTemplateDeleteRequest) (resp *types.ArticleTemplateDeleteResponse, err error) { | ||
| 27 | + logic := NewSystemArticleTemplateDeleteLogic(l.ctx, l.svcCtx) | ||
| 28 | + return logic.SystemArticleTemplateDelete(req) | ||
| 29 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type MiniArticleTemplateSaveLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewMiniArticleTemplateSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSaveLogic { | ||
| 23 | + return &MiniArticleTemplateSaveLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *MiniArticleTemplateSaveLogic) MiniArticleTemplateSave(req *types.ArticleTemplateSaveRequest) (resp *types.ArticleTemplateSaveResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + dm *domain.ArticleTemplate | ||
| 33 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 34 | + user *domain.User | ||
| 35 | + conn = l.svcCtx.DefaultDBConn() | ||
| 36 | + ) | ||
| 37 | + | ||
| 38 | + // 唯一判断 | ||
| 39 | + // 获取当前用户信息 | ||
| 40 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil { | ||
| 41 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + dm = NewDomainArticleTemplate(req.ArticleTemplate) | ||
| 45 | + dm.CompanyId = 0 | ||
| 46 | + | ||
| 47 | + dm.Operator = domain.Operator{ | ||
| 48 | + Id: userToken.UserId, | ||
| 49 | + Name: user.Name, | ||
| 50 | + Type: 2, | ||
| 51 | + } | ||
| 52 | + if req.BelongTo == int(domain.BelongToCompany) { | ||
| 53 | + dm.BelongTo = domain.BelongToCompany | ||
| 54 | + dm.CompanyId = user.CompanyId | ||
| 55 | + } else { | ||
| 56 | + dm.BelongTo = domain.BelongToIndividual | ||
| 57 | + dm.UserId = userToken.UserId | ||
| 58 | + } | ||
| 59 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 60 | + dm, err = l.svcCtx.ArticleTemplateRepository.Insert(l.ctx, conn, dm) | ||
| 61 | + return err | ||
| 62 | + }, true); err != nil { | ||
| 63 | + return nil, xerr.NewErrMsg("保存失败") | ||
| 64 | + } | ||
| 65 | + resp = &types.ArticleTemplateSaveResponse{} | ||
| 66 | + return | ||
| 67 | +} |
| 1 | +package template | ||
| 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 MiniArticleTemplateSearchLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewMiniArticleTemplateSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSearchLogic { | ||
| 23 | + return &MiniArticleTemplateSearchLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *MiniArticleTemplateSearchLogic) MiniArticleTemplateSearch(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 33 | + conn = l.svcCtx.DefaultDBConn() | ||
| 34 | + user *domain.User | ||
| 35 | + ) | ||
| 36 | + if user, err = l.svcCtx.UserRepository.FindOne(l.ctx, conn, userToken.UserId); err != nil { | ||
| 37 | + return nil, xerr.NewErrMsgErr("用户不存在", err) | ||
| 38 | + } | ||
| 39 | + req.CompanyId = user.CompanyId | ||
| 40 | + logic := NewSystemArticleTemplateSearchLogic(l.ctx, l.svcCtx) | ||
| 41 | + resp, err = logic.SystemArticleTemplateSearch(req) | ||
| 42 | + if err != nil { | ||
| 43 | + return nil, err | ||
| 44 | + } | ||
| 45 | + // 过滤可见性 | ||
| 46 | + list := make([]types.ArticleTemplateItem, 0) | ||
| 47 | + lo.ForEach(resp.List, func(item types.ArticleTemplateItem, index int) { | ||
| 48 | + if item.TargetWhoRead == int(domain.ArticleTemplateLimit) { | ||
| 49 | + if !lo.Contains(item.WhoRead, user.Id) { | ||
| 50 | + return | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + list = append(list, item) | ||
| 54 | + }) | ||
| 55 | + resp.List = list | ||
| 56 | + resp.Total = int64(len(list)) | ||
| 57 | + return | ||
| 58 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 9 | + | ||
| 10 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type MiniArticleTemplateSearchMineLogic struct { | ||
| 14 | + logx.Logger | ||
| 15 | + ctx context.Context | ||
| 16 | + svcCtx *svc.ServiceContext | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func NewMiniArticleTemplateSearchMineLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateSearchMineLogic { | ||
| 20 | + return &MiniArticleTemplateSearchMineLogic{ | ||
| 21 | + Logger: logx.WithContext(ctx), | ||
| 22 | + ctx: ctx, | ||
| 23 | + svcCtx: svcCtx, | ||
| 24 | + } | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (l *MiniArticleTemplateSearchMineLogic) MiniArticleTemplateSearchMine(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) { | ||
| 28 | + var ( | ||
| 29 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 30 | + ) | ||
| 31 | + req.UserId = userToken.UserId | ||
| 32 | + logic := NewSystemArticleTemplateSearchLogic(l.ctx, l.svcCtx) | ||
| 33 | + return logic.SystemArticleTemplateSearch(req) | ||
| 34 | +} |
| 1 | +package template | ||
| 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 MiniArticleTemplateUpdateLogic struct { | ||
| 13 | + logx.Logger | ||
| 14 | + ctx context.Context | ||
| 15 | + svcCtx *svc.ServiceContext | ||
| 16 | +} | ||
| 17 | + | ||
| 18 | +func NewMiniArticleTemplateUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniArticleTemplateUpdateLogic { | ||
| 19 | + return &MiniArticleTemplateUpdateLogic{ | ||
| 20 | + Logger: logx.WithContext(ctx), | ||
| 21 | + ctx: ctx, | ||
| 22 | + svcCtx: svcCtx, | ||
| 23 | + } | ||
| 24 | +} | ||
| 25 | + | ||
| 26 | +func (l *MiniArticleTemplateUpdateLogic) MiniArticleTemplateUpdate(req *types.ArticleTemplateUpdateRequest) (resp *types.ArticleTemplateUpdateResponse, err error) { | ||
| 27 | + logic := NewSystemArticleTemplateUpdateLogic(l.ctx, l.svcCtx) | ||
| 28 | + return logic.SystemArticleTemplateUpdate(req) | ||
| 29 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | + | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type SystemArticleTemplateBatchDeleteLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemArticleTemplateBatchDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateBatchDeleteLogic { | ||
| 22 | + return &SystemArticleTemplateBatchDeleteLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *SystemArticleTemplateBatchDeleteLogic) SystemArticleTemplateBatchDelete(req *types.ArticleTemplateBatchDeleteRequest) (resp *types.ArticleTemplateBatchResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + dm *domain.ArticleTemplate | ||
| 32 | + ) | ||
| 33 | + | ||
| 34 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 35 | + for _, id := range req.Ids { | ||
| 36 | + if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, int64(id)); err != nil { | ||
| 37 | + return xerr.NewErrMsgErr("不存在", err) | ||
| 38 | + } | ||
| 39 | + if dm, err = l.svcCtx.ArticleTemplateRepository.Delete(l.ctx, conn, dm); err != nil { | ||
| 40 | + return err | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + return nil | ||
| 44 | + }, true); err != nil { | ||
| 45 | + return nil, xerr.NewErrMsgErr("移除失败", err) | ||
| 46 | + } | ||
| 47 | + resp = &types.ArticleTemplateBatchResponse{} | ||
| 48 | + return | ||
| 49 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 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 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 10 | + | ||
| 11 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 12 | +) | ||
| 13 | + | ||
| 14 | +type SystemArticleTemplateClassSearchLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSystemArticleTemplateClassSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateClassSearchLogic { | ||
| 21 | + return &SystemArticleTemplateClassSearchLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SystemArticleTemplateClassSearchLogic) SystemArticleTemplateClassSearch(req *types.ArticleTemplateClassSearchRequest) (resp *types.ArticleTemplateClassSearchResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dms []*domain.ArticleTemplate | ||
| 32 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 33 | + ) | ||
| 34 | + queryOptions := domain.NewQueryOptions() | ||
| 35 | + queryOptions.WithKV("name", req.Name). | ||
| 36 | + MustWithKV("companyId", userToken.CompanyId) | ||
| 37 | + _, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions) | ||
| 38 | + class := lo.Uniq(domain.Values(dms, func(item *domain.ArticleTemplate) string { | ||
| 39 | + return item.TemplateClass | ||
| 40 | + })) | ||
| 41 | + resp = &types.ArticleTemplateClassSearchResponse{ | ||
| 42 | + Total: int64(len(class)), | ||
| 43 | + } | ||
| 44 | + lo.ForEach(class, func(item string, index int) { | ||
| 45 | + resp.List = append(resp.List, types.ArticleTemplateClassItem{ | ||
| 46 | + Name: item, | ||
| 47 | + }) | ||
| 48 | + }) | ||
| 49 | + return | ||
| 50 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 8 | + | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 11 | + | ||
| 12 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type SystemArticleTemplateDeleteLogic struct { | ||
| 16 | + logx.Logger | ||
| 17 | + ctx context.Context | ||
| 18 | + svcCtx *svc.ServiceContext | ||
| 19 | +} | ||
| 20 | + | ||
| 21 | +func NewSystemArticleTemplateDeleteLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateDeleteLogic { | ||
| 22 | + return &SystemArticleTemplateDeleteLogic{ | ||
| 23 | + Logger: logx.WithContext(ctx), | ||
| 24 | + ctx: ctx, | ||
| 25 | + svcCtx: svcCtx, | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +func (l *SystemArticleTemplateDeleteLogic) SystemArticleTemplateDelete(req *types.ArticleTemplateDeleteRequest) (resp *types.ArticleTemplateDeleteResponse, err error) { | ||
| 30 | + var ( | ||
| 31 | + conn = l.svcCtx.DefaultDBConn() | ||
| 32 | + dm *domain.ArticleTemplate | ||
| 33 | + ) | ||
| 34 | + if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 35 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 36 | + } | ||
| 37 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 38 | + if dm, err = l.svcCtx.ArticleTemplateRepository.Delete(l.ctx, conn, dm); err != nil { | ||
| 39 | + return err | ||
| 40 | + } | ||
| 41 | + return nil | ||
| 42 | + }, true); err != nil { | ||
| 43 | + return nil, xerr.NewErrMsgErr("移除失败", err) | ||
| 44 | + } | ||
| 45 | + resp = &types.ArticleTemplateDeleteResponse{} | ||
| 46 | + return | ||
| 47 | +} |
| 1 | +package template | ||
| 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 SystemArticleTemplateGetLogic struct { | ||
| 15 | + logx.Logger | ||
| 16 | + ctx context.Context | ||
| 17 | + svcCtx *svc.ServiceContext | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +func NewSystemArticleTemplateGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateGetLogic { | ||
| 21 | + return &SystemArticleTemplateGetLogic{ | ||
| 22 | + Logger: logx.WithContext(ctx), | ||
| 23 | + ctx: ctx, | ||
| 24 | + svcCtx: svcCtx, | ||
| 25 | + } | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +func (l *SystemArticleTemplateGetLogic) SystemArticleTemplateGet(req *types.ArticleTemplateGetRequest) (resp *types.ArticleTemplateGetResponse, err error) { | ||
| 29 | + var ( | ||
| 30 | + conn = l.svcCtx.DefaultDBConn() | ||
| 31 | + dm *domain.ArticleTemplate | ||
| 32 | + userMap = make(map[int64]*domain.User) | ||
| 33 | + ) | ||
| 34 | + // 货号唯一 | ||
| 35 | + if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 37 | + } | ||
| 38 | + item := NewTypesArticleTemplate(dm) | ||
| 39 | + for _, id := range dm.WhoRead { | ||
| 40 | + if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil { | ||
| 41 | + item.WhoReadInfo = append(item.WhoReadInfo, types.TargetUser{ | ||
| 42 | + Id: user.Id, | ||
| 43 | + Name: user.Name, | ||
| 44 | + }) | ||
| 45 | + } | ||
| 46 | + } | ||
| 47 | + for _, id := range dm.WhoReview { | ||
| 48 | + if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil { | ||
| 49 | + item.WhoReviewInfo = append(item.WhoReviewInfo, types.TargetUser{ | ||
| 50 | + Id: user.Id, | ||
| 51 | + Name: user.Name, | ||
| 52 | + }) | ||
| 53 | + } | ||
| 54 | + } | ||
| 55 | + resp = &types.ArticleTemplateGetResponse{ | ||
| 56 | + ArticleTemplate: item, | ||
| 57 | + } | ||
| 58 | + return | ||
| 59 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/google/uuid" | ||
| 6 | + "github.com/samber/lo" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/gateway/authlib" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 12 | + | ||
| 13 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 14 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 15 | + | ||
| 16 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 17 | +) | ||
| 18 | + | ||
| 19 | +type SystemArticleTemplateSaveLogic struct { | ||
| 20 | + logx.Logger | ||
| 21 | + ctx context.Context | ||
| 22 | + svcCtx *svc.ServiceContext | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +func NewSystemArticleTemplateSaveLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateSaveLogic { | ||
| 26 | + return &SystemArticleTemplateSaveLogic{ | ||
| 27 | + Logger: logx.WithContext(ctx), | ||
| 28 | + ctx: ctx, | ||
| 29 | + svcCtx: svcCtx, | ||
| 30 | + } | ||
| 31 | +} | ||
| 32 | + | ||
| 33 | +func (l *SystemArticleTemplateSaveLogic) SystemArticleTemplateSave(req *types.ArticleTemplateSaveRequest) (resp *types.ArticleTemplateSaveResponse, err error) { | ||
| 34 | + var ( | ||
| 35 | + dm *domain.ArticleTemplate | ||
| 36 | + userToken = contextdata.GetUserTokenFromCtx(l.ctx) | ||
| 37 | + ) | ||
| 38 | + // 唯一判断 | ||
| 39 | + // 获取当前用户信息 | ||
| 40 | + userMe, err := l.svcCtx.ApiAuthService.MeInfo(l.ctx, authlib.RequestUserMeQuery{Token: req.AccessToken}) | ||
| 41 | + if err != nil { | ||
| 42 | + return nil, xerr.NewErrMsgErr("获取当前用户信息失败", err) | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + dm = NewDomainArticleTemplate(req.ArticleTemplate) | ||
| 46 | + dm.CompanyId = userToken.CompanyId | ||
| 47 | + dm.UserId = 0 | ||
| 48 | + dm.BelongTo = domain.BelongToCompany | ||
| 49 | + dm.Operator = domain.Operator{ | ||
| 50 | + Id: userToken.UserId, | ||
| 51 | + Name: userMe.User.NickName, | ||
| 52 | + Type: 1, | ||
| 53 | + } | ||
| 54 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 55 | + dm, err = l.svcCtx.ArticleTemplateRepository.Insert(l.ctx, conn, dm) | ||
| 56 | + return err | ||
| 57 | + }, true); err != nil { | ||
| 58 | + return nil, xerr.NewErrMsg("保存失败") | ||
| 59 | + } | ||
| 60 | + resp = &types.ArticleTemplateSaveResponse{} | ||
| 61 | + return | ||
| 62 | +} | ||
| 63 | + | ||
| 64 | +func NewDomainArticleTemplate(item types.ArticleTemplateItem) *domain.ArticleTemplate { | ||
| 65 | + var paragraphs = make([]domain.Paragraph, 0) | ||
| 66 | + lo.ForEach(item.Paragraphs, func(p types.Paragraph, index int) { | ||
| 67 | + paragraphs = append(paragraphs, NewDomainParagraph(p)) | ||
| 68 | + }) | ||
| 69 | + return &domain.ArticleTemplate{ | ||
| 70 | + Name: item.Name, | ||
| 71 | + TemplateClass: item.TemplateClass, | ||
| 72 | + Paragraphs: paragraphs, | ||
| 73 | + Icon: item.Icon, | ||
| 74 | + TargetWhoRead: domain.ArticleTemplateTarget(item.TargetWhoRead), | ||
| 75 | + TargetWhoReview: domain.ArticleTemplateTarget(item.TargetWhoReview), | ||
| 76 | + WhoRead: item.WhoRead, | ||
| 77 | + WhoReview: item.WhoReview, | ||
| 78 | + } | ||
| 79 | +} | ||
| 80 | + | ||
| 81 | +func NewTypesArticleTemplate(item *domain.ArticleTemplate) types.ArticleTemplateItem { | ||
| 82 | + var paragraphs = make([]types.Paragraph, 0) | ||
| 83 | + lo.ForEach(item.Paragraphs, func(p domain.Paragraph, index int) { | ||
| 84 | + paragraphs = append(paragraphs, NewTypesParagraph(p)) | ||
| 85 | + }) | ||
| 86 | + return types.ArticleTemplateItem{ | ||
| 87 | + Id: item.Id, | ||
| 88 | + Name: item.Name, | ||
| 89 | + TemplateClass: item.TemplateClass, | ||
| 90 | + Paragraphs: paragraphs, | ||
| 91 | + Icon: item.Icon, | ||
| 92 | + TargetWhoRead: int(item.TargetWhoRead), | ||
| 93 | + TargetWhoReview: int(item.TargetWhoReview), | ||
| 94 | + WhoRead: item.WhoRead, | ||
| 95 | + WhoReview: item.WhoReview, | ||
| 96 | + Operator: item.Operator.Name, | ||
| 97 | + WhoReadInfo: make([]types.TargetUser, 0), | ||
| 98 | + WhoReviewInfo: make([]types.TargetUser, 0), | ||
| 99 | + UpdatedAt: item.UpdatedAt, | ||
| 100 | + } | ||
| 101 | +} | ||
| 102 | + | ||
| 103 | +func NewDomainParagraph(item types.Paragraph) domain.Paragraph { | ||
| 104 | + idGen, _ := uuid.NewUUID() | ||
| 105 | + return domain.Paragraph{ | ||
| 106 | + ID: idGen.String(), | ||
| 107 | + Title: item.Title, | ||
| 108 | + Prompt: item.Prompt, | ||
| 109 | + Required: item.Required, | ||
| 110 | + Type: item.Type, | ||
| 111 | + } | ||
| 112 | +} | ||
| 113 | + | ||
| 114 | +func NewTypesParagraph(item domain.Paragraph) types.Paragraph { | ||
| 115 | + return types.Paragraph{ | ||
| 116 | + ID: item.ID, | ||
| 117 | + Title: item.Title, | ||
| 118 | + Prompt: item.Prompt, | ||
| 119 | + Required: item.Required, | ||
| 120 | + Type: item.Type, | ||
| 121 | + } | ||
| 122 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 9 | + | ||
| 10 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 11 | +) | ||
| 12 | + | ||
| 13 | +type SystemArticleTemplateSearchLogic struct { | ||
| 14 | + logx.Logger | ||
| 15 | + ctx context.Context | ||
| 16 | + svcCtx *svc.ServiceContext | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func NewSystemArticleTemplateSearchLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateSearchLogic { | ||
| 20 | + return &SystemArticleTemplateSearchLogic{ | ||
| 21 | + Logger: logx.WithContext(ctx), | ||
| 22 | + ctx: ctx, | ||
| 23 | + svcCtx: svcCtx, | ||
| 24 | + } | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +func (l *SystemArticleTemplateSearchLogic) SystemArticleTemplateSearch(req *types.ArticleTemplateSearchRequest) (resp *types.ArticleTemplateSearchResponse, err error) { | ||
| 28 | + var ( | ||
| 29 | + conn = l.svcCtx.DefaultDBConn() | ||
| 30 | + dms []*domain.ArticleTemplate | ||
| 31 | + total int64 | ||
| 32 | + userMap = make(map[int64]*domain.User) | ||
| 33 | + ) | ||
| 34 | + | ||
| 35 | + queryOptions := domain.NewQueryOptions() | ||
| 36 | + if req.Page > 0 && req.Size > 0 { | ||
| 37 | + queryOptions.WithOffsetLimit(req.Page, req.Size) | ||
| 38 | + } | ||
| 39 | + queryOptions.WithKV("name", req.Name).WithKV("templateClass", req.TemplateClass). | ||
| 40 | + WithKV("companyId", req.CompanyId).WithKV("userId", req.UserId) | ||
| 41 | + if req.Target != nil { | ||
| 42 | + queryOptions.MustWithKV("target", *req.Target) | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + total, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions) | ||
| 46 | + list := make([]types.ArticleTemplateItem, 0) | ||
| 47 | + for i := range dms { | ||
| 48 | + item := NewTypesArticleTemplate(dms[i]) | ||
| 49 | + for _, id := range dms[i].WhoRead { | ||
| 50 | + if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil { | ||
| 51 | + item.WhoReadInfo = append(item.WhoReadInfo, types.TargetUser{ | ||
| 52 | + Id: user.Id, | ||
| 53 | + Name: user.Name, | ||
| 54 | + }) | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | + for _, id := range dms[i].WhoReview { | ||
| 58 | + if user, _ := domain.LazyLoad(userMap, l.ctx, conn, id, l.svcCtx.UserRepository.FindOne); user != nil { | ||
| 59 | + item.WhoReviewInfo = append(item.WhoReviewInfo, types.TargetUser{ | ||
| 60 | + Id: user.Id, | ||
| 61 | + Name: user.Name, | ||
| 62 | + }) | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + list = append(list, item) | ||
| 66 | + } | ||
| 67 | + resp = &types.ArticleTemplateSearchResponse{ | ||
| 68 | + List: list, | ||
| 69 | + Total: total, | ||
| 70 | + } | ||
| 71 | + return | ||
| 72 | +} |
| 1 | +package template | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "github.com/samber/lo" | ||
| 6 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 7 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 8 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr" | ||
| 9 | + | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types" | ||
| 12 | + | ||
| 13 | + "github.com/zeromicro/go-zero/core/logx" | ||
| 14 | +) | ||
| 15 | + | ||
| 16 | +type SystemArticleTemplateUpdateLogic struct { | ||
| 17 | + logx.Logger | ||
| 18 | + ctx context.Context | ||
| 19 | + svcCtx *svc.ServiceContext | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +func NewSystemArticleTemplateUpdateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemArticleTemplateUpdateLogic { | ||
| 23 | + return &SystemArticleTemplateUpdateLogic{ | ||
| 24 | + Logger: logx.WithContext(ctx), | ||
| 25 | + ctx: ctx, | ||
| 26 | + svcCtx: svcCtx, | ||
| 27 | + } | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +func (l *SystemArticleTemplateUpdateLogic) SystemArticleTemplateUpdate(req *types.ArticleTemplateUpdateRequest) (resp *types.ArticleTemplateUpdateResponse, err error) { | ||
| 31 | + var ( | ||
| 32 | + conn = l.svcCtx.DefaultDBConn() | ||
| 33 | + dm *domain.ArticleTemplate | ||
| 34 | + ) | ||
| 35 | + if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 36 | + return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 37 | + } | ||
| 38 | + // 不可编辑判断 | ||
| 39 | + | ||
| 40 | + // 赋值 | ||
| 41 | + item := req.ArticleTemplate | ||
| 42 | + var paragraphs = make([]domain.Paragraph, 0) | ||
| 43 | + lo.ForEach(item.Paragraphs, func(p types.Paragraph, index int) { | ||
| 44 | + paragraphs = append(paragraphs, NewDomainParagraph(p)) | ||
| 45 | + }) | ||
| 46 | + dm.Name = item.Name | ||
| 47 | + dm.TemplateClass = item.TemplateClass | ||
| 48 | + dm.Paragraphs = paragraphs | ||
| 49 | + dm.Icon = item.Icon | ||
| 50 | + dm.TargetWhoRead = domain.ArticleTemplateTarget(item.TargetWhoRead) | ||
| 51 | + dm.TargetWhoReview = domain.ArticleTemplateTarget(item.TargetWhoReview) | ||
| 52 | + dm.WhoRead = item.WhoRead | ||
| 53 | + dm.WhoReview = item.WhoReview | ||
| 54 | + | ||
| 55 | + // 更新 | ||
| 56 | + if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 57 | + dm, err = l.svcCtx.ArticleTemplateRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 58 | + return err | ||
| 59 | + }, true); err != nil { | ||
| 60 | + return nil, xerr.NewErrMsg("更新失败") | ||
| 61 | + } | ||
| 62 | + resp = &types.ArticleTemplateUpdateResponse{} | ||
| 63 | + return | ||
| 64 | +} |
| @@ -37,6 +37,7 @@ type ServiceContext struct { | @@ -37,6 +37,7 @@ type ServiceContext struct { | ||
| 37 | ArticleAndTagRepository domain.ArticleAndTagRepository | 37 | ArticleAndTagRepository domain.ArticleAndTagRepository |
| 38 | ArticleDraftOperationRepository domain.ArticleDraftOperationRepository | 38 | ArticleDraftOperationRepository domain.ArticleDraftOperationRepository |
| 39 | ArticleSecurityRepository domain.ArticleSecurityRepository | 39 | ArticleSecurityRepository domain.ArticleSecurityRepository |
| 40 | + ArticleTemplateRepository domain.ArticleTemplateRepository | ||
| 40 | 41 | ||
| 41 | CompanyRepository domain.CompanyRepository | 42 | CompanyRepository domain.CompanyRepository |
| 42 | DepartmentRepository domain.DepartmentRepository | 43 | DepartmentRepository domain.DepartmentRepository |
| @@ -96,6 +97,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | @@ -96,6 +97,7 @@ func NewServiceContext(c config.Config) *ServiceContext { | ||
| 96 | ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)), | 97 | ArticleCategoryRepository: repository.NewArticleCategoryRepository(cache.NewCachedRepository(mlCache)), |
| 97 | ArticleDraftOperationRepository: repository.NewArticleDraftOperationRepository(cache.NewCachedRepository(mlCache)), | 98 | ArticleDraftOperationRepository: repository.NewArticleDraftOperationRepository(cache.NewCachedRepository(mlCache)), |
| 98 | ArticleSecurityRepository: repository.NewArticleSecurityRepository(cache.NewCachedRepository(mlCache)), | 99 | ArticleSecurityRepository: repository.NewArticleSecurityRepository(cache.NewCachedRepository(mlCache)), |
| 100 | + ArticleTemplateRepository: repository.NewArticleTemplateRepository(cache.NewCachedRepository(mlCache)), | ||
| 99 | 101 | ||
| 100 | CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)), | 102 | CompanyRepository: repository.NewCompanyRepository(cache.NewCachedRepository(mlCache)), |
| 101 | DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)), | 103 | DepartmentRepository: repository.NewDepartmentRepository(cache.NewCachedRepository(mlCache)), |
| @@ -966,6 +966,7 @@ type MiniArticleCreateRequest struct { | @@ -966,6 +966,7 @@ type MiniArticleCreateRequest struct { | ||
| 966 | WhoReview []int64 `json:"whoReview,optional"` //谁可评论 | 966 | WhoReview []int64 `json:"whoReview,optional"` //谁可评论 |
| 967 | Location Location `json:"location,optional"` //定位坐标 | 967 | Location Location `json:"location,optional"` //定位坐标 |
| 968 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 968 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 969 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 969 | } | 970 | } |
| 970 | 971 | ||
| 971 | type MiniArticleCreateResponse struct { | 972 | type MiniArticleCreateResponse struct { |
| @@ -1006,6 +1007,9 @@ type ArticleSection struct { | @@ -1006,6 +1007,9 @@ type ArticleSection struct { | ||
| 1006 | Content string `json:"content"` // 文本内容 | 1007 | Content string `json:"content"` // 文本内容 |
| 1007 | SortBy int `json:"sortBy"` // 排序 | 1008 | SortBy int `json:"sortBy"` // 排序 |
| 1008 | TotalComment int `json:"totalComment"` // 评论的数量 | 1009 | TotalComment int `json:"totalComment"` // 评论的数量 |
| 1010 | + Images []string `json:"images"` // 照片列表 | ||
| 1011 | + ParagraphType int `json:"paragraphType"` // 段落类型 0:无样式 1:模板文本 2:模板图片 | ||
| 1012 | + ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板 | ||
| 1009 | } | 1013 | } |
| 1010 | 1014 | ||
| 1011 | type MiniArticleSearchMeRequest struct { | 1015 | type MiniArticleSearchMeRequest struct { |
| @@ -1166,6 +1170,7 @@ type MiniArticleDraftCreateRequest struct { | @@ -1166,6 +1170,7 @@ type MiniArticleDraftCreateRequest struct { | ||
| 1166 | WhoReview []int64 `json:"whoReview"` // 评论人 | 1170 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 1167 | Location Location `json:"location"` // 坐标 | 1171 | Location Location `json:"location"` // 坐标 |
| 1168 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 1172 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 1173 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 1169 | } | 1174 | } |
| 1170 | 1175 | ||
| 1171 | type MiniArticleDraftCreateResponse struct { | 1176 | type MiniArticleDraftCreateResponse struct { |
| @@ -1184,6 +1189,7 @@ type MiniArticleDraftUpdateRequest struct { | @@ -1184,6 +1189,7 @@ type MiniArticleDraftUpdateRequest struct { | ||
| 1184 | WhoReview []int64 `json:"whoReview"` // 评论人 | 1189 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 1185 | Location Location `json:"location"` // 坐标 | 1190 | Location Location `json:"location"` // 坐标 |
| 1186 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 1191 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 1192 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 1187 | } | 1193 | } |
| 1188 | 1194 | ||
| 1189 | type MiniArticleDraftUpdateResponse struct { | 1195 | type MiniArticleDraftUpdateResponse struct { |
| @@ -1400,6 +1406,7 @@ type SystemArticleCreateRequest struct { | @@ -1400,6 +1406,7 @@ type SystemArticleCreateRequest struct { | ||
| 1400 | MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 | 1406 | MatchUrl map[string]string `json:"matchUrl,optional"` // 匹配文章内容中的url文本 |
| 1401 | ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID | 1407 | ArticleDraftId int64 `json:"articleDraftId"` // 草稿ID |
| 1402 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token | 1408 | AccessToken string `header:"x-mmm-accesstoken"` // 授权token |
| 1409 | + Paragraphs []Paragraph `json:"paragraphs,optional"` // 段落 | ||
| 1403 | } | 1410 | } |
| 1404 | 1411 | ||
| 1405 | type SystemArticleCreateResponse struct { | 1412 | type SystemArticleCreateResponse struct { |
| @@ -1908,3 +1915,105 @@ type ContentDetailItem struct { | @@ -1908,3 +1915,105 @@ type ContentDetailItem struct { | ||
| 1908 | Type int `json:"type"` // 内容类型 (1:文章 2:评论) | 1915 | Type int `json:"type"` // 内容类型 (1:文章 2:评论) |
| 1909 | Text string `json:"text"` // 内容文本 | 1916 | Text string `json:"text"` // 内容文本 |
| 1910 | } | 1917 | } |
| 1918 | + | ||
| 1919 | +type ArticleTemplateGetRequest struct { | ||
| 1920 | + Id int64 `path:"id"` | ||
| 1921 | +} | ||
| 1922 | + | ||
| 1923 | +type ArticleTemplateGetResponse struct { | ||
| 1924 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 1925 | +} | ||
| 1926 | + | ||
| 1927 | +type ArticleTemplateSaveRequest struct { | ||
| 1928 | + AccessToken string `header:"x-mmm-accesstoken"` // 授权token | ||
| 1929 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 1930 | + BelongTo int `json:"belongTo,optional,default=2"` // 模板属于: 1:企业 、2:个人 | ||
| 1931 | +} | ||
| 1932 | + | ||
| 1933 | +type ArticleTemplateSaveResponse struct { | ||
| 1934 | +} | ||
| 1935 | + | ||
| 1936 | +type ArticleTemplateDeleteRequest struct { | ||
| 1937 | + Id int64 `path:"id"` | ||
| 1938 | +} | ||
| 1939 | + | ||
| 1940 | +type ArticleTemplateDeleteResponse struct { | ||
| 1941 | +} | ||
| 1942 | + | ||
| 1943 | +type ArticleTemplateBatchDeleteRequest struct { | ||
| 1944 | + Ids []int64 `json:"ids"` | ||
| 1945 | +} | ||
| 1946 | + | ||
| 1947 | +type ArticleTemplateBatchResponse struct { | ||
| 1948 | +} | ||
| 1949 | + | ||
| 1950 | +type ArticleTemplateUpdateRequest struct { | ||
| 1951 | + Id int64 `path:"id"` | ||
| 1952 | + ArticleTemplate ArticleTemplateItem `json:"item"` | ||
| 1953 | +} | ||
| 1954 | + | ||
| 1955 | +type ArticleTemplateUpdateResponse struct { | ||
| 1956 | +} | ||
| 1957 | + | ||
| 1958 | +type ArticleTemplateSearchRequest struct { | ||
| 1959 | + Page int `json:"page,optional"` | ||
| 1960 | + Size int `json:"size,optional"` | ||
| 1961 | + Name string `json:"name,optional"` // 模板名称 | ||
| 1962 | + TemplateClass string `json:"templateClass,optional"` // 模板分类 | ||
| 1963 | + Target *int `json:"target,optional"` // 目标 0 全员 1 指定人 | ||
| 1964 | + CompanyId int64 `json:",optional"` // 属于企业时有值 | ||
| 1965 | + UserId int64 `json:",optional"` // 属于个人时有值 | ||
| 1966 | +} | ||
| 1967 | + | ||
| 1968 | +type ArticleTemplateSearchResponse struct { | ||
| 1969 | + List []ArticleTemplateItem `json:"list"` | ||
| 1970 | + Total int64 `json:"total"` | ||
| 1971 | +} | ||
| 1972 | + | ||
| 1973 | +type ArticleTemplateClassSearchRequest struct { | ||
| 1974 | + Page int `json:"page,optional"` | ||
| 1975 | + Size int `json:"size,optional"` | ||
| 1976 | + Name string `json:"name,optional"` // 模板名称 | ||
| 1977 | + CompanyId int64 `json:",optional"` // 属于企业时有值 | ||
| 1978 | + UserId int64 `json:",optional"` // 属于个人时有值 | ||
| 1979 | +} | ||
| 1980 | + | ||
| 1981 | +type ArticleTemplateClassSearchResponse struct { | ||
| 1982 | + List []ArticleTemplateClassItem `json:"list"` | ||
| 1983 | + Total int64 `json:"total"` | ||
| 1984 | +} | ||
| 1985 | + | ||
| 1986 | +type ArticleTemplateClassItem struct { | ||
| 1987 | + Name string `json:"name"` // 名称 | ||
| 1988 | +} | ||
| 1989 | + | ||
| 1990 | +type ArticleTemplateItem struct { | ||
| 1991 | + Id int64 `json:"id,optional"` // 唯一标识 | ||
| 1992 | + Name string `json:"name"` // 模板名称 | ||
| 1993 | + TemplateClass string `json:"templateClass"` // 模板分类 | ||
| 1994 | + Paragraphs []Paragraph `json:"paragraphs"` // 段落列表 | ||
| 1995 | + Icon string `json:"icon,optional"` // 图标地址 | ||
| 1996 | + TargetWhoRead int `json:"targetWhoRead,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 1997 | + TargetWhoReview int `json:"targetWhoReview,optional"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 1998 | + WhoRead []int64 `json:"whoRead,optional"` // 谁可以看 | ||
| 1999 | + WhoReview []int64 `json:"whoReview,optional"` // 查看、评论人 | ||
| 2000 | + WhoReadInfo []TargetUser `json:"whoReadInfo,optional"` // 谁可查看 | ||
| 2001 | + WhoReviewInfo []TargetUser `json:"whoReviewInfo,optional"` // 谁可评论 | ||
| 2002 | + Operator string `json:"operator,omitempty,optional"` // 操作人 | ||
| 2003 | + UpdatedAt int64 `json:"updatedAt,omitempty,optional"` // 更新时间戳 | ||
| 2004 | +} | ||
| 2005 | + | ||
| 2006 | +type Paragraph struct { | ||
| 2007 | + ID string `json:"id,optional"` // 唯一标识 | ||
| 2008 | + Title string `json:"title,optional"` // 标题 | ||
| 2009 | + Prompt string `json:"prompt,optional"` // 文本提示 | ||
| 2010 | + Required bool `json:"required,optional"` // 必填 | ||
| 2011 | + Type int `json:"type,optional"` // 段落类型 1:文本 2:图片 | ||
| 2012 | + Text string `json:"text,optional,omitempty"` // 文本内容 | ||
| 2013 | + Images []string `json:"images,optional,omitempty"` // 图片地址列表 | ||
| 2014 | +} | ||
| 2015 | + | ||
| 2016 | +type TargetUser struct { | ||
| 2017 | + Id int64 `json:"id"` | ||
| 2018 | + Name string `json:"name"` | ||
| 2019 | +} |
cmd/discuss/doc/dsl/api/article_template.api
0 → 100644
| 1 | + | ||
| 2 | +syntax = "v1" | ||
| 3 | + | ||
| 4 | +info( | ||
| 5 | + title: "xx实例" | ||
| 6 | + desc: "xx实例" | ||
| 7 | + author: "author" | ||
| 8 | + email: "email" | ||
| 9 | + version: "v1" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +@server( | ||
| 13 | + prefix: article_template/v1 | ||
| 14 | + group: article_template | ||
| 15 | + jwt: JwtAuth | ||
| 16 | +) | ||
| 17 | +service Core { | ||
| 18 | + @doc "详情" | ||
| 19 | + @handler article_templateGet | ||
| 20 | + get /article_template/:id (ArticleTemplateGetRequest) returns (ArticleTemplateGetResponse) | ||
| 21 | + @doc "保存" | ||
| 22 | + @handler article_templateSave | ||
| 23 | + post /article_template (ArticleTemplateSaveRequest) returns (ArticleTemplateSaveResponse) | ||
| 24 | + @doc "删除" | ||
| 25 | + @handler article_templateDelete | ||
| 26 | + delete /article_template/:id (ArticleTemplateDeleteRequest) returns (ArticleTemplateDeleteResponse) | ||
| 27 | + @doc "更新" | ||
| 28 | + @handler article_templateUpdate | ||
| 29 | + put /article_template/:id (ArticleTemplateUpdateRequest) returns (ArticleTemplateUpdateResponse) | ||
| 30 | + @doc "搜索" | ||
| 31 | + @handler article_templateSearch | ||
| 32 | + post /article_template/search (ArticleTemplateSearchRequest) returns (ArticleTemplateSearchResponse) | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +type ( | ||
| 36 | + ArticleTemplateGetRequest { | ||
| 37 | + Id int64 `path:"id"` | ||
| 38 | + } | ||
| 39 | + ArticleTemplateGetResponse struct{ | ||
| 40 | + ArticleTemplate ArticleTemplateItem `json:"article_template"` | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + ArticleTemplateSaveRequest struct{ | ||
| 44 | + ArticleTemplate ArticleTemplateItem `json:"article_template"` | ||
| 45 | + } | ||
| 46 | + ArticleTemplateSaveResponse struct{} | ||
| 47 | + | ||
| 48 | + ArticleTemplateDeleteRequest struct{ | ||
| 49 | + Id int64 `path:"id"` | ||
| 50 | + } | ||
| 51 | + ArticleTemplateDeleteResponse struct{} | ||
| 52 | + | ||
| 53 | + ArticleTemplateUpdateRequest struct{ | ||
| 54 | + Id int64 `path:"id"` | ||
| 55 | + ArticleTemplate ArticleTemplateItem `json:"article_template"` | ||
| 56 | + } | ||
| 57 | + ArticleTemplateUpdateResponse struct{} | ||
| 58 | + | ||
| 59 | + ArticleTemplateSearchRequest struct{ | ||
| 60 | + Page int `json:"page"` | ||
| 61 | + Size int `json:"size"` | ||
| 62 | + } | ||
| 63 | + ArticleTemplateSearchResponse{ | ||
| 64 | + List []ArticleTemplateItem `json:"list"` | ||
| 65 | + Total int64 `json:"total"` | ||
| 66 | + } | ||
| 67 | + ArticleTemplateItem struct{ | ||
| 68 | + | ||
| 69 | + } | ||
| 70 | +) | ||
| 71 | + | ||
| 72 | +// logic CRUD | ||
| 73 | +// Save | ||
| 74 | + //var ( | ||
| 75 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 76 | + // dm *domain.ArticleTemplate | ||
| 77 | + //) | ||
| 78 | + //// 唯一判断 | ||
| 79 | + | ||
| 80 | + //dm = NewDomainArticleTemplate(req.ArticleTemplate) | ||
| 81 | + //if err = transaction.UseTrans(l.ctx, l.svcCtx.DB, func(ctx context.Context, conn transaction.Conn) error { | ||
| 82 | + // dm, err = l.svcCtx.ArticleTemplateRepository.Insert(l.ctx, conn, dm) | ||
| 83 | + // return err | ||
| 84 | + //}, true); err != nil { | ||
| 85 | + // return nil, xerr.NewErrMsg("保存失败") | ||
| 86 | + //} | ||
| 87 | + ////resp = &types.ArticleTemplateSaveResponse{} | ||
| 88 | + //return | ||
| 89 | + | ||
| 90 | +//func NewDomainArticleTemplate(item types.ArticleTemplateItem) *domain.ArticleTemplate { | ||
| 91 | +// return &domain.ArticleTemplate{ | ||
| 92 | + | ||
| 93 | +// } | ||
| 94 | +//} | ||
| 95 | +// | ||
| 96 | +//func NewTypesArticleTemplate(item *domain.ArticleTemplate) types.ArticleTemplateItem { | ||
| 97 | +// return types.ArticleTemplateItem{ | ||
| 98 | +// Id: item.Id, | ||
| 99 | +// } | ||
| 100 | +//} | ||
| 101 | + | ||
| 102 | +// Get | ||
| 103 | + //var ( | ||
| 104 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 105 | + // dm *domain.ArticleTemplate | ||
| 106 | + //) | ||
| 107 | + //// 货号唯一 | ||
| 108 | + //if dm, err = l.svcCtx.ArticleTemplateRepository.FindOne(l.ctx, conn, req.Id); err != nil { | ||
| 109 | + // return nil, xerr.NewErrMsgErr("不存在", err) | ||
| 110 | + //} | ||
| 111 | + //resp = &types.ArticleTemplateGetResponse{ | ||
| 112 | + // ArticleTemplate: NewTypesArticleTemplate(dm), | ||
| 113 | + //} | ||
| 114 | + //return | ||
| 115 | + | ||
| 116 | +// Delete | ||
| 117 | + //var ( | ||
| 118 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 119 | + // dm *domain.ArticleTemplate | ||
| 120 | + //) | ||
| 121 | + //if dm, err = l.svcCtx.ArticleTemplateRepository.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.ArticleTemplateRepository.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.ArticleTemplate | ||
| 138 | + // total int64 | ||
| 139 | + //) | ||
| 140 | + // | ||
| 141 | + //queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size). | ||
| 142 | + // WithKV("", "") | ||
| 143 | + | ||
| 144 | + //total, dms, err = l.svcCtx.ArticleTemplateRepository.Find(l.ctx, conn, queryOptions) | ||
| 145 | + //list := make([]types.ArticleTemplateItem, 0) | ||
| 146 | + //for i := range dms { | ||
| 147 | + // list = append(list, NewTypesArticleTemplate(dms[i])) | ||
| 148 | + //} | ||
| 149 | + //resp = &types.ArticleTemplateSearchResponse{ | ||
| 150 | + // List: list, | ||
| 151 | + // Total: total, | ||
| 152 | + //} | ||
| 153 | + //return | ||
| 154 | + | ||
| 155 | +// Update | ||
| 156 | + //var ( | ||
| 157 | + // conn = l.svcCtx.DefaultDBConn() | ||
| 158 | + // dm *domain.ArticleTemplate | ||
| 159 | + //) | ||
| 160 | + //if dm, err = l.svcCtx.ArticleTemplateRepository.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.ArticleTemplateRepository.UpdateWithVersion(l.ctx, conn, dm) | ||
| 170 | + // return err | ||
| 171 | + //}, true); err != nil { | ||
| 172 | + // return nil, xerr.NewErrMsg("更新失败") | ||
| 173 | + //} | ||
| 174 | + //resp = &types.ArticleTemplateUpdateResponse{} | ||
| 175 | + //return |
| 1 | + | ||
| 2 | +syntax = "proto3"; | ||
| 3 | + | ||
| 4 | +option go_package ="./pb"; | ||
| 5 | + | ||
| 6 | +package pb; | ||
| 7 | + | ||
| 8 | +message ArticleTemplateGetReq { | ||
| 9 | + int64 Id = 1; | ||
| 10 | +} | ||
| 11 | +message ArticleTemplateGetResp{ | ||
| 12 | + ArticleTemplateItem User = 1; | ||
| 13 | +} | ||
| 14 | + | ||
| 15 | +message ArticleTemplateSaveReq { | ||
| 16 | + | ||
| 17 | +} | ||
| 18 | +message ArticleTemplateSaveResp{ | ||
| 19 | + | ||
| 20 | +} | ||
| 21 | + | ||
| 22 | +message ArticleTemplateDeleteReq { | ||
| 23 | + int64 Id = 1; | ||
| 24 | +} | ||
| 25 | +message ArticleTemplateDeleteResp{ | ||
| 26 | + | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +message ArticleTemplateUpdateReq { | ||
| 30 | + int64 Id = 1; | ||
| 31 | +} | ||
| 32 | +message ArticleTemplateUpdateResp{ | ||
| 33 | + | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +message ArticleTemplateSearchReq { | ||
| 37 | + int64 PageNumber = 1; | ||
| 38 | + int64 PageSize = 2; | ||
| 39 | +} | ||
| 40 | +message ArticleTemplateSearchResp{ | ||
| 41 | + repeated ArticleTemplateItem List =1; | ||
| 42 | + int64 Total =2; | ||
| 43 | +} | ||
| 44 | +message ArticleTemplateItem { | ||
| 45 | + | ||
| 46 | +} | ||
| 47 | + | ||
| 48 | +service ArticleTemplateService { | ||
| 49 | + rpc ArticleTemplateGet(ArticleTemplateGetReq) returns(ArticleTemplateGetResp); | ||
| 50 | + rpc ArticleTemplateSave(ArticleTemplateSaveReq) returns(ArticleTemplateSaveResp); | ||
| 51 | + rpc ArticleTemplateDelete(ArticleTemplateDeleteReq) returns(ArticleTemplateDeleteResp); | ||
| 52 | + rpc ArticleTemplateUpdate(ArticleTemplateUpdateReq) returns(ArticleTemplateUpdateResp); | ||
| 53 | + rpc ArticleTemplateSearch(ArticleTemplateSearchReq) returns(ArticleTemplateSearchResp); | ||
| 54 | +} |
| @@ -32,6 +32,7 @@ func Migrate(db *gorm.DB) { | @@ -32,6 +32,7 @@ func Migrate(db *gorm.DB) { | ||
| 32 | //&models.ArticleDraftOperation{}, | 32 | //&models.ArticleDraftOperation{}, |
| 33 | //&models.ArticleCategory{}, | 33 | //&models.ArticleCategory{}, |
| 34 | &models.ArticleSecurity{}, | 34 | &models.ArticleSecurity{}, |
| 35 | + &models.ArticleTemplate{}, | ||
| 35 | } | 36 | } |
| 36 | 37 | ||
| 37 | db.AutoMigrate(modelsList...) | 38 | db.AutoMigrate(modelsList...) |
| @@ -26,6 +26,8 @@ type ArticleDraft struct { | @@ -26,6 +26,8 @@ type ArticleDraft struct { | ||
| 26 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 | 26 | WhoReview []int64 `gorm:"type:jsonb;serializer:json"` // 评论人 |
| 27 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 | 27 | Location domain.Location `gorm:"type:jsonb;serializer:json"` // 坐标 |
| 28 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 | 28 | MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本 |
| 29 | + | ||
| 30 | + Section []domain.ArticleSection `gorm:"type:jsonb;serializer:json"` | ||
| 29 | } | 31 | } |
| 30 | 32 | ||
| 31 | func (m *ArticleDraft) TableName() string { | 33 | func (m *ArticleDraft) TableName() string { |
| @@ -21,6 +21,9 @@ type ArticleSection struct { | @@ -21,6 +21,9 @@ type ArticleSection struct { | ||
| 21 | Content string // 文本内容 | 21 | Content string // 文本内容 |
| 22 | SortBy int // 排序 | 22 | SortBy int // 排序 |
| 23 | TotalComment int // 评论的数量 | 23 | TotalComment int // 评论的数量 |
| 24 | + ParagraphType int | ||
| 25 | + ParagraphTemplate domain.Paragraph `gorm:"type:jsonb;serializer:json"` | ||
| 26 | + Images []string `gorm:"type:jsonb;serializer:json"` | ||
| 24 | } | 27 | } |
| 25 | 28 | ||
| 26 | func (m *ArticleSection) TableName() string { | 29 | func (m *ArticleSection) TableName() string { |
| 1 | +package models | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "fmt" | ||
| 5 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 6 | + "gorm.io/gorm" | ||
| 7 | + "gorm.io/plugin/soft_delete" | ||
| 8 | +) | ||
| 9 | + | ||
| 10 | +type ArticleTemplate struct { | ||
| 11 | + Id int64 `json:",omitempty"` // 唯一标识 | ||
| 12 | + CompanyId int64 `json:",omitempty"` // 属于企业时有值 | ||
| 13 | + UserId int64 `json:",omitempty"` // 属于个人时有值 | ||
| 14 | + BelongTo int `json:",omitempty"` // 模板属于: 1:企业 、2:个人 | ||
| 15 | + TemplateClass string `json:",omitempty"` // 模板分类 | ||
| 16 | + Name string `json:",omitempty"` // 模板名称 | ||
| 17 | + Paragraphs []domain.Paragraph `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 段落列表 | ||
| 18 | + Icon string `json:",omitempty"` // 图标地址 | ||
| 19 | + TargetWhoRead int `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 20 | + TargetWhoReview int `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 21 | + WhoRead []int64 `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 谁可以看 | ||
| 22 | + WhoReview []int64 `gorm:"type:jsonb;serializer:json" json:",omitempty"` // 查看、评论人 | ||
| 23 | + Operator domain.Operator `gorm:"type:jsonb;serializer:json" json:",omitempty"` | ||
| 24 | + CreatedAt int64 `json:",omitempty"` | ||
| 25 | + UpdatedAt int64 `json:",omitempty"` | ||
| 26 | + DeletedAt int64 `json:",omitempty"` | ||
| 27 | + Version int `json:",omitempty"` | ||
| 28 | + IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"` | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +func (m *ArticleTemplate) TableName() string { | ||
| 32 | + return "article_template" | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +func (m *ArticleTemplate) BeforeCreate(tx *gorm.DB) (err error) { | ||
| 36 | + // m.CreatedAt = time.Now().Unix() | ||
| 37 | + // m.UpdatedAt = time.Now().Unix() | ||
| 38 | + return | ||
| 39 | +} | ||
| 40 | + | ||
| 41 | +func (m *ArticleTemplate) BeforeUpdate(tx *gorm.DB) (err error) { | ||
| 42 | + // m.UpdatedAt = time.Now().Unix() | ||
| 43 | + return | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +func (m *ArticleTemplate) CacheKeyFunc() string { | ||
| 47 | + if m.Id == 0 { | ||
| 48 | + return "" | ||
| 49 | + } | ||
| 50 | + return fmt.Sprintf("%v:cache:%v:id:%v", domain.ProjectName, m.TableName(), m.Id) | ||
| 51 | +} | ||
| 52 | + | ||
| 53 | +func (m *ArticleTemplate) CacheKeyFuncByObject(obj interface{}) string { | ||
| 54 | + if v, ok := obj.(*ArticleTemplate); ok { | ||
| 55 | + return v.CacheKeyFunc() | ||
| 56 | + } | ||
| 57 | + return "" | ||
| 58 | +} | ||
| 59 | + | ||
| 60 | +func (m *ArticleTemplate) CachePrimaryKeyFunc() string { | ||
| 61 | + if len("") == 0 { | ||
| 62 | + return "" | ||
| 63 | + } | ||
| 64 | + return fmt.Sprintf("%v:cache:%v:primarykey:%v", domain.ProjectName, m.TableName(), "key") | ||
| 65 | +} |
| @@ -177,6 +177,9 @@ func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.Arti | @@ -177,6 +177,9 @@ func (repository *ArticleSectionRepository) ModelToDomainModel(from *models.Arti | ||
| 177 | Content: from.Content, | 177 | Content: from.Content, |
| 178 | SortBy: from.SortBy, | 178 | SortBy: from.SortBy, |
| 179 | TotalComment: from.TotalComment, | 179 | TotalComment: from.TotalComment, |
| 180 | + ParagraphType: from.ParagraphType, | ||
| 181 | + ParagraphTemplate: from.ParagraphTemplate, | ||
| 182 | + Images: from.Images, | ||
| 180 | } | 183 | } |
| 181 | // err := copier.Copy(to, from) | 184 | // err := copier.Copy(to, from) |
| 182 | return to, nil | 185 | return to, nil |
| @@ -194,6 +197,9 @@ func (repository *ArticleSectionRepository) DomainModelToModel(from *domain.Arti | @@ -194,6 +197,9 @@ func (repository *ArticleSectionRepository) DomainModelToModel(from *domain.Arti | ||
| 194 | Content: from.Content, | 197 | Content: from.Content, |
| 195 | SortBy: from.SortBy, | 198 | SortBy: from.SortBy, |
| 196 | TotalComment: from.TotalComment, | 199 | TotalComment: from.TotalComment, |
| 200 | + ParagraphType: from.ParagraphType, | ||
| 201 | + ParagraphTemplate: from.ParagraphTemplate, | ||
| 202 | + Images: from.Images, | ||
| 197 | } | 203 | } |
| 198 | // err := copier.Copy(to, from) | 204 | // err := copier.Copy(to, from) |
| 199 | return to, nil | 205 | return to, nil |
| 1 | +package repository | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "context" | ||
| 5 | + "fmt" | ||
| 6 | + "github.com/jinzhu/copier" | ||
| 7 | + "github.com/pkg/errors" | ||
| 8 | + "github.com/tiptok/gocomm/pkg/cache" | ||
| 9 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/models" | ||
| 10 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction" | ||
| 11 | + "gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain" | ||
| 12 | + "gorm.io/gorm" | ||
| 13 | +) | ||
| 14 | + | ||
| 15 | +type ArticleTemplateRepository struct { | ||
| 16 | + *cache.CachedRepository | ||
| 17 | +} | ||
| 18 | + | ||
| 19 | +func (repository *ArticleTemplateRepository) Insert(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) { | ||
| 20 | + var ( | ||
| 21 | + err error | ||
| 22 | + m = &models.ArticleTemplate{} | ||
| 23 | + tx = conn.DB() | ||
| 24 | + ) | ||
| 25 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 26 | + return nil, err | ||
| 27 | + } | ||
| 28 | + if tx = tx.Model(m).Save(m); tx.Error != nil { | ||
| 29 | + return nil, tx.Error | ||
| 30 | + } | ||
| 31 | + dm.Id = m.Id | ||
| 32 | + return repository.ModelToDomainModel(m) | ||
| 33 | + | ||
| 34 | +} | ||
| 35 | + | ||
| 36 | +func (repository *ArticleTemplateRepository) Update(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) { | ||
| 37 | + var ( | ||
| 38 | + err error | ||
| 39 | + m *models.ArticleTemplate | ||
| 40 | + tx = conn.DB() | ||
| 41 | + ) | ||
| 42 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 43 | + return nil, err | ||
| 44 | + } | ||
| 45 | + queryFunc := func() (interface{}, error) { | ||
| 46 | + tx = tx.Model(m).Updates(m) | ||
| 47 | + return nil, tx.Error | ||
| 48 | + } | ||
| 49 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 50 | + return nil, err | ||
| 51 | + } | ||
| 52 | + return repository.ModelToDomainModel(m) | ||
| 53 | +} | ||
| 54 | + | ||
| 55 | +func (repository *ArticleTemplateRepository) UpdateWithVersion(ctx context.Context, transaction transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) { | ||
| 56 | + var ( | ||
| 57 | + err error | ||
| 58 | + m *models.ArticleTemplate | ||
| 59 | + tx = transaction.DB() | ||
| 60 | + ) | ||
| 61 | + if m, err = repository.DomainModelToModel(dm); err != nil { | ||
| 62 | + return nil, err | ||
| 63 | + } | ||
| 64 | + oldVersion := dm.Version | ||
| 65 | + m.Version += 1 | ||
| 66 | + queryFunc := func() (interface{}, error) { | ||
| 67 | + tx = tx.Model(m).Select("*").Where("id = ?", m.Id).Where("version = ?", oldVersion).Updates(m) | ||
| 68 | + if tx.RowsAffected == 0 { | ||
| 69 | + return nil, domain.ErrUpdateFail | ||
| 70 | + } | ||
| 71 | + return nil, tx.Error | ||
| 72 | + } | ||
| 73 | + if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 74 | + return nil, err | ||
| 75 | + } | ||
| 76 | + return repository.ModelToDomainModel(m) | ||
| 77 | +} | ||
| 78 | + | ||
| 79 | +func (repository *ArticleTemplateRepository) Delete(ctx context.Context, conn transaction.Conn, dm *domain.ArticleTemplate) (*domain.ArticleTemplate, error) { | ||
| 80 | + var ( | ||
| 81 | + tx = conn.DB() | ||
| 82 | + m = &models.ArticleTemplate{Id: dm.Identify().(int64)} | ||
| 83 | + ) | ||
| 84 | + queryFunc := func() (interface{}, error) { | ||
| 85 | + tx = tx.Where("id = ?", m.Id).Delete(m) | ||
| 86 | + return m, tx.Error | ||
| 87 | + } | ||
| 88 | + if _, err := repository.Query(queryFunc, m.CacheKeyFunc()); err != nil { | ||
| 89 | + return dm, err | ||
| 90 | + } | ||
| 91 | + return repository.ModelToDomainModel(m) | ||
| 92 | +} | ||
| 93 | + | ||
| 94 | +func (repository *ArticleTemplateRepository) FindOne(ctx context.Context, conn transaction.Conn, id int64) (*domain.ArticleTemplate, error) { | ||
| 95 | + var ( | ||
| 96 | + err error | ||
| 97 | + tx = conn.DB() | ||
| 98 | + m = new(models.ArticleTemplate) | ||
| 99 | + ) | ||
| 100 | + queryFunc := func() (interface{}, error) { | ||
| 101 | + tx = tx.Model(m).Where("id = ?", id).First(m) | ||
| 102 | + if errors.Is(tx.Error, gorm.ErrRecordNotFound) { | ||
| 103 | + return nil, domain.ErrNotFound | ||
| 104 | + } | ||
| 105 | + return m, tx.Error | ||
| 106 | + } | ||
| 107 | + cacheModel := new(models.ArticleTemplate) | ||
| 108 | + cacheModel.Id = id | ||
| 109 | + if err = repository.QueryCache(cacheModel.CacheKeyFunc, m, queryFunc); err != nil { | ||
| 110 | + return nil, err | ||
| 111 | + } | ||
| 112 | + return repository.ModelToDomainModel(m) | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +func (repository *ArticleTemplateRepository) Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*domain.ArticleTemplate, error) { | ||
| 116 | + var ( | ||
| 117 | + tx = conn.DB() | ||
| 118 | + ms []*models.ArticleTemplate | ||
| 119 | + dms = make([]*domain.ArticleTemplate, 0) | ||
| 120 | + total int64 | ||
| 121 | + ) | ||
| 122 | + queryFunc := func() (interface{}, error) { | ||
| 123 | + tx = tx.Model(&ms).Order("id desc") | ||
| 124 | + if v, ok := queryOptions["companyId"]; ok { | ||
| 125 | + tx.Where("company_id = ? ", v) | ||
| 126 | + } | ||
| 127 | + if v, ok := queryOptions["userId"]; ok { | ||
| 128 | + tx.Where("user_id = ? ", v) | ||
| 129 | + } | ||
| 130 | + if v, ok := queryOptions["name"]; ok { | ||
| 131 | + tx.Where("name like ? ", fmt.Sprintf("%%%v%%", v)) | ||
| 132 | + } | ||
| 133 | + if v, ok := queryOptions["templateClass"]; ok { | ||
| 134 | + tx.Where("template_class = ? ", v) | ||
| 135 | + } | ||
| 136 | + if v, ok := queryOptions["target"]; ok { | ||
| 137 | + tx.Where("target_who_read = ? ", v) | ||
| 138 | + } | ||
| 139 | + if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil { | ||
| 140 | + return dms, tx.Error | ||
| 141 | + } | ||
| 142 | + return dms, nil | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + if _, err := repository.Query(queryFunc); err != nil { | ||
| 146 | + return 0, nil, err | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + for _, item := range ms { | ||
| 150 | + if dm, err := repository.ModelToDomainModel(item); err != nil { | ||
| 151 | + return 0, dms, err | ||
| 152 | + } else { | ||
| 153 | + dms = append(dms, dm) | ||
| 154 | + } | ||
| 155 | + } | ||
| 156 | + return total, dms, nil | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +func (repository *ArticleTemplateRepository) ModelToDomainModel(from *models.ArticleTemplate) (*domain.ArticleTemplate, error) { | ||
| 160 | + to := &domain.ArticleTemplate{} | ||
| 161 | + err := copier.Copy(to, from) | ||
| 162 | + return to, err | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | +func (repository *ArticleTemplateRepository) DomainModelToModel(from *domain.ArticleTemplate) (*models.ArticleTemplate, error) { | ||
| 166 | + to := &models.ArticleTemplate{} | ||
| 167 | + err := copier.Copy(to, from) | ||
| 168 | + return to, err | ||
| 169 | +} | ||
| 170 | + | ||
| 171 | +func NewArticleTemplateRepository(cache *cache.CachedRepository) domain.ArticleTemplateRepository { | ||
| 172 | + return &ArticleTemplateRepository{CachedRepository: cache} | ||
| 173 | +} |
| @@ -24,6 +24,8 @@ type ArticleDraft struct { | @@ -24,6 +24,8 @@ type ArticleDraft struct { | ||
| 24 | WhoReview []int64 `json:"whoReview"` // 评论人 | 24 | WhoReview []int64 `json:"whoReview"` // 评论人 |
| 25 | Location Location `json:"location"` // 坐标 | 25 | Location Location `json:"location"` // 坐标 |
| 26 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 | 26 | MatchUrl map[string]string `json:"matchUrl"` // 匹配文章内容中的url文本 |
| 27 | + | ||
| 28 | + Section []*ArticleSection `json:"section"` // 分段内容 | ||
| 27 | } | 29 | } |
| 28 | type ArticleDraftRepository interface { | 30 | type ArticleDraftRepository interface { |
| 29 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error) | 31 | Insert(ctx context.Context, conn transaction.Conn, dm *ArticleDraft) (*ArticleDraft, error) |
| @@ -18,6 +18,9 @@ type ArticleSection struct { | @@ -18,6 +18,9 @@ type ArticleSection struct { | ||
| 18 | Content string `json:"content"` // 文本内容 | 18 | Content string `json:"content"` // 文本内容 |
| 19 | SortBy int `json:"sortBy"` // 排序 | 19 | SortBy int `json:"sortBy"` // 排序 |
| 20 | TotalComment int `json:"totalComment"` // 评论的数量 | 20 | TotalComment int `json:"totalComment"` // 评论的数量 |
| 21 | + Images []string `json:"images"` // 照片列表 | ||
| 22 | + ParagraphType int `json:"paragraphType"` // 段落类型 1:文本 2:图片 | ||
| 23 | + ParagraphTemplate Paragraph `json:"paragraphTemplate"` // 段落模板 | ||
| 21 | } | 24 | } |
| 22 | 25 | ||
| 23 | type ArticleSectionRepository interface { | 26 | type ArticleSectionRepository interface { |
| 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 ArticleTemplate struct { | ||
| 9 | + Id int64 `json:",omitempty"` // 唯一标识 | ||
| 10 | + CompanyId int64 `json:",omitempty"` // 属于企业时有值 | ||
| 11 | + UserId int64 `json:",omitempty"` // 属于个人时有值 | ||
| 12 | + BelongTo TemplateBelongToType `json:",omitempty"` // 模板属于: 1:企业 、2:个人 | ||
| 13 | + TemplateClass string `json:",omitempty"` // 模板分类 | ||
| 14 | + Name string `json:",omitempty"` // 模板名称 | ||
| 15 | + Paragraphs []Paragraph `json:",omitempty"` // 段落列表 | ||
| 16 | + Icon string `json:",omitempty"` // 图标地址 | ||
| 17 | + TargetWhoRead ArticleTemplateTarget `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 18 | + TargetWhoReview ArticleTemplateTarget `json:",omitempty"` // 分发方式 0 分发给所有人 1 分发给指定的人 | ||
| 19 | + WhoRead []int64 `json:",omitempty"` // 谁可以看 | ||
| 20 | + WhoReview []int64 `json:",omitempty"` // 查看、评论人 | ||
| 21 | + Operator Operator `json:",omitempty"` // 操作人(企业时有值) | ||
| 22 | + CreatedAt int64 `json:",omitempty"` | ||
| 23 | + UpdatedAt int64 `json:",omitempty"` | ||
| 24 | + DeletedAt int64 `json:",omitempty"` | ||
| 25 | + Version int `json:",omitempty"` | ||
| 26 | +} | ||
| 27 | + | ||
| 28 | +type ArticleTemplateRepository interface { | ||
| 29 | + Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error) | ||
| 30 | + Update(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error) | ||
| 31 | + UpdateWithVersion(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error) | ||
| 32 | + Delete(ctx context.Context, conn transaction.Conn, dm *ArticleTemplate) (*ArticleTemplate, error) | ||
| 33 | + FindOne(ctx context.Context, conn transaction.Conn, id int64) (*ArticleTemplate, error) | ||
| 34 | + Find(ctx context.Context, conn transaction.Conn, queryOptions map[string]interface{}) (int64, []*ArticleTemplate, error) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +func (m *ArticleTemplate) Identify() interface{} { | ||
| 38 | + if m.Id == 0 { | ||
| 39 | + return nil | ||
| 40 | + } | ||
| 41 | + return m.Id | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +type Paragraph struct { | ||
| 45 | + ID string `json:",omitempty"` // 唯一标识 | ||
| 46 | + Title string `json:",omitempty"` // 标题 | ||
| 47 | + Prompt string `json:",omitempty"` // 文本提示 | ||
| 48 | + Required bool `json:",omitempty"` // 必填 | ||
| 49 | + Type int `json:",omitempty"` // 段落类型 0:未使用模板 1:模板文本 2:模板图片 | ||
| 50 | +} | ||
| 51 | + | ||
| 52 | +type TemplateBelongToType int | ||
| 53 | + | ||
| 54 | +const ( | ||
| 55 | + // BelongToCompany 属于公司 | ||
| 56 | + BelongToCompany TemplateBelongToType = 1 | ||
| 57 | + // BelongToIndividual 属于个人 | ||
| 58 | + BelongToIndividual TemplateBelongToType = 2 | ||
| 59 | +) | ||
| 60 | + | ||
| 61 | +type ArticleTemplateTarget int | ||
| 62 | + | ||
| 63 | +const ( | ||
| 64 | + ArticleTemplateAll ArticleTarget = 0 //所有人 | ||
| 65 | + ArticleTemplateLimit ArticleTarget = 1 //指定的人 | ||
| 66 | +) |
| @@ -45,8 +45,9 @@ type UserSimple struct { | @@ -45,8 +45,9 @@ type UserSimple struct { | ||
| 45 | CompanyId int64 `json:"companyId"` | 45 | CompanyId int64 `json:"companyId"` |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | -// 运营操作人 | 48 | +// Operator 运营操作人 |
| 49 | type Operator struct { | 49 | type Operator struct { |
| 50 | Id int64 `json:"id,string"` // 人员id | 50 | Id int64 `json:"id,string"` // 人员id |
| 51 | Name string `json:"name"` // 人员名字 | 51 | Name string `json:"name"` // 人员名字 |
| 52 | + Type int `json:"type"` // 1:系统管理员 2:个人 | ||
| 52 | } | 53 | } |
| @@ -68,3 +68,13 @@ CREATE TABLE `article_security` ( | @@ -68,3 +68,13 @@ CREATE TABLE `article_security` ( | ||
| 68 | `id` int(0) NOT NULL COMMENT '唯一标识', | 68 | `id` int(0) NOT NULL COMMENT '唯一标识', |
| 69 | PRIMARY KEY (`id`) USING BTREE | 69 | PRIMARY KEY (`id`) USING BTREE |
| 70 | ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; | 70 | ) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; |
| 71 | + | ||
| 72 | +CREATE TABLE `article_template` ( | ||
| 73 | + `id` int(0) NOT NULL COMMENT '唯一标识', | ||
| 74 | + PRIMARY KEY (`id`) USING BTREE | ||
| 75 | +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; | ||
| 76 | + | ||
| 77 | +CREATE TABLE `article_template` ( | ||
| 78 | + `id` int(0) NOT NULL COMMENT '唯一标识', | ||
| 79 | + PRIMARY KEY (`id`) USING BTREE | ||
| 80 | +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; |
deploy/database/v1.0.3 升级脚本.sql
0 → 100644
-
请 注册 或 登录 后发表评论