feat(1.0): 优化代码
This commit is contained in:
parent
5f9908195f
commit
d4ec080dc5
194
docs/docs.go
194
docs/docs.go
@ -696,6 +696,72 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/admin/messages": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"LoginVerifyToken": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "获取消息日志",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"管理端.小程序"
|
||||||
|
],
|
||||||
|
"summary": "获取消息日志",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "小程序ID",
|
||||||
|
"name": "app_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "用户ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "当前页码",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 20,
|
||||||
|
"description": "每页返回的数据量,最多 100 条",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.appMessagePageListResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/admin/send_message": {
|
"/admin/send_message": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@ -721,7 +787,7 @@ const docTemplate = `{
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/message.adminSendMessageRequest"
|
"$ref": "#/definitions/app.adminSendMessageRequest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -729,7 +795,7 @@ const docTemplate = `{
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/message.adminSendMessageResponse"
|
"$ref": "#/definitions/app.adminSendMessageResponse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
@ -948,6 +1014,65 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.adminSendMessageRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"content",
|
||||||
|
"msg_type",
|
||||||
|
"to_user_id"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "小程序ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"description": "内容",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"msg_type": {
|
||||||
|
"description": "消息类型(1:文本 2:图片)",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"to_user_id": {
|
||||||
|
"description": "接收用户ID",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.adminSendMessageResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"description": "提示信息",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.appMessagePageListResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"list": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/app.listMessageData"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"description": "当前页码",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"page_size": {
|
||||||
|
"description": "每页返回的数据量",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"total": {
|
||||||
|
"description": "符合查询条件的总记录数",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.createAppRequest": {
|
"app.createAppRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -1075,6 +1200,35 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.listMessageData": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"content": {
|
||||||
|
"description": "消息内容",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"msg_type": {
|
||||||
|
"description": "消息类型(1:文本 2:图片)",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"receiver_id": {
|
||||||
|
"description": "接收人ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"send_time": {
|
||||||
|
"description": "发送时间",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sender_id": {
|
||||||
|
"description": "发送人ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sender_name": {
|
||||||
|
"description": "发送人昵称",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.listResponse": {
|
"app.listResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1446,42 +1600,6 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"message.adminSendMessageRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"app_id",
|
|
||||||
"content",
|
|
||||||
"msg_type",
|
|
||||||
"to_user_id"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"app_id": {
|
|
||||||
"description": "小程序ID",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"content": {
|
|
||||||
"description": "内容",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"msg_type": {
|
|
||||||
"description": "消息类型(1:文本 2:图片)",
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"to_user_id": {
|
|
||||||
"description": "接收用户ID",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"message.adminSendMessageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"message": {
|
|
||||||
"description": "提示信息",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"message.appMessagePageListResponse": {
|
"message.appMessagePageListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@ -688,6 +688,72 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"/admin/messages": {
|
||||||
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"LoginVerifyToken": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "获取消息日志",
|
||||||
|
"consumes": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"produces": [
|
||||||
|
"application/json"
|
||||||
|
],
|
||||||
|
"tags": [
|
||||||
|
"管理端.小程序"
|
||||||
|
],
|
||||||
|
"summary": "获取消息日志",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "小程序ID",
|
||||||
|
"name": "app_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"description": "用户ID",
|
||||||
|
"name": "user_id",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 1,
|
||||||
|
"description": "当前页码",
|
||||||
|
"name": "page",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "integer",
|
||||||
|
"default": 20,
|
||||||
|
"description": "每页返回的数据量,最多 100 条",
|
||||||
|
"name": "page_size",
|
||||||
|
"in": "query",
|
||||||
|
"required": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "OK",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/app.appMessagePageListResponse"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "Bad Request",
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/definitions/code.Failure"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"/admin/send_message": {
|
"/admin/send_message": {
|
||||||
"post": {
|
"post": {
|
||||||
"security": [
|
"security": [
|
||||||
@ -713,7 +779,7 @@
|
|||||||
"in": "body",
|
"in": "body",
|
||||||
"required": true,
|
"required": true,
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/message.adminSendMessageRequest"
|
"$ref": "#/definitions/app.adminSendMessageRequest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@ -721,7 +787,7 @@
|
|||||||
"200": {
|
"200": {
|
||||||
"description": "OK",
|
"description": "OK",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/definitions/message.adminSendMessageResponse"
|
"$ref": "#/definitions/app.adminSendMessageResponse"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"400": {
|
"400": {
|
||||||
@ -940,6 +1006,65 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.adminSendMessageRequest": {
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"app_id",
|
||||||
|
"content",
|
||||||
|
"msg_type",
|
||||||
|
"to_user_id"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"app_id": {
|
||||||
|
"description": "小程序ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"description": "内容",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"msg_type": {
|
||||||
|
"description": "消息类型(1:文本 2:图片)",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"to_user_id": {
|
||||||
|
"description": "接收用户ID",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.adminSendMessageResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"message": {
|
||||||
|
"description": "提示信息",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"app.appMessagePageListResponse": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"list": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/app.listMessageData"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"page": {
|
||||||
|
"description": "当前页码",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"page_size": {
|
||||||
|
"description": "每页返回的数据量",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"total": {
|
||||||
|
"description": "符合查询条件的总记录数",
|
||||||
|
"type": "integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.createAppRequest": {
|
"app.createAppRequest": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": [
|
||||||
@ -1067,6 +1192,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"app.listMessageData": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"content": {
|
||||||
|
"description": "消息内容",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"msg_type": {
|
||||||
|
"description": "消息类型(1:文本 2:图片)",
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
"receiver_id": {
|
||||||
|
"description": "接收人ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"send_time": {
|
||||||
|
"description": "发送时间",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sender_id": {
|
||||||
|
"description": "发送人ID",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"sender_name": {
|
||||||
|
"description": "发送人昵称",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"app.listResponse": {
|
"app.listResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
@ -1438,42 +1592,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"message.adminSendMessageRequest": {
|
|
||||||
"type": "object",
|
|
||||||
"required": [
|
|
||||||
"app_id",
|
|
||||||
"content",
|
|
||||||
"msg_type",
|
|
||||||
"to_user_id"
|
|
||||||
],
|
|
||||||
"properties": {
|
|
||||||
"app_id": {
|
|
||||||
"description": "小程序ID",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"content": {
|
|
||||||
"description": "内容",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"msg_type": {
|
|
||||||
"description": "消息类型(1:文本 2:图片)",
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"to_user_id": {
|
|
||||||
"description": "接收用户ID",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"message.adminSendMessageResponse": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"message": {
|
|
||||||
"description": "提示信息",
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"message.appMessagePageListResponse": {
|
"message.appMessagePageListResponse": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|||||||
@ -18,6 +18,48 @@ definitions:
|
|||||||
description: 登录成功后颁发的 Token
|
description: 登录成功后颁发的 Token
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
app.adminSendMessageRequest:
|
||||||
|
properties:
|
||||||
|
app_id:
|
||||||
|
description: 小程序ID
|
||||||
|
type: string
|
||||||
|
content:
|
||||||
|
description: 内容
|
||||||
|
type: string
|
||||||
|
msg_type:
|
||||||
|
description: 消息类型(1:文本 2:图片)
|
||||||
|
type: integer
|
||||||
|
to_user_id:
|
||||||
|
description: 接收用户ID
|
||||||
|
type: string
|
||||||
|
required:
|
||||||
|
- app_id
|
||||||
|
- content
|
||||||
|
- msg_type
|
||||||
|
- to_user_id
|
||||||
|
type: object
|
||||||
|
app.adminSendMessageResponse:
|
||||||
|
properties:
|
||||||
|
message:
|
||||||
|
description: 提示信息
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
|
app.appMessagePageListResponse:
|
||||||
|
properties:
|
||||||
|
list:
|
||||||
|
items:
|
||||||
|
$ref: '#/definitions/app.listMessageData'
|
||||||
|
type: array
|
||||||
|
page:
|
||||||
|
description: 当前页码
|
||||||
|
type: integer
|
||||||
|
page_size:
|
||||||
|
description: 每页返回的数据量
|
||||||
|
type: integer
|
||||||
|
total:
|
||||||
|
description: 符合查询条件的总记录数
|
||||||
|
type: integer
|
||||||
|
type: object
|
||||||
app.createAppRequest:
|
app.createAppRequest:
|
||||||
properties:
|
properties:
|
||||||
app_id:
|
app_id:
|
||||||
@ -108,6 +150,27 @@ definitions:
|
|||||||
description: 更新时间
|
description: 更新时间
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
|
app.listMessageData:
|
||||||
|
properties:
|
||||||
|
content:
|
||||||
|
description: 消息内容
|
||||||
|
type: string
|
||||||
|
msg_type:
|
||||||
|
description: 消息类型(1:文本 2:图片)
|
||||||
|
type: integer
|
||||||
|
receiver_id:
|
||||||
|
description: 接收人ID
|
||||||
|
type: string
|
||||||
|
send_time:
|
||||||
|
description: 发送时间
|
||||||
|
type: string
|
||||||
|
sender_id:
|
||||||
|
description: 发送人ID
|
||||||
|
type: string
|
||||||
|
sender_name:
|
||||||
|
description: 发送人昵称
|
||||||
|
type: string
|
||||||
|
type: object
|
||||||
app.listResponse:
|
app.listResponse:
|
||||||
properties:
|
properties:
|
||||||
list:
|
list:
|
||||||
@ -369,32 +432,6 @@ definitions:
|
|||||||
description: 提示信息
|
description: 提示信息
|
||||||
type: string
|
type: string
|
||||||
type: object
|
type: object
|
||||||
message.adminSendMessageRequest:
|
|
||||||
properties:
|
|
||||||
app_id:
|
|
||||||
description: 小程序ID
|
|
||||||
type: string
|
|
||||||
content:
|
|
||||||
description: 内容
|
|
||||||
type: string
|
|
||||||
msg_type:
|
|
||||||
description: 消息类型(1:文本 2:图片)
|
|
||||||
type: integer
|
|
||||||
to_user_id:
|
|
||||||
description: 接收用户ID
|
|
||||||
type: string
|
|
||||||
required:
|
|
||||||
- app_id
|
|
||||||
- content
|
|
||||||
- msg_type
|
|
||||||
- to_user_id
|
|
||||||
type: object
|
|
||||||
message.adminSendMessageResponse:
|
|
||||||
properties:
|
|
||||||
message:
|
|
||||||
description: 提示信息
|
|
||||||
type: string
|
|
||||||
type: object
|
|
||||||
message.appMessagePageListResponse:
|
message.appMessagePageListResponse:
|
||||||
properties:
|
properties:
|
||||||
list:
|
list:
|
||||||
@ -914,6 +951,50 @@ paths:
|
|||||||
summary: 管理员登录
|
summary: 管理员登录
|
||||||
tags:
|
tags:
|
||||||
- 管理端.登录
|
- 管理端.登录
|
||||||
|
/admin/messages:
|
||||||
|
get:
|
||||||
|
consumes:
|
||||||
|
- application/json
|
||||||
|
description: 获取消息日志
|
||||||
|
parameters:
|
||||||
|
- description: 小程序ID
|
||||||
|
in: query
|
||||||
|
name: app_id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- description: 用户ID
|
||||||
|
in: query
|
||||||
|
name: user_id
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
- default: 1
|
||||||
|
description: 当前页码
|
||||||
|
in: query
|
||||||
|
name: page
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
- default: 20
|
||||||
|
description: 每页返回的数据量,最多 100 条
|
||||||
|
in: query
|
||||||
|
name: page_size
|
||||||
|
required: true
|
||||||
|
type: integer
|
||||||
|
produces:
|
||||||
|
- application/json
|
||||||
|
responses:
|
||||||
|
"200":
|
||||||
|
description: OK
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/app.appMessagePageListResponse'
|
||||||
|
"400":
|
||||||
|
description: Bad Request
|
||||||
|
schema:
|
||||||
|
$ref: '#/definitions/code.Failure'
|
||||||
|
security:
|
||||||
|
- LoginVerifyToken: []
|
||||||
|
summary: 获取消息日志
|
||||||
|
tags:
|
||||||
|
- 管理端.小程序
|
||||||
/admin/send_message:
|
/admin/send_message:
|
||||||
post:
|
post:
|
||||||
consumes:
|
consumes:
|
||||||
@ -925,14 +1006,14 @@ paths:
|
|||||||
name: RequestBody
|
name: RequestBody
|
||||||
required: true
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/message.adminSendMessageRequest'
|
$ref: '#/definitions/app.adminSendMessageRequest'
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
responses:
|
||||||
"200":
|
"200":
|
||||||
description: OK
|
description: OK
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/message.adminSendMessageResponse'
|
$ref: '#/definitions/app.adminSendMessageResponse'
|
||||||
"400":
|
"400":
|
||||||
description: Bad Request
|
description: Bad Request
|
||||||
schema:
|
schema:
|
||||||
|
|||||||
131
internal/api/app/app_message_list.go
Normal file
131
internal/api/app/app_message_list.go
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"mini-chat/internal/code"
|
||||||
|
"mini-chat/internal/pkg/core"
|
||||||
|
"mini-chat/internal/pkg/timeutil"
|
||||||
|
"mini-chat/internal/pkg/validation"
|
||||||
|
|
||||||
|
"gorm.io/gorm"
|
||||||
|
)
|
||||||
|
|
||||||
|
type appMessagePageListRequest struct {
|
||||||
|
AppID string `form:"app_id" binding:"required"` // 小程序ID
|
||||||
|
UserID string `form:"user_id" binding:"required"` // 用户ID
|
||||||
|
Page int `form:"page"` // 当前页码,默认为第一页
|
||||||
|
PageSize int `form:"page_size"` // 每页返回的数据量
|
||||||
|
}
|
||||||
|
|
||||||
|
type listMessageData struct {
|
||||||
|
SendTime string `json:"send_time"` // 发送时间
|
||||||
|
SenderID string `json:"sender_id"` // 发送人ID
|
||||||
|
SenderName string `json:"sender_name"` // 发送人昵称
|
||||||
|
ReceiverID string `json:"receiver_id"` // 接收人ID
|
||||||
|
Content string `json:"content"` // 消息内容
|
||||||
|
MsgType int32 `json:"msg_type"` // 消息类型(1:文本 2:图片)
|
||||||
|
}
|
||||||
|
|
||||||
|
type appMessagePageListResponse struct {
|
||||||
|
Page int `json:"page"` // 当前页码
|
||||||
|
PageSize int `json:"page_size"` // 每页返回的数据量
|
||||||
|
Total int64 `json:"total"` // 符合查询条件的总记录数
|
||||||
|
List []listMessageData `json:"list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AppMessagePageList 获取消息日志
|
||||||
|
// @Summary 获取消息日志
|
||||||
|
// @Description 获取消息日志
|
||||||
|
// @Tags 管理端.小程序
|
||||||
|
// @Accept json
|
||||||
|
// @Produce json
|
||||||
|
// @Param app_id query string true "小程序ID"
|
||||||
|
// @Param user_id query string true "用户ID"
|
||||||
|
// @Param page query int true "当前页码" default(1)
|
||||||
|
// @Param page_size query int true "每页返回的数据量,最多 100 条" default(20)
|
||||||
|
// @Success 200 {object} appMessagePageListResponse
|
||||||
|
// @Failure 400 {object} code.Failure
|
||||||
|
// @Router /admin/messages [get]
|
||||||
|
// @Security LoginVerifyToken
|
||||||
|
func (h *handler) AppMessagePageList() core.HandlerFunc {
|
||||||
|
return func(ctx core.Context) {
|
||||||
|
req := new(appMessagePageListRequest)
|
||||||
|
res := new(appMessagePageListResponse)
|
||||||
|
if err := ctx.ShouldBindForm(req); err != nil {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.ParamBindError,
|
||||||
|
validation.Error(err)),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.Page == 0 {
|
||||||
|
req.Page = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.PageSize == 0 {
|
||||||
|
req.PageSize = 20
|
||||||
|
}
|
||||||
|
|
||||||
|
if req.PageSize > 100 {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.ListMessageError,
|
||||||
|
fmt.Sprintf("%s: 一次最多只能查询 100 条", code.Text(code.ListMessageError)),
|
||||||
|
))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
query := h.readDB.AppMessageLog.WithContext(ctx.RequestContext()).
|
||||||
|
Where(h.readDB.AppMessageLog.AppID.Eq(req.AppID)).
|
||||||
|
Where(h.readDB.AppMessageLog.SenderID.Eq(req.UserID)).Or(h.readDB.AppMessageLog.ReceiverID.Eq(req.UserID))
|
||||||
|
|
||||||
|
listQueryDB := query.Session(&gorm.Session{})
|
||||||
|
countQueryDB := query.Session(&gorm.Session{})
|
||||||
|
|
||||||
|
resultData, err := listQueryDB.
|
||||||
|
Order(h.readDB.AppMessageLog.SendTime.Desc()).
|
||||||
|
Limit(req.PageSize).
|
||||||
|
Offset((req.Page - 1) * req.PageSize).
|
||||||
|
Find()
|
||||||
|
if err != nil {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.ListMessageError,
|
||||||
|
fmt.Sprintf("%s:%s", code.Text(code.ListMessageError), err.Error())),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
count, err := countQueryDB.Count()
|
||||||
|
if err != nil {
|
||||||
|
ctx.AbortWithError(core.Error(
|
||||||
|
http.StatusBadRequest,
|
||||||
|
code.ListMessageError,
|
||||||
|
fmt.Sprintf("%s:%s", code.Text(code.ListMessageError), err.Error())),
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res.Page = req.Page
|
||||||
|
res.PageSize = req.PageSize
|
||||||
|
res.Total = count
|
||||||
|
res.List = make([]listMessageData, len(resultData))
|
||||||
|
|
||||||
|
for k, v := range resultData {
|
||||||
|
res.List[k] = listMessageData{
|
||||||
|
SendTime: timeutil.FriendlyTime(v.SendTime),
|
||||||
|
SenderID: v.SenderID,
|
||||||
|
SenderName: v.SenderName,
|
||||||
|
ReceiverID: v.ReceiverID,
|
||||||
|
Content: v.Content,
|
||||||
|
MsgType: v.MsgType,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.Payload(res)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package message
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -82,8 +82,9 @@ func NewHTTPMux(logger logger.CustomLogger, db mysql.Repo, cron cron.Server) (co
|
|||||||
adminAuthApiRouter.PUT("/app/keyword/material/:id", keywordHandler.ModifyKeywordMaterial()) // 修改意图关键字素材
|
adminAuthApiRouter.PUT("/app/keyword/material/:id", keywordHandler.ModifyKeywordMaterial()) // 修改意图关键字素材
|
||||||
adminAuthApiRouter.GET("/app/keyword/materials", keywordHandler.KeywordMaterialPageList()) // 获取意图关键字素材列表
|
adminAuthApiRouter.GET("/app/keyword/materials", keywordHandler.KeywordMaterialPageList()) // 获取意图关键字素材列表
|
||||||
|
|
||||||
adminAuthApiRouter.GET("/app/users", appHandler.UserPageList()) // 获取小程序用户列表
|
adminAuthApiRouter.GET("/app/users", appHandler.UserPageList()) // 获取小程序用户列表
|
||||||
adminAuthApiRouter.POST("/send_message", messageHandler.AdminSendMessage()) // 发送消息
|
adminAuthApiRouter.POST("/send_message", appHandler.AdminSendMessage()) // 发送消息
|
||||||
|
adminAuthApiRouter.GET("/messages", appHandler.AppMessagePageList()) // 获取小程序用户消息列表
|
||||||
}
|
}
|
||||||
|
|
||||||
return mux, nil
|
return mux, nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user