|
@@ -10,118 +10,74 @@ import (
|
|
|
"hongze/hongze_yb/models/tables/company_product"
|
|
|
"hongze/hongze_yb/models/tables/sys_role_admin"
|
|
|
"hongze/hongze_yb/models/tables/voice_broadcast"
|
|
|
+ "hongze/hongze_yb/models/tables/voice_broadcast_img"
|
|
|
"hongze/hongze_yb/models/tables/voice_broadcast_statistics"
|
|
|
"hongze/hongze_yb/models/tables/voice_section"
|
|
|
"hongze/hongze_yb/services/user"
|
|
|
"hongze/hongze_yb/services/wechat"
|
|
|
"hongze/hongze_yb/utils"
|
|
|
+ "strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-func GetVoiceBroadcastList(pageindex, pagesize, sectionId, broadcastId int, userInfo user.UserInfo) (list []response.Broadcast, err error) {
|
|
|
- if broadcastId == 0 {
|
|
|
- if sectionId == 0 {
|
|
|
- broadList, e := voice_broadcast.GetBroadcast(pageindex, pagesize)
|
|
|
- if e != nil {
|
|
|
- e = errors.New("获取语音播报列表失败 Err:" + e.Error())
|
|
|
- }
|
|
|
- for _, item := range broadList {
|
|
|
- var respItem response.Broadcast
|
|
|
- respItem = response.Broadcast{
|
|
|
- BroadcastId: item.BroadcastId,
|
|
|
- BroadcastName: item.BroadcastName,
|
|
|
- SectionId: item.SectionId,
|
|
|
- SectionName: item.SectionName,
|
|
|
- VarietyId: item.VarietyId,
|
|
|
- VarietyName: item.VarietyName,
|
|
|
- AuthorId: item.AuthorId,
|
|
|
- Author: item.Author,
|
|
|
- ImgUrl: item.ImgUrl,
|
|
|
- VoiceUrl: item.VoiceUrl,
|
|
|
- VoicePlaySeconds: item.VoicePlaySeconds,
|
|
|
- VoiceSize: item.VoiceSize,
|
|
|
- CreateTime: item.CreateTime,
|
|
|
- IsAuthor: false,
|
|
|
- }
|
|
|
- if int(userInfo.UserID) == item.AuthorId {
|
|
|
- respItem.IsAuthor = true
|
|
|
- // 是否可以推送消息
|
|
|
- if item.MsgState == 0 {
|
|
|
- respItem.CouldSendMsg = true
|
|
|
- }
|
|
|
- }
|
|
|
- list = append(list, respItem)
|
|
|
-
|
|
|
+// GetVoiceBroadcastList 获取语音播报列表
|
|
|
+func GetVoiceBroadcastList(pageIndex, pageSize, sectionId, broadcastId, authorId, mineStatus int, userInfo user.UserInfo) (resp []response.Broadcast, err error) {
|
|
|
+ condition := ` 1=1`
|
|
|
+ var pars []interface{}
|
|
|
+ // 分享进来的指定语音播报
|
|
|
+ if broadcastId > 0 {
|
|
|
+ condition += ` AND broadcast_id = ? AND publish_state = 1`
|
|
|
+ pars = append(pars, broadcastId)
|
|
|
+ } else {
|
|
|
+ // 我的-非我的只能看到已发布
|
|
|
+ if authorId > 0 {
|
|
|
+ condition += ` AND author_id = ?`
|
|
|
+ pars = append(pars, authorId)
|
|
|
+ // 我的语音播报状态: 0-未发布 1-已发布 2-全部
|
|
|
+ if mineStatus != 2 {
|
|
|
+ condition += ` AND publish_state = ?`
|
|
|
+ pars = append(pars, mineStatus)
|
|
|
}
|
|
|
- err = e
|
|
|
- return
|
|
|
+ } else {
|
|
|
+ condition += ` AND publish_state = 1`
|
|
|
}
|
|
|
- broadList, e := voice_broadcast.GetBroadcastByCondition(pageindex, pagesize, sectionId)
|
|
|
- if e != nil {
|
|
|
- e = errors.New("获取语音播报列表失败 Err:" + e.Error())
|
|
|
+ // 板块
|
|
|
+ if sectionId > 0 {
|
|
|
+ condition += ` AND section_id = ?`
|
|
|
+ pars = append(pars, sectionId)
|
|
|
}
|
|
|
- for _, item := range broadList {
|
|
|
- var respItem response.Broadcast
|
|
|
- respItem = response.Broadcast{
|
|
|
- BroadcastId: item.BroadcastId,
|
|
|
- BroadcastName: item.BroadcastName,
|
|
|
- SectionId: item.SectionId,
|
|
|
- SectionName: item.SectionName,
|
|
|
- VarietyId: item.VarietyId,
|
|
|
- VarietyName: item.VarietyName,
|
|
|
- AuthorId: item.AuthorId,
|
|
|
- Author: item.Author,
|
|
|
- ImgUrl: item.ImgUrl,
|
|
|
- VoiceUrl: item.VoiceUrl,
|
|
|
- VoicePlaySeconds: item.VoicePlaySeconds,
|
|
|
- VoiceSize: item.VoiceSize,
|
|
|
- CreateTime: item.CreateTime,
|
|
|
- IsAuthor: false,
|
|
|
- }
|
|
|
- if int(userInfo.UserID) == item.AuthorId {
|
|
|
- respItem.IsAuthor = true
|
|
|
- // 是否可以推送消息
|
|
|
- if item.MsgState == 0 {
|
|
|
- respItem.CouldSendMsg = true
|
|
|
- }
|
|
|
- }
|
|
|
- list = append(list, respItem)
|
|
|
-
|
|
|
- }
|
|
|
- err = e
|
|
|
+ }
|
|
|
+ voiceList, e := voice_broadcast.GetPageListByCondition(condition, pars, pageIndex, pageSize)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取语音播报列表失败, Err: " + e.Error())
|
|
|
return
|
|
|
- } else {
|
|
|
- broadList, e := voice_broadcast.GetBroadcastByIdAndPage(pageindex, pagesize, broadcastId)
|
|
|
- if e != nil {
|
|
|
- e = errors.New("获取语音播报列表失败 Err:" + e.Error())
|
|
|
- }
|
|
|
- for _, item := range broadList {
|
|
|
- var respItem response.Broadcast
|
|
|
- respItem = response.Broadcast{
|
|
|
- BroadcastId: item.BroadcastId,
|
|
|
- BroadcastName: item.BroadcastName,
|
|
|
- SectionId: item.SectionId,
|
|
|
- SectionName: item.SectionName,
|
|
|
- VarietyId: item.VarietyId,
|
|
|
- VarietyName: item.VarietyName,
|
|
|
- AuthorId: item.AuthorId,
|
|
|
- Author: item.Author,
|
|
|
- ImgUrl: item.ImgUrl,
|
|
|
- VoiceUrl: item.VoiceUrl,
|
|
|
- VoicePlaySeconds: item.VoicePlaySeconds,
|
|
|
- VoiceSize: item.VoiceSize,
|
|
|
- CreateTime: item.CreateTime,
|
|
|
- IsAuthor: false,
|
|
|
- }
|
|
|
- if int(userInfo.UserID) == item.AuthorId {
|
|
|
- respItem.IsAuthor = true
|
|
|
- }
|
|
|
- list = append(list, respItem)
|
|
|
-
|
|
|
- }
|
|
|
- err = e
|
|
|
+ }
|
|
|
+ listLen := len(voiceList)
|
|
|
+ if listLen == 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // 图片
|
|
|
+ voiceIds := make([]int, 0)
|
|
|
+ for i := 0; i < listLen; i++ {
|
|
|
+ voiceIds = append(voiceIds, voiceList[i].BroadcastId)
|
|
|
+ }
|
|
|
+ imgList, e := voice_broadcast_img.GetVoiceImgListByVoiceIds(voiceIds)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取语音播报列表图片失败, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ imgMap := make(map[int][]*voice_broadcast_img.YbVoiceBroadcastImg, 0)
|
|
|
+ imgListLen := len(imgList)
|
|
|
+ for i := 0; i < imgListLen; i++ {
|
|
|
+ imgMap[imgList[i].BroadcastId] = append(imgMap[imgList[i].BroadcastId], imgList[i])
|
|
|
+ }
|
|
|
+ // 响应数据
|
|
|
+ userId := int(userInfo.UserID)
|
|
|
+ for i := 0; i < listLen; i++ {
|
|
|
+ r := handleBroadcastItem(userId, voiceList[i], imgMap[voiceList[i].BroadcastId])
|
|
|
+ resp = append(resp, r)
|
|
|
+ }
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// GetVoiceAdminByUserInfo 判断当前用户是否为语音管理员
|
|
@@ -226,6 +182,11 @@ func SendBroadcastMsg(broadcastId, userId int) (errMsg string, err error) {
|
|
|
err = errors.New("获取语音播报信息失败, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
+ if broadcast.PublishState != 1 {
|
|
|
+ errMsg = "报告未发布, 不可推送"
|
|
|
+ err = errors.New("报告未发布, 不可推送")
|
|
|
+ return
|
|
|
+ }
|
|
|
if broadcast.AuthorId != userId {
|
|
|
errMsg = "仅语音播报创建人可推送"
|
|
|
err = errors.New("仅语音播报创建人可推送")
|
|
@@ -256,6 +217,144 @@ func SendBroadcastMsg(broadcastId, userId int) (errMsg string, err error) {
|
|
|
return
|
|
|
}
|
|
|
|
|
|
+// CreateVoiceBroadcast 新增语音播报
|
|
|
+func CreateVoiceBroadcast(sectionId, varietyId, authorId, userId int, broadcastName, sectionName, varietyName, author, voiceSeconds, voiceSize, voiceUrl, imgs string) (resp response.Broadcast, err error) {
|
|
|
+ nowTime := time.Now().Local()
|
|
|
+ item := &voice_broadcast.VoiceBroadcast{
|
|
|
+ BroadcastName: broadcastName,
|
|
|
+ SectionId: sectionId,
|
|
|
+ SectionName: sectionName,
|
|
|
+ VarietyId: varietyId,
|
|
|
+ VarietyName: varietyName,
|
|
|
+ AuthorId: authorId,
|
|
|
+ Author: author,
|
|
|
+ VoiceUrl: voiceUrl,
|
|
|
+ VoicePlaySeconds: voiceSeconds,
|
|
|
+ VoiceSize: voiceSize,
|
|
|
+ CreateTime: nowTime.Format(utils.FormatDateTime),
|
|
|
+ ModifyTime: nowTime.Format(utils.FormatDateTime),
|
|
|
+ }
|
|
|
+ // 图片
|
|
|
+ imgList := make([]*voice_broadcast_img.YbVoiceBroadcastImg, 0)
|
|
|
+ if imgs != "" {
|
|
|
+ imgArr := strings.Split(imgs, ",")
|
|
|
+ imgLen := len(imgArr)
|
|
|
+ for i := 0; i < imgLen; i++ {
|
|
|
+ if imgArr[i] == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ imgList = append(imgList, &voice_broadcast_img.YbVoiceBroadcastImg{
|
|
|
+ BroadcastId: item.BroadcastId,
|
|
|
+ ImgUrl: imgArr[i],
|
|
|
+ CreateTime: nowTime,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if e := voice_broadcast.CreateVoiceBroadcastAndImgs(item, imgList); e != nil {
|
|
|
+ err = errors.New("新增语音播报及图片失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp = handleBroadcastItem(userId, item, imgList)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// EditVoiceBroadcast 编辑语音播报
|
|
|
+func EditVoiceBroadcast(broadcastId, sectionId, varietyId, authorId, userId int, broadcastName, sectionName, varietyName, author, voiceSeconds, voiceSize, voiceUrl, imgs string) (resp response.Broadcast, err error) {
|
|
|
+ if broadcastId <= 0 {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item, e := voice_broadcast.GetBroadcastById(broadcastId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("语音播报信息有误")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ nowTime := time.Now().Local()
|
|
|
+ updateCols := []string{"BroadcastName", "SectionId", "SectionName", "VarietyId", "VarietyName", "AuthorId", "Author", "VoiceUrl",
|
|
|
+ "VoicePlaySeconds", "VoiceSize", "ModifyTime"}
|
|
|
+ item.BroadcastName = broadcastName
|
|
|
+ item.SectionId = sectionId
|
|
|
+ item.SectionName = sectionName
|
|
|
+ item.VarietyId = varietyId
|
|
|
+ item.VarietyName = varietyName
|
|
|
+ item.AuthorId = authorId
|
|
|
+ item.Author = author
|
|
|
+ item.VoiceUrl = voiceUrl
|
|
|
+ item.VoicePlaySeconds = voiceSeconds
|
|
|
+ item.VoiceSize = voiceSize
|
|
|
+ item.ModifyTime = nowTime.Format(utils.FormatDateTime)
|
|
|
+ // 图片
|
|
|
+ imgList := make([]*voice_broadcast_img.YbVoiceBroadcastImg, 0)
|
|
|
+ if imgs != "" {
|
|
|
+ imgArr := strings.Split(imgs, ",")
|
|
|
+ imgLen := len(imgArr)
|
|
|
+ for i := 0; i < imgLen; i++ {
|
|
|
+ if imgArr[i] == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ imgList = append(imgList, &voice_broadcast_img.YbVoiceBroadcastImg{
|
|
|
+ BroadcastId: item.BroadcastId,
|
|
|
+ ImgUrl: imgArr[i],
|
|
|
+ CreateTime: nowTime,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if e := voice_broadcast.UpdateVoiceBroadcastAndImgs(item, updateCols, imgList); e != nil {
|
|
|
+ err = errors.New("更新语音播报及图片失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp = handleBroadcastItem(userId, item, imgList)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// PublishVoiceBroadcast 发布语音播报
|
|
|
+func PublishVoiceBroadcast(broadcastId, publishType int, prePublishTime string) (err error) {
|
|
|
+ item, e := voice_broadcast.GetBroadcastById(broadcastId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("语音播报信息有误")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if item.PublishState == 1 {
|
|
|
+ err = errors.New("不可重复发布")
|
|
|
+ return
|
|
|
+ }
|
|
|
+ // publishType: 0-仅发布 1-发布并推送 2-定时发布; 发布类型为定时发送时, 分享图时间取预发布时间
|
|
|
+ updateCols := []string{"ImgUrl", "PublishState", "PublishTime", "PrePublishTime", "ModifyTime"}
|
|
|
+ publishTime := time.Now().Local()
|
|
|
+ if publishType == 2 {
|
|
|
+ item.PublishState = 0
|
|
|
+ item.PrePublishTime = prePublishTime
|
|
|
+ publishTime, e = time.ParseInLocation(utils.FormatDateTime, prePublishTime, time.Local)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("预发布时间有误, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 非定时发布时重置预发布时间
|
|
|
+ item.PublishState = 1
|
|
|
+ item.PublishTime = publishTime.Format(utils.FormatDateTime)
|
|
|
+ item.PrePublishTime = ""
|
|
|
+ }
|
|
|
+ // 分享背景图-取板块的图
|
|
|
+ section, e := voice_section.GetVoiceSectionById(item.SectionId)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取板块信息失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ shareTime := publishTime.Format(utils.FormatDate)
|
|
|
+ shareImg, e := createVoiceBroadcastShareImg(section.ImgUrl, item.SectionName, shareTime)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("生成分享图失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item.ImgUrl = shareImg
|
|
|
+ // 发布
|
|
|
+ if e = item.Update(updateCols); e != nil {
|
|
|
+ err = errors.New("发布语音播报失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
// VoiceBroadcastShareImgPars 语音播报分享图参数
|
|
|
type VoiceBroadcastShareImgPars struct {
|
|
|
BackgroundImg string `json:"background_img"`
|
|
@@ -263,67 +362,109 @@ type VoiceBroadcastShareImgPars struct {
|
|
|
CreateTime string `json:"create_time"`
|
|
|
}
|
|
|
|
|
|
-// UpdateVoiceBroadcastImgUrl 更新历史语音播报分享图
|
|
|
-func UpdateVoiceBroadcastImgUrl() (err error) {
|
|
|
- defer func() {
|
|
|
- if err != nil {
|
|
|
- fmt.Println(err.Error())
|
|
|
- }
|
|
|
- }()
|
|
|
- // 获取语音播报列表
|
|
|
- list, e := voice_broadcast.GetBroadcastList()
|
|
|
+// createVoiceBroadcastShareImg 生成动态分享图
|
|
|
+func createVoiceBroadcastShareImg(baseImg, sectionName, createTime string) (shareImg string, err error) {
|
|
|
+ pars := VoiceBroadcastShareImgPars{
|
|
|
+ BackgroundImg: baseImg,
|
|
|
+ Title: sectionName,
|
|
|
+ CreateTime: createTime,
|
|
|
+ }
|
|
|
+ parsByte, e := json.Marshal(pars)
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ shareImg, e = GetDynamicShareImg(VoiceBroadcastShareImgSource, string(parsByte))
|
|
|
+ if e != nil {
|
|
|
+ err = e
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetVoiceBroadcastDetail 获取语音播报详情
|
|
|
+func GetVoiceBroadcastDetail(broadcastId, userId int) (detail response.Broadcast, err error) {
|
|
|
+ item, e := voice_broadcast.GetBroadcastById(broadcastId)
|
|
|
if e != nil {
|
|
|
- err = errors.New("获取语音播报列表失败")
|
|
|
+ err = errors.New("获取语音播报详情失败, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- // 获取语音播报板块分享图
|
|
|
- sectionList, e := voice_section.GetVoiceSection()
|
|
|
+ // 语音播报图片
|
|
|
+ imgList, e := voice_broadcast_img.GetVoiceImgListByVoiceId(broadcastId)
|
|
|
if e != nil {
|
|
|
- err = errors.New("获取语音播报列表失败")
|
|
|
+ err = errors.New("获取语音播报图片失败, Err: " + e.Error())
|
|
|
return
|
|
|
}
|
|
|
- sectionMap := make(map[int]string, 0)
|
|
|
- sectionNameMap := make(map[int]string, 0)
|
|
|
- for _, s := range sectionList {
|
|
|
- sectionMap[s.SectionId] = s.ImgUrl
|
|
|
- sectionNameMap[s.SectionId] = s.SectionName
|
|
|
+ detail = handleBroadcastItem(userId, item, imgList)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// handleBroadcastItem 语音播报响应数据处理
|
|
|
+func handleBroadcastItem(userId int, item *voice_broadcast.VoiceBroadcast, imgs []*voice_broadcast_img.YbVoiceBroadcastImg) (resp response.Broadcast) {
|
|
|
+ if item == nil {
|
|
|
+ return
|
|
|
}
|
|
|
- // 生成语音分享图并更新
|
|
|
- listLen := len(list)
|
|
|
- fmt.Println("待更新数:", listLen)
|
|
|
- updateCols := []string{"ImgUrl"}
|
|
|
- for i := 0; i < listLen; i++ {
|
|
|
- item := list[i]
|
|
|
- fmt.Println("正在更新-Id:", item.BroadcastId)
|
|
|
- imgUrl := sectionMap[item.SectionId]
|
|
|
- if imgUrl == "" {
|
|
|
- fmt.Println("背景图为空-Id:", item.BroadcastId)
|
|
|
- continue
|
|
|
+ resp.BroadcastId = item.BroadcastId
|
|
|
+ resp.BroadcastName = item.BroadcastName
|
|
|
+ resp.SectionId = item.SectionId
|
|
|
+ resp.SectionName = item.SectionName
|
|
|
+ resp.VarietyId = item.VarietyId
|
|
|
+ resp.VarietyName = item.VarietyName
|
|
|
+ resp.AuthorId = item.AuthorId
|
|
|
+ resp.Author = item.Author
|
|
|
+ resp.ImgUrl = item.ImgUrl
|
|
|
+ resp.VoiceUrl = item.VoiceUrl
|
|
|
+ resp.VoicePlaySeconds = item.VoicePlaySeconds
|
|
|
+ resp.VoiceSize = item.VoiceSize
|
|
|
+ resp.CreateTime = item.CreateTime
|
|
|
+ resp.ModifyTime = item.ModifyTime
|
|
|
+ resp.PublishState = item.PublishState
|
|
|
+ resp.PublishTime = item.PublishTime
|
|
|
+ resp.PrePublishTime = item.PrePublishTime
|
|
|
+ // 是否为作者、是否可推送消息
|
|
|
+ if userId == item.AuthorId {
|
|
|
+ resp.IsAuthor = true
|
|
|
+ if item.MsgState == 0 {
|
|
|
+ resp.CouldSendMsg = true
|
|
|
}
|
|
|
- sectionName := sectionNameMap[item.SectionId]
|
|
|
- timeDate := item.CreateTime[0:10]
|
|
|
- pars := VoiceBroadcastShareImgPars{
|
|
|
- BackgroundImg: imgUrl,
|
|
|
- Title: sectionName,
|
|
|
- CreateTime: timeDate,
|
|
|
- }
|
|
|
- parsByte, e := json.Marshal(pars)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("分享图参数有误")
|
|
|
- return
|
|
|
- }
|
|
|
- shareImg, e := GetDynamicShareImg(VoiceBroadcastShareImgSource, string(parsByte))
|
|
|
- //fmt.Println(shareImg)
|
|
|
- if e != nil {
|
|
|
- err = errors.New("生成分享图失败")
|
|
|
- return
|
|
|
+ }
|
|
|
+ imgLen := len(imgs)
|
|
|
+ imgArr := make([]string, 0)
|
|
|
+ for i := 0; i < imgLen; i++ {
|
|
|
+ imgArr = append(imgArr, imgs[i].ImgUrl)
|
|
|
+ }
|
|
|
+ resp.Imgs = imgArr
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetMyVoiceBroadcastListCount 获取我的语音播报列表计数
|
|
|
+func GetMyVoiceBroadcastListCount(authorId, sectionId int) (resp response.BroadcastListStatusCount, err error) {
|
|
|
+ condition := ` 1=1 `
|
|
|
+ var pars []interface{}
|
|
|
+ // 我的-非我的只能看到已发布
|
|
|
+ if authorId > 0 {
|
|
|
+ condition += ` AND author_id = ?`
|
|
|
+ pars = append(pars, authorId)
|
|
|
+ }
|
|
|
+ // 板块
|
|
|
+ if sectionId > 0 {
|
|
|
+ condition += ` AND section_id = ?`
|
|
|
+ pars = append(pars, sectionId)
|
|
|
+ }
|
|
|
+ counts, e := voice_broadcast.GetVoiceBroadcastListStatusCount(condition, pars)
|
|
|
+ if e != nil {
|
|
|
+ err = errors.New("获取语音播报列表计数失败, Err: " + e.Error())
|
|
|
+ return
|
|
|
+ }
|
|
|
+ for _, v := range counts {
|
|
|
+ if v.State == 0 {
|
|
|
+ resp.Unpublished = v.Num
|
|
|
+ continue
|
|
|
}
|
|
|
- item.ImgUrl = shareImg
|
|
|
- if e = item.Update(updateCols); e != nil {
|
|
|
- err = errors.New("更新语音播报失败")
|
|
|
- return
|
|
|
+ if v.State == 1 {
|
|
|
+ resp.Published = v.Num
|
|
|
}
|
|
|
- fmt.Println("更新成功-Id:", item.BroadcastId)
|
|
|
}
|
|
|
+ resp.All = resp.Unpublished + resp.Published
|
|
|
return
|
|
|
-}
|
|
|
+}
|