gomod引用

This commit is contained in:
2025-12-18 17:51:33 +08:00
parent bdb356f300
commit 0814c6c819
9 changed files with 82 additions and 112 deletions

View File

@@ -39,7 +39,7 @@ func (s *StatReportService) GenerateDailyReport(ctx context.Context, req *dto.Re
}
return &dto.ReportGenerateResp{
ReportID: existingReport.Id,
ReportID: existingReport.Id.Hex(),
ReportType: "daily",
ReportDate: reportDate.Format("2006-01-02"),
Data: reportData,
@@ -54,7 +54,6 @@ func (s *StatReportService) GenerateDailyReport(ctx context.Context, req *dto.Re
// 保存报表
report := &entity.StatReport{
TenantId: req.TenantID,
AppID: strconv.FormatInt(req.AppID, 10),
ReportType: "daily",
ReportDate: reportDate,
@@ -69,7 +68,7 @@ func (s *StatReportService) GenerateDailyReport(ctx context.Context, req *dto.Re
}
return &dto.ReportGenerateResp{
ReportID: report.Id,
ReportID: report.Id.Hex(),
ReportType: "daily",
ReportDate: reportDate.Format("2006-01-02"),
Data: reportData,
@@ -95,7 +94,7 @@ func (s *StatReportService) GenerateMonthlyReport(ctx context.Context, req *dto.
}
return &dto.ReportGenerateResp{
ReportID: existingReport.Id,
ReportID: existingReport.Id.Hex(),
ReportType: "monthly",
ReportDate: reportDate.Format("2006-01"),
Data: reportData,
@@ -108,7 +107,6 @@ func (s *StatReportService) GenerateMonthlyReport(ctx context.Context, req *dto.
}
report := &entity.StatReport{
TenantId: req.TenantID,
AppID: strconv.FormatInt(req.AppID, 10),
ReportType: "monthly",
ReportDate: reportDate,
@@ -123,7 +121,7 @@ func (s *StatReportService) GenerateMonthlyReport(ctx context.Context, req *dto.
}
return &dto.ReportGenerateResp{
ReportID: report.Id,
ReportID: report.Id.Hex(),
ReportType: "monthly",
ReportDate: reportDate.Format("2006-01"),
Data: reportData,
@@ -150,7 +148,7 @@ func (s *StatReportService) GenerateWeeklyReport(ctx context.Context, req *dto.R
}
return &dto.ReportGenerateResp{
ReportID: existingReport.Id,
ReportID: existingReport.Id.Hex(),
ReportType: "weekly",
ReportDate: reportDate.Format("2006-W01"),
Data: reportData,
@@ -163,7 +161,6 @@ func (s *StatReportService) GenerateWeeklyReport(ctx context.Context, req *dto.R
}
report := &entity.StatReport{
TenantId: req.TenantID,
AppID: strconv.FormatInt(req.AppID, 10),
ReportType: "weekly",
ReportDate: reportDate,
@@ -178,7 +175,7 @@ func (s *StatReportService) GenerateWeeklyReport(ctx context.Context, req *dto.R
}
return &dto.ReportGenerateResp{
ReportID: report.Id,
ReportID: report.Id.Hex(),
ReportType: "weekly",
ReportDate: reportDate.Format("2006-W01"),
Data: reportData,
@@ -204,7 +201,7 @@ func (s *StatReportService) GenerateQuarterlyReport(ctx context.Context, req *dt
}
return &dto.ReportGenerateResp{
ReportID: existingReport.Id,
ReportID: existingReport.Id.Hex(),
ReportType: "quarterly",
ReportDate: reportDate.Format("2006-Q1"),
Data: reportData,
@@ -217,7 +214,6 @@ func (s *StatReportService) GenerateQuarterlyReport(ctx context.Context, req *dt
}
report := &entity.StatReport{
TenantId: req.TenantID,
AppID: strconv.FormatInt(req.AppID, 10),
ReportType: "quarterly",
ReportDate: reportDate,
@@ -232,7 +228,7 @@ func (s *StatReportService) GenerateQuarterlyReport(ctx context.Context, req *dt
}
return &dto.ReportGenerateResp{
ReportID: report.Id,
ReportID: report.Id.Hex(),
ReportType: "quarterly",
ReportDate: reportDate.Format("2006-Q1"),
Data: reportData,
@@ -258,7 +254,7 @@ func (s *StatReportService) GenerateYearlyReport(ctx context.Context, req *dto.R
}
return &dto.ReportGenerateResp{
ReportID: existingReport.Id,
ReportID: existingReport.Id.Hex(),
ReportType: "yearly",
ReportDate: reportDate.Format("2006"),
Data: reportData,
@@ -271,7 +267,6 @@ func (s *StatReportService) GenerateYearlyReport(ctx context.Context, req *dto.R
}
report := &entity.StatReport{
TenantId: req.TenantID,
AppID: strconv.FormatInt(req.AppID, 10),
ReportType: "yearly",
ReportDate: reportDate,
@@ -286,7 +281,7 @@ func (s *StatReportService) GenerateYearlyReport(ctx context.Context, req *dto.R
}
return &dto.ReportGenerateResp{
ReportID: report.Id,
ReportID: report.Id.Hex(),
ReportType: "yearly",
ReportDate: reportDate.Format("2006"),
Data: reportData,
@@ -596,10 +591,17 @@ func (s *StatReportService) GetReportList(ctx context.Context, req *dto.ReportLi
var reportDTOs []*dto.ReportDTO
for _, report := range reports {
appID, _ := strconv.ParseInt(report.AppID, 10, 64)
id, _ := strconv.ParseInt(report.Id, 10, 64)
// 使用ObjectId的十六进制字符串作为ID在DTO中保持为字符串
idStr := report.Id.Hex()
// 将ObjectId的十六进制字符串转换为int64如果失败则使用0
var idInt64 int64
if id, err := strconv.ParseInt(idStr, 16, 64); err == nil {
idInt64 = id
}
reportDTOs = append(reportDTOs, &dto.ReportDTO{
ID: id,
ID: idInt64,
TenantID: report.TenantId,
AppID: appID,
ReportType: report.ReportType,
@@ -635,10 +637,16 @@ func (s *StatReportService) GetReportDetail(ctx context.Context, reportID int64)
}
appID, _ := strconv.ParseInt(report.AppID, 10, 64)
id, _ := strconv.ParseInt(report.Id, 10, 64)
idStr := report.Id.Hex()
// 将ObjectId的十六进制字符串转换为int64如果失败则使用0
var idInt64 int64
if id, err := strconv.ParseInt(idStr, 16, 64); err == nil {
idInt64 = id
}
return &dto.ReportDetailResp{
ID: id,
ID: idInt64,
TenantID: report.TenantId,
AppID: appID,
ReportType: report.ReportType,