Compare commits

..

21 Commits

Author SHA1 Message Date
daiyb
6d3056d990 Merge branch 'feature-publishLog-daiyb' 2026-03-02 09:17:11 +08:00
daiyb
65ce2132e7 修改配置文件 2026-02-28 15:46:06 +08:00
daiyb
2d93ad6df1 Update work.go 2026-02-28 15:34:35 +08:00
daiyb
979e050108 恢复代码 2026-02-28 15:29:32 +08:00
daiyb
111eeeb56f Update work.go 2026-02-28 14:55:50 +08:00
daiyb
b56763ed03 Update work.go 2026-02-28 14:54:32 +08:00
daiyb
b922b4bd88 Update work.go 2026-02-28 14:53:26 +08:00
daiyb
77248eb885 Update work.go 2026-02-28 14:49:52 +08:00
daiyb
1791397782 测试定时检测改成1分钟 2026-02-28 14:24:34 +08:00
daiyb
37771a9b5a 添加调试日志 2026-02-28 14:21:00 +08:00
daiyb
8dbe5744e5 导出 2026-02-26 15:55:33 +08:00
daiyb
d526db4c31 发布记录 2026-02-26 14:41:14 +08:00
daiyb
1608207281 1 2026-02-26 14:04:49 +08:00
daiyb
762c9640de Update work.go 2026-02-26 11:53:17 +08:00
daiyb
addd492875 Update work.go 2026-02-26 11:31:13 +08:00
daiyb
73b183a1e4 Update work.go 2026-02-26 11:18:40 +08:00
daiyb
64e52b5ec4 添加一次字段 2026-02-26 11:11:31 +08:00
daiyb
ed40212dec dm 发送log 2026-02-26 09:32:51 +08:00
daiyb
25c89523cc Update test.go 2026-02-25 16:01:43 +08:00
daiyb
f6a7e0ad8c 修改工具函数 2026-02-25 15:41:05 +08:00
daiyb
37246ed813 作品发布记录 2026-02-24 16:27:36 +08:00
14 changed files with 6116 additions and 9459 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
// versions:
// - protoc-gen-go-triple v1.0.8
// - protoc v3.21.1
// - protoc v6.32.0--rc2
// source: pb/fiee/cast.proto
package cast
@ -136,6 +136,8 @@ type CastClient interface {
DeleteCompetitiveReport(ctx context.Context, in *DeleteCompetitiveReportReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment)
UpdateCompetitiveReportApprovalID(ctx context.Context, in *UpdateCompetitiveReportApprovalIDReq, opts ...grpc_go.CallOption) (*emptypb.Empty, common.ErrorWithAttachment)
CountCompetitiveReportByWorkUuids(ctx context.Context, in *CountCompetitiveReportByWorkUuidsReq, opts ...grpc_go.CallOption) (*CountCompetitiveReportByWorkUuidsResp, common.ErrorWithAttachment)
// 发布记录相关接口
ListPublishLog(ctx context.Context, in *ListPublishLogReq, opts ...grpc_go.CallOption) (*ListPublishLogResp, common.ErrorWithAttachment)
}
type castClient struct {
@ -235,6 +237,7 @@ type CastClientImpl struct {
DeleteCompetitiveReport func(ctx context.Context, in *DeleteCompetitiveReportReq) (*emptypb.Empty, error)
UpdateCompetitiveReportApprovalID func(ctx context.Context, in *UpdateCompetitiveReportApprovalIDReq) (*emptypb.Empty, error)
CountCompetitiveReportByWorkUuids func(ctx context.Context, in *CountCompetitiveReportByWorkUuidsReq) (*CountCompetitiveReportByWorkUuidsResp, error)
ListPublishLog func(ctx context.Context, in *ListPublishLogReq) (*ListPublishLogResp, error)
}
func (c *CastClientImpl) GetDubboStub(cc *triple.TripleConn) CastClient {
@ -801,6 +804,12 @@ func (c *castClient) CountCompetitiveReportByWorkUuids(ctx context.Context, in *
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CountCompetitiveReportByWorkUuids", in, out)
}
func (c *castClient) ListPublishLog(ctx context.Context, in *ListPublishLogReq, opts ...grpc_go.CallOption) (*ListPublishLogResp, common.ErrorWithAttachment) {
out := new(ListPublishLogResp)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ListPublishLog", in, out)
}
// CastServer is the server API for Cast service.
// All implementations must embed UnimplementedCastServer
// for forward compatibility
@ -912,6 +921,8 @@ type CastServer interface {
DeleteCompetitiveReport(context.Context, *DeleteCompetitiveReportReq) (*emptypb.Empty, error)
UpdateCompetitiveReportApprovalID(context.Context, *UpdateCompetitiveReportApprovalIDReq) (*emptypb.Empty, error)
CountCompetitiveReportByWorkUuids(context.Context, *CountCompetitiveReportByWorkUuidsReq) (*CountCompetitiveReportByWorkUuidsResp, error)
// 发布记录相关接口
ListPublishLog(context.Context, *ListPublishLogReq) (*ListPublishLogResp, error)
mustEmbedUnimplementedCastServer()
}
@ -1196,6 +1207,9 @@ func (UnimplementedCastServer) UpdateCompetitiveReportApprovalID(context.Context
func (UnimplementedCastServer) CountCompetitiveReportByWorkUuids(context.Context, *CountCompetitiveReportByWorkUuidsReq) (*CountCompetitiveReportByWorkUuidsResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method CountCompetitiveReportByWorkUuids not implemented")
}
func (UnimplementedCastServer) ListPublishLog(context.Context, *ListPublishLogReq) (*ListPublishLogResp, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListPublishLog not implemented")
}
func (s *UnimplementedCastServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -3892,6 +3906,35 @@ func _Cast_CountCompetitiveReportByWorkUuids_Handler(srv interface{}, ctx contex
return interceptor(ctx, in, info, handler)
}
func _Cast_ListPublishLog_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ListPublishLogReq)
if err := dec(in); err != nil {
return nil, err
}
base := srv.(dubbo3.Dubbo3GrpcService)
args := []interface{}{}
args = append(args, in)
md, _ := metadata.FromIncomingContext(ctx)
invAttachment := make(map[string]interface{}, len(md))
for k, v := range md {
invAttachment[k] = v
}
invo := invocation.NewRPCInvocation("ListPublishLog", args, invAttachment)
if interceptor == nil {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
info := &grpc_go.UnaryServerInfo{
Server: srv,
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
return result, result.Error()
}
return interceptor(ctx, in, info, handler)
}
// Cast_ServiceDesc is the grpc_go.ServiceDesc for Cast service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -4267,6 +4310,10 @@ var Cast_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "CountCompetitiveReportByWorkUuids",
Handler: _Cast_CountCompetitiveReportByWorkUuids_Handler,
},
{
MethodName: "ListPublishLog",
Handler: _Cast_ListPublishLog_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/fiee/cast.proto",

View File

@ -38,4 +38,11 @@ TelNum = "18021272627"
Password = "Gy.123456"
[service]
IsHTTPS = false
IsHTTPS = false
[zapLog]
level = "info"
filename = "logs/fiee_zap.log"
maxsize = 5
maxage = 30
maxbackups = 30

View File

@ -43,6 +43,6 @@ Webhookkey = "whsec_uOQpG6IZTqtfLuePIDtfLCGJPqedSCCN"
[zapLog]
level = "info"
filename = "logs/fiee_zap.log"
max_size = 5
max_age = 30
max_backups = 30
maxsize = 5
maxage = 30
maxbackups = 30

View File

@ -43,6 +43,6 @@ Webhookkey = "whsec_Mol32WD1KcKHUdYsSwap0LR03q2g9qNY"
[zapLog]
level = "info"
filename = "logs/fiee_zap.log"
max_size = 5
max_age = 30
max_backups = 30
maxsize = 5
maxage = 30
maxbackups = 30

View File

@ -44,6 +44,6 @@ Webhookkey = "whsec_uOQpG6IZTqtfLuePIDtfLCGJPqedSCCN"
[zapLog]
level = "info"
filename = "logs/fiee_zap.log"
max_size = 5
max_age = 30
max_backups = 30
maxsize = 5
maxage = 30
maxbackups = 30

View File

@ -31,7 +31,7 @@ func InitTasks() error {
err := cm.AddTask("refreshWorkApprovalStatus", "0 */5 * * * *", RefreshApprovalStatusTask)
err = cm.AddTask("artistAutoConfirm", "0 */1 * * * *", ArtistAutoConfirmTask)
err = cm.AddTask("refreshPublishStatus", "0 */5 * * * *", PublishTask)
err = cm.AddTask("scheduledPublish", "0 */30 * * * *", ScheduledPublishTask)
err = cm.AddTask("scheduledPublish", "0 */1 * * * *", ScheduledPublishTask) //FIXME
err = cm.AddTask("artistAutoConfirmAnalysis", "0 */1 * * * *", ArtistAutoConfirmAnalysisTask)
err = cm.AddTask("refreshWorkAnalysisApprovalStatus", "0 */5 * * * *", RefreshWorkAnalysisApprovalStatusTask)

View File

@ -1,6 +1,7 @@
package cast
import (
"fmt"
"fonchain-fiee/api/cast"
modelCast "fonchain-fiee/pkg/model/cast"
"strings"
@ -102,3 +103,44 @@ func (w *Work) ExportExcelWorkList(data []*cast.WorkListResp_Info) (*excelize.Fi
return f, nil
}
func (w *Work) ExportPublishLogList(data []*cast.PublishLogInfo, savePath string) error {
f := excelize.NewFile()
defer f.Close()
sheetName := "Sheet1"
f.SetSheetName("Sheet1", sheetName)
headers := []string{
"状态", "失败原因", "提交发布时间", "发布平台", "发布方式", "作品类型", "作品标题", "艺人", "用户编号",
}
for col, h := range headers {
cell, _ := excelize.CoordinatesToCellName(col+1, 1)
f.SetCellValue(sheetName, cell, h)
}
for rowIndex, info := range data {
row := rowIndex + 2
platformName := modelCast.PlatformNameKv[info.PlatformID]
if platformName == "" {
platformName = fmt.Sprintf("%d", info.PlatformID)
}
values := []interface{}{
modelCast.PublishStatusMM[int(info.PublishMediaStatus)],
info.Detail,
info.CreatedAt,
modelCast.PlatformNameKv[info.PlatformID],
modelCast.PublishSourceMM[int(info.PublishSource)],
modelCast.WorkCategoryMM[int(info.WorkCategory)],
info.Title,
info.ArtistName,
info.ArtistSubNum,
}
for col, v := range values {
cell, _ := excelize.CoordinatesToCellName(col+1, row)
f.SetCellValue(sheetName, cell, v)
}
}
return f.SaveAs(savePath)
}

View File

@ -32,6 +32,18 @@ var WorkCategoryMM = map[int]string{
1: "图文",
2: "视频",
}
var PublishSourceMM = map[int]string{
1: "手动发布",
2: "定时任务",
3: "手动发布",
}
var PublishStatusMM = map[int]string{
1: "进行中",
2: "发布成功",
3: "发布失败",
4: "发布异常",
}
var WorkCostTypeMM = map[int]string{
1: "套餐",

View File

@ -50,11 +50,12 @@ func MediaRouter(r *gin.RouterGroup) {
work.POST("import-batch", serviceCast.ImportWorkBatch)
work.POST("list-published", serviceCast.WorkListPublished)
work.POST("update-work-script", serviceCast.UpdateWorkScript)
work.POST("publish-log-list", serviceCast.PublishLogList)
work.Any("publish-log-list-export", serviceCast.PublishLogListExport)
}
workNoAuth := noAuth.Group("work")
{
workNoAuth.POST("cron-republish", serviceCast.CronRePublish)
}

View File

@ -0,0 +1,119 @@
package cast
import (
"context"
"fmt"
"strings"
"time"
"fonchain-fiee/api/cast"
"fonchain-fiee/pkg/cache"
logicCast "fonchain-fiee/pkg/logic/cast"
"fonchain-fiee/pkg/model/login"
"fonchain-fiee/pkg/service"
"fonchain-fiee/pkg/utils"
"github.com/gin-gonic/gin"
"go.uber.org/zap"
)
// PublishLogList 查询发布记录列表
func PublishLogList(ctx *gin.Context) {
var req cast.ListPublishLogReq
if err := ctx.ShouldBind(&req); err != nil {
service.Error(ctx, err)
return
}
resp, err := service.CastProvider.ListPublishLog(context.Background(), &req)
if err != nil {
service.Error(ctx, err)
return
}
service.Success(ctx, resp)
}
// PublishLogListExport 导出发布记录列表 Excel
func PublishLogListExport(ctx *gin.Context) {
var req cast.ListPublishLogReq
if err := ctx.ShouldBind(&req); err != nil {
return
}
loginInfo := login.GetUserInfoFromC(ctx)
newCtx := NewCtxWithUserInfo(ctx)
lockKey := "PublishLogListExport" + fmt.Sprint(loginInfo.ID)
replay := cache.RedisClient.SetNX(lockKey, time.Now().Unix(), time.Minute*30)
if !replay.Val() {
return
}
defer cache.RedisClient.Del(lockKey)
const batchSize = 5000
var allData []*cast.PublishLogInfo
page := int32(1)
if req.Page > 0 {
page = req.Page
}
originalPageSize := req.PageSize
req.PageSize = batchSize
zap.L().Info("开始分批导出发布记录列表", zap.Int32("batchSize", batchSize))
for {
req.Page = page
zap.L().Info("获取第 N 页数据", zap.Int32("page", page), zap.Int32("pageSize", req.PageSize))
resp, err := service.CastProvider.ListPublishLog(newCtx, &req)
if err != nil {
zap.L().Error("获取发布记录失败", zap.Error(err), zap.Int32("page", page))
return
}
if resp == nil || len(resp.Data) == 0 {
zap.L().Info("没有更多数据", zap.Int32("page", page))
break
}
allData = append(allData, resp.Data...)
zap.L().Info("获取数据成功",
zap.Int32("page", page),
zap.Int("本批次数量", len(resp.Data)),
zap.Int("累计总数", len(allData)))
if len(resp.Data) < batchSize {
zap.L().Info("已到最后一页", zap.Int32("page", page))
break
}
page++
}
req.PageSize = originalPageSize
zap.L().Info("数据获取完成开始生成Excel", zap.Int("总数据量", len(allData)))
if len(allData) == 0 {
return
}
fileName := fmt.Sprintf("发布记录_%s.xlsx", time.Now().Format("20060102150405"))
filePath := fmt.Sprintf("./runtime/%d/%s", loginInfo.ID, fileName)
utils.CheckDirPath("./runtime/"+fmt.Sprint(loginInfo.ID), true)
var logicWork = new(logicCast.Work)
if err := logicWork.ExportPublishLogList(allData, filePath); err != nil {
zap.L().Error("生成Excel失败", zap.Error(err))
service.Error(ctx, err)
return
}
scheme := "http"
if ctx.GetHeader("X-Forwarded-Proto") == "https" {
scheme = "https"
}
exportUrl := fmt.Sprintf("%s://%s/api/fiee/static/%s", scheme, ctx.Request.Host, strings.Replace(filePath, "./runtime/", "", 1))
zap.L().Info("Excel导出成功", zap.String("文件名", fileName), zap.Int("记录数", len(allData)))
service.Success(ctx, gin.H{"url": exportUrl})
}

View File

@ -189,6 +189,14 @@ func Test(ctx *gin.Context) {
return
}
if action == "addDecodoProxies" {
service.CastProvider.Tools(context.Background(), &cast.ToolsReq{Action: action, CfgLinks: []string{
"http://spd7b09ho0:sqx_1MlQ1rN5gfm2Dx@isp.decodo.com:10001",
"http://spd7b09ho0:sqx_1MlQ1rN5gfm2Dx@isp.decodo.com:10002",
"http://spd7b09ho0:sqx_1MlQ1rN5gfm2Dx@isp.decodo.com:10003",
}})
}
service.Success(ctx, "unknow")
return
}

View File

@ -735,7 +735,7 @@ func PostAS(ctx context.Context, workUuid string, publishSource cast.PublishSour
return nil
//return errors.New("作品无发布平台")
}
zap.L().Info("post 2", zap.Any("workUuid", workUuid))
zap.L().Info("post 2", zap.Any("workUuid", workUuid), zap.Any("needPlatformIDs", needPlatformIDs))
var mediaUrls []string
var isVideo bool
//var urlResp *UploadMediaResponse
@ -893,11 +893,12 @@ func PostAS(ctx context.Context, workUuid string, publishSource cast.PublishSour
}
if _err != nil {
_, errS := service.CastProvider.UpdateWorkPublishLog(context.Background(), &cast.UpdateWorkPublishLogReq{
WorkUuid: workUuid,
PlatformID: cast.PlatformIDENUM(platformID),
Action: "post",
Detail: _err.Error(),
PublishSource: publishSource,
WorkUuid: workUuid,
PlatformID: cast.PlatformIDENUM(platformID),
Action: "post",
Detail: _err.Error(),
PublishSource: publishSource,
PublishMediaStatus: cast.PublishStatusENUM_PublishMediaStatus_EXCEPTION,
})
if errS != nil {
zap.L().Error("PostAs UpdateWorkPublishLog err", zap.Error(errS), zap.Any("WorkUuid", workDetail.WorkUuid))
@ -978,12 +979,22 @@ func PostAS(ctx context.Context, workUuid string, publishSource cast.PublishSour
Remark: string(postData),
PublishSource: publishSource,
})
_, _ = service.CastProvider.UpdateWorkPublishLog(context.Background(), &cast.UpdateWorkPublishLogReq{
PlatformID: cast.PlatformIDENUM(platformID),
WorkUuid: workUuid,
Action: "post",
Detail: string(postData),
PublishSource: publishSource,
PublishMediaStatus: publishStatus,
PublishMediaID: postResp.Posts[0].Id,
})
}
zap.L().Info("post 10", zap.Any("workUuid", workUuid), zap.Any("platformID", platformID))
_, err = service.CastProvider.UpdateWorkPlatformInfo(context.Background(), infoReq)
if err != nil {
zap.L().Error("Publish UpdateWorkPlatformInfo failed", zap.String("workUuid", workUuid), zap.Error(err))
}
zap.L().Info("Publish Ayrshare PostResp", zap.Any("postResp", postResp))
}
zap.L().Info("post 5.1", zap.Any("workUuid", workUuid))
@ -1014,6 +1025,7 @@ func RePublish(ctx *gin.Context) {
}
func republishCore(gCtx *gin.Context, newCtx context.Context, req *cast.RePublishReq) error {
zap.L().Info("republishCore", zap.Any("req", req))
var resp *cast.RePublishResp
var err error
if len(req.PlatformIDs) == 0 && len(req.MediaAccountUuids) == 0 {
@ -1973,6 +1985,15 @@ func RefreshPublish() error {
PlatformUuid: platformInfo.PlatformUuid,
})
_, _ = service.CastProvider.UpdateWorkPlatformInfo(context.Background(), infoReq)
go func(work *cast.RefreshWorkListResp_Info, platform *cast.RefreshWorkListResp_Info_PlatformInfo, postResult string) {
_, _ = service.CastProvider.UpdateWorkPublishLog(context.Background(), &cast.UpdateWorkPublishLogReq{
PlatformID: platform.PlatformID,
WorkUuid: work.WorkUuid,
Action: "getPost",
Detail: postResult,
PublishMediaID: platform.PublishMediaID,
})
}(workInfo, platformInfo, string(dmData))
} else {
// 未发布的先不管,不能标记失败
/*infoReq.PlatformInfoData = append(infoReq.PlatformInfoData, &cast.PlatformInfo{
@ -1995,15 +2016,16 @@ func RefreshPublish() error {
ProfileKey: workInfo.ProfileKey,
})
go func() {
postBytes, _ := json.Marshal(postResp)
go func(work *cast.RefreshWorkListResp_Info, platform *cast.RefreshWorkListResp_Info_PlatformInfo, post *aryshare.GetPostResponse) {
postBytes, _ := json.Marshal(post)
_, _ = service.CastProvider.UpdateWorkPublishLog(context.Background(), &cast.UpdateWorkPublishLogReq{
PlatformID: platformInfo.PlatformID,
WorkUuid: workInfo.WorkUuid,
Action: "getPost",
Detail: string(postBytes),
PlatformID: platform.PlatformID,
WorkUuid: work.WorkUuid,
Action: "getPost",
Detail: string(postBytes),
PublishMediaID: platform.PublishMediaID,
})
}()
}(workInfo, platformInfo, postResp)
if _err != nil {
zap.L().Error("GetPost err", zap.Error(_err))