Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: site info add term of service and private policy

LinkinStard02f64b7a91b
diff --git a/docs/docs.go b/docs/docs.go
index 27ec7532..e805e73e 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -503,6 +503,77 @@ const docTemplate = `{
}
}
},
+ "/answer/admin/api/siteinfo/branding": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "get site interface",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "get site interface",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteBrandingResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site info branding",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site info branding",
+ "parameters": [
+ {
+ "description": "branding info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteBrandingReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/admin/api/siteinfo/general": {
"get": {
"security": [
@@ -645,6 +716,148 @@ const docTemplate = `{
}
}
},
+ "/answer/admin/api/siteinfo/legal": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "Set the legal information for the site",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "Set the legal information for the site",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteLegalResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site legal info",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site legal info",
+ "parameters": [
+ {
+ "description": "write info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteLegalReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
+ "/answer/admin/api/siteinfo/write": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "get site interface",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "get site interface",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteWriteResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site write info",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site write info",
+ "parameters": [
+ {
+ "description": "write info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteWriteReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/admin/api/theme/options": {
"get": {
"security": [
@@ -1323,6 +1536,64 @@ const docTemplate = `{
}
}
},
+ "/answer/api/v1/file": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "upload file",
+ "consumes": [
+ "multipart/form-data"
+ ],
+ "tags": [
+ "Upload"
+ ],
+ "summary": "upload file",
+ "parameters": [
+ {
+ "enum": [
+ "post",
+ "avatar",
+ "branding"
+ ],
+ "type": "string",
+ "description": "identify the source of the file upload",
+ "name": "source",
+ "in": "formData",
+ "required": true
+ },
+ {
+ "type": "file",
+ "description": "file",
+ "name": "file",
+ "in": "formData",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/answer/api/v1/follow": {
"post": {
"security": [
@@ -3106,52 +3377,6 @@ const docTemplate = `{
}
}
},
- "/answer/api/v1/user/avatar/upload": {
- "post": {
- "security": [
- {
- "ApiKeyAuth": []
- }
- ],
- "description": "UserUpdateInfo",
- "consumes": [
- "multipart/form-data"
- ],
- "tags": [
- "User"
- ],
- "summary": "UserUpdateInfo",
- "parameters": [
- {
- "type": "file",
- "description": "file",
- "name": "file",
- "in": "formData",
- "required": true
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "string"
- }
- }
- }
- ]
- }
- }
- }
- }
- },
"/answer/api/v1/user/email": {
"put": {
"security": [
@@ -3671,52 +3896,6 @@ const docTemplate = `{
}
}
},
- "/answer/api/v1/user/post/file": {
- "post": {
- "security": [
- {
- "ApiKeyAuth": []
- }
- ],
- "description": "upload user post file",
- "consumes": [
- "multipart/form-data"
- ],
- "tags": [
- "User"
- ],
- "summary": "upload user post file",
- "parameters": [
- {
- "type": "file",
- "description": "file",
- "name": "file",
- "in": "formData",
- "required": true
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "string"
- }
- }
- }
- ]
- }
- }
- }
- }
- },
"/answer/api/v1/user/register/email": {
"post": {
"description": "UserRegisterByEmail",
@@ -5571,6 +5750,56 @@ const docTemplate = `{
}
}
},
+ "schema.SiteBrandingReq": {
+ "type": "object",
+ "required": [
+ "logo",
+ "square_icon"
+ ],
+ "properties": {
+ "favicon": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "mobile_logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "square_icon": {
+ "type": "string",
+ "maxLength": 512
+ }
+ }
+ },
+ "schema.SiteBrandingResp": {
+ "type": "object",
+ "required": [
+ "logo",
+ "square_icon"
+ ],
+ "properties": {
+ "favicon": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "mobile_logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "square_icon": {
+ "type": "string",
+ "maxLength": 512
+ }
+ }
+ },
"schema.SiteGeneralReq": {
"type": "object",
"required": [
@@ -5647,10 +5876,6 @@ const docTemplate = `{
"type": "string",
"maxLength": 128
},
- "logo": {
- "type": "string",
- "maxLength": 256
- },
"theme": {
"type": "string",
"maxLength": 128
@@ -5673,10 +5898,6 @@ const docTemplate = `{
"type": "string",
"maxLength": 128
},
- "logo": {
- "type": "string",
- "maxLength": 256
- },
"theme": {
"type": "string",
"maxLength": 128
@@ -5687,6 +5908,50 @@ const docTemplate = `{
}
}
},
+ "schema.SiteLegalReq": {
+ "type": "object",
+ "properties": {
+ "privacy_policy": {
+ "type": "string"
+ },
+ "terms_of_service": {
+ "type": "string"
+ }
+ }
+ },
+ "schema.SiteLegalResp": {
+ "type": "object",
+ "properties": {
+ "privacy_policy": {
+ "type": "string"
+ },
+ "terms_of_service": {
+ "type": "string"
+ }
+ }
+ },
+ "schema.SiteWriteReq": {
+ "type": "object",
+ "required": [
+ "required_tag"
+ ],
+ "properties": {
+ "required_tag": {
+ "type": "boolean"
+ }
+ }
+ },
+ "schema.SiteWriteResp": {
+ "type": "object",
+ "required": [
+ "required_tag"
+ ],
+ "properties": {
+ "required_tag": {
+ "type": "boolean"
+ }
+ }
+ },
"schema.TagItem": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 39b4c363..684666ae 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -491,6 +491,77 @@
}
}
},
+ "/answer/admin/api/siteinfo/branding": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "get site interface",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "get site interface",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteBrandingResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site info branding",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site info branding",
+ "parameters": [
+ {
+ "description": "branding info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteBrandingReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/admin/api/siteinfo/general": {
"get": {
"security": [
@@ -633,6 +704,148 @@
}
}
},
+ "/answer/admin/api/siteinfo/legal": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "Set the legal information for the site",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "Set the legal information for the site",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteLegalResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site legal info",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site legal info",
+ "parameters": [
+ {
+ "description": "write info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteLegalReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
+ "/answer/admin/api/siteinfo/write": {
+ "get": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "get site interface",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "get site interface",
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "$ref": "#/definitions/schema.SiteWriteResp"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ },
+ "put": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "update site write info",
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "admin"
+ ],
+ "summary": "update site write info",
+ "parameters": [
+ {
+ "description": "write info",
+ "name": "data",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/schema.SiteWriteReq"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/handler.RespBody"
+ }
+ }
+ }
+ }
+ },
"/answer/admin/api/theme/options": {
"get": {
"security": [
@@ -1311,6 +1524,64 @@
}
}
},
+ "/answer/api/v1/file": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "upload file",
+ "consumes": [
+ "multipart/form-data"
+ ],
+ "tags": [
+ "Upload"
+ ],
+ "summary": "upload file",
+ "parameters": [
+ {
+ "enum": [
+ "post",
+ "avatar",
+ "branding"
+ ],
+ "type": "string",
+ "description": "identify the source of the file upload",
+ "name": "source",
+ "in": "formData",
+ "required": true
+ },
+ {
+ "type": "file",
+ "description": "file",
+ "name": "file",
+ "in": "formData",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "allOf": [
+ {
+ "$ref": "#/definitions/handler.RespBody"
+ },
+ {
+ "type": "object",
+ "properties": {
+ "data": {
+ "type": "string"
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ },
"/answer/api/v1/follow": {
"post": {
"security": [
@@ -3094,52 +3365,6 @@
}
}
},
- "/answer/api/v1/user/avatar/upload": {
- "post": {
- "security": [
- {
- "ApiKeyAuth": []
- }
- ],
- "description": "UserUpdateInfo",
- "consumes": [
- "multipart/form-data"
- ],
- "tags": [
- "User"
- ],
- "summary": "UserUpdateInfo",
- "parameters": [
- {
- "type": "file",
- "description": "file",
- "name": "file",
- "in": "formData",
- "required": true
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "string"
- }
- }
- }
- ]
- }
- }
- }
- }
- },
"/answer/api/v1/user/email": {
"put": {
"security": [
@@ -3659,52 +3884,6 @@
}
}
},
- "/answer/api/v1/user/post/file": {
- "post": {
- "security": [
- {
- "ApiKeyAuth": []
- }
- ],
- "description": "upload user post file",
- "consumes": [
- "multipart/form-data"
- ],
- "tags": [
- "User"
- ],
- "summary": "upload user post file",
- "parameters": [
- {
- "type": "file",
- "description": "file",
- "name": "file",
- "in": "formData",
- "required": true
- }
- ],
- "responses": {
- "200": {
- "description": "OK",
- "schema": {
- "allOf": [
- {
- "$ref": "#/definitions/handler.RespBody"
- },
- {
- "type": "object",
- "properties": {
- "data": {
- "type": "string"
- }
- }
- }
- ]
- }
- }
- }
- }
- },
"/answer/api/v1/user/register/email": {
"post": {
"description": "UserRegisterByEmail",
@@ -5559,6 +5738,56 @@
}
}
},
+ "schema.SiteBrandingReq": {
+ "type": "object",
+ "required": [
+ "logo",
+ "square_icon"
+ ],
+ "properties": {
+ "favicon": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "mobile_logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "square_icon": {
+ "type": "string",
+ "maxLength": 512
+ }
+ }
+ },
+ "schema.SiteBrandingResp": {
+ "type": "object",
+ "required": [
+ "logo",
+ "square_icon"
+ ],
+ "properties": {
+ "favicon": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "mobile_logo": {
+ "type": "string",
+ "maxLength": 512
+ },
+ "square_icon": {
+ "type": "string",
+ "maxLength": 512
+ }
+ }
+ },
"schema.SiteGeneralReq": {
"type": "object",
"required": [
@@ -5635,10 +5864,6 @@
"type": "string",
"maxLength": 128
},
- "logo": {
- "type": "string",
- "maxLength": 256
- },
"theme": {
"type": "string",
"maxLength": 128
@@ -5661,10 +5886,6 @@
"type": "string",
"maxLength": 128
},
- "logo": {
- "type": "string",
- "maxLength": 256
- },
"theme": {
"type": "string",
"maxLength": 128
@@ -5675,6 +5896,50 @@
}
}
},
+ "schema.SiteLegalReq": {
+ "type": "object",
+ "properties": {
+ "privacy_policy": {
+ "type": "string"
+ },
+ "terms_of_service": {
+ "type": "string"
+ }
+ }
+ },
+ "schema.SiteLegalResp": {
+ "type": "object",
+ "properties": {
+ "privacy_policy": {
+ "type": "string"
+ },
+ "terms_of_service": {
+ "type": "string"
+ }
+ }
+ },
+ "schema.SiteWriteReq": {
+ "type": "object",
+ "required": [
+ "required_tag"
+ ],
+ "properties": {
+ "required_tag": {
+ "type": "boolean"
+ }
+ }
+ },
+ "schema.SiteWriteResp": {
+ "type": "object",
+ "required": [
+ "required_tag"
+ ],
+ "properties": {
+ "required_tag": {
+ "type": "boolean"
+ }
+ }
+ },
"schema.TagItem": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 72801460..f5461450 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -1050,6 +1050,42 @@ definitions:
description: object_type
type: string
type: object
+ schema.SiteBrandingReq:
+ properties:
+ favicon:
+ maxLength: 512
+ type: string
+ logo:
+ maxLength: 512
+ type: string
+ mobile_logo:
+ maxLength: 512
+ type: string
+ square_icon:
+ maxLength: 512
+ type: string
+ required:
+ - logo
+ - square_icon
+ type: object
+ schema.SiteBrandingResp:
+ properties:
+ favicon:
+ maxLength: 512
+ type: string
+ logo:
+ maxLength: 512
+ type: string
+ mobile_logo:
+ maxLength: 512
+ type: string
+ square_icon:
+ maxLength: 512
+ type: string
+ required:
+ - logo
+ - square_icon
+ type: object
schema.SiteGeneralReq:
properties:
contact_email:
@@ -1103,9 +1139,6 @@ definitions:
language:
maxLength: 128
type: string
- logo:
- maxLength: 256
- type: string
theme:
maxLength: 128
type: string
@@ -1122,9 +1155,6 @@ definitions:
language:
maxLength: 128
type: string
- logo:
- maxLength: 256
- type: string
theme:
maxLength: 128
type: string
@@ -1136,6 +1166,34 @@ definitions:
- theme
- time_zone
type: object
+ schema.SiteLegalReq:
+ properties:
+ privacy_policy:
+ type: string
+ terms_of_service:
+ type: string
+ type: object
+ schema.SiteLegalResp:
+ properties:
+ privacy_policy:
+ type: string
+ terms_of_service:
+ type: string
+ type: object
+ schema.SiteWriteReq:
+ properties:
+ required_tag:
+ type: boolean
+ required:
+ - required_tag
+ type: object
+ schema.SiteWriteResp:
+ properties:
+ required_tag:
+ type: boolean
+ required:
+ - required_tag
+ type: object
schema.TagItem:
properties:
display_name:
@@ -1784,6 +1842,47 @@ paths:
summary: update smtp config
tags:
- admin
+ /answer/admin/api/siteinfo/branding:
+ get:
+ description: get site interface
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/handler.RespBody'
+ - properties:
+ data:
+ $ref: '#/definitions/schema.SiteBrandingResp'
+ type: object
+ security:
+ - ApiKeyAuth: []
+ summary: get site interface
+ tags:
+ - admin
+ put:
+ description: update site info branding
+ parameters:
+ - description: branding info
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/schema.SiteBrandingReq'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/handler.RespBody'
+ security:
+ - ApiKeyAuth: []
+ summary: update site info branding
+ tags:
+ - admin
/answer/admin/api/siteinfo/general:
get:
description: get site general information
@@ -1866,6 +1965,88 @@ paths:
summary: update site info interface
tags:
- admin
+ /answer/admin/api/siteinfo/legal:
+ get:
+ description: Set the legal information for the site
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/handler.RespBody'
+ - properties:
+ data:
+ $ref: '#/definitions/schema.SiteLegalResp'
+ type: object
+ security:
+ - ApiKeyAuth: []
+ summary: Set the legal information for the site
+ tags:
+ - admin
+ put:
+ description: update site legal info
+ parameters:
+ - description: write info
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/schema.SiteLegalReq'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/handler.RespBody'
+ security:
+ - ApiKeyAuth: []
+ summary: update site legal info
+ tags:
+ - admin
+ /answer/admin/api/siteinfo/write:
+ get:
+ description: get site interface
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/handler.RespBody'
+ - properties:
+ data:
+ $ref: '#/definitions/schema.SiteWriteResp'
+ type: object
+ security:
+ - ApiKeyAuth: []
+ summary: get site interface
+ tags:
+ - admin
+ put:
+ description: update site write info
+ parameters:
+ - description: write info
+ in: body
+ name: data
+ required: true
+ schema:
+ $ref: '#/definitions/schema.SiteWriteReq'
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: '#/definitions/handler.RespBody'
+ security:
+ - ApiKeyAuth: []
+ summary: update site write info
+ tags:
+ - admin
/answer/admin/api/theme/options:
get:
description: Get theme options
@@ -2272,6 +2453,41 @@ paths:
summary: get comment page
tags:
- Comment
+ /answer/api/v1/file:
+ post:
+ consumes:
+ - multipart/form-data
+ description: upload file
+ parameters:
+ - description: identify the source of the file upload
+ enum:
+ - post
+ - avatar
+ - branding
+ in: formData
+ name: source
+ required: true
+ type: string
+ - description: file
+ in: formData
+ name: file
+ required: true
+ type: file
+ responses:
+ "200":
+ description: OK
+ schema:
+ allOf:
+ - $ref: '#/definitions/handler.RespBody'
+ - properties:
+ data:
+ type: string
+ type: object
+ security:
+ - ApiKeyAuth: []
+ summary: upload file
+ tags:
+ - Upload
/answer/api/v1/follow:
post:
consumes:
@@ -3362,32 +3578,6 @@ paths:
summary: ActionRecord
tags:
- User
- /answer/api/v1/user/avatar/upload:
- post:
- consumes:
- - multipart/form-data
- description: UserUpdateInfo
- parameters:
- - description: file
- in: formData
- name: file
- required: true
- type: file
- responses:
- "200":
- description: OK
- schema:
- allOf:
- - $ref: '#/definitions/handler.RespBody'
- - properties:
- data:
- type: string
- type: object
- security:
- - ApiKeyAuth: []
- summary: UserUpdateInfo
- tags:
- - User
/answer/api/v1/user/email:
put:
consumes:
@@ -3708,32 +3898,6 @@ paths:
summary: RetrievePassWord
tags:
- User
- /answer/api/v1/user/post/file:
- post:
- consumes:
- - multipart/form-data
- description: upload user post file
- parameters:
- - description: file
- in: formData
- name: file
- required: true
- type: file
- responses:
- "200":
- description: OK
- schema:
- allOf:
- - $ref: '#/definitions/handler.RespBody'
- - properties:
- data:
- type: string
- type: object
- security:
- - ApiKeyAuth: []
- summary: upload user post file
- tags:
- - User
/answer/api/v1/user/register/email:
post:
consumes:
diff --git a/internal/base/constant/constant.go b/internal/base/constant/constant.go
index 7953916c..54a95c86 100644
--- a/internal/base/constant/constant.go
+++ b/internal/base/constant/constant.go
@@ -55,4 +55,5 @@ const (
SiteTypeInterface = "interface"
SiteTypeBranding = "branding"
SiteTypeWrite = "write"
+ SiteTypeLegal = "legal"
)
diff --git a/internal/controller_backyard/siteinfo_controller.go b/internal/controller_backyard/siteinfo_controller.go
index b32bbf77..3d00f7d7 100644
--- a/internal/controller_backyard/siteinfo_controller.go
+++ b/internal/controller_backyard/siteinfo_controller.go
@@ -65,12 +65,25 @@ func (sc *SiteInfoController) GetSiteBranding(ctx *gin.Context) {
// @Tags admin
// @Produce json
// @Success 200 {object} handler.RespBody{data=schema.SiteWriteResp}
-// @Router /answer/admin/api/siteinfo/branding [get]
+// @Router /answer/admin/api/siteinfo/write [get]
func (sc *SiteInfoController) GetSiteWrite(ctx *gin.Context) {
resp, err := sc.siteInfoService.GetSiteWrite(ctx)
handler.HandleResponse(ctx, err, resp)
}
+// GetSiteLegal Set the legal information for the site
+// @Summary Set the legal information for the site
+// @Description Set the legal information for the site
+// @Security ApiKeyAuth
+// @Tags admin
+// @Produce json
+// @Success 200 {object} handler.RespBody{data=schema.SiteLegalResp}
+// @Router /answer/admin/api/siteinfo/legal [get]
+func (sc *SiteInfoController) GetSiteLegal(ctx *gin.Context) {
+ resp, err := sc.siteInfoService.GetSiteLegal(ctx)
+ handler.HandleResponse(ctx, err, resp)
+}
+
// UpdateGeneral update site general information
// @Summary update site general information
// @Description update site general information
@@ -143,6 +156,24 @@ func (sc *SiteInfoController) UpdateSiteWrite(ctx *gin.Context) {
handler.HandleResponse(ctx, err, nil)
}
+// UpdateSiteLegal update site legal info
+// @Summary update site legal info
+// @Description update site legal info
+// @Security ApiKeyAuth
+// @Tags admin
+// @Produce json
+// @Param data body schema.SiteLegalReq true "write info"
+// @Success 200 {object} handler.RespBody{}
+// @Router /answer/admin/api/siteinfo/legal [put]
+func (sc *SiteInfoController) UpdateSiteLegal(ctx *gin.Context) {
+ req := &schema.SiteLegalReq{}
+ if handler.BindAndCheck(ctx, req) {
+ return
+ }
+ err := sc.siteInfoService.SaveSiteLegal(ctx, req)
+ handler.HandleResponse(ctx, err, nil)
+}
+
// GetSMTPConfig get smtp config
// @Summary GetSMTPConfig get smtp config
// @Description GetSMTPConfig get smtp config
diff --git a/internal/router/answer_api_router.go b/internal/router/answer_api_router.go
index 7020b82f..a9a3e6a7 100644
--- a/internal/router/answer_api_router.go
+++ b/internal/router/answer_api_router.go
@@ -229,10 +229,12 @@ func (a *AnswerAPIRouter) RegisterAnswerCmsAPIRouter(r *gin.RouterGroup) {
r.GET("/siteinfo/interface", a.siteInfoController.GetInterface)
r.GET("/siteinfo/branding", a.siteInfoController.GetSiteBranding)
r.GET("/siteinfo/write", a.siteInfoController.GetSiteWrite)
+ r.GET("/siteinfo/legal", a.siteInfoController.GetSiteLegal)
r.PUT("/siteinfo/general", a.siteInfoController.UpdateGeneral)
r.PUT("/siteinfo/interface", a.siteInfoController.UpdateInterface)
r.PUT("/siteinfo/branding", a.siteInfoController.UpdateBranding)
r.PUT("/siteinfo/write", a.siteInfoController.UpdateSiteWrite)
+ r.PUT("/siteinfo/legal", a.siteInfoController.UpdateSiteLegal)
r.GET("/setting/smtp", a.siteInfoController.GetSMTPConfig)
r.PUT("/setting/smtp", a.siteInfoController.UpdateSMTPConfig)
diff --git a/internal/schema/siteinfo_schema.go b/internal/schema/siteinfo_schema.go
index 8684be8b..665fa50c 100644
--- a/internal/schema/siteinfo_schema.go
+++ b/internal/schema/siteinfo_schema.go
@@ -42,6 +42,12 @@ type SiteWriteReq struct {
RequiredTag bool `validate:"required" form:"required_tag" json:"required_tag"`
}
+// SiteLegalReq site branding request
+type SiteLegalReq struct {
+ TermsOfService string `validate:"omitempty" form:"terms_of_service" json:"terms_of_service,omitempty"`
+ PrivacyPolicy string `validate:"omitempty" form:"privacy_policy" json:"privacy_policy,omitempty"`
+}
+
// SiteGeneralResp site general response
type SiteGeneralResp SiteGeneralReq
@@ -54,6 +60,9 @@ type SiteBrandingResp SiteBrandingReq
// SiteWriteResp site write response
type SiteWriteResp SiteWriteReq
+// SiteLegalResp site write response
+type SiteLegalResp SiteLegalReq
+
// SiteInfoResp get site info response
type SiteInfoResp struct {
General *SiteGeneralResp `json:"general"`
diff --git a/internal/service/siteinfo/siteinfo_service.go b/internal/service/siteinfo/siteinfo_service.go
index 66917ae4..03d1661c 100644
--- a/internal/service/siteinfo/siteinfo_service.go
+++ b/internal/service/siteinfo/siteinfo_service.go
@@ -84,6 +84,20 @@ func (s *SiteInfoService) GetSiteWrite(ctx context.Context) (resp *schema.SiteWr
return resp, nil
}
+// GetSiteLegal get site legal info
+func (s *SiteInfoService) GetSiteLegal(ctx context.Context) (resp *schema.SiteLegalResp, err error) {
+ siteInfo, exist, err := s.siteInfoRepo.GetByType(ctx, constant.SiteTypeLegal)
+ if err != nil {
+ return nil, err
+ }
+ if !exist {
+ return nil, errors.BadRequest(reason.SiteInfoNotFound)
+ }
+ resp = &schema.SiteLegalResp{}
+ _ = json.Unmarshal([]byte(siteInfo.Content), resp)
+ return resp, nil
+}
+
func (s *SiteInfoService) SaveSiteGeneral(ctx context.Context, req schema.SiteGeneralReq) (err error) {
req.FormatSiteUrl()
var (
@@ -159,6 +173,17 @@ func (s *SiteInfoService) SaveSiteWrite(ctx context.Context, req *schema.SiteWri
return s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeWrite, data)
}
+// SaveSiteLegal save site legal configuration
+func (s *SiteInfoService) SaveSiteLegal(ctx context.Context, req *schema.SiteLegalReq) (err error) {
+ content, _ := json.Marshal(req)
+ data := &entity.SiteInfo{
+ Type: constant.SiteTypeLegal,
+ Content: string(content),
+ Status: 1,
+ }
+ return s.siteInfoRepo.SaveByType(ctx, constant.SiteTypeLegal, data)
+}
+
// GetSMTPConfig get smtp config
func (s *SiteInfoService) GetSMTPConfig(ctx context.Context) (
resp *schema.GetSMTPConfigResp, err error,