初始化项目
This commit is contained in:
@@ -40,13 +40,8 @@ func (c *adPosition) List(ctx context.Context, req *dto.ListAdPositionReq) (res
|
|||||||
return service.AdPosition.List(ctx, req)
|
return service.AdPosition.List(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatistics 获取广告位统计数据
|
|
||||||
func (c *adPosition) GetStatistics(ctx context.Context, req *dto.GetAdPositionStatisticsReq) (res *dto.GetAdPositionStatisticsRes, err error) {
|
|
||||||
return service.AdPosition.GetStatistics(ctx, req)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAvailableAdPositions 获取可用的广告位列表
|
// GetAvailableAdPositions 获取可用的广告位列表
|
||||||
func (c *adPosition) GetAvailableAdPositions(ctx context.Context, req *dto.GetAvailableAdPositionsReq) (res *dto.GetAvailableAdPositionsRes, err error) {
|
func (c *adPosition) GetAvailableAdPositions(ctx context.Context, _ *dto.GetAvailableAdPositionsReq) (res *dto.GetAvailableAdPositionsRes, err error) {
|
||||||
list, err := service.AdPosition.GetAvailableAdPositions(ctx)
|
list, err := service.AdPosition.GetAvailableAdPositions(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -44,8 +44,3 @@ func (c *advertisement) GetOne(ctx context.Context, req *dto.GetAdvertisementReq
|
|||||||
func (c *advertisement) List(ctx context.Context, req *dto.ListAdvertisementReq) (res *dto.ListAdvertisementRes, err error) {
|
func (c *advertisement) List(ctx context.Context, req *dto.ListAdvertisementReq) (res *dto.ListAdvertisementRes, err error) {
|
||||||
return service.Advertisement.List(ctx, req)
|
return service.Advertisement.List(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatistics 获取广告统计数据
|
|
||||||
func (c *advertisement) GetStatistics(ctx context.Context, req *dto.GetAdStatisticsForAdvertisementReq) (res *dto.GetAdStatisticsForAdvertisementRes, err error) {
|
|
||||||
return service.Advertisement.GetStatistics(ctx, req)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -33,20 +33,6 @@ func (c *cid) GenerateCID(ctx context.Context, req *dto.GenerateCIDReq) (res *dt
|
|||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatistics 获取CID统计信息
|
|
||||||
func (c *cid) GetStatistics(ctx context.Context, req *dto.GetCIDStatisticsReq) (res *dto.GetCIDStatisticsRes, err error) {
|
|
||||||
if req == nil {
|
|
||||||
return nil, gerror.New("请求参数不能为空")
|
|
||||||
}
|
|
||||||
|
|
||||||
result, err := service.CID.GetCIDStatistics(ctx, req)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCIDHistory 获取CID历史记录
|
// GetCIDHistory 获取CID历史记录
|
||||||
func (c *cid) GetCIDHistory(ctx context.Context, req *dto.GetCIDHistoryReq) (res *dto.GetCIDHistoryRes, err error) {
|
func (c *cid) GetCIDHistory(ctx context.Context, req *dto.GetCIDHistoryReq) (res *dto.GetCIDHistoryRes, err error) {
|
||||||
if req == nil {
|
if req == nil {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ func (c *statReport) RealTimeStats(ctx context.Context, req *dto.RealTimeStatReq
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ExportReport 导出报表
|
// ExportReport 导出报表
|
||||||
func (c *statReport) ExportReport(ctx context.Context, req *dto.ReportDetailReq) (res *dto.ExportReportRes, err error) {
|
func (c *statReport) ExportReport(ctx context.Context, req *dto.ExportReportReq) (res *dto.ExportReportRes, err error) {
|
||||||
// 获取报表详情
|
// 获取报表详情
|
||||||
resp, err := service.StatReport.GetReportDetail(ctx, req.ReportID)
|
resp, err := service.StatReport.GetReportDetail(ctx, req.ReportID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var AdSource = &adSourceDao{}
|
||||||
AdSource = adSourceDao{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type adSourceDao struct{}
|
type adSourceDao struct{}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var CIDRequest = &cidRequestDao{}
|
||||||
CIDRequest = cidRequestDao{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type cidRequestDao struct{}
|
type cidRequestDao struct{}
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var Strategy = &strategyDao{}
|
||||||
Strategy = strategyDao{}
|
|
||||||
)
|
|
||||||
|
|
||||||
type strategyDao struct{}
|
type strategyDao struct{}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Tenant = tenantDao{}
|
var Tenant = &tenantDao{}
|
||||||
|
|
||||||
type tenantDao struct{}
|
type tenantDao struct{}
|
||||||
|
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -22,7 +22,7 @@ func main() {
|
|||||||
controller.Report,
|
controller.Report,
|
||||||
//controller.RateLimit,
|
//controller.RateLimit,
|
||||||
//controller.Application,
|
//controller.Application,
|
||||||
//controller.StatReport,
|
controller.StatReport,
|
||||||
})
|
})
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,21 +126,6 @@ type UpdateAdPositionStatusReq struct {
|
|||||||
Status string `json:"status" v:"required"` // 广告位状态:启用、禁用、测试
|
Status string `json:"status" v:"required"` // 广告位状态:启用、禁用、测试
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAdPositionStatisticsReq 获取广告位统计数据请求
|
|
||||||
type GetAdPositionStatisticsReq struct {
|
|
||||||
g.Meta `path:"/getStatistics" method:"get" tags:"广告位管理" summary:"获取广告位统计数据" dc:"获取广告位的统计数据"`
|
|
||||||
|
|
||||||
Id string `json:"id" v:"required"` // 广告位ID
|
|
||||||
StatType string `json:"statType" v:"required"` // 统计类型:天、周、月
|
|
||||||
StartDate int64 `json:"startDate"` // 开始日期
|
|
||||||
EndDate int64 `json:"endDate"` // 结束日期
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetAdPositionStatisticsRes struct {
|
|
||||||
Statistics []*entity.AdStatistics `json:"statistics"`
|
|
||||||
Total int `json:"total"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetAvailableAdPositionsReq 获取可用广告位请求
|
// GetAvailableAdPositionsReq 获取可用广告位请求
|
||||||
type GetAvailableAdPositionsReq struct {
|
type GetAvailableAdPositionsReq struct {
|
||||||
g.Meta `path:"/getAvailableAdPositions" method:"get" tags:"广告位管理" summary:"获取可用广告位列表" dc:"获取所有启用的广告位列表"`
|
g.Meta `path:"/getAvailableAdPositions" method:"get" tags:"广告位管理" summary:"获取可用广告位列表" dc:"获取所有启用的广告位列表"`
|
||||||
|
|||||||
@@ -117,17 +117,3 @@ type UpdateAdStatusReq struct {
|
|||||||
Id string `json:"id" v:"required"` // 广告ID
|
Id string `json:"id" v:"required"` // 广告ID
|
||||||
Status string `json:"status" v:"required"` // 广告状态:启用、禁用
|
Status string `json:"status" v:"required"` // 广告状态:启用、禁用
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAdStatisticsReq 获取广告统计数据请求
|
|
||||||
type GetAdStatisticsForAdvertisementReq struct {
|
|
||||||
g.Meta `path:"/getStatistics" method:"get" tags:"广告管理" summary:"获取广告统计数据" dc:"获取广告的统计数据"`
|
|
||||||
|
|
||||||
Id string `json:"id" v:"required"` // 广告ID
|
|
||||||
StatType string `json:"statType" v:"required"` // 统计类型:天、周、月
|
|
||||||
StartDate int64 `json:"startDate"` // 开始日期
|
|
||||||
EndDate int64 `json:"endDate"` // 结束日期
|
|
||||||
}
|
|
||||||
|
|
||||||
type GetAdStatisticsForAdvertisementRes struct {
|
|
||||||
Statistics []*entity.AdStatistics `json:"statistics"`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -36,24 +36,6 @@ type GenerateCIDRes struct {
|
|||||||
GeneratedAt string `json:"generated_at"` // 生成时间
|
GeneratedAt string `json:"generated_at"` // 生成时间
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCIDStatisticsReq 获取CID统计请求
|
|
||||||
type GetCIDStatisticsReq struct {
|
|
||||||
g.Meta `path:"/getStatistics" method:"get" tags:"CID服务" summary:"获取CID统计" dc:"获取CID服务的统计信息"`
|
|
||||||
UserId int64 `json:"user_id"` // 用户ID(可选)
|
|
||||||
TenantId int64 `json:"tenant_id"` // 租户ID(可选)
|
|
||||||
DateFrom int64 `json:"date_from"` // 开始日期
|
|
||||||
DateTo int64 `json:"date_to"` // 结束日期
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCIDStatisticsRes 获取CID统计响应
|
|
||||||
type GetCIDStatisticsRes struct {
|
|
||||||
TotalRequests int64 `json:"total_requests"` // 总请求数
|
|
||||||
SuccessfulReq int64 `json:"successful_requests"` // 成功请求数
|
|
||||||
AverageProcessTime float64 `json:"average_process_time"` // 平均处理时间
|
|
||||||
TopSources []string `json:"top_sources"` // 主要广告源
|
|
||||||
ConversionStats map[string]float64 `json:"conversion_stats"` // 转化率统计
|
|
||||||
}
|
|
||||||
|
|
||||||
// CIDRequestHistory CID请求历史记录
|
// CIDRequestHistory CID请求历史记录
|
||||||
type CIDRequestHistory struct {
|
type CIDRequestHistory struct {
|
||||||
Id int64 `json:"id"` // 记录ID
|
Id int64 `json:"id"` // 记录ID
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ type ReportDetailReq struct {
|
|||||||
g.Meta `path:"/getReportDetail" method:"get"`
|
g.Meta `path:"/getReportDetail" method:"get"`
|
||||||
ReportID int64 `json:"report_id" v:"required"`
|
ReportID int64 `json:"report_id" v:"required"`
|
||||||
}
|
}
|
||||||
|
type ExportReportReq struct {
|
||||||
|
g.Meta `path:"/exportReport" method:"get"`
|
||||||
|
ReportID int64 `json:"report_id" v:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
// 报表详情响应
|
// 报表详情响应
|
||||||
type ReportDetailResp struct {
|
type ReportDetailResp struct {
|
||||||
|
|||||||
@@ -81,35 +81,6 @@ func (s *adPosition) List(ctx context.Context, req *dto.ListAdPositionReq) (res
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatistics 获取广告位统计数据
|
|
||||||
func (s *adPosition) GetStatistics(ctx context.Context, req *dto.GetAdPositionStatisticsReq) (res *dto.GetAdPositionStatisticsRes, err error) {
|
|
||||||
statReq := &dto.GetAdStatisticsReq{
|
|
||||||
StatType: "adPosition",
|
|
||||||
StatDimension: req.StatType,
|
|
||||||
TargetId: req.Id,
|
|
||||||
StartDate: req.StartDate,
|
|
||||||
EndDate: req.EndDate,
|
|
||||||
DeviceType: "",
|
|
||||||
Platform: "",
|
|
||||||
Region: "",
|
|
||||||
Gender: "",
|
|
||||||
AgeGroup: "",
|
|
||||||
SortBy: "",
|
|
||||||
SortDirection: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
list, total, err := dao.AdStatistics.GetStatistics(ctx, statReq)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
res = &dto.GetAdPositionStatisticsRes{
|
|
||||||
Statistics: list,
|
|
||||||
Total: int(total),
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetByCode 根据编码获取广告位
|
// GetByCode 根据编码获取广告位
|
||||||
func (s *adPosition) GetByCode(ctx context.Context, code string) (adPosition *entity.AdPosition, err error) {
|
func (s *adPosition) GetByCode(ctx context.Context, code string) (adPosition *entity.AdPosition, err error) {
|
||||||
return dao.AdPosition.GetByCode(ctx, code)
|
return dao.AdPosition.GetByCode(ctx, code)
|
||||||
|
|||||||
@@ -92,35 +92,6 @@ func (s *advertisement) List(ctx context.Context, req *dto.ListAdvertisementReq)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetStatistics 获取广告统计数据
|
|
||||||
func (s *advertisement) GetStatistics(ctx context.Context, req *dto.GetAdStatisticsForAdvertisementReq) (res *dto.GetAdStatisticsForAdvertisementRes, err error) {
|
|
||||||
statReq := &dto.GetAdStatisticsReq{
|
|
||||||
StatType: "advertisement",
|
|
||||||
StatDimension: req.StatType,
|
|
||||||
TargetId: req.Id,
|
|
||||||
StartDate: req.StartDate,
|
|
||||||
EndDate: req.EndDate,
|
|
||||||
DeviceType: "",
|
|
||||||
Platform: "",
|
|
||||||
Region: "",
|
|
||||||
Gender: "",
|
|
||||||
AgeGroup: "",
|
|
||||||
SortBy: "",
|
|
||||||
SortDirection: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
list, _, err := dao.AdStatistics.GetStatistics(ctx, statReq)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
res = &dto.GetAdStatisticsForAdvertisementRes{
|
|
||||||
Statistics: list,
|
|
||||||
}
|
|
||||||
// Total字段不存在,已移除
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// UpdateAdStatistics 更新广告统计
|
// UpdateAdStatistics 更新广告统计
|
||||||
func (s *advertisement) UpdateAdStatistics(ctx context.Context, id string, impressions, clicks, conversions int64, cost int64) (err error) {
|
func (s *advertisement) UpdateAdStatistics(ctx context.Context, id string, impressions, clicks, conversions int64, cost int64) (err error) {
|
||||||
// 获取广告信息
|
// 获取广告信息
|
||||||
|
|||||||
@@ -311,23 +311,6 @@ func (s *cidService) recordCIDRequest(ctx context.Context, req *dto.GenerateCIDR
|
|||||||
dao.CIDRequest.Create(ctx, request)
|
dao.CIDRequest.Create(ctx, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCIDStatistics 获取CID统计信息
|
|
||||||
func (s *cidService) GetCIDStatistics(ctx context.Context, req *dto.GetCIDStatisticsReq) (res *dto.GetCIDStatisticsRes, err error) {
|
|
||||||
// 这里应该实现真实的统计逻辑
|
|
||||||
// 暂时返回模拟数据
|
|
||||||
return &dto.GetCIDStatisticsRes{
|
|
||||||
TotalRequests: int64(rand.Intn(9000) + 1000),
|
|
||||||
SuccessfulReq: int64(rand.Intn(8100) + 900),
|
|
||||||
AverageProcessTime: rand.Float64()*200 + 50,
|
|
||||||
TopSources: []string{"self", "google", "facebook"},
|
|
||||||
ConversionStats: map[string]float64{
|
|
||||||
"self": rand.Float64() * 0.1,
|
|
||||||
"google": rand.Float64() * 0.2,
|
|
||||||
"facebook": rand.Float64() * 0.15,
|
|
||||||
},
|
|
||||||
}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetCIDHistory 获取CID请求历史
|
// GetCIDHistory 获取CID请求历史
|
||||||
func (s *cidService) GetCIDHistory(ctx context.Context, userId int64, page, size int) (res *dto.GetCIDHistoryRes, err error) {
|
func (s *cidService) GetCIDHistory(ctx context.Context, userId int64, page, size int) (res *dto.GetCIDHistoryRes, err error) {
|
||||||
history, total, err := dao.CIDRequest.GetHistory(ctx, userId, page, size)
|
history, total, err := dao.CIDRequest.GetHistory(ctx, userId, page, size)
|
||||||
|
|||||||
Reference in New Issue
Block a user