feat: add Go backend
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
package sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
type DashboardSummaryInp struct {
|
||||
StartDate *gtime.Time `json:"startDate" dc:"开始日期"`
|
||||
EndDate *gtime.Time `json:"endDate" dc:"结束日期"`
|
||||
}
|
||||
|
||||
func (in *DashboardSummaryInp) Filter(ctx context.Context) error {
|
||||
if in.StartDate == nil && in.EndDate == nil {
|
||||
return nil
|
||||
}
|
||||
if in.StartDate == nil || in.EndDate == nil {
|
||||
return gerror.New("开始日期和结束日期必须同时填写")
|
||||
}
|
||||
if in.StartDate.After(in.EndDate) {
|
||||
return gerror.New("开始日期不能晚于结束日期")
|
||||
}
|
||||
if in.EndDate.Sub(in.StartDate) > 366*24*60*60*1e9 {
|
||||
return gerror.New("单次最多查询366天")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DashboardRangeModel struct {
|
||||
StartDate string `json:"startDate"`
|
||||
EndDate string `json:"endDate"`
|
||||
}
|
||||
|
||||
type DashboardMetricModel struct {
|
||||
Code string `json:"code"`
|
||||
Title string `json:"title"`
|
||||
Value int64 `json:"value"`
|
||||
PreviousValue int64 `json:"previousValue"`
|
||||
ChangeRate float64 `json:"changeRate"`
|
||||
ValueType string `json:"valueType" dc:"count或amount"`
|
||||
Masked bool `json:"masked"`
|
||||
Description string `json:"description"`
|
||||
RouteName string `json:"routeName"`
|
||||
}
|
||||
|
||||
type DashboardTrendPointModel struct {
|
||||
Date string `json:"date"`
|
||||
OrderAmount int64 `json:"orderAmount"`
|
||||
RechargeAmount int64 `json:"rechargeAmount"`
|
||||
WithdrawalAmount int64 `json:"withdrawalAmount"`
|
||||
CommissionAmount int64 `json:"commissionAmount"`
|
||||
}
|
||||
|
||||
type DashboardChannelModel struct {
|
||||
Channel string `json:"channel"`
|
||||
Label string `json:"label"`
|
||||
RechargeCount int64 `json:"rechargeCount"`
|
||||
RechargeAmount int64 `json:"rechargeAmount"`
|
||||
WithdrawalCount int64 `json:"withdrawalCount"`
|
||||
WithdrawalAmount int64 `json:"withdrawalAmount"`
|
||||
PreviousRechargeCount int64 `json:"previousRechargeCount"`
|
||||
PreviousRechargeAmount int64 `json:"previousRechargeAmount"`
|
||||
PreviousWithdrawalCount int64 `json:"previousWithdrawalCount"`
|
||||
PreviousWithdrawalAmount int64 `json:"previousWithdrawalAmount"`
|
||||
Masked bool `json:"masked"`
|
||||
}
|
||||
|
||||
type DashboardSummaryModel struct {
|
||||
Range DashboardRangeModel `json:"range"`
|
||||
Metrics []*DashboardMetricModel `json:"metrics"`
|
||||
Trend []*DashboardTrendPointModel `json:"trend"`
|
||||
Channels []*DashboardChannelModel `json:"channels"`
|
||||
GeneratedAt *gtime.Time `json:"generatedAt"`
|
||||
DataAsOf *gtime.Time `json:"dataAsOf"`
|
||||
DataDelaySeconds int64 `json:"dataDelaySeconds"`
|
||||
DataReady bool `json:"dataReady"`
|
||||
Warning string `json:"warning"`
|
||||
}
|
||||
Reference in New Issue
Block a user