You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
601 B
26 lines
601 B
package service
|
|
|
|
import (
|
|
"errors"
|
|
"main_program/common"
|
|
entity "main_program/entity"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type videoService struct{}
|
|
|
|
var VideoService videoService
|
|
|
|
func (v *videoService) QueryOneByVideoId(videoId string) (video entity.Video, err error) {
|
|
var videoEntity entity.Video
|
|
result := common.MysqlDB.Where(&entity.Video{VideoId: videoId}).First(&videoEntity)
|
|
if result.Error != nil {
|
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
|
return videoEntity, errors.New("no video")
|
|
}
|
|
return videoEntity, errors.New("query video failed")
|
|
} else {
|
|
return videoEntity, nil
|
|
}
|
|
}
|
|
|