// Package artshowVideo ----------------------------- // @file : artshowVideo.go // @author : JJXu // @contact : wavingbear@163.com // @time : 2023/3/2 9:08 // ------------------------------------------- package asArtshow import ( "dubbo.apache.org/dubbo-go/v3/common/logger" "github.com/fonchain_enterprise/fonchain-main/pkg/service/artistInfo/asPush" "github.com/fonchain_enterprise/fonchain-main/pkg/service/artistInfo/asUser" "sort" "github.com/fonchain_enterprise/fonchain-main/api/artistInfoUser" "github.com/fonchain_enterprise/fonchain-main/api/artistinfoArtshow" "github.com/fonchain_enterprise/fonchain-main/pkg/e" "github.com/fonchain_enterprise/fonchain-main/pkg/service" "github.com/gin-gonic/gin" "github.com/jinzhu/copier" ) var ArtshowVideo = new(artshowVideo) type artshowVideo struct { } // GenerateArtshowVideoRecord 生成画展视频资料记录 func (a artshowVideo) GenerateArtshowVideoRecord(c *gin.Context) { var req = RequestGenerateArtshowRecord{} if err := c.ShouldBindJSON(&req); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } if requestData, err := req.ConvertGrpcRequest(); err != nil { service.ErrorWithMark(c, e.Failed, err, "GenerateArtshowVideoRecord:ConvertGrpcRequest Error ", err.Error()) } else { _, err = service.GrpcArtistInfoArtshowImpl.BatchCreateArtshowVideo(c, &artistinfoArtshow.BatchCreateArtshowVideoRequest{ Data: requestData, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GenerateArtshowVideoRecord: GrpcArtshowImpl.BatchCreateArtshowVideo Error ", err.Error()) return } else { service.Success(c) } } } // GetArtshowVideoListAtUserSide 获取用户端画展视频资料列表 func (a artshowVideo) GetArtshowVideoListAtUserSide(c *gin.Context) { var req RequestGetArtshowVideoListAtUserSide if err := c.ShouldBindJSON(&req); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } //获取艺术家uid if req.ArtistUid == "" { userInfo, err, code := asUser.GetUserInfoWithToken(c) if err != nil { service.Error(c, code, err, err.Error()) return } req.ArtistUid = userInfo.MgmtArtistUid } res, err := service.GrpcArtistInfoArtshowImpl.GetArtshowVideoList(c, &artistinfoArtshow.GetArtshowVideoListRequst{ Page: req.Page, PageSize: req.PageSize, ArtistUid: req.ArtistUid, Status: 2, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtshowVideoListAtUserSide: GrpcArtshowImpl.GetArtshowVideoList Error ", "查询失败") return } var datas []*ArtshowVideoInfo err = copier.Copy(&datas, &res.Data) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtshowVideoListAtBackendSide: copier.Copy Error ", "查询失败") return } service.ResponseList(c, datas, service.OptionPage(res.Page.Page, res.Page.PageSize, res.Page.Total), service.OptionMsg("查询成功")) } // GetArtshowVideoListAtBackendSide 获取后端画展视频资料列表 func (a artshowVideo) GetArtshowVideoListAtBackendSide(c *gin.Context) { var request = GetVideoRecordsReq{} //artistinfoArtshow.GetArtshowVideoListRequst{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } var res *artistinfoArtshow.GetArtshowVideoListResponse var err error if request.History { res, err = service.GrpcArtistInfoArtshowImpl.GetArtshowVideoList(c, &artistinfoArtshow.GetArtshowVideoListRequst{ Page: int64(request.Page), PageSize: int64(request.PageSize), ArtistName: request.ArtistName, AuditStatus: request.AuditStatus, Status: 3, //后台查询解锁的记录,即历史数据 }) } else { res, err = service.GrpcArtistInfoArtshowImpl.GetArtshowVideoList(c, &artistinfoArtshow.GetArtshowVideoListRequst{ Page: int64(request.Page), PageSize: int64(request.PageSize), ArtistName: request.ArtistName, AuditStatus: request.AuditStatus, Status: 2, //后台查询锁定的数据 }) } if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtshowVideoListAtBackendSide: GrpcArtshowImpl.GetArtshowVideoList Error ", "查询失败") return } var datas []*ArtshowVideoInfo err = copier.Copy(&datas, &res.Data) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtshowVideoListAtBackendSide: copier.Copy Error ", "查询失败") return } service.ResponseList(c, datas, service.OptionPage(res.Page.Page, res.Page.PageSize, res.Page.Total), service.OptionMsg("查询成功"), service.OptionAddField_ArtshowCount("artistUid"), ) } func (a artshowVideo) UpdateArtshowVideo(c *gin.Context) { var request = artistinfoArtshow.ArtshowVideoInfo{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } _, err := service.GrpcArtistInfoArtshowImpl.UpdateArtshowVideo(c, &artistinfoArtshow.UpdateArtshowVideoRequest{ Id: request.Id, VideoUrl: request.VideoUrl, AuditStatus: 2, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetArtshowVideoListAtBackendSide: GrpcArtshowImpl.GetArtshowVideoList Error ", "查询失败") return } service.Success(c) } func (a artshowVideo) AuditArtshowVideo(c *gin.Context) { var request = AuditArtshowVideoRequest{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } var protoRerquest = &artistinfoArtshow.AuditArtshowVideoRequest{ ArtshowVideoIds: request.ArtshowVideoIds, AuditStatus: request.AuditStatus, AuditMark1: request.AuditMark1, AuditMark2: request.AuditMark2, } go func() { for _, id := range request.ArtshowVideoIds { asUser.UpdateOperationTime(c, artistinfoArtshow.OdType_video, id) artshowDetail, err := service.GrpcArtistInfoArtshowImpl.GetArtshowVideoDetail(c, &artistinfoArtshow.GetArtshowVideoDetailRequest{Id: id}) if err == nil { userInfo, errs := service.GrpcArtistInfoUserImpl.FindUser(c, &artistInfoUser.FindUserRequest{MgmtArtistUid: artshowDetail.ArtistUid}) if errs == nil { //if errs = asUser.ArtistInfoPushNotice.ArtistArtshowSupplementAuditNotice(userInfo.Id, asUser.AuditType_Video); errs != nil { // logger.Error("AuditArtshowVideo,发送app通知失败:" + errs.Error()) //} pusher := asPush.NewPusher() if errs = pusher.ArtistArtshowSupplementAuditNotice(userInfo.Id, asUser.AuditType_Video); errs != nil { logger.Error("AuditArtshowVideo,发送app通知失败:" + errs.Error()) } } } } }() _, err := service.GrpcArtistInfoArtshowImpl.AuditArtshowVideo(c, protoRerquest) if err != nil { service.ErrorWithMark(c, e.Failed, err, "AuditArtshowVideo: GrpcArtshowImpl.AuditArtshowVideo Error ", err.Error()) return } service.Success(c) } func (a artshowVideo) GetLockedArtistList(c *gin.Context) { var request = artistinfoArtshow.ArtistListRequest{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } lockedUsers, err := service.GrpcArtistInfoUserImpl.FindUsers(c, &artistInfoUser.FindUsersRequest{ ArtistRealName: request.ArtistName, Page: int32(request.Page), PageSize: int32(request.PageSize), IsArtist: 2, IsLock: true, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetLockedArtistList: service.GrpcArtistInfoUserImpl.FindUsers ", err.Error()) return } var returnData = ResponseGetLockedArtistList{} for _, user := range lockedUsers.Data { artistIndexList, err := service.GrpcArtistInfoArtshowImpl.GetArtshowVideoList(c, &artistinfoArtshow.GetArtshowVideoListRequst{ ArtistUid: user.MgmtArtistUid, //LockTime: user.LatestLockTime, Status: 2, Page: 1, PageSize: -1, }) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetLockedArtistList: service.GrpcArtistInfoUserImpl.FindUsers ", err.Error()) return } //查找最新一次更新的记录,然后拿去该条数据的更新时间 dataCreatedAt := "" dataUpdatedAt := "" if len(artistIndexList.Data) > 0 { sort.Slice(artistIndexList.Data, func(i, j int) bool { // asc return artistIndexList.Data[i].UpdatedAt > artistIndexList.Data[j].UpdatedAt }) dataCreatedAt = artistIndexList.Data[0].CreatedAt //time.Unix(artistIndexList.Data[0].CreatedAt, 0).Format(stime.Format_Normal_YMDhms) dataUpdatedAt = artistIndexList.Data[0].UpdatedAt //time.Unix(artistIndexList.Data[0].UpdatedAt, 0).Format(stime.Format_Normal_YMDhms) } returnData.Data = append(returnData.Data, ArtistUserInfo{ ArtistUid: user.MgmtArtistUid, ArtistName: user.RealName.Name, DataCreatedAt: dataCreatedAt, DataUpdatedAt: dataUpdatedAt, }) } if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetLockedArtistList: GrpcArtshowImpl.AuditArtistIndex Error ", err.Error()) return } service.ResponseList(c, returnData.Data, service.OptionPage(request.Page, request.PageSize, lockedUsers.Page.Total), service.OptionMsg("查询成功")) } func (a artshowVideo) GetVideoDetail(c *gin.Context) { var request = artistinfoArtshow.GetArtshowVideoDetailRequest{} if err := c.ShouldBindJSON(&request); err != nil { service.Error(c, e.InvalidParams, err, err.Error()) return } video, err := service.GrpcArtistInfoArtshowImpl.GetArtshowVideoDetail(c, &request) if err != nil { service.ErrorWithMark(c, e.Failed, err, "GetVideoDetail: GrpcArtshowImpl.GetArtshowVideoDetail ", err.Error()) return } var data = ResponseVideoDetail{} data.ConvertResponse(video) service.ResponseData(c, data, service.OptionMsg("查询成功")) } //func (a artshowVideo) GetVideoDetail(c *gin.Context) { // var request = artistinfoArtshow.ArtistListRequest{} // if err := c.ShouldBindJSON(&request); err != nil { // service.Error(c, e.InvalidParams, err, err.Error()) // return // } // lockedUsers, err := service.GrpcArtshowImpl.GetArtshowVideoDetail(c, &artistinfoArtshow.GetArtshowVideoDetailRequest{ // ArtistUid: "", // LockTime: "", // Status: 0, // }) // if err != nil { // service.ErrorWithMark(c, e.Failed, err, "GetLockedArtistList: service.GrpcArtistInfoUserImpl.FindUsers ", err.Error()) // return // } // // if err != nil { // service.ErrorWithMark(c, e.Failed, err, "GetVideoDetail: GrpcArtshowImpl.AuditArtistIndex Error ", err.Error()) // return // } // service.ResponseData(c, returnData.Data, service.OptionMsg("查询成功")) //}