重构数据引擎
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
)
|
||||
|
||||
type AccountReport struct{}
|
||||
|
||||
// AccountReportDetail CidAccountReportDetail 广告数据报表详情控制器
|
||||
var AccountReportDetail = new(AccountReport)
|
||||
|
||||
// CreateCidAccountReportDetail 创建广告数据报表详情
|
||||
func (c *AccountReport) CreateCidAccountReportDetail(ctx context.Context, req *dto.CreateCidAccountReportDetailReq) (res *dto.CreateCidAccountReportDetailRes, err error) {
|
||||
return service.CidAccountReportDetail.Create(ctx, req.CidAccountReportDetailItem)
|
||||
}
|
||||
|
||||
// BatchCreateCidAccountReportDetail 批量创建广告数据报表详情
|
||||
func (c *AccountReport) BatchCreateCidAccountReportDetail(ctx context.Context, req *dto.BatchCreateCidAccountReportDetailReq) (res *dto.BatchCreateCidAccountReportDetailRes, err error) {
|
||||
return service.CidAccountReportDetail.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// CreateCidAccountReportSum 创建广告数据报表汇总
|
||||
func (c *AccountReport) CreateCidAccountReportSum(ctx context.Context, req *dto.CreateCidAccountReportSumReq) (res *dto.CreateCidAccountReportSumRes, err error) {
|
||||
return service.CidAccountReportDetail.CreateSum(ctx, req.CidAccountReportSumItem)
|
||||
}
|
||||
|
||||
// BatchCreateCidAccountReportSum 批量创建广告数据报表汇总
|
||||
func (c *AccountReport) BatchCreateCidAccountReportSum(ctx context.Context, req *dto.BatchCreateCidAccountReportSumReq) (res *dto.BatchCreateCidAccountReportSumRes, err error) {
|
||||
return service.CidAccountReportDetail.BatchCreateSum(ctx, req)
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type campaignReport struct{}
|
||||
|
||||
var CampaignReport = new(campaignReport)
|
||||
|
||||
// CreateCampaignReportSum 创建广告计划效果指标表
|
||||
func (c *campaignReport) CreateCampaignReportSum(ctx context.Context, req *dto.CreateCampaignReportSumReq) (res *dto.CreateCampaignReportSumRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.CampaignReportSum.Create(ctx, req.CampaignReportSumItem)
|
||||
}
|
||||
|
||||
// BatchCreateCampaignReportSum 批量创建广告计划效果指标表
|
||||
func (c *campaignReport) BatchCreateCampaignReportSum(ctx context.Context, req *dto.BatchCreateCampaignReportSumReq) (res *dto.BatchCreateCampaignReportSumRes, err error) {
|
||||
return service.CampaignReportSum.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// CreateCampaignReportDetail 创建广告效果指标表
|
||||
func (c *campaignReport) CreateCampaignReportDetail(ctx context.Context, req *dto.CreateCampaignReportDetailReq) (res *dto.CreateCampaignReportDetailRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.CampaignReportSum.CreateDetail(ctx, req.CampaignReportDetailItem)
|
||||
}
|
||||
|
||||
// BatchCreateCampaignReportDetail 批量创建广告效果指标表
|
||||
func (c *campaignReport) BatchCreateCampaignReportDetail(ctx context.Context, req *dto.BatchCreateCampaignReportDetailReq) (res *dto.BatchCreateCampaignReportDetailRes, err error) {
|
||||
return service.CampaignReportSum.BatchCreateDetail(ctx, req)
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
)
|
||||
|
||||
type creativeReport struct{}
|
||||
|
||||
// CreativeReport 广告效果指标表控制器
|
||||
var CreativeReport = new(creativeReport)
|
||||
|
||||
// CreateCreativeReportSum 创建广告效果指标表
|
||||
func (c *creativeReport) CreateCreativeReportSum(ctx context.Context, req *dto.CreateCreativeReportSumReq) (res *dto.CreateCreativeReportSumRes, err error) {
|
||||
return service.CreativeReportSum.Create(ctx, req.CreativeReportSumItem)
|
||||
}
|
||||
|
||||
// BatchCreateCreativeReportSum 批量创建广告效果指标表
|
||||
func (c *creativeReport) BatchCreateCreativeReportSum(ctx context.Context, req *dto.BatchCreateCreativeReportSumReq) (res *dto.BatchCreateCreativeReportSumRes, err error) {
|
||||
return service.CreativeReportSum.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
func (c *creativeReport) CreateCreativeReportDetail(ctx context.Context, req *dto.CreateCreativeReportDetailReq) (res *dto.CreateCreativeReportDetailRes, err error) {
|
||||
return service.CreativeReportSum.CreateDetail(ctx, req.CreativeReportDetailItem)
|
||||
}
|
||||
|
||||
func (c *creativeReport) BatchCreateCreativeReportDetail(ctx context.Context, req *dto.BatchCreateCreativeReportDetailReq) (res *dto.BatchCreateCreativeReportDetailRes, err error) {
|
||||
return service.CreativeReportSum.BatchCreateDetail(ctx, req)
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
)
|
||||
|
||||
type materialReport struct{}
|
||||
|
||||
// MaterialReport 素材报表数据控制器
|
||||
var MaterialReport = new(materialReport)
|
||||
|
||||
// CreateMaterialReport 创建素材报表数据
|
||||
func (c *materialReport) CreateMaterialReport(ctx context.Context, req *dto.CreateMaterialReportReq) (res *dto.CreateMaterialReportRes, err error) {
|
||||
return service.MaterialReport.Create(ctx, req.MaterialReportItem)
|
||||
}
|
||||
|
||||
// BatchCreateMaterialReport 批量创建素材报表数据
|
||||
func (c *materialReport) BatchCreateMaterialReport(ctx context.Context, req *dto.BatchCreateMaterialReportReq) (res *dto.BatchCreateMaterialReportRes, err error) {
|
||||
return service.MaterialReport.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// ListMaterialReport 获取素材报表数据列表
|
||||
func (c *materialReport) ListMaterialReport(ctx context.Context, req *dto.ListMaterialReportReq) (res *dto.ListMaterialReportRes, err error) {
|
||||
return service.MaterialReport.List(ctx, req)
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
var PopulationReport = new(populationReport)
|
||||
|
||||
type populationReport struct{}
|
||||
|
||||
// CreatePopulationReport 创建人群报表数据
|
||||
func (c *populationReport) CreatePopulationReport(ctx context.Context, req *dto.CreatePopulationReportReq) (*dto.CreatePopulationReportRes, error) {
|
||||
return service.PopulationReportService.Create(ctx, req.PopulationReportItem)
|
||||
}
|
||||
|
||||
// BatchCreatePopulationReport 批量创建人群报表数据
|
||||
func (c *populationReport) BatchCreatePopulationReport(ctx context.Context, req *dto.BatchCreatePopulationReportReq) (*dto.BatchCreatePopulationReportRes, error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.PopulationReportService.BatchCreate(ctx, req.Items)
|
||||
}
|
||||
|
||||
// ListPopulationReport 查询人群报表数据列表
|
||||
func (c *populationReport) ListPopulationReport(ctx context.Context, req *dto.ListPopulationReportReq) (*dto.ListPopulationReportRes, error) {
|
||||
return service.PopulationReportService.List(ctx, req)
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
)
|
||||
|
||||
type storewideReport struct{}
|
||||
|
||||
// StorewideReport 广告效果指标控制器
|
||||
var StorewideReport = new(storewideReport)
|
||||
|
||||
// CreateStorewideReport 创建广告效果指标表
|
||||
func (c *storewideReport) CreateStorewideReport(ctx context.Context, req *dto.CreateStorewideReportSumReq) (res *dto.CreateStorewideReportSumRes, err error) {
|
||||
return service.StorewideReportSum.Create(ctx, req.StorewideReportSumItem)
|
||||
}
|
||||
|
||||
// BatchCreateStorewideReport 批量创建广告效果指标表
|
||||
func (c *storewideReport) BatchCreateStorewideReport(ctx context.Context, req *dto.BatchCreateStorewideReportSumReq) (res *dto.BatchCreateStorewideReportSumRes, err error) {
|
||||
return service.StorewideReportSum.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// CreateStorewideReportDetail 创建广告效果指标表
|
||||
func (c *storewideReport) CreateStorewideReportDetail(ctx context.Context, req *dto.CreateStorewideReportDetailReq) (res *dto.CreateStorewideReportDetailRes, err error) {
|
||||
return service.StorewideReportSum.CreateDetail(ctx, req.StorewideReportDetailItem)
|
||||
}
|
||||
|
||||
// BatchCreateStorewideReportDetail 批量创建广告效果指标表
|
||||
func (c *storewideReport) BatchCreateStorewideReportDetail(ctx context.Context, req *dto.BatchCreateStorewideReportDetailReq) (res *dto.BatchCreateStorewideReportDetailRes, err error) {
|
||||
return service.StorewideReportSum.BatchCreateDetail(ctx, req)
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
service "dataengine/service/copydata"
|
||||
)
|
||||
|
||||
type taskReport struct{}
|
||||
|
||||
// TaskReport 调控任务数据控制器
|
||||
var TaskReport = new(taskReport)
|
||||
|
||||
// CreateTaskReport 创建调控任务数据
|
||||
func (c *taskReport) CreateTaskReport(ctx context.Context, req *dto.CreateTaskReportReq) (res *dto.CreateTaskReportRes, err error) {
|
||||
return service.TaskReport.Create(ctx, req.TaskReportItem)
|
||||
}
|
||||
|
||||
// BatchCreateTaskReport 批量创建调控任务数据
|
||||
func (c *taskReport) BatchCreateTaskReport(ctx context.Context, req *dto.BatchCreateTaskReportReq) (res *dto.BatchCreateTaskReportRes, err error) {
|
||||
return service.TaskReport.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// ListTaskReport 获取调控任务数据列表
|
||||
func (c *taskReport) ListTaskReport(ctx context.Context, req *dto.ListTaskReportReq) (res *dto.ListTaskReportRes, err error) {
|
||||
return service.TaskReport.List(ctx, req)
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package copydata
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/copydata"
|
||||
"dataengine/service/copydata"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type unitReport struct{}
|
||||
|
||||
// UnitReport 获取广告单元数据控制器
|
||||
var UnitReport = new(unitReport)
|
||||
|
||||
// Create 创建广告效果指标
|
||||
func (c *unitReport) Create(ctx context.Context, req *dto.CreateUnitReportSumReq) (res *dto.CreateUnitReportSumRes, err error) {
|
||||
return copydata.UnitReportSumService.Create(ctx, req.UnitReportSumItem)
|
||||
}
|
||||
|
||||
// BatchCreate 批量创建广告效果指标
|
||||
func (c *unitReport) BatchCreate(ctx context.Context, req *dto.BatchCreateUnitReportSumReq) (res *dto.BatchCreateUnitReportSumRes, err error) {
|
||||
return copydata.UnitReportSumService.BatchCreate(ctx, req)
|
||||
}
|
||||
|
||||
// CreateDetail 创建广告效果指标详情
|
||||
func (c *unitReport) CreateDetail(ctx context.Context, req *dto.CreateUnitReportDetailReq) (res *dto.CreateUnitReportDetailRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return copydata.UnitReportSumService.CreateDetail(ctx, req.UnitReportDetailItem)
|
||||
}
|
||||
|
||||
// BatchCreateDetail 批量创建广告效果指标详情
|
||||
func (c *unitReport) BatchCreateDetail(ctx context.Context, req *dto.BatchCreateUnitReportDetailReq) (res *dto.BatchCreateUnitReportDetailRes, err error) {
|
||||
return copydata.UnitReportSumService.BatchCreateDetail(ctx, req)
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
package dict
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/dict"
|
||||
service "dataengine/service/dict"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type fieldMappingConfigController struct{}
|
||||
|
||||
// FieldMappingConfig 字段映射配置控制器
|
||||
var FieldMappingConfig = new(fieldMappingConfigController)
|
||||
|
||||
// CreateFieldMappingConfig 创建字段映射配置
|
||||
func (c *fieldMappingConfigController) CreateFieldMappingConfig(ctx context.Context, req *dto.CreateFieldMappingConfigReq) (res *dto.CreateFieldMappingConfigRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.FieldMappingConfig.Create(ctx, req)
|
||||
}
|
||||
|
||||
// ListFieldMappingConfig 获取字段映射配置列表
|
||||
func (c *fieldMappingConfigController) ListFieldMappingConfig(ctx context.Context, req *dto.ListFieldMappingConfigReq) (res *dto.ListFieldMappingConfigRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.FieldMappingConfig.List(ctx, req)
|
||||
}
|
||||
|
||||
// GetFieldMappingConfig 获取字段映射配置详情
|
||||
func (c *fieldMappingConfigController) GetFieldMappingConfig(ctx context.Context, req *dto.GetFieldMappingConfigReq) (res *dto.GetFieldMappingConfigRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.FieldMappingConfig.GetOne(ctx, req)
|
||||
}
|
||||
|
||||
// UpdateFieldMappingConfig 更新字段映射配置
|
||||
func (c *fieldMappingConfigController) UpdateFieldMappingConfig(ctx context.Context, req *dto.UpdateFieldMappingConfigReq) (res *beans.ResponseEmpty, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
err = service.FieldMappingConfig.Update(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateFieldMappingConfigStatus 更新字段映射配置状态
|
||||
func (c *fieldMappingConfigController) UpdateFieldMappingConfigStatus(ctx context.Context, req *dto.UpdateFieldMappingConfigStatusReq) (res *beans.ResponseEmpty, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
err = service.FieldMappingConfig.UpdateStatus(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// DeleteFieldMappingConfig 删除字段映射配置
|
||||
func (c *fieldMappingConfigController) DeleteFieldMappingConfig(ctx context.Context, req *dto.DeleteFieldMappingConfigReq) (res *beans.ResponseEmpty, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
err = service.FieldMappingConfig.Delete(ctx, req)
|
||||
return
|
||||
}
|
||||
|
||||
// QueryFieldMappingByVendorApi 根据厂商和接口查询字段映射
|
||||
func (c *fieldMappingConfigController) QueryFieldMappingByVendorApi(ctx context.Context, req *dto.QueryFieldMappingByVendorApiReq) (res *dto.QueryFieldMappingByVendorApiRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.FieldMappingConfig.QueryByVendorApi(ctx, req)
|
||||
}
|
||||
|
||||
// ValidateFieldMapping 验证字段映射配置
|
||||
func (c *fieldMappingConfigController) ValidateFieldMapping(ctx context.Context, req *dto.ValidateFieldMappingReq) (res *dto.ValidateFieldMappingRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.FieldMappingConfig.Validate(ctx, req)
|
||||
}
|
||||
92
controller/sync/platform_sync_controller.go
Normal file
92
controller/sync/platform_sync_controller.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
svc "dataengine/service/sync"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
var PlatformSyncController = new(syncCtrl)
|
||||
|
||||
type syncCtrl struct{}
|
||||
|
||||
// TriggerSyncReq 触发同步请求
|
||||
type TriggerSyncReq struct {
|
||||
g.Meta `path:"/trigger" method:"post" tags:"平台同步" summary:"触发同步" dc:"根据平台编码和接口编码触发数据同步"`
|
||||
PlatformCode string `json:"platformCode" v:"required" dc:"平台编码"`
|
||||
InterfaceCode string `json:"interfaceCode" v:"required" dc:"接口编码"`
|
||||
FullSync bool `json:"fullSync" dc:"是否全量同步,true=全量 false=增量"`
|
||||
}
|
||||
|
||||
// TriggerSyncRes 触发同步响应
|
||||
type TriggerSyncRes struct {
|
||||
Success bool `json:"success"`
|
||||
TableName string `json:"tableName"`
|
||||
TotalRows int `json:"totalRows"`
|
||||
InsertedRows int `json:"insertedRows"`
|
||||
Duration string `json:"duration"`
|
||||
}
|
||||
|
||||
// TriggerSync 触发同步
|
||||
func (c *syncCtrl) TriggerSync(ctx context.Context, req *TriggerSyncReq) (*TriggerSyncRes, error) {
|
||||
logrus.Infof("触发同步: platform=%s, interface=%s, fullSync=%v", req.PlatformCode, req.InterfaceCode, req.FullSync)
|
||||
result, err := svc.SyncByConfig(ctx, req.PlatformCode, req.InterfaceCode, req.FullSync)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &TriggerSyncRes{
|
||||
Success: true, TableName: result.TableName,
|
||||
TotalRows: result.TotalRows, InsertedRows: result.InsertedRows,
|
||||
Duration: result.Duration,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// QueryPlatformConfigReq 查询平台配置请求
|
||||
type QueryPlatformConfigReq struct {
|
||||
g.Meta `path:"/config" method:"get" tags:"平台同步" summary:"查询平台配置" dc:"查看平台和接口配置"`
|
||||
PlatformCode string `json:"platformCode" v:"required" dc:"平台编码"`
|
||||
}
|
||||
|
||||
// QueryPlatformConfigRes 查询平台配置响应
|
||||
type QueryPlatformConfigRes struct {
|
||||
PlatformName string `json:"platformName"`
|
||||
PlatformCode string `json:"platformCode"`
|
||||
ApiBaseUrl string `json:"apiBaseUrl"`
|
||||
AuthType string `json:"authType"`
|
||||
HasToken bool `json:"hasToken"`
|
||||
InterfaceCount int `json:"interfaceCount"`
|
||||
Interfaces []struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
HasTableDef bool `json:"hasTableDef"`
|
||||
} `json:"interfaces"`
|
||||
}
|
||||
|
||||
// QueryConfig 查询配置
|
||||
func (c *syncCtrl) QueryConfig(ctx context.Context, req *QueryPlatformConfigReq) (*QueryPlatformConfigRes, error) {
|
||||
pm := &svc.PlatformManager{}
|
||||
platform, interfaces, err := pm.GetPlatformWithInterfaces(ctx, req.PlatformCode)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res := &QueryPlatformConfigRes{
|
||||
PlatformName: platform.PlatformName, PlatformCode: platform.PlatformCode,
|
||||
ApiBaseUrl: platform.ApiBaseUrl, AuthType: platform.AuthType,
|
||||
HasToken: platform.AccessToken != "", InterfaceCount: len(interfaces),
|
||||
}
|
||||
for _, iface := range interfaces {
|
||||
res.Interfaces = append(res.Interfaces, struct {
|
||||
Code string `json:"code"`
|
||||
Name string `json:"name"`
|
||||
Url string `json:"url"`
|
||||
HasTableDef bool `json:"hasTableDef"`
|
||||
}{
|
||||
Code: iface.Code, Name: iface.Name, Url: iface.Url,
|
||||
HasTableDef: iface.TableDefinition != nil && len(iface.TableDefinition) > 0,
|
||||
})
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
package tencent
|
||||
|
||||
import (
|
||||
"context"
|
||||
dto "dataengine/model/dto/tencent"
|
||||
entity "dataengine/model/entity/tencent"
|
||||
service "dataengine/service/tencent"
|
||||
|
||||
"gitea.com/red-future/common/beans"
|
||||
)
|
||||
|
||||
type oauthController struct{}
|
||||
|
||||
// OauthController OAuth控制器
|
||||
var OauthController = new(oauthController)
|
||||
|
||||
// RefreshToken 刷新腾讯广告Token
|
||||
func (c *oauthController) RefreshToken(ctx context.Context, req *dto.RefreshTokenReq) (res *dto.RefreshTokenRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.OauthService.RefreshToken(ctx, req)
|
||||
}
|
||||
|
||||
// SyncAccountRelation 同步账户关系(自动分页获取所有数据)
|
||||
func (c *oauthController) SyncAccountRelation(ctx context.Context, req *dto.SyncAccountRelationReq) (res *dto.SyncAccountRelationRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.AccountRelationService.SyncAll(ctx, req)
|
||||
}
|
||||
|
||||
// ListAccountRelation 获取所有账户关系
|
||||
func (c *oauthController) ListAccountRelation(ctx context.Context, req *dto.ListAccountRelationReq) (res *dto.ListAccountRelationRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
|
||||
list, err := service.AccountRelationService.ListAll(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// 转换为DTO
|
||||
items := make([]dto.AccountRelationItem, 0, len(list))
|
||||
for _, item := range list {
|
||||
items = append(items, dto.AccountRelationItem{
|
||||
ID: item.Id,
|
||||
AccountID: item.AccountID,
|
||||
CorporationName: item.CorporationName,
|
||||
IsAdx: item.IsAdx,
|
||||
IsBid: item.IsBid,
|
||||
IsMp: item.IsMp,
|
||||
})
|
||||
}
|
||||
|
||||
res = &dto.ListAccountRelationRes{
|
||||
List: items,
|
||||
}
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// SyncAudio 同步音乐素材(自动分页获取所有数据)
|
||||
func (c *oauthController) SyncAudio(ctx context.Context, req *dto.SyncAudioReq) (res *dto.SyncAudioRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.AudioService.SyncAll(ctx, req)
|
||||
}
|
||||
|
||||
// ListAudio 获取所有音乐素材
|
||||
func (c *oauthController) ListAudio(ctx context.Context, req *dto.ListAudioReq) (res []entity.Audio, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.AudioService.ListAll(ctx)
|
||||
}
|
||||
|
||||
// SyncImage 同步图片素材(遍历所有账户,自动分页)
|
||||
func (c *oauthController) SyncImage(ctx context.Context, req *dto.SyncImageReq) (res *dto.SyncImageRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.ImageService.SyncAll(ctx, req)
|
||||
}
|
||||
|
||||
// ListImage 获取所有图片素材(旧接口,保留兼容)
|
||||
func (c *oauthController) ListImage(ctx context.Context, req *dto.ListImageReq) (res []entity.Image, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.ImageService.ListAll(ctx)
|
||||
}
|
||||
|
||||
// ListImagePage 分页查询图片素材(支持时间过滤)
|
||||
func (c *oauthController) ListImagePage(ctx context.Context, req *dto.ListImagePageReq) (res *dto.ListImageRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
// 转换请求参数为Service层使用的类型
|
||||
queryReq := &dto.ListImageQueryReq{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
AccountId: req.AccountId,
|
||||
StartTime: req.StartTime,
|
||||
EndTime: req.EndTime,
|
||||
Status: req.Status,
|
||||
}
|
||||
return service.ImageService.ListWithPage(ctx, queryReq)
|
||||
}
|
||||
|
||||
// SyncVideo 同步视频素材(遍历所有账户,自动分页)
|
||||
func (c *oauthController) SyncVideo(ctx context.Context, req *dto.SyncVideoReq) (res *dto.SyncVideoRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.VideoService.SyncAll(ctx, req)
|
||||
}
|
||||
|
||||
// ListVideo 获取所有视频素材(旧接口,保留兼容)
|
||||
func (c *oauthController) ListVideo(ctx context.Context, req *dto.ListVideoReq) (res []entity.Video, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
return service.VideoService.ListAll(ctx)
|
||||
}
|
||||
|
||||
// ListVideoPage 分页查询视频素材(支持时间过滤)
|
||||
func (c *oauthController) ListVideoPage(ctx context.Context, req *dto.ListVideoPageReq) (res *dto.ListVideoRes, err error) {
|
||||
ctx = context.WithValue(ctx, "user", &beans.User{UserName: "admin"})
|
||||
// 转换请求参数为Service层使用的类型
|
||||
queryReq := &dto.ListVideoQueryReq{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
AccountId: req.AccountId,
|
||||
StartTime: req.StartTime,
|
||||
EndTime: req.EndTime,
|
||||
Status: req.Status,
|
||||
}
|
||||
return service.VideoService.ListWithPage(ctx, queryReq)
|
||||
}
|
||||
Reference in New Issue
Block a user