|
@@ -337,27 +337,29 @@ func UpdateVoiceBroadcastImgUrl() (err error) {
|
|
// PublishVoiceBroadcast 发布语音播报
|
|
// PublishVoiceBroadcast 发布语音播报
|
|
func PublishVoiceBroadcast(broadcastId, sectionId, varietyId, authorId, publishType int, broadcastName, sectionName, varietyName, author,
|
|
func PublishVoiceBroadcast(broadcastId, sectionId, varietyId, authorId, publishType int, broadcastName, sectionName, varietyName, author,
|
|
imgUrl, prePublishTime, imgs string, voiceFile *multipart.FileHeader) (errMsg string, err error) {
|
|
imgUrl, prePublishTime, imgs string, voiceFile *multipart.FileHeader) (errMsg string, err error) {
|
|
- // broadcastId > 0为编辑
|
|
|
|
|
|
+ // broadcastId>0时为编辑
|
|
var e error
|
|
var e error
|
|
item := new(voice_broadcast.VoiceBroadcast)
|
|
item := new(voice_broadcast.VoiceBroadcast)
|
|
if broadcastId > 0 {
|
|
if broadcastId > 0 {
|
|
// 语音播报
|
|
// 语音播报
|
|
- // TODO:主键
|
|
|
|
- item, e := voice_broadcast.GetBroadcastById(broadcastId)
|
|
|
|
- fmt.Println(broadcastId)
|
|
|
|
- if e != nil || item.BroadcastId == 0 {
|
|
|
|
|
|
+ exists, e := voice_broadcast.GetBroadcastById(broadcastId)
|
|
|
|
+ if e != nil || exists.BroadcastId == 0 {
|
|
errMsg = "语音播报信息有误"
|
|
errMsg = "语音播报信息有误"
|
|
err = errors.New("语音播报信息有误\n")
|
|
err = errors.New("语音播报信息有误\n")
|
|
return
|
|
return
|
|
}
|
|
}
|
|
|
|
+ if exists.PublishState == 1 {
|
|
|
|
+ errMsg = "请勿重复发布"
|
|
|
|
+ err = errors.New("该语音播报已发布\n")
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ item = exists
|
|
}
|
|
}
|
|
- fmt.Println(item.BroadcastId)
|
|
|
|
- return
|
|
|
|
item.CreateTime = time.Now().Local().Format(utils.FormatDateTime)
|
|
item.CreateTime = time.Now().Local().Format(utils.FormatDateTime)
|
|
item.PublishTime = ""
|
|
item.PublishTime = ""
|
|
item.PrePublishTime = ""
|
|
item.PrePublishTime = ""
|
|
updateCols := []string{"BroadcastName", "SectionId", "SectionName", "VarietyId", "VarietyName", "AuthorId", "Author", "ImgUrl", "VoiceUrl",
|
|
updateCols := []string{"BroadcastName", "SectionId", "SectionName", "VarietyId", "VarietyName", "AuthorId", "Author", "ImgUrl", "VoiceUrl",
|
|
- "VoicePlaySeconds", "VoiceSize", "ModifyTime", "PublisState"}
|
|
|
|
|
|
+ "VoicePlaySeconds", "VoiceSize", "ModifyTime", "PublishState"}
|
|
|
|
|
|
// publishType: 0-仅发布 1-发布并推送 2-定时发布; 发布类型为定时发送时, 分享图时间取预发布时间
|
|
// publishType: 0-仅发布 1-发布并推送 2-定时发布; 发布类型为定时发送时, 分享图时间取预发布时间
|
|
publishTime := time.Now().Local()
|
|
publishTime := time.Now().Local()
|
|
@@ -372,7 +374,7 @@ func PublishVoiceBroadcast(broadcastId, sectionId, varietyId, authorId, publishT
|
|
return
|
|
return
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- // TODO:新增时为定时发布,编辑时为仅发布是否需要重置定时发布时间
|
|
|
|
|
|
+ // 非定时发布时重置预发布时间
|
|
updateCols = append(updateCols, "PublishTime", "PrePublishTime")
|
|
updateCols = append(updateCols, "PublishTime", "PrePublishTime")
|
|
item.PublishState = 1
|
|
item.PublishState = 1
|
|
item.PublishTime = publishTime.Format(utils.FormatDateTime)
|
|
item.PublishTime = publishTime.Format(utils.FormatDateTime)
|
|
@@ -415,13 +417,13 @@ func PublishVoiceBroadcast(broadcastId, sectionId, varietyId, authorId, publishT
|
|
|
|
|
|
imgList := make([]*voice_broadcast_img.YbVoiceBroadcastImg, 0)
|
|
imgList := make([]*voice_broadcast_img.YbVoiceBroadcastImg, 0)
|
|
imgArr := strings.Split(imgs, ",")
|
|
imgArr := strings.Split(imgs, ",")
|
|
- imgLen := len(imgList)
|
|
|
|
|
|
+ imgLen := len(imgArr)
|
|
nowTime := time.Now().Local()
|
|
nowTime := time.Now().Local()
|
|
for i := 0; i < imgLen; i++ {
|
|
for i := 0; i < imgLen; i++ {
|
|
imgList = append(imgList, &voice_broadcast_img.YbVoiceBroadcastImg{
|
|
imgList = append(imgList, &voice_broadcast_img.YbVoiceBroadcastImg{
|
|
BroadcastId: item.BroadcastId,
|
|
BroadcastId: item.BroadcastId,
|
|
- ImgUrl: imgArr[i],
|
|
|
|
- CreateTime: nowTime,
|
|
|
|
|
|
+ ImgUrl: imgArr[i],
|
|
|
|
+ CreateTime: nowTime,
|
|
})
|
|
})
|
|
}
|
|
}
|
|
// 新增/更新
|
|
// 新增/更新
|