96 lines
3.3 KiB
Go
96 lines
3.3 KiB
Go
package service
|
|
|
|
import (
|
|
"service/api/consts"
|
|
"service/dbstruct"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
goproto "google.golang.org/protobuf/proto"
|
|
)
|
|
|
|
func (s *Service) CreateUpdateAccountImageAudit(ctx *gin.Context, oldAccount *dbstruct.Account, newAccount *dbstruct.Account) (tasks []*dbstruct.ImageAuditTask) {
|
|
if newAccount.Avatar == nil {
|
|
return nil
|
|
}
|
|
|
|
tasks = make([]*dbstruct.ImageAuditTask, 0)
|
|
|
|
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
|
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
|
AssociativeDatabase: goproto.String("account"),
|
|
AssociativeTableName: goproto.String("account"),
|
|
AssociativeTableId: newAccount.Mid,
|
|
AssociativeTableColumn: goproto.String("avatar"),
|
|
AuditedMedia: newAccount.Avatar,
|
|
OldMedia: oldAccount.Avatar,
|
|
})
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) CreateUpdateStreamerImageAudit(ctx *gin.Context, oldStreamer *dbstruct.Streamer, newStreamer *dbstruct.Streamer) (tasks []*dbstruct.ImageAuditTask) {
|
|
tasks = make([]*dbstruct.ImageAuditTask, 0)
|
|
|
|
if newStreamer.Cover != nil {
|
|
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
|
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
|
AssociativeDatabase: goproto.String("streamer"),
|
|
AssociativeTableName: goproto.String("streamer"),
|
|
AssociativeTableId: oldStreamer.Mid,
|
|
AssociativeTableColumn: goproto.String("cover"),
|
|
AuditedMedia: newStreamer.Cover,
|
|
OldMedia: oldStreamer.Cover,
|
|
})
|
|
}
|
|
|
|
if newStreamer.Album != nil {
|
|
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
|
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
|
AssociativeDatabase: goproto.String("streamer"),
|
|
AssociativeTableName: goproto.String("streamer"),
|
|
AssociativeTableId: oldStreamer.Mid,
|
|
AssociativeTableColumn: goproto.String("album"),
|
|
AuditedMedia: newStreamer.Album,
|
|
OldMedia: oldStreamer.Album,
|
|
})
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) CreateMomentImageAudit(ctx *gin.Context, newMoment *dbstruct.Moment) (tasks []*dbstruct.ImageAuditTask) {
|
|
|
|
if newMoment.MediaComp != nil && len(newMoment.MediaComp.GetImageIds()) > 0 {
|
|
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
|
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
|
AssociativeDatabase: goproto.String("moment"),
|
|
AssociativeTableName: goproto.String("moment"),
|
|
AssociativeTableId: newMoment.Id,
|
|
AssociativeTableColumn: goproto.String("media_component"),
|
|
AuditedMedia: newMoment.MediaComp,
|
|
OldMedia: nil,
|
|
IsAligned: goproto.Int64(consts.ImageAuditIsAligned_Yes),
|
|
})
|
|
}
|
|
|
|
return
|
|
}
|
|
|
|
func (s *Service) CreateZoneMomentImageAudit(ctx *gin.Context, newZoneMoment *dbstruct.ZoneMoment) (tasks []*dbstruct.ImageAuditTask) {
|
|
|
|
if newZoneMoment.MediaComp != nil && len(newZoneMoment.MediaComp.GetImageIds()) > 0 {
|
|
tasks = append(tasks, &dbstruct.ImageAuditTask{
|
|
RouteUrl: goproto.String(ctx.Request.URL.Path),
|
|
AssociativeDatabase: goproto.String("zone_moment"),
|
|
AssociativeTableName: goproto.String("zone_moment"),
|
|
AssociativeTableId: newZoneMoment.Id,
|
|
AssociativeTableColumn: goproto.String("media_component"),
|
|
AuditedMedia: newZoneMoment.MediaComp,
|
|
OldMedia: nil,
|
|
IsAligned: goproto.Int64(consts.ImageAuditIsAligned_Yes),
|
|
})
|
|
}
|
|
|
|
return
|
|
}
|