@@ -44,7 +44,7 @@ func (h *Handler) Register(rg *gin.RouterGroup) {
rg . GET ( "/content/reviews" , h . listReviews ) // 送审待办队列(待审/待发码)
rg . GET ( "/content/list" , h . listContents ) // 内容队列(待入库/待发布/待注入)
rg . POST ( "/data/playback" , h . reportPlayback ) // 播放数据回传(需求9)
rg . GET ( "/data/playback-summary" , h . playbackSummary ) // 按MA 码聚合可信播放数据(需求9/21)
rg . GET ( "/data/playback-summary" , h . playbackSummary ) // 按CC 码聚合可信播放数据(需求9/21)
rg . POST ( "/settlement/compute" , h . computeSettlement ) // 基于可信播放数据分账(需求21)
rg . GET ( "/content/provenance" , h . provenance ) // 全链路存证(需求22)
rg . GET ( "/content/accountability" , h . accountability ) // 责任界定取证(需求22)
@@ -147,7 +147,7 @@ func (h *Handler) issue(c *gin.Context) {
}
type verifyReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
FileHash string ` json:"file_sha256" `
}
@@ -157,7 +157,7 @@ func (h *Handler) verify(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . Verify ( req . MACode , req . FileHash )
res , err := h . svc . Verify ( req . CCCode , req . FileHash )
if err != nil {
// 验真不匹配也返回结果体,便于调用方据 match 处理
httpx . Error ( c , http . StatusBadRequest , "VERIFY_MISMATCH" , err . Error ( ) )
@@ -210,7 +210,7 @@ func (h *Handler) bindTranscoded(c *gin.Context) {
}
type ingestReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
CTID string ` json:"content_twin_id" `
MediaAssetID string ` json:"media_asset_id" `
LibName string ` json:"lib_name" `
@@ -222,15 +222,15 @@ func (h *Handler) ingest(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
if err := h . svc . IngestToLibrary ( roleOf ( c ) , req . MACode , req . CTID , req . MediaAssetID , req . LibName ) ; err != nil {
if err := h . svc . IngestToLibrary ( roleOf ( c ) , req . CCCode , req . CTID , req . MediaAssetID , req . LibName ) ; err != nil {
httpx . Error ( c , http . StatusBadRequest , "INGEST_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "status" : "in_library" } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "status" : "in_library" } )
}
type publishReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Certificate string ` json:"certificate" `
}
@@ -240,16 +240,16 @@ func (h *Handler) publish(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
if err := h . svc . PublishToOperator ( service . PublishRequest { MACode : req . MACode , Certificate : req . Certificate } ) ; err != nil {
if err := h . svc . PublishToOperator ( service . PublishRequest { CCCode : req . CCCode , Certificate : req . Certificate } ) ; err != nil {
httpx . Error ( c , http . StatusBadRequest , "PUBLISH_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "status" : "published" } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "status" : "published" } )
}
type injectReq struct {
CTID string ` json:"content_twin_id" `
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
FileHash string ` json:"file_sha256" `
OperatorID string ` json:"operator_id" `
CDNEndpoint string ` json:"cdn_endpoint" `
@@ -261,7 +261,7 @@ func (h *Handler) inject(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . InjectToCDN ( roleOf ( c ) , req . CTID , req . MACode , req . FileHash , req . OperatorID , req . CDNEndpoint )
res , err := h . svc . InjectToCDN ( roleOf ( c ) , req . CTID , req . CCCode , req . FileHash , req . OperatorID , req . CDNEndpoint )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "INJECT_REJECTED" , err . Error ( ) )
return
@@ -293,7 +293,7 @@ func (h *Handler) versionChange(c *gin.Context) {
}
type takedownReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Reason string ` json:"reason" `
}
@@ -303,7 +303,7 @@ func (h *Handler) takedown(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . Takedown ( roleOf ( c ) , req . MACode , req . Reason )
res , err := h . svc . Takedown ( roleOf ( c ) , req . CCCode , req . Reason )
if err != nil {
httpx . Error ( c , http . StatusForbidden , "TAKEDOWN_FAILED" , err . Error ( ) )
return
@@ -312,7 +312,7 @@ func (h *Handler) takedown(c *gin.Context) {
}
type takedownEpisodeReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Episode int ` json:"episode" `
Reason string ` json:"reason" `
}
@@ -323,11 +323,11 @@ func (h *Handler) takedownEpisode(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
if err := h . svc . TakedownEpisode ( roleOf ( c ) , req . MACode , req . Episode , req . Reason ) ; err != nil {
if err := h . svc . TakedownEpisode ( roleOf ( c ) , req . CCCode , req . Episode , req . Reason ) ; err != nil {
httpx . Error ( c , http . StatusForbidden , "TAKEDOWN_EPISODE_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "episode" : req . Episode , "revoked" : true } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "episode" : req . Episode , "revoked" : true } )
}
func ( h * Handler ) restore ( c * gin . Context ) {
@@ -336,11 +336,11 @@ func (h *Handler) restore(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
if err := h . svc . Restore ( roleOf ( c ) , req . MACode ) ; err != nil {
if err := h . svc . Restore ( roleOf ( c ) , req . CCCode ) ; err != nil {
httpx . Error ( c , http . StatusForbidden , "RESTORE_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "status" : "published" } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "status" : "published" } )
}
func ( h * Handler ) restoreEpisode ( c * gin . Context ) {
@@ -349,20 +349,20 @@ func (h *Handler) restoreEpisode(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
if err := h . svc . RestoreEpisode ( roleOf ( c ) , req . MACode , req . Episode ) ; err != nil {
if err := h . svc . RestoreEpisode ( roleOf ( c ) , req . CCCode , req . Episode ) ; err != nil {
httpx . Error ( c , http . StatusForbidden , "RESTORE_EPISODE_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "episode" : req . Episode , "revoked" : false } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "episode" : req . Episode , "revoked" : false } )
}
func ( h * Handler ) mappings ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
res , err := h . svc . QueryMappings ( maCode )
res , err := h . svc . QueryMappings ( ccCode )
if err != nil {
httpx . Error ( c , http . StatusNotFound , "NOT_FOUND" , err . Error ( ) )
return
@@ -371,7 +371,7 @@ func (h *Handler) mappings(c *gin.Context) {
}
type verifyEpisodeReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Episode int ` json:"episode" `
FileHash string ` json:"file_sha256" `
}
@@ -382,7 +382,7 @@ func (h *Handler) verifyEpisode(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . VerifyEpisode ( req . MACode , req . Episode , req . FileHash )
res , err := h . svc . VerifyEpisode ( req . CCCode , req . Episode , req . FileHash )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "VERIFY_MISMATCH" , err . Error ( ) )
return
@@ -391,17 +391,17 @@ func (h *Handler) verifyEpisode(c *gin.Context) {
}
func ( h * Handler ) listEpisodes ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
eps , err := h . svc . ListEpisodes ( maCode )
eps , err := h . svc . ListEpisodes ( ccCode )
if err != nil {
httpx . Error ( c , http . StatusNotFound , "NOT_FOUND" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : maCode , "episodes" : eps , "count" : len ( eps ) } )
httpx . OK ( c , gin . H { "ma_code" : ccCode , "episodes" : eps , "count" : len ( eps ) } )
}
func ( h * Handler ) listReviews ( c * gin . Context ) {
@@ -422,7 +422,7 @@ func (h *Handler) listContents(c *gin.Context) {
type playbackReq struct {
PlatformID string ` json:"platform_id" `
Batch [ ] struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Episode int ` json:"episode" `
UserHash string ` json:"user_hash" `
EventType string ` json:"event_type" `
@@ -440,7 +440,7 @@ func (h *Handler) reportPlayback(c *gin.Context) {
events := make ( [ ] model . PlaybackEvent , 0 , len ( req . Batch ) )
for _ , b := range req . Batch {
events = append ( events , model . PlaybackEvent {
MACode : b . MACode , Episode : b . Episode , PlatformID : req . PlatformID ,
CCCode : b . CCCode , Episode : b . Episode , PlatformID : req . PlatformID ,
UserHash : b . UserHash , EventType : model . PlaybackEventType ( b . EventType ) ,
DurationSec : b . DurationSec , RevenueCent : b . RevenueCent , EventTime : time . Now ( ) ,
} )
@@ -450,16 +450,16 @@ func (h *Handler) reportPlayback(c *gin.Context) {
}
func ( h * Handler ) playbackSummary ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
httpx . OK ( c , h . svc . PlaybackSummary ( maCode ) )
httpx . OK ( c , h . svc . PlaybackSummary ( ccCode ) )
}
type settlementReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Period string ` json:"period" `
}
@@ -469,7 +469,7 @@ func (h *Handler) computeSettlement(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
st , err := h . svc . ComputeSettlement ( req . MACode , req . Period )
st , err := h . svc . ComputeSettlement ( req . CCCode , req . Period )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "SETTLEMENT_FAILED" , err . Error ( ) )
return
@@ -480,30 +480,30 @@ func (h *Handler) computeSettlement(c *gin.Context) {
// ---- 二期:追责取证与确权举证(需求22/23) ----
func ( h * Handler ) provenance ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
httpx . OK ( c , gin . H { "ma_code" : maCode , "trail" : h . svc . Provenance ( maCode ) } )
httpx . OK ( c , gin . H { "ma_code" : ccCode , "trail" : h . svc . Provenance ( ccCode ) } )
}
func ( h * Handler ) accountability ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
httpx . OK ( c , h . svc . Accountability ( maCode ) )
httpx . OK ( c , h . svc . Accountability ( ccCode ) )
}
func ( h * Handler ) evidence ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
ev , err := h . svc . CopyrightEvidence ( maCode )
ev , err := h . svc . CopyrightEvidence ( ccCode )
if err != nil {
httpx . Error ( c , http . StatusNotFound , "NOT_FOUND" , err . Error ( ) )
return
@@ -540,7 +540,7 @@ func (h *Handler) infringeMatch(c *gin.Context) {
// ---- 二期:授权链/追更/跨省/终端抽检(需求25/24/13/8) ----
type authorizeReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Regions [ ] string ` json:"regions" `
Platforms [ ] string ` json:"platforms" `
ExpiryAt string ` json:"expiry_at" ` // RFC3339,空=长期
@@ -556,15 +556,15 @@ func (h *Handler) authorize(c *gin.Context) {
if req . ExpiryAt != "" {
expiry , _ = time . Parse ( time . RFC3339 , req . ExpiryAt )
}
if err := h . svc . RecordAuthorization ( req . MACode , req . Regions , req . Platforms , expiry ) ; err != nil {
if err := h . svc . RecordAuthorization ( req . CCCode , req . Regions , req . Platforms , expiry ) ; err != nil {
httpx . Error ( c , http . StatusBadRequest , "AUTHORIZE_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "authorized" : true } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "authorized" : true } )
}
type authCheckReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Region string ` json:"region" `
Platform string ` json:"platform" `
}
@@ -575,11 +575,11 @@ func (h *Handler) authCheck(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
httpx . OK ( c , h . svc . CheckAuthorization ( req . MACode , req . Region , req . Platform ) )
httpx . OK ( c , h . svc . CheckAuthorization ( req . CCCode , req . Region , req . Platform ) )
}
type addEpisodesReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Episodes [ ] struct {
Episode int ` json:"episode" `
FileSHA256 string ` json:"file_sha256" `
@@ -597,15 +597,15 @@ func (h *Handler) addEpisodes(c *gin.Context) {
for _ , e := range req . Episodes {
eps = append ( eps , model . EpisodeHash { Episode : e . Episode , FileSHA256 : e . FileSHA256 , MerkleRoot : e . MerkleRoot } )
}
if err := h . svc . AddEpisodes ( roleOf ( c ) , req . MACode , eps ) ; err != nil {
if err := h . svc . AddEpisodes ( roleOf ( c ) , req . CCCode , eps ) ; err != nil {
httpx . Error ( c , http . StatusBadRequest , "ADD_EPISODES_FAILED" , err . Error ( ) )
return
}
httpx . OK ( c , gin . H { "ma_code" : req . MACode , "added" : len ( eps ) } )
httpx . OK ( c , gin . H { "ma_code" : req . CCCode , "added" : len ( eps ) } )
}
type crossProvinceReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
FileHash string ` json:"file_sha256" `
Province string ` json:"province" `
}
@@ -616,11 +616,11 @@ func (h *Handler) crossProvince(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
httpx . OK ( c , h . svc . CrossProvinceAdmit ( req . MACode , req . FileHash , req . Province ) )
httpx . OK ( c , h . svc . CrossProvinceAdmit ( req . CCCode , req . FileHash , req . Province ) )
}
type terminalVerifyReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
Episode int ` json:"episode" `
SegHash string ` json:"segment_hash" `
}
@@ -631,14 +631,14 @@ func (h *Handler) terminalVerify(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
ok , msg := h . svc . TerminalVerifySegment ( req . MACode , req . Episode , req . SegHash )
ok , msg := h . svc . TerminalVerifySegment ( req . CCCode , req . Episode , req . SegHash )
httpx . OK ( c , gin . H { "ok" : ok , "message" : msg } )
}
// ---- 三期:备案对接/全国统计/监管上报/号段管理 ----
type bindFilingReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
LicenseNo string ` json:"license_no" `
FilingNo string ` json:"filing_no" `
}
@@ -649,7 +649,7 @@ func (h *Handler) bindFiling(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
rec , err := h . svc . BindFiling ( req . MACode , req . LicenseNo , req . FilingNo )
rec , err := h . svc . BindFiling ( req . CCCode , req . LicenseNo , req . FilingNo )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "BIND_FILING_FAILED" , err . Error ( ) )
return
@@ -658,8 +658,8 @@ func (h *Handler) bindFiling(c *gin.Context) {
}
func ( h * Handler ) queryFiling ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
rec , ok := h . svc . QueryFiling ( maCode )
ccCode := c . Query ( "ma_code" )
rec , ok := h . svc . QueryFiling ( ccCode )
if ! ok {
httpx . Error ( c , http . StatusNotFound , "NOT_FOUND" , "未关联备案" )
return
@@ -696,16 +696,16 @@ func (h *Handler) listSegments(c *gin.Context) {
// ---- 四期:大小屏融合(跨域解析/扫码验真/跨屏权益)----
func ( h * Handler ) resolve ( c * gin . Context ) {
maCode := c . Query ( "ma_code" )
if maCode == "" {
ccCode := c . Query ( "ma_code" )
if ccCode == "" {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , "缺少 ma_code" )
return
}
httpx . OK ( c , h . svc . Resolve ( maCode ) )
httpx . OK ( c , h . svc . Resolve ( ccCode ) )
}
type scanVerifyReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
}
func ( h * Handler ) scanVerify ( c * gin . Context ) {
@@ -714,11 +714,11 @@ func (h *Handler) scanVerify(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
httpx . OK ( c , h . svc . ScanVerify ( req . MACode ) )
httpx . OK ( c , h . svc . ScanVerify ( req . CCCode ) )
}
type purchaseReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
UserHash string ` json:"user_hash" `
Screen string ` json:"screen" ` // iptv/ott/app
}
@@ -729,7 +729,7 @@ func (h *Handler) recordPurchase(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
rec , err := h . svc . RecordPurchase ( req . MACode , req . UserHash , model . ScreenType ( req . Screen ) )
rec , err := h . svc . RecordPurchase ( req . CCCode , req . UserHash , model . ScreenType ( req . Screen ) )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "PURCHASE_FAILED" , err . Error ( ) )
return
@@ -738,7 +738,7 @@ func (h *Handler) recordPurchase(c *gin.Context) {
}
type verifyRightsReq struct {
MACode string ` json:"ma_code" `
CCCode string ` json:"ma_code" `
UserHash string ` json:"user_hash" `
Screen string ` json:"screen" ` // 当前请求屏
}
@@ -749,7 +749,7 @@ func (h *Handler) verifyRights(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
httpx . OK ( c , h . svc . VerifyCrossScreenRights ( req . MACode , req . UserHash , model . ScreenType ( req . Screen ) ) )
httpx . OK ( c , h . svc . VerifyCrossScreenRights ( req . CCCode , req . UserHash , model . ScreenType ( req . Screen ) ) )
}
// ---- 多维度标识查询 handlers ----
@@ -808,7 +808,7 @@ func (h *Handler) mergeMA(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . MergeMACodes ( roleOf ( c ) , req )
res , err := h . svc . MergeCCCodes ( roleOf ( c ) , req )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "MERGE_FAILED" , err . Error ( ) )
return
@@ -823,7 +823,7 @@ func (h *Handler) splitMA(c *gin.Context) {
httpx . Error ( c , http . StatusBadRequest , "INVALID_REQUEST" , err . Error ( ) )
return
}
res , err := h . svc . SplitMACode ( roleOf ( c ) , req )
res , err := h . svc . SplitCCCode ( roleOf ( c ) , req )
if err != nil {
httpx . Error ( c , http . StatusBadRequest , "SPLIT_FAILED" , err . Error ( ) )
return