diff --git a/api-complete.json b/api-complete.json new file mode 100644 index 0000000..caad98b --- /dev/null +++ b/api-complete.json @@ -0,0 +1,1478 @@ +{ + "openapi": "3.0.0", + "info": { + "title": "DataEngine API", + "version": "1.0.0", + "description": "DataEngine 数据引擎 API 文档" + }, + "servers": [ + { + "url": "http://localhost:8080", + "description": "本地环境" + } + ], + "paths": { + "/api/interface/controller/createApiInterface": { + "post": { + "tags": ["接口管理"], + "summary": "创建接口", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "platformId": 1, + "name": "快手广告接口", + "code": "KUAISHOU_AD_API", + "url": "https://ad.e.kuaishou.com/rest/openapi/v1/campaign/list", + "method": "POST", + "status": "active", + "authType": "TOKEN", + "requestConfig": { + "headers": { + "Content-Type": "application/json" + }, + "params": { + "advertiserId": "123456" + } + }, + "responseConfig": { + "dataPath": "data.list", + "totalPath": "data.total" + }, + "limitConfig": { + "rateLimitPerMinute": 60 + } + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/api/interface/controller/listApiInterfaces": { + "get": { + "tags": ["接口管理"], + "summary": "获取接口列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer", "example": 1}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer", "example": 10}}, + {"name": "platformId", "in": "query", "schema": {"type": "integer"}}, + {"name": "keyword", "in": "query", "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/api/interface/controller/getApiInterface": { + "get": { + "tags": ["接口管理"], + "summary": "获取接口详情", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/api/interface/controller/updateApiInterface": { + "put": { + "tags": ["接口管理"], + "summary": "更新接口", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "platformId": 1, + "name": "快手广告接口", + "code": "KUAISHOU_AD_API", + "url": "https://ad.e.kuaishou.com/rest/openapi/v1/campaign/list", + "method": "POST", + "status": "active", + "authType": "TOKEN", + "requestConfig": { + "headers": { + "Content-Type": "application/json" + } + }, + "responseConfig": {}, + "limitConfig": {} + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/api/interface/controller/updateApiInterfaceStatus": { + "put": { + "tags": ["接口管理"], + "summary": "更新接口状态", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "status": "active" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/api/interface/controller/deleteApiInterface": { + "delete": { + "tags": ["接口管理"], + "summary": "删除接口", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/createDatasourcePlatform": { + "post": { + "tags": ["数据源平台管理"], + "summary": "创建数据源平台", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "platformCode": "KUAISHOU", + "platformName": "快手平台", + "description": "快手广告数据源", + "status": "ACTIVE", + "apiBaseUrl": "https://ad.e.kuaishou.com", + "authType": "TOKEN", + "token": "your_token_here", + "rateLimitPerMinute": 60, + "rateLimitPerHour": 1000, + "concurrencyLimit": 10, + "requestTimeoutMs": 30000, + "maxRetries": 3, + "retryDelayMs": 1000, + "createdBy": "admin", + "createdAt": "2026-04-30 10:00:00", + "updatedBy": "admin", + "updatedAt": "2026-04-30 10:00:00" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/listDatasourcePlatforms": { + "get": { + "tags": ["数据源平台管理"], + "summary": "获取数据源平台列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer", "example": 1}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer", "example": 10}}, + {"name": "keyword", "in": "query", "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/getDatasourcePlatform": { + "get": { + "tags": ["数据源平台管理"], + "summary": "获取数据源平台详情", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/getPlatformByCode": { + "get": { + "tags": ["数据源平台管理"], + "summary": "根据编码获取平台信息", + "parameters": [ + {"name": "platformCode", "in": "query", "required": true, "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/updateDatasourcePlatform": { + "put": { + "tags": ["数据源平台管理"], + "summary": "更新数据源平台", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "platformCode": "KUAISHOU", + "platformName": "快手平台", + "description": "快手广告数据源", + "status": "ACTIVE", + "apiBaseUrl": "https://ad.e.kuaishou.com", + "authType": "TOKEN", + "token": "your_token_here", + "rateLimitPerMinute": 60, + "rateLimitPerHour": 1000, + "concurrencyLimit": 10, + "requestTimeoutMs": 30000, + "maxRetries": 3, + "retryDelayMs": 1000, + "updatedBy": "admin", + "updatedAt": "2026-04-30 10:00:00", + "version": "1" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/updateDatasourcePlatformStatus": { + "put": { + "tags": ["数据源平台管理"], + "summary": "更新数据源平台状态", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "status": "ACTIVE", + "updatedBy": "admin" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/deleteDatasourcePlatform": { + "delete": { + "tags": ["数据源平台管理"], + "summary": "删除数据源平台", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/testPlatformConnection": { + "post": { + "tags": ["数据源平台管理"], + "summary": "测试平台连接", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "platformCode": "KUAISHOU", + "apiBaseUrl": "https://ad.e.kuaishou.com", + "authType": "TOKEN", + "token": "your_token_here" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/datasource/platform/controller/getPlatformStatistics": { + "get": { + "tags": ["数据源平台管理"], + "summary": "获取平台统计信息", + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs": { + "post": { + "tags": ["字段映射配置"], + "summary": "创建字段映射配置", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "configName": "快手广告计划ID映射", + "vendorName": "KUAISHOU", + "apiName": "campaign.list", + "apiVersion": "v1", + "sourceField": "campaign_id", + "sourceFieldType": "string", + "sourceFieldDesc": "快手广告计划ID", + "targetField": "campaignId", + "targetFieldType": "bigint", + "targetFieldDesc": "系统广告计划ID", + "transformType": "direct", + "transformParams": {}, + "validationRules": { + "pattern": "^[0-9]+$" + }, + "defaultValue": "", + "isRequired": true, + "isActive": true, + "priority": 0, + "businessDomain": "advertising", + "fieldGroup": "basic", + "configVersion": 1, + "createdBy": "admin" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs": { + "get": { + "tags": ["字段映射配置"], + "summary": "获取字段映射配置列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer", "example": 1}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer", "example": 10}}, + {"name": "vendorName", "in": "query", "schema": {"type": "string"}}, + {"name": "apiName", "in": "query", "schema": {"type": "string"}}, + {"name": "keyword", "in": "query", "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/{id}": { + "get": { + "tags": ["字段映射配置"], + "summary": "获取字段映射配置详情", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/{id}": { + "put": { + "tags": ["字段映射配置"], + "summary": "更新字段映射配置", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "configName": "快手广告计划ID映射", + "vendorName": "KUAISHOU", + "apiName": "campaign.list", + "sourceField": "campaign_id", + "targetField": "campaignId", + "targetFieldType": "bigint", + "transformType": "direct", + "isActive": true + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/{id}/status": { + "put": { + "tags": ["字段映射配置"], + "summary": "更新字段映射配置状态", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "id": 1, + "isActive": true + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/{id}": { + "delete": { + "tags": ["字段映射配置"], + "summary": "删除字段映射配置", + "parameters": [ + {"name": "id", "in": "query", "required": true, "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/query": { + "get": { + "tags": ["字段映射配置"], + "summary": "根据厂商和接口查询字段映射", + "parameters": [ + {"name": "vendorName", "in": "query", "required": true, "schema": {"type": "string"}}, + {"name": "apiName", "in": "query", "required": true, "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/field/mapping/config/controller/field-mapping-configs/validate": { + "post": { + "tags": ["字段映射配置"], + "summary": "验证字段映射配置", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "configName": "测试映射配置", + "vendorName": "KUAISHOU", + "apiName": "campaign.list", + "sourceField": "campaign_id", + "targetField": "campaignId", + "testValue": "123456" + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/createCidAccountReportDetail": { + "post": { + "tags": ["广告账户数据"], + "summary": "创建广告数据报表详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "dataType": "detail", + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "liveName": "测试直播间", + "photoId": "photo_001", + "photoName": "测试视频", + "creativeMaterialType": "VERTICAL_SCREEN", + "costTotal": 1000.50, + "t0OrderPaymentAmt": 5000.00, + "t0Gmv": 5000.00, + "t0Roi": 5.0, + "t0OrderCnt": 50, + "adEffectivePlayNum": 10000, + "click": 500, + "adShow": 10000, + "impression": 10000, + "conversionNum": 100, + "merchantRecoFans": 200 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/batchCreateCidAccountReportDetail": { + "post": { + "tags": ["广告账户数据"], + "summary": "批量创建广告数据报表详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "dataType": "detail", + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "liveName": "测试直播间", + "photoId": "photo_001", + "photoName": "测试视频", + "creativeMaterialType": "VERTICAL_SCREEN", + "costTotal": 1000.50, + "t0OrderPaymentAmt": 5000.00, + "t0Gmv": 5000.00, + "t0Roi": 5.0, + "t0OrderCnt": 50, + "adEffectivePlayNum": 10000, + "click": 500, + "adShow": 10000 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/listCidAccountReportDetail": { + "get": { + "tags": ["广告账户数据"], + "summary": "获取广告数据报表详情列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/createCidAccountReportSum": { + "post": { + "tags": ["广告账户数据"], + "summary": "创建广告账户数据汇总", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "dataType": "sum", + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "liveName": "测试直播间", + "costTotal": 1000.50, + "t0OrderPaymentAmt": 5000.00, + "t0Gmv": 5000.00, + "t0Roi": 5.0, + "t0OrderCnt": 50, + "adShow": 10000, + "click": 500, + "impression": 10000, + "conversionNum": 100 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/batchCreateCidAccountReportSum": { + "post": { + "tags": ["广告账户数据"], + "summary": "批量创建广告账户数据汇总", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "dataType": "sum", + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "liveName": "测试直播间", + "costTotal": 1000.50, + "t0OrderPaymentAmt": 5000.00, + "t0Gmv": 5000.00, + "t0Roi": 5.0, + "t0OrderCnt": 50, + "adShow": 10000, + "click": 500 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/account/report/listCidAccountReportSum": { + "get": { + "tags": ["广告账户数据"], + "summary": "获取广告账户数据汇总列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/createCampaignReportSum": { + "post": { + "tags": ["广告计划报表"], + "summary": "创建广告计划效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "campaignName": "测试计划", + "unitId": 789, + "unitName": "测试单元", + "costTotal": 1000.50, + "t0Gmv": 5000.00, + "t0Roi": 5.0, + "t0OrderCnt": 50, + "adShow": 10000, + "click": 500, + "impression": 10000 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/batchCreateCampaignReportSum": { + "post": { + "tags": ["广告计划报表"], + "summary": "批量创建广告计划效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "campaignName": "测试计划", + "costTotal": 1000.50, + "t0Gmv": 5000.00, + "t0Roi": 5.0 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/listCampaignReportSum": { + "get": { + "tags": ["广告计划报表"], + "summary": "获取广告计划效果指标表列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/createCampaignReportDetail": { + "post": { + "tags": ["广告计划报表"], + "summary": "创建广告效果指标表明细", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "campaignName": "测试计划", + "unitId": 789, + "unitName": "测试单元", + "ageSegment": "24-30", + "gender": "女", + "province": "广东", + "costTotal": 1000.50, + "t0Gmv": 5000.00, + "t0Roi": 5.0 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/batchCreateCampaignReportDetail": { + "post": { + "tags": ["广告计划报表"], + "summary": "批量创建广告效果指标表明细", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "unitId": 789, + "costTotal": 1000.50, + "t0Gmv": 5000.00 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/campaign/report/listCampaignReportDetail": { + "get": { + "tags": ["广告计划报表"], + "summary": "获取广告效果指标表明细列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/createUnitReportSum": { + "post": { + "tags": ["广告单元报表"], + "summary": "创建广告效果指标", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "unitId": 789, + "unitName": "测试单元", + "costTotal": 1000.50, + "t0Gmv": 5000.00, + "t0Roi": 5.0 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/batchCreateUnitReportSum": { + "post": { + "tags": ["广告单元报表"], + "summary": "批量创建广告效果指标", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "unitId": 789, + "costTotal": 1000.50, + "t0Gmv": 5000.00 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/listUnitReportSum": { + "get": { + "tags": ["广告单元报表"], + "summary": "获取广告效果指标列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/createUnitReportDetail": { + "post": { + "tags": ["广告单元报表"], + "summary": "创建广告效果指标详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "unitId": 789, + "ageSegment": "24-30", + "gender": "男", + "costTotal": 1000.50 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/batchCreateUnitReportDetail": { + "post": { + "tags": ["广告单元报表"], + "summary": "批量创建广告效果指标详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "unitId": 789, + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/unit/report/listUnitReportDetail": { + "get": { + "tags": ["广告单元报表"], + "summary": "获取广告效果指标详情列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/createCreativeReportSum": { + "post": { + "tags": ["广告创意报表"], + "summary": "创建广告效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "creativeId": 111, + "creativeName": "测试创意", + "costTotal": 1000.50, + "t0Gmv": 5000.00 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/batchCreateCreativeReportSum": { + "post": { + "tags": ["广告创意报表"], + "summary": "批量创建广告效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "creativeId": 111, + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/listCreativeReportSum": { + "get": { + "tags": ["广告创意报表"], + "summary": "获取广告效果指标表列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/createCreativeReportDetail": { + "post": { + "tags": ["广告创意报表"], + "summary": "创建广告创意详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "creativeId": 111, + "creativeMaterialType": "VERTICAL_SCREEN", + "costTotal": 1000.50 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/batchCreateCreativeReportDetail": { + "post": { + "tags": ["广告创意报表"], + "summary": "批量创建广告创意详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "creativeId": 111, + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/creative/report/listCreativeReportDetail": { + "get": { + "tags": ["广告创意报表"], + "summary": "获取广告创意详情列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/createStorewideReportSum": { + "post": { + "tags": ["全站数据报表"], + "summary": "创建广告效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "costTotal": 1000.50, + "t0Gmv": 5000.00 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/batchCreateStorewideReportSum": { + "post": { + "tags": ["全站数据报表"], + "summary": "批量创建广告效果指标表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/listStorewideReportSum": { + "get": { + "tags": ["全站数据报表"], + "summary": "获取广告效果指标表列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/createStorewideReportDetail": { + "post": { + "tags": ["全站数据报表"], + "summary": "创建广告效果指标表详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "ageSegment": "24-30", + "costTotal": 1000.50 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/batchCreateStorewideReportDetail": { + "post": { + "tags": ["全站数据报表"], + "summary": "批量创建广告效果指标表详情", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/storewide/report/listStorewideReportDetail": { + "get": { + "tags": ["全站数据报表"], + "summary": "获取广告效果指标表详情列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer"}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/material/report/createMaterialReport": { + "post": { + "tags": ["素材报表"], + "summary": "创建素材报表数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "photoId": "photo_001", + "photoName": "测试素材", + "costTotal": 1000.50, + "t0Gmv": 5000.00 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/material/report/batchCreateMaterialReport": { + "post": { + "tags": ["素材报表"], + "summary": "批量创建素材报表数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "authorId": "123456789", + "photoId": "photo_001", + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/material/report/listMaterialReport": { + "get": { + "tags": ["素材报表"], + "summary": "获取素材报表数据列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer", "example": 1}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer", "example": 10}}, + {"name": "reportDateStr", "in": "query", "schema": {"type": "string"}}, + {"name": "authorId", "in": "query", "schema": {"type": "string"}}, + {"name": "keyword", "in": "query", "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/population/report/createPopulationReport": { + "post": { + "tags": ["人群报表"], + "summary": "创建人群报表数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "ageSegment": "24-30", + "gender": "女", + "province": "广东", + "costTotal": 1000.50 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/population/report/batchCreatePopulationReport": { + "post": { + "tags": ["人群报表"], + "summary": "批量创建人群报表数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "campaignId": 123456, + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/population/report/listPopulationReport": { + "post": { + "tags": ["人群报表"], + "summary": "查询人群报表数据列表", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "page": 1, + "pageSize": 10, + "reportDateStr": "2026-04-30", + "campaignId": 123456 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/task/report/createTaskReport": { + "post": { + "tags": ["调控任务报表"], + "summary": "创建调控任务数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "reportDateStr": "2026-04-30", + "taskId": "task_001", + "taskName": "测试任务", + "photoId": "photo_001", + "costTotal": 1000.50 + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/task/report/batchCreateTaskReport": { + "post": { + "tags": ["调控任务报表"], + "summary": "批量创建调控任务数据", + "requestBody": { + "required": true, + "content": { + "application/json": { + "example": { + "items": [ + { + "reportDateStr": "2026-04-30", + "taskId": "task_001", + "costTotal": 1000.50 + } + ] + } + } + } + }, + "responses": { + "200": { + "description": "成功" + } + } + } + }, + "/task/report/listTaskReport": { + "get": { + "tags": ["调控任务报表"], + "summary": "获取调控任务数据列表", + "parameters": [ + {"name": "page", "in": "query", "schema": {"type": "integer", "example": 1}}, + {"name": "pageSize", "in": "query", "schema": {"type": "integer", "example": 10}}, + {"name": "reportDateStr", "in": "query", "schema": {"type": "string"}}, + {"name": "photoId", "in": "query", "schema": {"type": "string"}}, + {"name": "keyword", "in": "query", "schema": {"type": "string"}} + ], + "responses": { + "200": { + "description": "成功" + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/consts/public/collections.go b/consts/public/collections.go index e33f1a2..1ff959e 100644 --- a/consts/public/collections.go +++ b/consts/public/collections.go @@ -2,11 +2,11 @@ package public // PostgreSQL表名常量 const ( - ApiInterfaceTable = "cid_api_interface" // 接口管理表 + ApiInterfaceTable = "api_interface" // 接口管理表 CidAccountReportDetailTable = "cid_account_report_detail" // 广告账户数据明细表 CidAccountReportSumTable = "cid_account_report_sum" // 广告账户数据汇总表 - FieldMappingConfigTable = "field_mapping_config" // 字段映射表 - DatasourcePlatformTable = "datasource_platform" // 数据源平台表 + FieldMappingConfigTable = "api_field_mapping_config" // 字段映射表 + DatasourcePlatformTable = "api_datasource_platform" // 数据源平台表 TaskReportTable = "task_report" // 调控任务数据表 PopulationReportTable = "population_report" // 人群报表表 MaterialReportTable = "material_report" // 素材报表表 diff --git a/controller/copydata/api_account_report_controller.go b/controller/copydata/api_account_report_controller.go index 3dc6ee2..38b6787 100644 --- a/controller/copydata/api_account_report_controller.go +++ b/controller/copydata/api_account_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" ) type AccountReport struct{} diff --git a/controller/copydata/campaign_report_controller.go b/controller/copydata/campaign_report_controller.go index 3fde1fd..e3a7852 100644 --- a/controller/copydata/campaign_report_controller.go +++ b/controller/copydata/campaign_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" "gitea.com/red-future/common/beans" ) diff --git a/controller/copydata/creative_report_sum_controller.go b/controller/copydata/creative_report_sum_controller.go index 8289b83..60f908c 100644 --- a/controller/copydata/creative_report_sum_controller.go +++ b/controller/copydata/creative_report_sum_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" ) type creativeReport struct{} diff --git a/controller/copydata/material_report_controller.go b/controller/copydata/material_report_controller.go index c44f9fa..cf10d85 100644 --- a/controller/copydata/material_report_controller.go +++ b/controller/copydata/material_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" ) type materialReport struct{} diff --git a/controller/copydata/population_report_controller.go b/controller/copydata/population_report_controller.go index 8731a40..8919360 100644 --- a/controller/copydata/population_report_controller.go +++ b/controller/copydata/population_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" "gitea.com/red-future/common/beans" ) diff --git a/controller/copydata/storewide_report_sum_controller.go b/controller/copydata/storewide_report_sum_controller.go index c281f7e..c827e78 100644 --- a/controller/copydata/storewide_report_sum_controller.go +++ b/controller/copydata/storewide_report_sum_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" ) type storewideReport struct{} diff --git a/controller/copydata/task_report_controller.go b/controller/copydata/task_report_controller.go index 52a8421..9959ca8 100644 --- a/controller/copydata/task_report_controller.go +++ b/controller/copydata/task_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - service "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + service "dataengine/service/copydata" ) type taskReport struct{} diff --git a/controller/copydata/unit_report_controller.go b/controller/copydata/unit_report_controller.go index 0172102..0d2160b 100644 --- a/controller/copydata/unit_report_controller.go +++ b/controller/copydata/unit_report_controller.go @@ -1,9 +1,9 @@ package copydata import ( - dto "cid/model/dto/copydata" - "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + "dataengine/service/copydata" "gitea.com/red-future/common/beans" ) diff --git a/controller/dict/api_datasource_platform_controller.go b/controller/dict/api_datasource_platform_controller.go index 67c416f..2a26ab7 100644 --- a/controller/dict/api_datasource_platform_controller.go +++ b/controller/dict/api_datasource_platform_controller.go @@ -1,9 +1,9 @@ package dict import ( - dto "cid/model/dto/dict" - service "cid/service/dict" "context" + dto "dataengine/model/dto/dict" + service "dataengine/service/dict" "gitea.com/red-future/common/beans" ) diff --git a/controller/dict/api_field_mapping_config_controller.go b/controller/dict/api_field_mapping_config_controller.go index 45af8e4..13d7052 100644 --- a/controller/dict/api_field_mapping_config_controller.go +++ b/controller/dict/api_field_mapping_config_controller.go @@ -1,9 +1,9 @@ package dict import ( - dto "cid/model/dto/dict" - service "cid/service/dict" "context" + dto "dataengine/model/dto/dict" + service "dataengine/service/dict" "gitea.com/red-future/common/beans" ) diff --git a/controller/dict/api_interface_controller.go b/controller/dict/api_interface_controller.go index e4ffd83..6850e60 100644 --- a/controller/dict/api_interface_controller.go +++ b/controller/dict/api_interface_controller.go @@ -1,9 +1,9 @@ package dict import ( - dto "cid/model/dto/dict" - service "cid/service/dict" "context" + dto "dataengine/model/dto/dict" + service "dataengine/service/dict" "gitea.com/red-future/common/beans" ) diff --git a/dao/copydata/api_account_report_detail_dao.go b/dao/copydata/api_account_report_detail_dao.go index ed78303..efce28f 100644 --- a/dao/copydata/api_account_report_detail_dao.go +++ b/dao/copydata/api_account_report_detail_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/api_account_report_sum_dao.go b/dao/copydata/api_account_report_sum_dao.go index 8a013a9..dec0c25 100644 --- a/dao/copydata/api_account_report_sum_dao.go +++ b/dao/copydata/api_account_report_sum_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/campaign_report_detail_dao.go b/dao/copydata/campaign_report_detail_dao.go index 9212913..cd6fb92 100644 --- a/dao/copydata/campaign_report_detail_dao.go +++ b/dao/copydata/campaign_report_detail_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/campaign_report_sum_dao.go b/dao/copydata/campaign_report_sum_dao.go index 8178d78..cd677ab 100644 --- a/dao/copydata/campaign_report_sum_dao.go +++ b/dao/copydata/campaign_report_sum_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/creative_report_detail_dao.go b/dao/copydata/creative_report_detail_dao.go index 89c1e6f..6f69443 100644 --- a/dao/copydata/creative_report_detail_dao.go +++ b/dao/copydata/creative_report_detail_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/creative_report_sum_dao.go b/dao/copydata/creative_report_sum_dao.go index 717601a..3e90154 100644 --- a/dao/copydata/creative_report_sum_dao.go +++ b/dao/copydata/creative_report_sum_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/material_report_dao.go b/dao/copydata/material_report_dao.go index 38cbf89..4a168bc 100644 --- a/dao/copydata/material_report_dao.go +++ b/dao/copydata/material_report_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/population_report_dao.go b/dao/copydata/population_report_dao.go index 80276f1..6baad39 100644 --- a/dao/copydata/population_report_dao.go +++ b/dao/copydata/population_report_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/storewide_report_detail_dao.go b/dao/copydata/storewide_report_detail_dao.go index 6a3cdd1..e5853d2 100644 --- a/dao/copydata/storewide_report_detail_dao.go +++ b/dao/copydata/storewide_report_detail_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/storewide_report_sum_dao.go b/dao/copydata/storewide_report_sum_dao.go index 730552e..42f48c0 100644 --- a/dao/copydata/storewide_report_sum_dao.go +++ b/dao/copydata/storewide_report_sum_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/sync_task_log_dao.go b/dao/copydata/sync_task_log_dao.go index baf52da..c407804 100644 --- a/dao/copydata/sync_task_log_dao.go +++ b/dao/copydata/sync_task_log_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "time" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/task_report_dao.go b/dao/copydata/task_report_dao.go index d052c4a..19321ae 100644 --- a/dao/copydata/task_report_dao.go +++ b/dao/copydata/task_report_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/unit_report_detail_dao.go b/dao/copydata/unit_report_detail_dao.go index 6382b0b..a55a6fd 100644 --- a/dao/copydata/unit_report_detail_dao.go +++ b/dao/copydata/unit_report_detail_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/copydata/unit_report_sum_dao.go b/dao/copydata/unit_report_sum_dao.go index 301bd8f..84e95dd 100644 --- a/dao/copydata/unit_report_sum_dao.go +++ b/dao/copydata/unit_report_sum_dao.go @@ -1,10 +1,10 @@ package copydata import ( - consts "cid/consts/public" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/db/gfdb" diff --git a/dao/dict/api_datasource_platform_dao.go b/dao/dict/api_datasource_platform_dao.go index 9c3c82e..08c29e6 100644 --- a/dao/dict/api_datasource_platform_dao.go +++ b/dao/dict/api_datasource_platform_dao.go @@ -1,11 +1,11 @@ package dict import ( - consts1 "cid/consts/api-feature" - consts "cid/consts/public" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + consts1 "dataengine/consts/api-feature" + consts "dataengine/consts/public" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "strconv" "time" diff --git a/dao/dict/api_field_mapping_config_dao.go b/dao/dict/api_field_mapping_config_dao.go index e578124..bd12b7a 100644 --- a/dao/dict/api_field_mapping_config_dao.go +++ b/dao/dict/api_field_mapping_config_dao.go @@ -1,10 +1,10 @@ package dict import ( - consts "cid/consts/public" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "time" "gitea.com/red-future/common/beans" diff --git a/dao/dict/api_interface_dao.go b/dao/dict/api_interface_dao.go index 8bded40..05637ad 100644 --- a/dao/dict/api_interface_dao.go +++ b/dao/dict/api_interface_dao.go @@ -1,10 +1,10 @@ package dict import ( - consts "cid/consts/public" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + consts "dataengine/consts/public" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "gitea.com/red-future/common/db/gfdb" "github.com/gogf/gf/v2/database/gdb" diff --git a/go.mod b/go.mod index 9158534..3b673ec 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module cid +module dataengine go 1.26.0 @@ -22,16 +22,22 @@ require ( github.com/cenkalti/backoff/v5 v5.0.3 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/dgraph-io/badger/v4 v4.2.0 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/dustin/go-humanize v1.0.1 // indirect + github.com/emicklei/go-restful/v3 v3.12.2 // indirect github.com/emirpasic/gods/v2 v2.0.0-alpha // indirect github.com/fatih/color v1.18.0 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-ego/gse v1.0.2 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/swag v0.23.0 // indirect github.com/gogf/gf/contrib/registry/consul/v2 v2.9.5 // indirect github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.9.5 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -41,6 +47,7 @@ require ( github.com/golang/protobuf v1.5.4 // indirect github.com/golang/snappy v1.0.0 // indirect github.com/google/flatbuffers v1.12.1 // indirect + github.com/google/gnostic-models v0.7.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect @@ -54,23 +61,31 @@ require ( github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v1.0.2 // indirect github.com/hashicorp/serf v0.10.1 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.18.0 // indirect github.com/lib/pq v1.10.9 // indirect github.com/magiconair/properties v1.8.10 // indirect + github.com/mailru/easyjson v0.9.0 // indirect github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/olekukonko/ll v0.0.9 // indirect github.com/olekukonko/tablewriter v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/r3labs/diff/v2 v2.15.1 // indirect github.com/redis/go-redis/v9 v9.12.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect + github.com/spf13/pflag v1.0.9 // indirect github.com/tiger1103/gfast-token v1.0.10 // indirect github.com/vcaesar/cedar v0.30.0 // indirect github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect + github.com/x448/float16 v0.8.4 // indirect go.mongodb.org/mongo-driver/v2 v2.4.0 // indirect go.opencensus.io v0.23.0 // indirect go.opentelemetry.io/auto/sdk v1.1.0 // indirect @@ -81,13 +96,30 @@ require ( go.opentelemetry.io/otel/sdk v1.38.0 // indirect go.opentelemetry.io/otel/trace v1.38.0 // indirect go.opentelemetry.io/proto/otlp v1.7.1 // indirect + go.yaml.in/yaml/v2 v2.4.3 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect + golang.org/x/oauth2 v0.30.0 // indirect golang.org/x/sys v0.38.0 // indirect + golang.org/x/term v0.37.0 // indirect golang.org/x/text v0.31.0 // indirect + golang.org/x/time v0.9.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect google.golang.org/grpc v1.75.0 // indirect google.golang.org/protobuf v1.36.8 // indirect + gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.35.3 // indirect + k8s.io/apimachinery v0.35.3 // indirect + k8s.io/client-go v0.35.3 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect + k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect + sigs.k8s.io/randfill v1.0.0 // indirect + sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect + sigs.k8s.io/yaml v1.6.0 // indirect ) diff --git a/main.go b/main.go index 504fa17..702b8c3 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,8 @@ package main import ( - "cid/controller/copydata" - "cid/controller/dict" + "dataengine/controller/copydata" + "dataengine/controller/dict" "gitea.com/red-future/common/http" "gitea.com/red-future/common/jaeger" diff --git a/model/dto/dict/api_datasource_platform_dto.go b/model/dto/dict/api_datasource_platform_dto.go index c85e869..dedf01a 100644 --- a/model/dto/dict/api_datasource_platform_dto.go +++ b/model/dto/dict/api_datasource_platform_dto.go @@ -1,8 +1,8 @@ package api_feature import ( - "cid/consts/api-feature" - entity "cid/model/entity/dict" + "dataengine/consts/api-feature" + entity "dataengine/model/entity/dict" "gitea.com/red-future/common/beans" "github.com/gogf/gf/v2/frame/g" diff --git a/model/dto/dict/api_field_mapping_config_dto.go b/model/dto/dict/api_field_mapping_config_dto.go index d51efda..95261eb 100644 --- a/model/dto/dict/api_field_mapping_config_dto.go +++ b/model/dto/dict/api_field_mapping_config_dto.go @@ -1,7 +1,7 @@ package api_feature import ( - entity "cid/model/entity/dict" + entity "dataengine/model/entity/dict" "time" "gitea.com/red-future/common/beans" diff --git a/model/dto/dict/api_interface_dto.go b/model/dto/dict/api_interface_dto.go index c47798b..82b440d 100644 --- a/model/dto/dict/api_interface_dto.go +++ b/model/dto/dict/api_interface_dto.go @@ -1,8 +1,8 @@ package api_feature import ( - "cid/consts/api-feature" - entity "cid/model/entity/dict" + "dataengine/consts/api-feature" + entity "dataengine/model/entity/dict" "gitea.com/red-future/common/beans" "github.com/gogf/gf/v2/frame/g" diff --git a/model/entity/dict/api_interface.go b/model/entity/dict/api_interface.go index dd4668e..c114d53 100644 --- a/model/entity/dict/api_interface.go +++ b/model/entity/dict/api_interface.go @@ -1,7 +1,7 @@ package dict import ( - consts "cid/consts/api-feature" + consts "dataengine/consts/api-feature" "gitea.com/red-future/common/beans" ) diff --git a/scheduler/run_account_report_task.go b/scheduler/run_account_report_task.go index 5fe867c..165423d 100644 --- a/scheduler/run_account_report_task.go +++ b/scheduler/run_account_report_task.go @@ -1,8 +1,8 @@ package main import ( - "cid/syncdata" "context" + "dataengine/syncdata" "fmt" "time" diff --git a/scheduler/run_sync_task_log_task.go b/scheduler/run_sync_task_log_task.go index 8585808..aed1f6e 100644 --- a/scheduler/run_sync_task_log_task.go +++ b/scheduler/run_sync_task_log_task.go @@ -1,10 +1,10 @@ package main import ( - dao "cid/dao/copydata" - taskDto "cid/model/dto/copydata" - "cid/syncdata" "context" + dao "dataengine/dao/copydata" + taskDto "dataengine/model/dto/copydata" + "dataengine/syncdata" "fmt" "strings" "sync" diff --git a/service/api_service.go b/service/api_service.go index 00e9b3c..15d776f 100644 --- a/service/api_service.go +++ b/service/api_service.go @@ -9,7 +9,7 @@ import ( "net/http" "time" - entities "cid/entities" + entities "dataengine/entities" ) // APIService API服务接口 diff --git a/service/copydata/api_account_report_service.go b/service/copydata/api_account_report_service.go index cf76fb1..88c1421 100644 --- a/service/copydata/api_account_report_service.go +++ b/service/copydata/api_account_report_service.go @@ -1,9 +1,9 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/campaign_report_service.go b/service/copydata/campaign_report_service.go index 1d724f6..bd76a81 100644 --- a/service/copydata/campaign_report_service.go +++ b/service/copydata/campaign_report_service.go @@ -1,9 +1,9 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/creative_report_sum_service.go b/service/copydata/creative_report_sum_service.go index 084957e..14d896f 100644 --- a/service/copydata/creative_report_sum_service.go +++ b/service/copydata/creative_report_sum_service.go @@ -1,9 +1,9 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/material_report_service.go b/service/copydata/material_report_service.go index adb49d6..939154e 100644 --- a/service/copydata/material_report_service.go +++ b/service/copydata/material_report_service.go @@ -1,10 +1,10 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/population_report_service.go b/service/copydata/population_report_service.go index debbb5a..cebb458 100644 --- a/service/copydata/population_report_service.go +++ b/service/copydata/population_report_service.go @@ -1,10 +1,10 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" ) diff --git a/service/copydata/storewide_report_sum_service.go b/service/copydata/storewide_report_sum_service.go index 7a01db3..432c3bd 100644 --- a/service/copydata/storewide_report_sum_service.go +++ b/service/copydata/storewide_report_sum_service.go @@ -1,9 +1,9 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/task_report_service.go b/service/copydata/task_report_service.go index 704820a..8d426f6 100644 --- a/service/copydata/task_report_service.go +++ b/service/copydata/task_report_service.go @@ -1,10 +1,10 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" - entity "cid/model/entity/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" + entity "dataengine/model/entity/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/copydata/unit_report_service.go b/service/copydata/unit_report_service.go index 0935b08..e13c8ad 100644 --- a/service/copydata/unit_report_service.go +++ b/service/copydata/unit_report_service.go @@ -1,9 +1,9 @@ package copydata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" "errors" "gitea.com/red-future/common/beans" diff --git a/service/dict/api_datasource_platform_service.go b/service/dict/api_datasource_platform_service.go index eef7aab..f00a6db 100644 --- a/service/dict/api_datasource_platform_service.go +++ b/service/dict/api_datasource_platform_service.go @@ -1,11 +1,11 @@ package dict import ( - api_feature "cid/consts/api-feature" - dao "cid/dao/dict" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + api_feature "dataengine/consts/api-feature" + dao "dataengine/dao/dict" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "strconv" "time" diff --git a/service/dict/api_field_mapping_config_service.go b/service/dict/api_field_mapping_config_service.go index 8943608..a7a49ff 100644 --- a/service/dict/api_field_mapping_config_service.go +++ b/service/dict/api_field_mapping_config_service.go @@ -1,11 +1,11 @@ package dict import ( - consts "cid/consts/dict" - "cid/dao/dict" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + consts "dataengine/consts/dict" + "dataengine/dao/dict" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "errors" "fmt" "time" diff --git a/service/dict/api_interface_service.go b/service/dict/api_interface_service.go index 5e78b85..7d0022a 100644 --- a/service/dict/api_interface_service.go +++ b/service/dict/api_interface_service.go @@ -1,11 +1,11 @@ package dict import ( - consts "cid/consts/api-feature" - "cid/dao/dict" - dto "cid/model/dto/dict" - entity "cid/model/entity/dict" "context" + consts "dataengine/consts/api-feature" + "dataengine/dao/dict" + dto "dataengine/model/dto/dict" + entity "dataengine/model/entity/dict" "errors" ) diff --git a/sql/00_main_schema.sql b/sql/00_main_schema.sql new file mode 100644 index 0000000..b92fc07 --- /dev/null +++ b/sql/00_main_schema.sql @@ -0,0 +1,38 @@ +-- PostgreSQL Database Schema for Data Engine +-- Generated from Go entity classes +-- This file serves as the main schema file that imports all other schema files +-- Execute in the following order: +-- 1. 00_main_schema.sql (this file) +-- 2. 01_dict_tables.sql +-- 3. 02_account_report_tables.sql +-- 4. 03_campaign_report_tables.sql +-- 5. 04_creative_report_tables.sql +-- 6. 05_unit_report_tables.sql +-- 7. 06_storewide_report_tables.sql +-- 8. 07_material_population_tables.sql +-- 9. 08_sync_task_tables.sql + +-- ============================================= +-- Database Settings +-- ============================================= +-- Set timezone (optional, adjust as needed) +SET timezone = 'Asia/Shanghai'; + +-- ============================================= +-- Import all schema files +-- ============================================= + +\i 01_dict_tables.sql +\i 02_account_report_tables.sql +\i 03_campaign_report_tables.sql +\i 04_creative_report_tables.sql +\i 05_unit_report_tables.sql +\i 06_storewide_report_tables.sql +\i 07_material_population_tables.sql +\i 08_sync_task_tables.sql + +-- ============================================= +-- Grant permissions (optional, adjust as needed) +-- ============================================= +-- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO your_user; +-- GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO your_user; diff --git a/sql/01_dict_tables.sql b/sql/01_dict_tables.sql new file mode 100644 index 0000000..fdd2199 --- /dev/null +++ b/sql/01_dict_tables.sql @@ -0,0 +1,183 @@ +-- PostgreSQL 建表脚本 - dict 包 + +-- ============================================= +-- 数据源平台配置表 (api_datasource_platform) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS api_datasource_platform_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS api_datasource_platform ( + id BIGINT NOT NULL DEFAULT nextval('api_datasource_platform_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + platform_code VARCHAR(100) NOT NULL, + platform_name VARCHAR(200) NOT NULL, + description TEXT, + status VARCHAR(50) DEFAULT 'ACTIVE', + api_base_url VARCHAR(500), + auth_type VARCHAR(50) DEFAULT 'API_KEY', + token VARCHAR(500), + api_key VARCHAR(500), + client_id VARCHAR(200), + client_secret VARCHAR(500), + rate_limit_per_minute INT DEFAULT 60, + rate_limit_per_hour INT DEFAULT 3600, + concurrency_limit INT DEFAULT 10, + request_timeout_ms INT DEFAULT 30000, + max_retries INT DEFAULT 3, + retry_delay_ms INT DEFAULT 1000, + version INT DEFAULT 0, + PRIMARY KEY (id) +); + +COMMENT ON TABLE api_datasource_platform IS '数据源平台配置表'; +COMMENT ON COLUMN api_datasource_platform.id IS '主键ID'; +COMMENT ON COLUMN api_datasource_platform.tenant_id IS '租户ID'; +COMMENT ON COLUMN api_datasource_platform.creator IS '创建人'; +COMMENT ON COLUMN api_datasource_platform.created_at IS '创建时间'; +COMMENT ON COLUMN api_datasource_platform.updater IS '更新人'; +COMMENT ON COLUMN api_datasource_platform.updated_at IS '更新时间'; +COMMENT ON COLUMN api_datasource_platform.deleted_at IS '软删除时间'; +COMMENT ON COLUMN api_datasource_platform.platform_code IS '平台编码,唯一标识'; +COMMENT ON COLUMN api_datasource_platform.platform_name IS '平台名称'; +COMMENT ON COLUMN api_datasource_platform.description IS '平台描述'; +COMMENT ON COLUMN api_datasource_platform.status IS '状态: ACTIVE启用, INACTIVE停用'; +COMMENT ON COLUMN api_datasource_platform.api_base_url IS 'API基础地址'; +COMMENT ON COLUMN api_datasource_platform.auth_type IS '认证类型: TOKEN/API_KEY/OAUTH2/BASIC'; +COMMENT ON COLUMN api_datasource_platform.token IS '认证token/密钥'; +COMMENT ON COLUMN api_datasource_platform.api_key IS 'API Key'; +COMMENT ON COLUMN api_datasource_platform.client_id IS 'OAuth2 Client ID'; +COMMENT ON COLUMN api_datasource_platform.client_secret IS 'OAuth2 Client Secret'; +COMMENT ON COLUMN api_datasource_platform.rate_limit_per_minute IS '每分钟请求限制'; +COMMENT ON COLUMN api_datasource_platform.rate_limit_per_hour IS '每小时请求限制'; +COMMENT ON COLUMN api_datasource_platform.concurrency_limit IS '并发连接限制'; +COMMENT ON COLUMN api_datasource_platform.request_timeout_ms IS '请求超时时间(毫秒)'; +COMMENT ON COLUMN api_datasource_platform.max_retries IS '最大重试次数'; +COMMENT ON COLUMN api_datasource_platform.retry_delay_ms IS '重试延迟(毫秒)'; +COMMENT ON COLUMN api_datasource_platform.version IS '版本号(乐观锁)'; + +CREATE UNIQUE INDEX idx_api_datasource_platform_code ON api_datasource_platform(tenant_id, platform_code); + +-- ============================================= +-- 字段映射配置表 (api_field_mapping_config) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS api_field_mapping_config_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS api_field_mapping_config ( + id BIGINT NOT NULL DEFAULT nextval('api_field_mapping_config_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + config_name VARCHAR(200) NOT NULL, + vendor_name VARCHAR(100), + api_name VARCHAR(200), + api_version VARCHAR(50), + source_field VARCHAR(200), + source_field_type VARCHAR(100), + source_field_desc VARCHAR(500), + target_field VARCHAR(200), + target_field_type VARCHAR(100), + target_field_desc VARCHAR(500), + transform_type VARCHAR(100), + transform_params JSONB, + validation_rules JSONB, + default_value VARCHAR(500), + is_required BOOLEAN DEFAULT FALSE, + is_active BOOLEAN DEFAULT TRUE, + priority INT DEFAULT 0, + business_domain VARCHAR(100), + field_group VARCHAR(100), + config_version INT DEFAULT 1, + effective_date TIMESTAMP WITH TIME ZONE, + expiry_date TIMESTAMP WITH TIME ZONE, + PRIMARY KEY (id) +); + +COMMENT ON TABLE api_field_mapping_config IS '字段映射配置表'; +COMMENT ON COLUMN api_field_mapping_config.id IS '主键ID'; +COMMENT ON COLUMN api_field_mapping_config.tenant_id IS '租户ID'; +COMMENT ON COLUMN api_field_mapping_config.creator IS '创建人'; +COMMENT ON COLUMN api_field_mapping_config.created_at IS '创建时间'; +COMMENT ON COLUMN api_field_mapping_config.updater IS '更新人'; +COMMENT ON COLUMN api_field_mapping_config.updated_at IS '更新时间'; +COMMENT ON COLUMN api_field_mapping_config.deleted_at IS '软删除时间'; +COMMENT ON COLUMN api_field_mapping_config.config_name IS '配置名称'; +COMMENT ON COLUMN api_field_mapping_config.vendor_name IS '厂商名称'; +COMMENT ON COLUMN api_field_mapping_config.api_name IS '接口名称'; +COMMENT ON COLUMN api_field_mapping_config.api_version IS '接口版本'; +COMMENT ON COLUMN api_field_mapping_config.source_field IS '源字段名'; +COMMENT ON COLUMN api_field_mapping_config.source_field_type IS '源字段数据类型'; +COMMENT ON COLUMN api_field_mapping_config.source_field_desc IS '源字段描述'; +COMMENT ON COLUMN api_field_mapping_config.target_field IS '目标字段名'; +COMMENT ON COLUMN api_field_mapping_config.target_field_type IS '目标数据类型'; +COMMENT ON COLUMN api_field_mapping_config.target_field_desc IS '字段描述'; +COMMENT ON COLUMN api_field_mapping_config.transform_type IS '转换类型'; +COMMENT ON COLUMN api_field_mapping_config.transform_params IS '转换参数'; +COMMENT ON COLUMN api_field_mapping_config.validation_rules IS '验证规则'; +COMMENT ON COLUMN api_field_mapping_config.default_value IS '默认值'; +COMMENT ON COLUMN api_field_mapping_config.is_required IS '是否必填'; +COMMENT ON COLUMN api_field_mapping_config.is_active IS '是否启用'; +COMMENT ON COLUMN api_field_mapping_config.priority IS '优先级'; +COMMENT ON COLUMN api_field_mapping_config.business_domain IS '业务域'; +COMMENT ON COLUMN api_field_mapping_config.field_group IS '字段分组'; +COMMENT ON COLUMN api_field_mapping_config.config_version IS '配置版本号'; +COMMENT ON COLUMN api_field_mapping_config.effective_date IS '生效时间'; +COMMENT ON COLUMN api_field_mapping_config.expiry_date IS '失效时间'; + +CREATE INDEX idx_api_field_mapping_config_vendor ON api_field_mapping_config(tenant_id, vendor_name, api_name); +CREATE INDEX idx_api_field_mapping_config_active ON api_field_mapping_config(tenant_id, is_active); + +-- ============================================= +-- API接口管理表 (api_interface) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS api_interface_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS api_interface ( + id BIGINT NOT NULL DEFAULT nextval('api_interface_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + platform_id BIGINT NOT NULL, + name VARCHAR(200) NOT NULL, + code VARCHAR(100) NOT NULL, + url VARCHAR(500) NOT NULL, + method VARCHAR(20) NOT NULL DEFAULT 'GET', + status VARCHAR(50) DEFAULT 'active', + auth_type VARCHAR(50) DEFAULT 'api_key', + request_config JSONB, + response_config JSONB, + limit_config JSONB, + PRIMARY KEY (id) +); + +COMMENT ON TABLE api_interface IS 'API接口管理表'; +COMMENT ON COLUMN api_interface.id IS '主键ID'; +COMMENT ON COLUMN api_interface.tenant_id IS '租户ID'; +COMMENT ON COLUMN api_interface.creator IS '创建人'; +COMMENT ON COLUMN api_interface.created_at IS '创建时间'; +COMMENT ON COLUMN api_interface.updater IS '更新人'; +COMMENT ON COLUMN api_interface.updated_at IS '更新时间'; +COMMENT ON COLUMN api_interface.deleted_at IS '软删除时间'; +COMMENT ON COLUMN api_interface.platform_id IS '所属平台ID'; +COMMENT ON COLUMN api_interface.name IS '接口名称'; +COMMENT ON COLUMN api_interface.code IS '接口编码'; +COMMENT ON COLUMN api_interface.url IS '接口地址'; +COMMENT ON COLUMN api_interface.method IS '请求方法:GET/POST/PUT/DELETE等'; +COMMENT ON COLUMN api_interface.status IS '接口状态:active启用/inactive停用'; +COMMENT ON COLUMN api_interface.auth_type IS '认证类型:oauth2/apikey/basic等'; +COMMENT ON COLUMN api_interface.request_config IS '请求配置'; +COMMENT ON COLUMN api_interface.response_config IS '响应配置'; +COMMENT ON COLUMN api_interface.limit_config IS '接口独立限流配置(可选,覆盖平台配置)'; + +CREATE UNIQUE INDEX idx_api_interface_code ON api_interface(tenant_id, code); +CREATE INDEX idx_api_interface_platform_id ON api_interface(tenant_id, platform_id); +CREATE INDEX idx_api_interface_status ON api_interface(tenant_id, status); diff --git a/sql/02_account_report_tables.sql b/sql/02_account_report_tables.sql new file mode 100644 index 0000000..acd30c6 --- /dev/null +++ b/sql/02_account_report_tables.sql @@ -0,0 +1,115 @@ +-- PostgreSQL 建表脚本 - 账户报告表 + +-- ============================================= +-- 账户报告明细表 (cid_account_report_detail) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS cid_account_report_detail_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS cid_account_report_detail ( + id BIGINT NOT NULL DEFAULT nextval('cid_account_report_detail_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + report_date_str VARCHAR(50), + account_id VARCHAR(100), + account_name VARCHAR(200), + cost_total DECIMAL(20,4), + impression BIGINT, + click BIGINT, + ctr DECIMAL(10,6), + cpc DECIMAL(20,4), + cpm DECIMAL(20,4), + conversion BIGINT, + conversion_rate DECIMAL(10,6), + cpa DECIMAL(20,4), + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE cid_account_report_detail IS '账户报告明细表'; +COMMENT ON COLUMN cid_account_report_detail.id IS '主键ID'; +COMMENT ON COLUMN cid_account_report_detail.tenant_id IS '租户ID'; +COMMENT ON COLUMN cid_account_report_detail.creator IS '创建人'; +COMMENT ON COLUMN cid_account_report_detail.created_at IS '创建时间'; +COMMENT ON COLUMN cid_account_report_detail.updater IS '更新人'; +COMMENT ON COLUMN cid_account_report_detail.updated_at IS '更新时间'; +COMMENT ON COLUMN cid_account_report_detail.deleted_at IS '软删除时间'; +COMMENT ON COLUMN cid_account_report_detail.cid IS '广告账户ID'; +COMMENT ON COLUMN cid_account_report_detail.report_date_str IS '报告日期'; +COMMENT ON COLUMN cid_account_report_detail.account_id IS '账户ID'; +COMMENT ON COLUMN cid_account_report_detail.account_name IS '账户名称'; +COMMENT ON COLUMN cid_account_report_detail.cost_total IS '总花费'; +COMMENT ON COLUMN cid_account_report_detail.impression IS '曝光数'; +COMMENT ON COLUMN cid_account_report_detail.click IS '点击数'; +COMMENT ON COLUMN cid_account_report_detail.ctr IS '点击率'; +COMMENT ON COLUMN cid_account_report_detail.cpc IS '点击单价'; +COMMENT ON COLUMN cid_account_report_detail.cpm IS '千次曝光成本'; +COMMENT ON COLUMN cid_account_report_detail.conversion IS '转化数'; +COMMENT ON COLUMN cid_account_report_detail.conversion_rate IS '转化率'; +COMMENT ON COLUMN cid_account_report_detail.cpa IS '转化成本'; +COMMENT ON COLUMN cid_account_report_detail.datasource IS '数据源'; + +CREATE INDEX idx_cid_account_report_detail_cid ON cid_account_report_detail(tenant_id, cid); +CREATE INDEX idx_cid_account_report_detail_date ON cid_account_report_detail(tenant_id, report_date_str); +CREATE INDEX idx_cid_account_report_detail_datasource ON cid_account_report_detail(tenant_id, datasource); + +-- ============================================= +-- 账户报告汇总表 (cid_account_report_sum) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS cid_account_report_sum_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS cid_account_report_sum ( + id BIGINT NOT NULL DEFAULT nextval('cid_account_report_sum_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + report_date_str VARCHAR(50), + account_id VARCHAR(100), + account_name VARCHAR(200), + cost_total DECIMAL(20,4), + impression BIGINT, + click BIGINT, + ctr DECIMAL(10,6), + cpc DECIMAL(20,4), + cpm DECIMAL(20,4), + conversion BIGINT, + conversion_rate DECIMAL(10,6), + cpa DECIMAL(20,4), + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE cid_account_report_sum IS '账户报告汇总表'; +COMMENT ON COLUMN cid_account_report_sum.id IS '主键ID'; +COMMENT ON COLUMN cid_account_report_sum.tenant_id IS '租户ID'; +COMMENT ON COLUMN cid_account_report_sum.creator IS '创建人'; +COMMENT ON COLUMN cid_account_report_sum.created_at IS '创建时间'; +COMMENT ON COLUMN cid_account_report_sum.updater IS '更新人'; +COMMENT ON COLUMN cid_account_report_sum.updated_at IS '更新时间'; +COMMENT ON COLUMN cid_account_report_sum.deleted_at IS '软删除时间'; +COMMENT ON COLUMN cid_account_report_sum.cid IS '广告账户ID'; +COMMENT ON COLUMN cid_account_report_sum.report_date_str IS '报告日期'; +COMMENT ON COLUMN cid_account_report_sum.account_id IS '账户ID'; +COMMENT ON COLUMN cid_account_report_sum.account_name IS '账户名称'; +COMMENT ON COLUMN cid_account_report_sum.cost_total IS '总花费'; +COMMENT ON COLUMN cid_account_report_sum.impression IS '曝光数'; +COMMENT ON COLUMN cid_account_report_sum.click IS '点击数'; +COMMENT ON COLUMN cid_account_report_sum.ctr IS '点击率'; +COMMENT ON COLUMN cid_account_report_sum.cpc IS '点击单价'; +COMMENT ON COLUMN cid_account_report_sum.cpm IS '千次曝光成本'; +COMMENT ON COLUMN cid_account_report_sum.conversion IS '转化数'; +COMMENT ON COLUMN cid_account_report_sum.conversion_rate IS '转化率'; +COMMENT ON COLUMN cid_account_report_sum.cpa IS '转化成本'; +COMMENT ON COLUMN cid_account_report_sum.datasource IS '数据源'; + +CREATE INDEX idx_cid_account_report_sum_cid ON cid_account_report_sum(tenant_id, cid); +CREATE INDEX idx_cid_account_report_sum_date ON cid_account_report_sum(tenant_id, report_date_str); +CREATE INDEX idx_cid_account_report_sum_datasource ON cid_account_report_sum(tenant_id, datasource); diff --git a/sql/03_campaign_report_tables.sql b/sql/03_campaign_report_tables.sql new file mode 100644 index 0000000..c4e6ddc --- /dev/null +++ b/sql/03_campaign_report_tables.sql @@ -0,0 +1,419 @@ +-- PostgreSQL 建表脚本 - 广告系列报告表 + +-- ============================================= +-- 广告系列报告明细表 (campaign_report_detail) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS campaign_report_detail_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS campaign_report_detail ( + id BIGINT NOT NULL DEFAULT nextval('campaign_report_detail_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + t0_order_payment_amt DECIMAL(20,4), + creative_material_type VARCHAR(100), + live_name VARCHAR(200), + author_id VARCHAR(100), + pic_url VARCHAR(500), + pic_name VARCHAR(200), + pic_id VARCHAR(100), + cover_url VARCHAR(500), + cover_id BIGINT, + item_order_conversion_ratio DECIMAL(10,6), + item_card_click_ratio DECIMAL(10,6), + item_card_clk_cnt BIGINT, + live_play_cnt_cost DECIMAL(20,4), + ad_merchant_follow_cost DECIMAL(20,4), + ad_merchant_follow BIGINT, + net_t0_order_cnt BIGINT, + net_t0_roi DECIMAL(10,6), + net_t0_gmv DECIMAL(20,4), + photo_name VARCHAR(200), + photo_id_str VARCHAR(100), + photo_id VARCHAR(100), + mod_price_segment VARCHAR(100), + age_segment VARCHAR(100), + province VARCHAR(100), + gender VARCHAR(20), + ad_photo_played_five_ratio DECIMAL(10,6), + ad_photo_played_three_ratio DECIMAL(10,6), + order_submit_roi DECIMAL(10,6), + order_submit_amt BIGINT, + event_order_submit_cost DECIMAL(20,4), + event_order_submit BIGINT, + event_order_paid_roi DECIMAL(10,6), + event_app_invoked BIGINT, + event_add_shopping_cart BIGINT, + conversion_num_cost DECIMAL(20,4), + ad_effective_play_num BIGINT, + ad_item_click BIGINT, + merchant_product_id VARCHAR(100), + cost_total DECIMAL(20,4), + ad_show BIGINT, + ad_show1k_cost DECIMAL(20,4), + impression BIGINT, + photo_click BIGINT, + photo_click_ratio DECIMAL(10,6), + click BIGINT, + actionbar_click BIGINT, + actionbar_click_cost DECIMAL(20,4), + esp_click_ratio DECIMAL(10,6), + action_ratio DECIMAL(10,6), + ad_item_click_count BIGINT, + esp_live_played_seconds BIGINT, + played_three_seconds BIGINT, + play3s_ratio DECIMAL(10,6), + played_five_seconds BIGINT, + play5s_ratio DECIMAL(10,6), + played_end BIGINT, + play_end_ratio DECIMAL(10,6), + share BIGINT, + comment BIGINT, + likes BIGINT, + report BIGINT, + block BIGINT, + item_negative BIGINT, + live_share BIGINT, + live_comment BIGINT, + live_reward BIGINT, + effective_play_count BIGINT, + effective_play_ratio DECIMAL(10,6), + conversion_num BIGINT, + conversion_cost_esp DECIMAL(20,4), + roi DECIMAL(10,6), + gmv DECIMAL(20,4), + t0_gmv DECIMAL(20,4), + t1_gmv DECIMAL(20,4), + t7_gmv DECIMAL(20,4), + t15_gmv DECIMAL(20,4), + t30_gmv DECIMAL(20,4), + t0_roi DECIMAL(10,6), + t1_roi DECIMAL(10,6), + t7_roi DECIMAL(10,6), + t15_roi DECIMAL(10,6), + t30_roi DECIMAL(10,6), + paied_order BIGINT, + order_ratio DECIMAL(10,6), + t0_order_cnt BIGINT, + t0_order_cnt_cost DECIMAL(20,4), + t0_order_cnt_ratio DECIMAL(10,6), + t1_order_cnt BIGINT, + t7_order_cnt BIGINT, + t15_order_cnt BIGINT, + t30_order_cnt BIGINT, + merchant_reco_fans BIGINT, + t1_retention DECIMAL(10,4), + t7_retention DECIMAL(10,4), + t15_retention DECIMAL(10,4), + t30_retention DECIMAL(10,4), + t1_retention_ratio DECIMAL(10,6), + t7_retention_ratio DECIMAL(10,6), + t15_retention_ratio DECIMAL(10,6), + t30_retention_ratio DECIMAL(10,6), + reservation_success BIGINT, + reservation_cost DECIMAL(20,4), + standard_live_played_started BIGINT, + ad_live_play_cnt BIGINT, + ad_live_play_cnt_cost DECIMAL(20,4), + live_audience_cost DECIMAL(20,4), + live_event_goods_view BIGINT, + goods_click_ratio DECIMAL(10,6), + direct_attr_plat_new_buyer_cnt BIGINT, + t30_attr_plat_total_buyer_cnt BIGINT, + direct_attr_seller_new_buyer_cnt BIGINT, + t30_attr_seller_total_buyer_cnt BIGINT, + t3_gmv DECIMAL(20,4), + t3_order_cnt BIGINT, + t3_roi DECIMAL(10,6), + t7_indirect_order_amt DECIMAL(20,4), + t7_indirect_order_cnt BIGINT, + fans_t0_gmv_per_fans DECIMAL(20,4), + fans_t3_gmv_per_fans DECIMAL(20,4), + fans_t7_gmv_per_fans DECIMAL(20,4), + fans_t15_gmv_per_fans DECIMAL(20,4), + fans_t30_gmv_per_fans DECIMAL(20,4), + reco_fans_cost DECIMAL(20,4), + qcpx_whitebox_direct_order_payment_amt DECIMAL(20,4), + qcpx_whitebox_direct_order_cnt BIGINT, + fans_t0_gmv DECIMAL(20,4), + fans_t1_gmv DECIMAL(20,4), + fans_t7_gmv DECIMAL(20,4), + fans_t15_gmv DECIMAL(20,4), + fans_t30_gmv DECIMAL(20,4), + fans_t0_roi DECIMAL(10,6), + fans_t1_roi DECIMAL(10,6), + fans_t7_roi DECIMAL(10,6), + fans_t15_roi DECIMAL(10,6), + fans_t30_roi DECIMAL(10,6), + t0_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t1_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t3_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t7_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t15_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t30_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t0_shop_new_buyer_order_cnt BIGINT, + t1_shop_new_buyer_order_cnt BIGINT, + t3_shop_new_buyer_order_cnt BIGINT, + t7_shop_new_buyer_order_cnt BIGINT, + t15_shop_new_buyer_order_cnt BIGINT, + t30_shop_new_buyer_order_cnt BIGINT, + t1_new_buyer_repurchase_ratio DECIMAL(10,6), + t3_new_buyer_repurchase_ratio DECIMAL(10,6), + t7_new_buyer_repurchase_ratio DECIMAL(10,6), + t15_new_buyer_repurchase_ratio DECIMAL(10,6), + t30_new_buyer_repurchase_ratio DECIMAL(10,6), + t0_shop_new_buyer_roi DECIMAL(10,6), + t1_shop_new_buyer_roi DECIMAL(10,6), + t3_shop_new_buyer_roi DECIMAL(10,6), + t7_shop_new_buyer_roi DECIMAL(10,6), + t15_shop_new_buyer_roi DECIMAL(10,6), + t30_shop_new_buyer_roi DECIMAL(10,6), + create_card_order_cnt BIGINT, + forward_ts_create_card_order_cnt BIGINT, + create_card_order_cost DECIMAL(20,4), + forward_ts_create_card_order_cost DECIMAL(20,4), + activate_card_order_cnt BIGINT, + forward_ts_activate_card_order_cnt BIGINT, + activate_card_order_cost DECIMAL(20,4), + forward_ts_activate_card_order_cost DECIMAL(20,4), + create_card_order_ratio DECIMAL(10,6), + forward_ts_create_card_order_ratio DECIMAL(10,6), + activate_card_order_cnt_ratio DECIMAL(10,6), + forward_ts_activate_card_order_ratio DECIMAL(10,6), + live_play_cnt BIGINT, + item_entrance_clk_cnt BIGINT, + show_cnt BIGINT, + report_date_str VARCHAR(50), + campaign_id BIGINT, + campaign_name VARCHAR(200), + unit_id BIGINT, + unit_name VARCHAR(200), + creative_id BIGINT, + creative_name VARCHAR(200), + cid_actual_roi_after_subsidy DECIMAL(10,6), + cid_coupon_amount BIGINT, + cid_coupon_callback_paid_refund_amount BIGINT, + cid_voucher_cost DECIMAL(20,4), + PRIMARY KEY (id) +); + +COMMENT ON TABLE campaign_report_detail IS '广告系列报告明细表'; + +CREATE INDEX idx_campaign_report_detail_cid ON campaign_report_detail(tenant_id, cid); +CREATE INDEX idx_campaign_report_detail_campaign_id ON campaign_report_detail(tenant_id, campaign_id); +CREATE INDEX idx_campaign_report_detail_date ON campaign_report_detail(tenant_id, report_date_str); +CREATE INDEX idx_campaign_report_detail_datasource ON campaign_report_detail(tenant_id, datasource); + +-- ============================================= +-- 广告系列报告汇总表 (campaign_report_sum) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS campaign_report_sum_id_seq START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS campaign_report_sum ( + id BIGINT NOT NULL DEFAULT nextval('campaign_report_sum_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(100) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + updater VARCHAR(100) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP, + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + t0_order_payment_amt DECIMAL(20,4), + creative_material_type VARCHAR(100), + live_name VARCHAR(200), + author_id VARCHAR(100), + pic_url VARCHAR(500), + pic_name VARCHAR(200), + pic_id VARCHAR(100), + cover_url VARCHAR(500), + cover_id BIGINT, + item_order_conversion_ratio DECIMAL(10,6), + item_card_click_ratio DECIMAL(10,6), + item_card_clk_cnt BIGINT, + live_play_cnt_cost DECIMAL(20,4), + ad_merchant_follow_cost DECIMAL(20,4), + ad_merchant_follow BIGINT, + net_t0_order_cnt BIGINT, + net_t0_roi DECIMAL(10,6), + net_t0_gmv DECIMAL(20,4), + photo_name VARCHAR(200), + photo_id_str VARCHAR(100), + photo_id VARCHAR(100), + mod_price_segment VARCHAR(100), + age_segment VARCHAR(100), + province VARCHAR(100), + gender VARCHAR(20), + ad_photo_played_five_ratio DECIMAL(10,6), + ad_photo_played_three_ratio DECIMAL(10,6), + order_submit_roi DECIMAL(10,6), + order_submit_amt BIGINT, + event_order_submit_cost DECIMAL(20,4), + event_order_submit BIGINT, + event_order_paid_roi DECIMAL(10,6), + event_app_invoked BIGINT, + event_add_shopping_cart BIGINT, + conversion_num_cost DECIMAL(20,4), + ad_effective_play_num BIGINT, + ad_item_click BIGINT, + merchant_product_id VARCHAR(100), + cost_total DECIMAL(20,4), + ad_show BIGINT, + ad_show1k_cost DECIMAL(20,4), + impression BIGINT, + photo_click BIGINT, + photo_click_ratio DECIMAL(10,6), + click BIGINT, + actionbar_click BIGINT, + actionbar_click_cost DECIMAL(20,4), + esp_click_ratio DECIMAL(10,6), + action_ratio DECIMAL(10,6), + ad_item_click_count BIGINT, + esp_live_played_seconds BIGINT, + played_three_seconds BIGINT, + play3s_ratio DECIMAL(10,6), + played_five_seconds BIGINT, + play5s_ratio DECIMAL(10,6), + played_end BIGINT, + play_end_ratio DECIMAL(10,6), + share BIGINT, + comment BIGINT, + likes BIGINT, + report BIGINT, + block BIGINT, + item_negative BIGINT, + live_share BIGINT, + live_comment BIGINT, + live_reward BIGINT, + effective_play_count BIGINT, + effective_play_ratio DECIMAL(10,6), + conversion_num BIGINT, + conversion_cost_esp DECIMAL(20,4), + roi DECIMAL(10,6), + gmv DECIMAL(20,4), + t0_gmv DECIMAL(20,4), + t1_gmv DECIMAL(20,4), + t7_gmv DECIMAL(20,4), + t15_gmv DECIMAL(20,4), + t30_gmv DECIMAL(20,4), + t0_roi DECIMAL(10,6), + t1_roi DECIMAL(10,6), + t7_roi DECIMAL(10,6), + t15_roi DECIMAL(10,6), + t30_roi DECIMAL(10,6), + paied_order BIGINT, + order_ratio DECIMAL(10,6), + t0_order_cnt BIGINT, + t0_order_cnt_cost DECIMAL(20,4), + t0_order_cnt_ratio DECIMAL(10,6), + t1_order_cnt BIGINT, + t7_order_cnt BIGINT, + t15_order_cnt BIGINT, + t30_order_cnt BIGINT, + merchant_reco_fans BIGINT, + t1_retention DECIMAL(10,4), + t7_retention DECIMAL(10,4), + t15_retention DECIMAL(10,4), + t30_retention DECIMAL(10,4), + t1_retention_ratio DECIMAL(10,6), + t7_retention_ratio DECIMAL(10,6), + t15_retention_ratio DECIMAL(10,6), + t30_retention_ratio DECIMAL(10,6), + reservation_success BIGINT, + reservation_cost DECIMAL(20,4), + standard_live_played_started BIGINT, + ad_live_play_cnt BIGINT, + ad_live_play_cnt_cost DECIMAL(20,4), + live_audience_cost DECIMAL(20,4), + live_event_goods_view BIGINT, + goods_click_ratio DECIMAL(10,6), + direct_attr_plat_new_buyer_cnt BIGINT, + t30_attr_plat_total_buyer_cnt BIGINT, + direct_attr_seller_new_buyer_cnt BIGINT, + t30_attr_seller_total_buyer_cnt BIGINT, + t3_gmv DECIMAL(20,4), + t3_order_cnt BIGINT, + t3_roi DECIMAL(10,6), + t7_indirect_order_amt DECIMAL(20,4), + t7_indirect_order_cnt BIGINT, + fans_t0_gmv_per_fans DECIMAL(20,4), + fans_t3_gmv_per_fans DECIMAL(20,4), + fans_t7_gmv_per_fans DECIMAL(20,4), + fans_t15_gmv_per_fans DECIMAL(20,4), + fans_t30_gmv_per_fans DECIMAL(20,4), + reco_fans_cost DECIMAL(20,4), + qcpx_whitebox_direct_order_payment_amt DECIMAL(20,4), + qcpx_whitebox_direct_order_cnt BIGINT, + fans_t0_gmv DECIMAL(20,4), + fans_t1_gmv DECIMAL(20,4), + fans_t7_gmv DECIMAL(20,4), + fans_t15_gmv DECIMAL(20,4), + fans_t30_gmv DECIMAL(20,4), + fans_t0_roi DECIMAL(10,6), + fans_t1_roi DECIMAL(10,6), + fans_t7_roi DECIMAL(10,6), + fans_t15_roi DECIMAL(10,6), + fans_t30_roi DECIMAL(10,6), + t0_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t1_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t3_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t7_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t15_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t30_shop_new_buyer_order_payment_amt DECIMAL(20,4), + t0_shop_new_buyer_order_cnt BIGINT, + t1_shop_new_buyer_order_cnt BIGINT, + t3_shop_new_buyer_order_cnt BIGINT, + t7_shop_new_buyer_order_cnt BIGINT, + t15_shop_new_buyer_order_cnt BIGINT, + t30_shop_new_buyer_order_cnt BIGINT, + t1_new_buyer_repurchase_ratio DECIMAL(10,6), + t3_new_buyer_repurchase_ratio DECIMAL(10,6), + t7_new_buyer_repurchase_ratio DECIMAL(10,6), + t15_new_buyer_repurchase_ratio DECIMAL(10,6), + t30_new_buyer_repurchase_ratio DECIMAL(10,6), + t0_shop_new_buyer_roi DECIMAL(10,6), + t1_shop_new_buyer_roi DECIMAL(10,6), + t3_shop_new_buyer_roi DECIMAL(10,6), + t7_shop_new_buyer_roi DECIMAL(10,6), + t15_shop_new_buyer_roi DECIMAL(10,6), + t30_shop_new_buyer_roi DECIMAL(10,6), + create_card_order_cnt BIGINT, + forward_ts_create_card_order_cnt BIGINT, + create_card_order_cost DECIMAL(20,4), + forward_ts_create_card_order_cost DECIMAL(20,4), + activate_card_order_cnt BIGINT, + forward_ts_activate_card_order_cnt BIGINT, + activate_card_order_cost DECIMAL(20,4), + forward_ts_activate_card_order_cost DECIMAL(20,4), + create_card_order_ratio DECIMAL(10,6), + forward_ts_create_card_order_ratio DECIMAL(10,6), + activate_card_order_cnt_ratio DECIMAL(10,6), + forward_ts_activate_card_order_ratio DECIMAL(10,6), + live_play_cnt BIGINT, + item_entrance_clk_cnt BIGINT, + show_cnt BIGINT, + report_date_str VARCHAR(50), + campaign_id BIGINT, + campaign_name VARCHAR(200), + unit_id BIGINT, + unit_name VARCHAR(200), + creative_id BIGINT, + creative_name VARCHAR(200), + cid_actual_roi_after_subsidy DECIMAL(10,6), + cid_coupon_amount BIGINT, + cid_coupon_callback_paid_refund_amount BIGINT, + cid_voucher_cost DECIMAL(20,4), + PRIMARY KEY (id) +); + +COMMENT ON TABLE campaign_report_sum IS '广告系列报告汇总表'; + +CREATE INDEX idx_campaign_report_sum_cid ON campaign_report_sum(tenant_id, cid); +CREATE INDEX idx_campaign_report_sum_campaign_id ON campaign_report_sum(tenant_id, campaign_id); +CREATE INDEX idx_campaign_report_sum_date ON campaign_report_sum(tenant_id, report_date_str); +CREATE INDEX idx_campaign_report_sum_datasource ON campaign_report_sum(tenant_id, datasource); diff --git a/sql/04_creative_report_tables.sql b/sql/04_creative_report_tables.sql new file mode 100644 index 0000000..8b3a919 --- /dev/null +++ b/sql/04_creative_report_tables.sql @@ -0,0 +1,206 @@ +-- Creative Report Tables (创意报告表) + +-- ============================================= +-- 创意报告明细表 (creative_report_detail) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS creative_report_detail_id_seq; + +CREATE TABLE IF NOT EXISTS creative_report_detail ( + id BIGINT NOT NULL DEFAULT nextval('creative_report_detail_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + ad_name VARCHAR(255) NOT NULL DEFAULT '', + render_mode VARCHAR(32) NOT NULL DEFAULT '', + inventory_type VARCHAR(32) NOT NULL DEFAULT '', + promotion_target_id VARCHAR(64) NOT NULL DEFAULT '', + material_hash VARCHAR(128) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + primary_url VARCHAR(1024) NOT NULL DEFAULT '', + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0, + game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0, + onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE creative_report_detail IS '创意报告明细表'; +COMMENT ON COLUMN creative_report_detail.id IS '主键ID'; +COMMENT ON COLUMN creative_report_detail.tenant_id IS '租户ID'; +COMMENT ON COLUMN creative_report_detail.creator IS '创建人'; +COMMENT ON COLUMN creative_report_detail.created_at IS '创建时间'; +COMMENT ON COLUMN creative_report_detail.updater IS '更新人'; +COMMENT ON COLUMN creative_report_detail.updated_at IS '更新时间'; +COMMENT ON COLUMN creative_report_detail.deleted_at IS '软删除时间'; +COMMENT ON COLUMN creative_report_detail.cid IS '广告账户ID'; +COMMENT ON COLUMN creative_report_detail.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN creative_report_detail.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN creative_report_detail.ad_id IS '创意ID'; +COMMENT ON COLUMN creative_report_detail.ad_name IS '创意名称'; +COMMENT ON COLUMN creative_report_detail.render_mode IS '创意类型'; +COMMENT ON COLUMN creative_report_detail.inventory_type IS '投放位置'; +COMMENT ON COLUMN creative_report_detail.promotion_target_id IS '推广目标ID'; +COMMENT ON COLUMN creative_report_detail.material_hash IS '素材哈希'; +COMMENT ON COLUMN creative_report_detail.impression IS '展示数'; +COMMENT ON COLUMN creative_report_detail.click IS '点击数'; +COMMENT ON COLUMN creative_report_detail.cost IS '花费(元)'; +COMMENT ON COLUMN creative_report_detail.ctr IS '点击率'; +COMMENT ON COLUMN creative_report_detail.cpc IS '平均点击价格'; +COMMENT ON COLUMN creative_report_detail.cpm IS '千次展现成本'; +COMMENT ON COLUMN creative_report_detail.conversion IS '转化数'; +COMMENT ON COLUMN creative_report_detail.conversion_rate IS '转化率'; +COMMENT ON COLUMN creative_report_detail.cpp IS '单次转化成本'; +COMMENT ON COLUMN creative_report_detail.primary_url IS '落地页URL'; +COMMENT ON COLUMN creative_report_detail.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN creative_report_detail.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN creative_report_detail.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN creative_report_detail.video_interaction_count IS '视频互动数'; +COMMENT ON COLUMN creative_report_detail.video_three_second_play_count IS '视频3秒播放次数'; +COMMENT ON COLUMN creative_report_detail.video_five_second_play_count IS '视频5秒播放次数'; +COMMENT ON COLUMN creative_report_detail.tweet_engage_count IS '推文参与数'; +COMMENT ON COLUMN creative_report_detail.tweet_share_count IS '推文分享数'; +COMMENT ON COLUMN creative_report_detail.tweet_comment_count IS '推文评论数'; +COMMENT ON COLUMN creative_report_detail.tweet_like_count IS '推文点赞数'; +COMMENT ON COLUMN creative_report_detail.tweet_repost_count IS '推文转发数'; +COMMENT ON COLUMN creative_report_detail.game_download_count IS '游戏下载数'; +COMMENT ON COLUMN creative_report_detail.app_download_count IS '应用下载数'; +COMMENT ON COLUMN creative_report_detail.app_install_count IS '应用安装数'; +COMMENT ON COLUMN creative_report_detail.onsite_leads_count IS '预注册数'; +COMMENT ON COLUMN creative_report_detail.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN creative_report_detail.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN creative_report_detail.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN creative_report_detail.day IS '数据日期'; +COMMENT ON COLUMN creative_report_detail.datasource IS '数据源'; + +CREATE INDEX idx_creative_report_detail_cid ON creative_report_detail(tenant_id, cid); +CREATE INDEX idx_creative_report_detail_campaign_id ON creative_report_detail(tenant_id, campaign_id); +CREATE INDEX idx_creative_report_detail_ad_id ON creative_report_detail(tenant_id, ad_id); +CREATE INDEX idx_creative_report_detail_day ON creative_report_detail(tenant_id, day); +CREATE INDEX idx_creative_report_detail_datasource ON creative_report_detail(tenant_id, datasource); +CREATE INDEX idx_creative_report_detail_material_hash ON creative_report_detail(tenant_id, material_hash); + +-- ============================================= +-- 创意报告汇总表 (creative_report_sum) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS creative_report_sum_id_seq; + +CREATE TABLE IF NOT EXISTS creative_report_sum ( + id BIGINT NOT NULL DEFAULT nextval('creative_report_sum_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + ad_name VARCHAR(255) NOT NULL DEFAULT '', + render_mode VARCHAR(32) NOT NULL DEFAULT '', + inventory_type VARCHAR(32) NOT NULL DEFAULT '', + promotion_target_id VARCHAR(64) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0, + game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0, + onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + hour VARCHAR(2) NOT NULL DEFAULT '', + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE creative_report_sum IS '创意报告汇总表'; +COMMENT ON COLUMN creative_report_sum.id IS '主键ID'; +COMMENT ON COLUMN creative_report_sum.tenant_id IS '租户ID'; +COMMENT ON COLUMN creative_report_sum.creator IS '创建人'; +COMMENT ON COLUMN creative_report_sum.created_at IS '创建时间'; +COMMENT ON COLUMN creative_report_sum.updater IS '更新人'; +COMMENT ON COLUMN creative_report_sum.updated_at IS '更新时间'; +COMMENT ON COLUMN creative_report_sum.deleted_at IS '软删除时间'; +COMMENT ON COLUMN creative_report_sum.cid IS '广告账户ID'; +COMMENT ON COLUMN creative_report_sum.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN creative_report_sum.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN creative_report_sum.ad_id IS '创意ID'; +COMMENT ON COLUMN creative_report_sum.ad_name IS '创意名称'; +COMMENT ON COLUMN creative_report_sum.render_mode IS '创意类型'; +COMMENT ON COLUMN creative_report_sum.inventory_type IS '投放位置'; +COMMENT ON COLUMN creative_report_sum.promotion_target_id IS '推广目标ID'; +COMMENT ON COLUMN creative_report_sum.impression IS '展示数'; +COMMENT ON COLUMN creative_report_sum.click IS '点击数'; +COMMENT ON COLUMN creative_report_sum.cost IS '花费(元)'; +COMMENT ON COLUMN creative_report_sum.ctr IS '点击率'; +COMMENT ON COLUMN creative_report_sum.cpc IS '平均点击价格'; +COMMENT ON COLUMN creative_report_sum.cpm IS '千次展现成本'; +COMMENT ON COLUMN creative_report_sum.conversion IS '转化数'; +COMMENT ON COLUMN creative_report_sum.conversion_rate IS '转化率'; +COMMENT ON COLUMN creative_report_sum.cpp IS '单次转化成本'; +COMMENT ON COLUMN creative_report_sum.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN creative_report_sum.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN creative_report_sum.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN creative_report_sum.video_interaction_count IS '视频互动数'; +COMMENT ON COLUMN creative_report_sum.game_download_count IS '游戏下载数'; +COMMENT ON COLUMN creative_report_sum.app_download_count IS '应用下载数'; +COMMENT ON COLUMN creative_report_sum.app_install_count IS '应用安装数'; +COMMENT ON COLUMN creative_report_sum.onsite_leads_count IS '预注册数'; +COMMENT ON COLUMN creative_report_sum.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN creative_report_sum.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN creative_report_sum.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN creative_report_sum.hour IS '数据小时'; +COMMENT ON COLUMN creative_report_sum.day IS '数据日期'; +COMMENT ON COLUMN creative_report_sum.datasource IS '数据源'; + +CREATE INDEX idx_creative_report_sum_cid ON creative_report_sum(tenant_id, cid); +CREATE INDEX idx_creative_report_sum_campaign_id ON creative_report_sum(tenant_id, campaign_id); +CREATE INDEX idx_creative_report_sum_ad_id ON creative_report_sum(tenant_id, ad_id); +CREATE INDEX idx_creative_report_sum_day ON creative_report_sum(tenant_id, day); +CREATE INDEX idx_creative_report_sum_hour ON creative_report_sum(tenant_id, hour); +CREATE INDEX idx_creative_report_sum_datasource ON creative_report_sum(tenant_id, datasource); +CREATE UNIQUE INDEX idx_creative_report_sum_unique ON creative_report_sum(tenant_id, ad_id, hour, day, datasource); diff --git a/sql/05_unit_report_tables.sql b/sql/05_unit_report_tables.sql new file mode 100644 index 0000000..ae302af --- /dev/null +++ b/sql/05_unit_report_tables.sql @@ -0,0 +1,207 @@ +-- Unit Report Tables (单元报告表) + +-- ============================================= +-- 单元报告明细表 (unit_report_detail) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS unit_report_detail_id_seq; + +CREATE TABLE IF NOT EXISTS unit_report_detail ( + id BIGINT NOT NULL DEFAULT nextval('unit_report_detail_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_name VARCHAR(255) NOT NULL DEFAULT '', + marketing_target_id VARCHAR(64) NOT NULL DEFAULT '', + marketing_target_name VARCHAR(255) NOT NULL DEFAULT '', + placement_type VARCHAR(32) NOT NULL DEFAULT '', + inventory_type VARCHAR(32) NOT NULL DEFAULT '', + campaign_budget DECIMAL(20,6) NOT NULL DEFAULT 0, + adgroup_budget DECIMAL(20,6) NOT NULL DEFAULT 0, + bid_mode VARCHAR(32) NOT NULL DEFAULT '', + bid_amount DECIMAL(20,6) NOT NULL DEFAULT 0, + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + primary_url VARCHAR(1024) NOT NULL DEFAULT '', + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0, + game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0, + onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE unit_report_detail IS '单元报告明细表'; +COMMENT ON COLUMN unit_report_detail.id IS '主键ID'; +COMMENT ON COLUMN unit_report_detail.tenant_id IS '租户ID'; +COMMENT ON COLUMN unit_report_detail.creator IS '创建人'; +COMMENT ON COLUMN unit_report_detail.created_at IS '创建时间'; +COMMENT ON COLUMN unit_report_detail.updater IS '更新人'; +COMMENT ON COLUMN unit_report_detail.updated_at IS '更新时间'; +COMMENT ON COLUMN unit_report_detail.deleted_at IS '软删除时间'; +COMMENT ON COLUMN unit_report_detail.cid IS '广告账户ID'; +COMMENT ON COLUMN unit_report_detail.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN unit_report_detail.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN unit_report_detail.adgroup_name IS '广告组名称'; +COMMENT ON COLUMN unit_report_detail.marketing_target_id IS '营销标的ID'; +COMMENT ON COLUMN unit_report_detail.marketing_target_name IS '营销标的名称'; +COMMENT ON COLUMN unit_report_detail.placement_type IS '投放版位'; +COMMENT ON COLUMN unit_report_detail.inventory_type IS '投放位置'; +COMMENT ON COLUMN unit_report_detail.campaign_budget IS '广告系列预算'; +COMMENT ON COLUMN unit_report_detail.adgroup_budget IS '广告组预算'; +COMMENT ON COLUMN unit_report_detail.bid_mode IS '出价方式'; +COMMENT ON COLUMN unit_report_detail.bid_amount IS '出价/代理出价'; +COMMENT ON COLUMN unit_report_detail.impression IS '展示数'; +COMMENT ON COLUMN unit_report_detail.click IS '点击数'; +COMMENT ON COLUMN unit_report_detail.cost IS '花费(元)'; +COMMENT ON COLUMN unit_report_detail.ctr IS '点击率'; +COMMENT ON COLUMN unit_report_detail.cpc IS '平均点击价格'; +COMMENT ON COLUMN unit_report_detail.cpm IS '千次展现成本'; +COMMENT ON COLUMN unit_report_detail.conversion IS '转化数'; +COMMENT ON COLUMN unit_report_detail.conversion_rate IS '转化率'; +COMMENT ON COLUMN unit_report_detail.cpp IS '单次转化成本'; +COMMENT ON COLUMN unit_report_detail.primary_url IS '落地页URL'; +COMMENT ON COLUMN unit_report_detail.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN unit_report_detail.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN unit_report_detail.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN unit_report_detail.video_interaction_count IS '视频互动数'; +COMMENT ON COLUMN unit_report_detail.tweet_engage_count IS '推文参与数'; +COMMENT ON COLUMN unit_report_detail.tweet_share_count IS '推文分享数'; +COMMENT ON COLUMN unit_report_detail.tweet_comment_count IS '推文评论数'; +COMMENT ON COLUMN unit_report_detail.tweet_like_count IS '推文点赞数'; +COMMENT ON COLUMN unit_report_detail.tweet_repost_count IS '推文转发数'; +COMMENT ON COLUMN unit_report_detail.game_download_count IS '游戏下载数'; +COMMENT ON COLUMN unit_report_detail.app_download_count IS '应用下载数'; +COMMENT ON COLUMN unit_report_detail.app_install_count IS '应用安装数'; +COMMENT ON COLUMN unit_report_detail.onsite_leads_count IS '预注册数'; +COMMENT ON COLUMN unit_report_detail.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN unit_report_detail.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN unit_report_detail.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN unit_report_detail.day IS '数据日期'; +COMMENT ON COLUMN unit_report_detail.datasource IS '数据源'; + +CREATE INDEX idx_unit_report_detail_cid ON unit_report_detail(tenant_id, cid); +CREATE INDEX idx_unit_report_detail_campaign_id ON unit_report_detail(tenant_id, campaign_id); +CREATE INDEX idx_unit_report_detail_adgroup_id ON unit_report_detail(tenant_id, adgroup_id); +CREATE INDEX idx_unit_report_detail_day ON unit_report_detail(tenant_id, day); +CREATE INDEX idx_unit_report_detail_datasource ON unit_report_detail(tenant_id, datasource); + +-- ============================================= +-- 单元报告汇总表 (unit_report_sum) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS unit_report_sum_id_seq; + +CREATE TABLE IF NOT EXISTS unit_report_sum ( + id BIGINT NOT NULL DEFAULT nextval('unit_report_sum_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_name VARCHAR(255) NOT NULL DEFAULT '', + marketing_target_id VARCHAR(64) NOT NULL DEFAULT '', + marketing_target_name VARCHAR(255) NOT NULL DEFAULT '', + placement_type VARCHAR(32) NOT NULL DEFAULT '', + inventory_type VARCHAR(32) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0, + game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0, + onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + hour VARCHAR(2) NOT NULL DEFAULT '', + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE unit_report_sum IS '单元报告汇总表'; +COMMENT ON COLUMN unit_report_sum.id IS '主键ID'; +COMMENT ON COLUMN unit_report_sum.tenant_id IS '租户ID'; +COMMENT ON COLUMN unit_report_sum.creator IS '创建人'; +COMMENT ON COLUMN unit_report_sum.created_at IS '创建时间'; +COMMENT ON COLUMN unit_report_sum.updater IS '更新人'; +COMMENT ON COLUMN unit_report_sum.updated_at IS '更新时间'; +COMMENT ON COLUMN unit_report_sum.deleted_at IS '软删除时间'; +COMMENT ON COLUMN unit_report_sum.cid IS '广告账户ID'; +COMMENT ON COLUMN unit_report_sum.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN unit_report_sum.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN unit_report_sum.adgroup_name IS '广告组名称'; +COMMENT ON COLUMN unit_report_sum.marketing_target_id IS '营销标的ID'; +COMMENT ON COLUMN unit_report_sum.marketing_target_name IS '营销标的名称'; +COMMENT ON COLUMN unit_report_sum.placement_type IS '投放版位'; +COMMENT ON COLUMN unit_report_sum.inventory_type IS '投放位置'; +COMMENT ON COLUMN unit_report_sum.impression IS '展示数'; +COMMENT ON COLUMN unit_report_sum.click IS '点击数'; +COMMENT ON COLUMN unit_report_sum.cost IS '花费(元)'; +COMMENT ON COLUMN unit_report_sum.ctr IS '点击率'; +COMMENT ON COLUMN unit_report_sum.cpc IS '平均点击价格'; +COMMENT ON COLUMN unit_report_sum.cpm IS '千次展现成本'; +COMMENT ON COLUMN unit_report_sum.conversion IS '转化数'; +COMMENT ON COLUMN unit_report_sum.conversion_rate IS '转化率'; +COMMENT ON COLUMN unit_report_sum.cpp IS '单次转化成本'; +COMMENT ON COLUMN unit_report_sum.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN unit_report_sum.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN unit_report_sum.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN unit_report_sum.video_interaction_count IS '视频互动数'; +COMMENT ON COLUMN unit_report_sum.game_download_count IS '游戏下载数'; +COMMENT ON COLUMN unit_report_sum.app_download_count IS '应用下载数'; +COMMENT ON COLUMN unit_report_sum.app_install_count IS '应用安装数'; +COMMENT ON COLUMN unit_report_sum.onsite_leads_count IS '预注册数'; +COMMENT ON COLUMN unit_report_sum.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN unit_report_sum.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN unit_report_sum.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN unit_report_sum.hour IS '数据小时'; +COMMENT ON COLUMN unit_report_sum.day IS '数据日期'; +COMMENT ON COLUMN unit_report_sum.datasource IS '数据源'; + +CREATE INDEX idx_unit_report_sum_cid ON unit_report_sum(tenant_id, cid); +CREATE INDEX idx_unit_report_sum_campaign_id ON unit_report_sum(tenant_id, campaign_id); +CREATE INDEX idx_unit_report_sum_adgroup_id ON unit_report_sum(tenant_id, adgroup_id); +CREATE INDEX idx_unit_report_sum_day ON unit_report_sum(tenant_id, day); +CREATE INDEX idx_unit_report_sum_hour ON unit_report_sum(tenant_id, hour); +CREATE INDEX idx_unit_report_sum_datasource ON unit_report_sum(tenant_id, datasource); +CREATE UNIQUE INDEX idx_unit_report_sum_unique ON unit_report_sum(tenant_id, adgroup_id, hour, day, datasource); diff --git a/sql/06_storewide_report_tables.sql b/sql/06_storewide_report_tables.sql new file mode 100644 index 0000000..acf8737 --- /dev/null +++ b/sql/06_storewide_report_tables.sql @@ -0,0 +1,177 @@ +-- Storewide Report Tables (全店报告表) + +-- ============================================= +-- 全店报告明细表 (storewide_report_detail) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS storewide_report_detail_id_seq; + +CREATE TABLE IF NOT EXISTS storewide_report_detail ( + id BIGINT NOT NULL DEFAULT nextval('storewide_report_detail_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + ad_name VARCHAR(255) NOT NULL DEFAULT '', + primary_url VARCHAR(1024) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + direct_conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + indirect_conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + roe DECIMAL(20,8) NOT NULL DEFAULT 0, + gmv DECIMAL(20,6) NOT NULL DEFAULT 0, + order_count DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_order_price DECIMAL(20,8) NOT NULL DEFAULT 0, + cart_count DECIMAL(20,6) NOT NULL DEFAULT 0, + favorite_count DECIMAL(20,6) NOT NULL DEFAULT 0, + page_view DECIMAL(20,6) NOT NULL DEFAULT 0, + browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE storewide_report_detail IS '全店报告明细表'; +COMMENT ON COLUMN storewide_report_detail.id IS '主键ID'; +COMMENT ON COLUMN storewide_report_detail.tenant_id IS '租户ID'; +COMMENT ON COLUMN storewide_report_detail.creator IS '创建人'; +COMMENT ON COLUMN storewide_report_detail.created_at IS '创建时间'; +COMMENT ON COLUMN storewide_report_detail.updater IS '更新人'; +COMMENT ON COLUMN storewide_report_detail.updated_at IS '更新时间'; +COMMENT ON COLUMN storewide_report_detail.deleted_at IS '软删除时间'; +COMMENT ON COLUMN storewide_report_detail.cid IS '广告账户ID'; +COMMENT ON COLUMN storewide_report_detail.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN storewide_report_detail.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN storewide_report_detail.ad_id IS '创意ID'; +COMMENT ON COLUMN storewide_report_detail.ad_name IS '创意名称'; +COMMENT ON COLUMN storewide_report_detail.primary_url IS '落地页URL'; +COMMENT ON COLUMN storewide_report_detail.impression IS '展示数'; +COMMENT ON COLUMN storewide_report_detail.click IS '点击数'; +COMMENT ON COLUMN storewide_report_detail.cost IS '花费(元)'; +COMMENT ON COLUMN storewide_report_detail.ctr IS '点击率'; +COMMENT ON COLUMN storewide_report_detail.cpc IS '平均点击价格'; +COMMENT ON COLUMN storewide_report_detail.cpm IS '千次展现成本'; +COMMENT ON COLUMN storewide_report_detail.direct_conversion IS '直接转化数'; +COMMENT ON COLUMN storewide_report_detail.indirect_conversion IS '间接转化数'; +COMMENT ON COLUMN storewide_report_detail.conversion IS '总转化数'; +COMMENT ON COLUMN storewide_report_detail.conversion_rate IS '转化率'; +COMMENT ON COLUMN storewide_report_detail.cpp IS '单次转化成本'; +COMMENT ON COLUMN storewide_report_detail.roe IS '投资回报率(ROE)'; +COMMENT ON COLUMN storewide_report_detail.gmv IS 'GMV(元)'; +COMMENT ON COLUMN storewide_report_detail.order_count IS '订单数'; +COMMENT ON COLUMN storewide_report_detail.avg_order_price IS '平均客单价'; +COMMENT ON COLUMN storewide_report_detail.cart_count IS '加购数'; +COMMENT ON COLUMN storewide_report_detail.favorite_count IS '收藏数'; +COMMENT ON COLUMN storewide_report_detail.page_view IS '页面浏览数'; +COMMENT ON COLUMN storewide_report_detail.browse_duration IS '浏览时长'; +COMMENT ON COLUMN storewide_report_detail.avg_browse_duration IS '平均浏览时长(秒)'; +COMMENT ON COLUMN storewide_report_detail.day IS '数据日期'; +COMMENT ON COLUMN storewide_report_detail.datasource IS '数据源'; + +CREATE INDEX idx_storewide_report_detail_cid ON storewide_report_detail(tenant_id, cid); +CREATE INDEX idx_storewide_report_detail_campaign_id ON storewide_report_detail(tenant_id, campaign_id); +CREATE INDEX idx_storewide_report_detail_ad_id ON storewide_report_detail(tenant_id, ad_id); +CREATE INDEX idx_storewide_report_detail_day ON storewide_report_detail(tenant_id, day); +CREATE INDEX idx_storewide_report_detail_datasource ON storewide_report_detail(tenant_id, datasource); + +-- ============================================= +-- 全店报告汇总表 (storewide_report_sum) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS storewide_report_sum_id_seq; + +CREATE TABLE IF NOT EXISTS storewide_report_sum ( + id BIGINT NOT NULL DEFAULT nextval('storewide_report_sum_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + ad_name VARCHAR(255) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + direct_conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + indirect_conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + roe DECIMAL(20,8) NOT NULL DEFAULT 0, + gmv DECIMAL(20,6) NOT NULL DEFAULT 0, + order_count DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_order_price DECIMAL(20,8) NOT NULL DEFAULT 0, + cart_count DECIMAL(20,6) NOT NULL DEFAULT 0, + favorite_count DECIMAL(20,6) NOT NULL DEFAULT 0, + page_view DECIMAL(20,6) NOT NULL DEFAULT 0, + browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + hour VARCHAR(2) NOT NULL DEFAULT '', + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE storewide_report_sum IS '全店报告汇总表'; +COMMENT ON COLUMN storewide_report_sum.id IS '主键ID'; +COMMENT ON COLUMN storewide_report_sum.tenant_id IS '租户ID'; +COMMENT ON COLUMN storewide_report_sum.creator IS '创建人'; +COMMENT ON COLUMN storewide_report_sum.created_at IS '创建时间'; +COMMENT ON COLUMN storewide_report_sum.updater IS '更新人'; +COMMENT ON COLUMN storewide_report_sum.updated_at IS '更新时间'; +COMMENT ON COLUMN storewide_report_sum.deleted_at IS '软删除时间'; +COMMENT ON COLUMN storewide_report_sum.cid IS '广告账户ID'; +COMMENT ON COLUMN storewide_report_sum.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN storewide_report_sum.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN storewide_report_sum.ad_id IS '创意ID'; +COMMENT ON COLUMN storewide_report_sum.ad_name IS '创意名称'; +COMMENT ON COLUMN storewide_report_sum.impression IS '展示数'; +COMMENT ON COLUMN storewide_report_sum.click IS '点击数'; +COMMENT ON COLUMN storewide_report_sum.cost IS '花费(元)'; +COMMENT ON COLUMN storewide_report_sum.ctr IS '点击率'; +COMMENT ON COLUMN storewide_report_sum.cpc IS '平均点击价格'; +COMMENT ON COLUMN storewide_report_sum.cpm IS '千次展现成本'; +COMMENT ON COLUMN storewide_report_sum.direct_conversion IS '直接转化数'; +COMMENT ON COLUMN storewide_report_sum.indirect_conversion IS '间接转化数'; +COMMENT ON COLUMN storewide_report_sum.conversion IS '总转化数'; +COMMENT ON COLUMN storewide_report_sum.conversion_rate IS '转化率'; +COMMENT ON COLUMN storewide_report_sum.cpp IS '单次转化成本'; +COMMENT ON COLUMN storewide_report_sum.roe IS '投资回报率(ROE)'; +COMMENT ON COLUMN storewide_report_sum.gmv IS 'GMV(元)'; +COMMENT ON COLUMN storewide_report_sum.order_count IS '订单数'; +COMMENT ON COLUMN storewide_report_sum.avg_order_price IS '平均客单价'; +COMMENT ON COLUMN storewide_report_sum.cart_count IS '加购数'; +COMMENT ON COLUMN storewide_report_sum.favorite_count IS '收藏数'; +COMMENT ON COLUMN storewide_report_sum.page_view IS '页面浏览数'; +COMMENT ON COLUMN storewide_report_sum.browse_duration IS '浏览时长'; +COMMENT ON COLUMN storewide_report_sum.avg_browse_duration IS '平均浏览时长(秒)'; +COMMENT ON COLUMN storewide_report_sum.hour IS '数据小时'; +COMMENT ON COLUMN storewide_report_sum.day IS '数据日期'; +COMMENT ON COLUMN storewide_report_sum.datasource IS '数据源'; + +CREATE INDEX idx_storewide_report_sum_cid ON storewide_report_sum(tenant_id, cid); +CREATE INDEX idx_storewide_report_sum_campaign_id ON storewide_report_sum(tenant_id, campaign_id); +CREATE INDEX idx_storewide_report_sum_ad_id ON storewide_report_sum(tenant_id, ad_id); +CREATE INDEX idx_storewide_report_sum_day ON storewide_report_sum(tenant_id, day); +CREATE INDEX idx_storewide_report_sum_hour ON storewide_report_sum(tenant_id, hour); +CREATE INDEX idx_storewide_report_sum_datasource ON storewide_report_sum(tenant_id, datasource); +CREATE UNIQUE INDEX idx_storewide_report_sum_unique ON storewide_report_sum(tenant_id, ad_id, hour, day, datasource); diff --git a/sql/07_material_population_tables.sql b/sql/07_material_population_tables.sql new file mode 100644 index 0000000..c241699 --- /dev/null +++ b/sql/07_material_population_tables.sql @@ -0,0 +1,184 @@ +-- Material and Population Report Tables (素材报告和人群报告表) + +-- ============================================= +-- 素材报告表 (material_report) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS material_report_id_seq; + +CREATE TABLE IF NOT EXISTS material_report ( + id BIGINT NOT NULL DEFAULT nextval('material_report_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + ad_name VARCHAR(255) NOT NULL DEFAULT '', + material_hash VARCHAR(128) NOT NULL DEFAULT '', + material_url VARCHAR(2048) NOT NULL DEFAULT '', + material_type VARCHAR(32) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE material_report IS '素材报告表'; +COMMENT ON COLUMN material_report.id IS '主键ID'; +COMMENT ON COLUMN material_report.tenant_id IS '租户ID'; +COMMENT ON COLUMN material_report.creator IS '创建人'; +COMMENT ON COLUMN material_report.created_at IS '创建时间'; +COMMENT ON COLUMN material_report.updater IS '更新人'; +COMMENT ON COLUMN material_report.updated_at IS '更新时间'; +COMMENT ON COLUMN material_report.deleted_at IS '软删除时间'; +COMMENT ON COLUMN material_report.cid IS '广告账户ID'; +COMMENT ON COLUMN material_report.ad_id IS '创意ID'; +COMMENT ON COLUMN material_report.ad_name IS '创意名称'; +COMMENT ON COLUMN material_report.material_hash IS '素材哈希'; +COMMENT ON COLUMN material_report.material_url IS '素材URL'; +COMMENT ON COLUMN material_report.material_type IS '素材类型'; +COMMENT ON COLUMN material_report.impression IS '展示数'; +COMMENT ON COLUMN material_report.click IS '点击数'; +COMMENT ON COLUMN material_report.cost IS '花费(元)'; +COMMENT ON COLUMN material_report.ctr IS '点击率'; +COMMENT ON COLUMN material_report.cpc IS '平均点击价格'; +COMMENT ON COLUMN material_report.cpm IS '千次展现成本'; +COMMENT ON COLUMN material_report.conversion IS '转化数'; +COMMENT ON COLUMN material_report.conversion_rate IS '转化率'; +COMMENT ON COLUMN material_report.cpp IS '单次转化成本'; +COMMENT ON COLUMN material_report.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN material_report.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN material_report.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN material_report.video_three_second_play_count IS '视频3秒播放次数'; +COMMENT ON COLUMN material_report.video_five_second_play_count IS '视频5秒播放次数'; +COMMENT ON COLUMN material_report.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN material_report.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN material_report.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN material_report.day IS '数据日期'; +COMMENT ON COLUMN material_report.datasource IS '数据源'; + +CREATE INDEX idx_material_report_cid ON material_report(tenant_id, cid); +CREATE INDEX idx_material_report_ad_id ON material_report(tenant_id, ad_id); +CREATE INDEX idx_material_report_material_hash ON material_report(tenant_id, material_hash); +CREATE INDEX idx_material_report_day ON material_report(tenant_id, day); +CREATE INDEX idx_material_report_datasource ON material_report(tenant_id, datasource); + +-- ============================================= +-- 人群报告表 (population_report) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS population_report_id_seq; + +CREATE TABLE IF NOT EXISTS population_report ( + id BIGINT NOT NULL DEFAULT nextval('population_report_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + audience_template_id VARCHAR(64) NOT NULL DEFAULT '', + audience_template_name VARCHAR(255) NOT NULL DEFAULT '', + audience_type VARCHAR(32) NOT NULL DEFAULT '', + audience_source VARCHAR(32) NOT NULL DEFAULT '', + impression DECIMAL(20,6) NOT NULL DEFAULT 0, + click DECIMAL(20,6) NOT NULL DEFAULT 0, + cost DECIMAL(20,6) NOT NULL DEFAULT 0, + ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0, + video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0, + tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0, + game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0, + app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0, + onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0, + deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0, + day VARCHAR(10) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + PRIMARY KEY (id) +); + +COMMENT ON TABLE population_report IS '人群报告表'; +COMMENT ON COLUMN population_report.id IS '主键ID'; +COMMENT ON COLUMN population_report.tenant_id IS '租户ID'; +COMMENT ON COLUMN population_report.creator IS '创建人'; +COMMENT ON COLUMN population_report.created_at IS '创建时间'; +COMMENT ON COLUMN population_report.updater IS '更新人'; +COMMENT ON COLUMN population_report.updated_at IS '更新时间'; +COMMENT ON COLUMN population_report.deleted_at IS '软删除时间'; +COMMENT ON COLUMN population_report.cid IS '广告账户ID'; +COMMENT ON COLUMN population_report.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN population_report.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN population_report.audience_template_id IS '人群包ID'; +COMMENT ON COLUMN population_report.audience_template_name IS '人群包名称'; +COMMENT ON COLUMN population_report.audience_type IS '人群类型'; +COMMENT ON COLUMN population_report.audience_source IS '人群来源'; +COMMENT ON COLUMN population_report.impression IS '展示数'; +COMMENT ON COLUMN population_report.click IS '点击数'; +COMMENT ON COLUMN population_report.cost IS '花费(元)'; +COMMENT ON COLUMN population_report.ctr IS '点击率'; +COMMENT ON COLUMN population_report.cpc IS '平均点击价格'; +COMMENT ON COLUMN population_report.cpm IS '千次展现成本'; +COMMENT ON COLUMN population_report.conversion IS '转化数'; +COMMENT ON COLUMN population_report.conversion_rate IS '转化率'; +COMMENT ON COLUMN population_report.cpp IS '单次转化成本'; +COMMENT ON COLUMN population_report.video_play_count IS '视频播放次数'; +COMMENT ON COLUMN population_report.video_play_uv IS '视频播放人数'; +COMMENT ON COLUMN population_report.avg_video_play_duration IS '平均播放时长(秒)'; +COMMENT ON COLUMN population_report.video_three_second_play_count IS '视频3秒播放次数'; +COMMENT ON COLUMN population_report.video_five_second_play_count IS '视频5秒播放次数'; +COMMENT ON COLUMN population_report.tweet_engage_count IS '推文参与数'; +COMMENT ON COLUMN population_report.tweet_share_count IS '推文分享数'; +COMMENT ON COLUMN population_report.tweet_comment_count IS '推文评论数'; +COMMENT ON COLUMN population_report.tweet_like_count IS '推文点赞数'; +COMMENT ON COLUMN population_report.tweet_repost_count IS '推文转发数'; +COMMENT ON COLUMN population_report.game_download_count IS '游戏下载数'; +COMMENT ON COLUMN population_report.app_download_count IS '应用下载数'; +COMMENT ON COLUMN population_report.app_install_count IS '应用安装数'; +COMMENT ON COLUMN population_report.onsite_leads_count IS '预注册数'; +COMMENT ON COLUMN population_report.deep_convert_count IS '深度转化数'; +COMMENT ON COLUMN population_report.deep_convert_rate IS '深度转化率'; +COMMENT ON COLUMN population_report.deep_convert_cost IS '深度转化成本'; +COMMENT ON COLUMN population_report.day IS '数据日期'; +COMMENT ON COLUMN population_report.datasource IS '数据源'; + +CREATE INDEX idx_population_report_cid ON population_report(tenant_id, cid); +CREATE INDEX idx_population_report_campaign_id ON population_report(tenant_id, campaign_id); +CREATE INDEX idx_population_report_adgroup_id ON population_report(tenant_id, adgroup_id); +CREATE INDEX idx_population_report_audience_template_id ON population_report(tenant_id, audience_template_id); +CREATE INDEX idx_population_report_day ON population_report(tenant_id, day); +CREATE INDEX idx_population_report_datasource ON population_report(tenant_id, datasource); diff --git a/sql/08_sync_task_tables.sql b/sql/08_sync_task_tables.sql new file mode 100644 index 0000000..e6fa5cf --- /dev/null +++ b/sql/08_sync_task_tables.sql @@ -0,0 +1,120 @@ +-- Sync Task and Task Report Tables (同步任务日志和任务报告表) + +-- ============================================= +-- 同步任务日志表 (sync_task_log) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS sync_task_log_id_seq; + +CREATE TABLE IF NOT EXISTS sync_task_log ( + id BIGINT NOT NULL DEFAULT nextval('sync_task_log_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + task_id BIGINT NOT NULL DEFAULT 0, + report_type VARCHAR(64) NOT NULL DEFAULT '', + report_date VARCHAR(10) NOT NULL DEFAULT '', + cid VARCHAR(64) NOT NULL DEFAULT '', + campaign_id VARCHAR(64) NOT NULL DEFAULT '', + adgroup_id VARCHAR(64) NOT NULL DEFAULT '', + ad_id VARCHAR(64) NOT NULL DEFAULT '', + datasource VARCHAR(64) NOT NULL DEFAULT '', + sync_status VARCHAR(32) NOT NULL DEFAULT '', + error_message TEXT NOT NULL DEFAULT '', + start_time TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + end_time TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + PRIMARY KEY (id) +); + +COMMENT ON TABLE sync_task_log IS '同步任务日志表'; +COMMENT ON COLUMN sync_task_log.id IS '主键ID'; +COMMENT ON COLUMN sync_task_log.tenant_id IS '租户ID'; +COMMENT ON COLUMN sync_task_log.creator IS '创建人'; +COMMENT ON COLUMN sync_task_log.created_at IS '创建时间'; +COMMENT ON COLUMN sync_task_log.updater IS '更新人'; +COMMENT ON COLUMN sync_task_log.updated_at IS '更新时间'; +COMMENT ON COLUMN sync_task_log.deleted_at IS '软删除时间'; +COMMENT ON COLUMN sync_task_log.task_id IS '调控任务ID'; +COMMENT ON COLUMN sync_task_log.report_type IS '报告类型'; +COMMENT ON COLUMN sync_task_log.report_date IS '报告日期'; +COMMENT ON COLUMN sync_task_log.cid IS '广告账户ID'; +COMMENT ON COLUMN sync_task_log.campaign_id IS '广告系列ID'; +COMMENT ON COLUMN sync_task_log.adgroup_id IS '广告组ID'; +COMMENT ON COLUMN sync_task_log.ad_id IS '创意ID'; +COMMENT ON COLUMN sync_task_log.datasource IS '数据源'; +COMMENT ON COLUMN sync_task_log.sync_status IS '同步状态'; +COMMENT ON COLUMN sync_task_log.error_message IS '错误信息'; +COMMENT ON COLUMN sync_task_log.start_time IS '开始时间'; +COMMENT ON COLUMN sync_task_log.end_time IS '结束时间'; + +CREATE INDEX idx_sync_task_log_task_id ON sync_task_log(tenant_id, task_id); +CREATE INDEX idx_sync_task_log_report_type ON sync_task_log(tenant_id, report_type); +CREATE INDEX idx_sync_task_log_report_date ON sync_task_log(tenant_id, report_date); +CREATE INDEX idx_sync_task_log_cid ON sync_task_log(tenant_id, cid); +CREATE INDEX idx_sync_task_log_datasource ON sync_task_log(tenant_id, datasource); +CREATE INDEX idx_sync_task_log_sync_status ON sync_task_log(tenant_id, sync_status); +CREATE INDEX idx_sync_task_log_created_at ON sync_task_log(tenant_id, created_at); + +-- ============================================= +-- 调控任务报告表 (task_report) +-- ============================================= +CREATE SEQUENCE IF NOT EXISTS task_report_id_seq; + +CREATE TABLE IF NOT EXISTS task_report ( + id BIGINT NOT NULL DEFAULT nextval('task_report_id_seq'::regclass), + tenant_id BIGINT NOT NULL DEFAULT 0, + creator VARCHAR(64) DEFAULT '', + created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + updater VARCHAR(64) DEFAULT '', + updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00', + deleted_at TIMESTAMP WITH TIME ZONE, + task_id BIGINT NOT NULL DEFAULT 0, + datasource VARCHAR(64) NOT NULL DEFAULT '', + report_date VARCHAR(10) NOT NULL DEFAULT '', + total_count BIGINT NOT NULL DEFAULT 0, + success_count BIGINT NOT NULL DEFAULT 0, + fail_count BIGINT NOT NULL DEFAULT 0, + skip_count BIGINT NOT NULL DEFAULT 0, + total_cost DECIMAL(20,6) NOT NULL DEFAULT 0, + total_impression DECIMAL(20,6) NOT NULL DEFAULT 0, + total_click DECIMAL(20,6) NOT NULL DEFAULT 0, + total_conversion DECIMAL(20,6) NOT NULL DEFAULT 0, + avg_ctr DECIMAL(20,8) NOT NULL DEFAULT 0, + avg_cpc DECIMAL(20,8) NOT NULL DEFAULT 0, + avg_cpm DECIMAL(20,8) NOT NULL DEFAULT 0, + avg_conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0, + avg_cpp DECIMAL(20,8) NOT NULL DEFAULT 0, + PRIMARY KEY (id) +); + +COMMENT ON TABLE task_report IS '调控任务报告表'; +COMMENT ON COLUMN task_report.id IS '主键ID'; +COMMENT ON COLUMN task_report.tenant_id IS '租户ID'; +COMMENT ON COLUMN task_report.creator IS '创建人'; +COMMENT ON COLUMN task_report.created_at IS '创建时间'; +COMMENT ON COLUMN task_report.updater IS '更新人'; +COMMENT ON COLUMN task_report.updated_at IS '更新时间'; +COMMENT ON COLUMN task_report.deleted_at IS '软删除时间'; +COMMENT ON COLUMN task_report.task_id IS '调控任务ID'; +COMMENT ON COLUMN task_report.datasource IS '数据源'; +COMMENT ON COLUMN task_report.report_date IS '报告日期'; +COMMENT ON COLUMN task_report.total_count IS '总数量'; +COMMENT ON COLUMN task_report.success_count IS '成功数量'; +COMMENT ON COLUMN task_report.fail_count IS '失败数量'; +COMMENT ON COLUMN task_report.skip_count IS '跳过数量'; +COMMENT ON COLUMN task_report.total_cost IS '总花费(元)'; +COMMENT ON COLUMN task_report.total_impression IS '总展示数'; +COMMENT ON COLUMN task_report.total_click IS '总点击数'; +COMMENT ON COLUMN task_report.total_conversion IS '总转化数'; +COMMENT ON COLUMN task_report.avg_ctr IS '平均点击率'; +COMMENT ON COLUMN task_report.avg_cpc IS '平均点击价格'; +COMMENT ON COLUMN task_report.avg_cpm IS '平均千次展现成本'; +COMMENT ON COLUMN task_report.avg_conversion_rate IS '平均转化率'; +COMMENT ON COLUMN task_report.avg_cpp IS '平均单次转化成本'; + +CREATE INDEX idx_task_report_task_id ON task_report(tenant_id, task_id); +CREATE INDEX idx_task_report_datasource ON task_report(tenant_id, datasource); +CREATE INDEX idx_task_report_report_date ON task_report(tenant_id, report_date); +CREATE UNIQUE INDEX idx_task_report_unique ON task_report(tenant_id, task_id, datasource, report_date); diff --git a/syncdata/account_report_sync.go b/syncdata/account_report_sync.go index 229a59f..d9f7654 100644 --- a/syncdata/account_report_sync.go +++ b/syncdata/account_report_sync.go @@ -1,9 +1,9 @@ package syncdata import ( - dto "cid/model/dto/copydata" - "cid/service/copydata" "context" + dto "dataengine/model/dto/copydata" + "dataengine/service/copydata" "encoding/json" "fmt" diff --git a/syncdata/data_converter.go b/syncdata/data_converter.go index 6792f8d..539257c 100644 --- a/syncdata/data_converter.go +++ b/syncdata/data_converter.go @@ -1,7 +1,7 @@ package syncdata import ( - "cid/model/dto/copydata" + "dataengine/model/dto/copydata" ) type DataConverter struct{} diff --git a/syncdata/sync_service.go b/syncdata/sync_service.go index 902380f..119cd12 100644 --- a/syncdata/sync_service.go +++ b/syncdata/sync_service.go @@ -1,11 +1,11 @@ package syncdata import ( - dao "cid/dao/copydata" - dto "cid/model/dto/copydata" - taskDto "cid/model/dto/copydata" - "cid/service/copydata" "context" + dao "dataengine/dao/copydata" + dto "dataengine/model/dto/copydata" + taskDto "dataengine/model/dto/copydata" + "dataengine/service/copydata" "encoding/json" "fmt" "sync"