fonchain-artistinfo/cmd/internal/logic/artistinfo_artshowVideo.go

104 lines
3.5 KiB
Go
Raw Normal View History

// Package logic -----------------------------
// @file : artistinfo_artshowVideo.go
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2023/3/2 11:51
// -------------------------------------------
package logic
import (
"github.com/fonchain/fonchain-artistinfo/cmd/internal/dao"
"github.com/fonchain/fonchain-artistinfo/cmd/model"
"github.com/fonchain/fonchain-artistinfo/pb/artistinfoArtshow"
"google.golang.org/protobuf/types/known/emptypb"
)
type ArtshowVideoLogic struct{}
2023-03-02 09:22:10 +00:00
func (a ArtshowVideoLogic) BatchCreateArtshowVideo(request *artistinfoArtshow.BatchCreateArtshowVideoRequest) error {
var datas = []model.ArtshowRecord{}
for _, v := range request.Data {
datas = append(datas, model.ArtshowRecord{
ArtistUid: v.ArtistUid,
LockTime: v.LockTime,
ArtistName: v.ArtistName,
VideoUrl: v.VideoUrl,
AuditStatus: model.AuditStatus(v.AuditStatus),
AuditMark1: v.AuditMark1,
AuditMark2: v.AuditMark2,
Status: v.Status,
})
}
return dao.ArtistinfoArtshowVideo.BatchCreateData(datas)
}
func (a ArtshowVideoLogic) CreateArtshowVideo(request *artistinfoArtshow.ArtshowVideoInfo) error {
return dao.ArtistinfoArtshowVideo.CreateData(&model.ArtshowRecord{
ArtistUid: request.ArtistUid,
LockTime: request.LockTime,
ArtistName: request.ArtistName,
VideoUrl: request.VideoUrl,
AuditStatus: model.AuditStatus(request.AuditStatus),
AuditMark1: request.AuditMark1,
AuditMark2: request.AuditMark2,
Status: request.Status,
})
}
func (a ArtshowVideoLogic) GetArtshowVideoList(request *artistinfoArtshow.GetArtshowVideoListRequst) (res *artistinfoArtshow.GetArtshowVideoListResponse, err error) {
res = &artistinfoArtshow.GetArtshowVideoListResponse{}
datas, total, err := dao.ArtistinfoArtshowVideo.GetDataList(request)
if err != nil {
return nil, err
}
res.Page = &artistinfoArtshow.VideoPagination{
Page: request.Page,
PageSize: request.PageSize,
Total: total,
}
for _, v := range datas {
res.Data = append(res.Data, &artistinfoArtshow.ArtshowVideoInfo{
Id: v.ID,
ArtistUid: v.ArtistUid,
LockTime: v.LockTime,
VideoUrl: v.VideoUrl,
AuditStatus: int64(v.AuditStatus),
AuditMark1: v.AuditMark1,
AuditMark2: v.AuditMark2,
CreatedAt: v.CreatedAt.Unix(),
2023-03-02 09:22:10 +00:00
UpdatedAt: v.UpdatedAt.Unix(),
DeletedAt: int64(v.DeletedAt),
2023-03-02 09:22:10 +00:00
Status: v.Status,
})
}
return
}
func (a ArtshowVideoLogic) AuditArtshowVideo(request *artistinfoArtshow.AuditArtshowVideoRequest) (*emptypb.Empty, error) {
err := dao.ArtistinfoArtshowVideo.Audit(model.AuditStatus(request.AuditStatus), request.AuditMark1, request.AuditMark2, request.ArtshowVideoIds...)
return nil, err
}
func (a ArtshowVideoLogic) UpdateArtshowVideo(request *artistinfoArtshow.UpdateArtshowVideoRequest) (*emptypb.Empty, error) {
err := dao.ArtistinfoArtshowVideo.UpdateData(&model.ArtshowRecord{
Model: model.Model{ID: request.Id},
ArtistUid: request.ArtistUid,
LockTime: request.LockTime,
ArtistName: request.ArtistName,
VideoUrl: request.VideoUrl,
AuditStatus: model.AuditStatus(request.AuditStatus),
AuditMark1: request.AuditMark1,
AuditMark2: request.AuditMark2,
})
return nil, err
}
func (a ArtshowVideoLogic) DeletedArtshowVideo(request *artistinfoArtshow.DeletedArtshowVideoRequest) (*emptypb.Empty, error) {
var ids = []int64{}
if request.Id != 0 {
ids = append(ids, request.Id)
} else if len(request.Ids) > 0 {
ids = append(ids, request.Ids...)
}
err := dao.ArtistinfoArtshowVideo.DeletedData(ids...)
return nil, err
}