package archive import ( "context" "fmt" "go-common/app/admin/main/videoup/model/archive" "go-common/library/database/sql" "go-common/library/log" "go-common/library/xstr" ) const ( _videoByCid = "SELECT vr.id,vr.aid,vr.title AS eptitle,vr.description,v.filename,v.src_type,vr.cid,v.duration,v.filesize,v.resolutions,vr.index_order,vr.ctime,vr.mtime,v.status,v.playurl,v.attribute,v.failcode AS failinfo,v.xcode_state,v.weblink FROM archive_video_relation AS vr LEFT JOIN video AS v ON vr.cid = v.id WHERE vr.cid = ?" _inRelationSQL = "INSERT IGNORE INTO archive_video_relation (id,aid,cid,title,description,index_order,ctime,mtime) VALUES (?,?,?,?,?,?,?,?)" _upRelationSQL = "UPDATE archive_video_relation SET title=?,description=? WHERE id=?" _upRelationOrderSQL = "UPDATE archive_video_relation SET index_order=? WHERE id=?" _upRelationStateSQL = "UPDATE archive_video_relation SET state=? WHERE id=?" _upVideoLinkSQL = "UPDATE video SET weblink=? WHERE id=?" _upVideoStatusSQL = "UPDATE video SET status=? WHERE id=?" _upVideoAttrSQL = "UPDATE video SET attribute=attribute&(~(1< 0 { v.Content = formatDesc } return } //VideoRelated related videos func (d *Dao) VideoRelated(c context.Context, aid int64) (vs []*archive.RelationVideo, err error) { var rows *sql.Rows vs = []*archive.RelationVideo{} if rows, err = d.rddb.Query(c, _videoRelated, aid); err != nil { log.Error("VideoRelated d.rddb.Query error(%v) aid(%d)", err, aid) return } defer rows.Close() for rows.Next() { v := &archive.RelationVideo{} if err = rows.Scan(&v.Filename, &v.Status, &v.AID, &v.IndexOrder, &v.Title, &v.Ctime); err != nil { log.Error("VideoRelated rows.Scan error(%v) aid(%d)", err, aid) return } vs = append(vs, v) } return }