63 lines
2.5 KiB
Go
63 lines
2.5 KiB
Go
|
|
package public
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"github.com/gogf/gf/v2/frame/g"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// QueryReq 公共查询请求
|
|||
|
|
type QueryReq struct {
|
|||
|
|
g.Meta `path:"/public/query" method:"post" tags:"公共查询" summary:"公共数据查询" dc:"支持字段/表名/过滤/分组/分页的通用查询接口"`
|
|||
|
|
Table string `json:"table" v:"required" dc:"表名(白名单限制)"`
|
|||
|
|
Fields string `json:"fields" dc:"查询字段,逗号分隔,默认 *"`
|
|||
|
|
Where map[string]interface{} `json:"where" dc:"过滤条件,支持操作符: =, !=, >, <, >=, <=, like, in, between"`
|
|||
|
|
GroupBy string `json:"groupBy" dc:"分组字段,逗号分隔"`
|
|||
|
|
OrderBy string `json:"orderBy" dc:"排序字段,如: create_time desc"`
|
|||
|
|
Page int `json:"page" dc:"页码,默认1" d:"1"`
|
|||
|
|
PageSize int `json:"pageSize" dc:"每页条数,默认20,最大100" d:"20"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// QueryRes 公共查询响应
|
|||
|
|
type QueryRes struct {
|
|||
|
|
List []map[string]interface{} `json:"list" dc:"数据列表"`
|
|||
|
|
Total int64 `json:"total" dc:"总数"`
|
|||
|
|
Page int `json:"page" dc:"当前页码"`
|
|||
|
|
Size int `json:"size" dc:"每页条数"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// TableListReq 获取可查询表列表请求
|
|||
|
|
type TableListReq struct {
|
|||
|
|
g.Meta `path:"/public/tables" method:"get" tags:"公共查询" summary:"获取可查询表列表" dc:"获取配置了表结构的同步表列表"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// TableListRes 获取可查询表列表响应
|
|||
|
|
type TableListRes struct {
|
|||
|
|
List []TableInfo `json:"list" dc:"表列表"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// TableInfo 表信息
|
|||
|
|
type TableInfo struct {
|
|||
|
|
TableName string `json:"tableName" dc:"表名"`
|
|||
|
|
PlatformName string `json:"platformName" dc:"平台名称"`
|
|||
|
|
InterfaceName string `json:"interfaceName" dc:"接口名称"`
|
|||
|
|
Columns []string `json:"columns" dc:"可用字段列表"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ColumnListReq 获取表字段列表请求
|
|||
|
|
type ColumnListReq struct {
|
|||
|
|
g.Meta `path:"/public/tables/{table}/columns" method:"get" tags:"公共查询" summary:"获取表字段列表" dc:"获取指定表的字段列表"`
|
|||
|
|
Table string `json:"table" dc:"表名"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// ColumnListRes 获取表字段列表响应
|
|||
|
|
type ColumnListRes struct {
|
|||
|
|
TableName string `json:"tableName" dc:"表名"`
|
|||
|
|
Columns []Column `json:"columns" dc:"字段列表"`
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// Column 字段信息
|
|||
|
|
type Column struct {
|
|||
|
|
Name string `json:"name" dc:"字段名"`
|
|||
|
|
Type string `json:"type" dc:"字段类型"`
|
|||
|
|
Comment string `json:"comment" dc:"字段说明"`
|
|||
|
|
}
|