Browse Source

no message

xingzai 1 year ago
parent
commit
996e0ee2f8
3 changed files with 143 additions and 0 deletions
  1. 122 0
      controllers/cygx/activity_video.go
  2. 12 0
      models/cygx/activity_video.go
  3. 9 0
      routers/commentsRouter.go

+ 122 - 0
controllers/cygx/activity_video.go

@@ -553,3 +553,125 @@ func (this *ActivityVideoCoAntroller) ActivityVoiceAndVideoList() {
 	br.Msg = "获取成功"
 	br.Data = resp
 }
+
+// @Title 留言列表详情
+// @Description 获取留言列表详情接口
+// @Param   ActivityId   query   int  true     "活动ID"
+// @Param   IsExport   query   bool  false       "是否导出excel,默认是false"
+// @Success 200 {object} cygx.ArticleCommentListResp
+// @router /activity_voice_and_video/commentList [get]
+func (this *ActivityVideoCoAntroller) VoiceAndVideoCommentList() {
+	br := new(models.BaseResponse).Init()
+	defer func() {
+		this.Data["json"] = br
+		this.ServeJSON()
+	}()
+	sysUser := this.SysUser
+	if sysUser == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录,SysUser Is Empty"
+		return
+	}
+	activityId, _ := this.GetInt("ActivityId")
+	//是否导出报表
+	isExport, _ := this.GetBool("IsExport")
+	var condition string
+	var pars []interface{}
+
+	videoInfo, _ := cygx.GetCygxActivityVideoReqDetailByVideoId(activityId)
+	if videoInfo != nil {
+		condition += `  AND activity_id =  ? AND video_id = ?  `
+		pars = append(pars, videoInfo.ActivityId, videoInfo.VideoId)
+	} else {
+		videoInfo, _ := cygx.GetMicroRoadshowVoiceById(activityId)
+		if videoInfo == nil {
+			br.Msg = "操作失败"
+			br.ErrMsg = "音频ID错误"
+			return
+		}
+		condition += `  AND activity_voice_id = ? `
+		pars = append(pars, videoInfo.ActivityVoiceId)
+	}
+	list, err := cygx.GetArticleCommentListSearch(condition, pars)
+	if err != nil {
+		br.Msg = "获取失败"
+		br.ErrMsg = "获取失败,Err:" + err.Error()
+		return
+	}
+
+	resp := new(cygx.ArticleCommentListResp)
+	resp.List = list
+	//导出excel
+	if isExport {
+		VoiceAndVideoCommentListExport(this, resp, br)
+		return
+	}
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "获取成功"
+	br.Data = resp
+}
+
+// MorningMeetingHistoryListExport 导出Excel
+func VoiceAndVideoCommentListExport(this *ActivityVideoCoAntroller, resp *cygx.ArticleCommentListResp, br *models.BaseResponse) {
+	//创建excel
+	dir, err := os.Executable()
+	exPath := filepath.Dir(dir)
+	downLoadnFilePath := exPath + "/" + time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	xlsxFile := xlsx.NewFile()
+	if err != nil {
+		br.Msg = "生成文件失败"
+		br.ErrMsg = "生成文件失败"
+		return
+	}
+	style := xlsx.NewStyle()
+	alignment := xlsx.Alignment{
+		Horizontal: "center",
+		Vertical:   "center",
+		WrapText:   true,
+	}
+	style.Alignment = alignment
+	style.ApplyAlignment = true
+	sheet, err := xlsxFile.AddSheet("阅读明细")
+	if err != nil {
+		br.Msg = "新增Sheet失败"
+		br.ErrMsg = "新增Sheet失败,Err:" + err.Error()
+		return
+	}
+	//标头
+	rowTitle := sheet.AddRow()
+	cellA := rowTitle.AddCell()
+	cellA.Value = "姓名"
+	cellB := rowTitle.AddCell()
+	cellB.Value = "公司名称"
+	cellC := rowTitle.AddCell()
+	cellC.Value = "留言"
+	cellD := rowTitle.AddCell()
+	cellD.Value = "提交时间"
+
+	for _, item := range resp.List {
+		row := sheet.AddRow()
+		cellA := row.AddCell()
+		cellA.Value = item.RealName
+		cellB := row.AddCell()
+		cellB.Value = item.CompanyName
+		cellC := row.AddCell()
+		cellC.Value = item.Content
+		cellD := row.AddCell()
+		cellD.Value = item.CreateTime
+	}
+	err = xlsxFile.Save(downLoadnFilePath)
+	if err != nil {
+		br.Msg = "保存文件失败"
+		br.ErrMsg = "保存文件失败"
+		return
+	}
+	downloadFileName := time.Now().Format(utils.FormatDateTimeUnSpace) + ".xlsx"
+	this.Ctx.Output.Download(downLoadnFilePath, downloadFileName)
+	defer func() {
+		os.Remove(downLoadnFilePath)
+	}()
+	br.Ret = 200
+	br.Success = true
+	br.Msg = "导出成功"
+}

+ 12 - 0
models/cygx/activity_video.go

@@ -97,6 +97,18 @@ func GetActivityVideoCount(condition string, pars []interface{}) (count int, err
 	return
 }
 
+// 获取数量
+func GetActivityVideoCountByActivityId(activityId int) (count int, err error) {
+	o := orm.NewOrmUsingDB("hz_cygx")
+	sqlCount := ` SELECT
+				COUNT( 1 ) AS count 
+			FROM
+   				JOIN cygx_activity_video
+			WHERE activity_id = ? `
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
 // 列表
 func GetActivityVideoListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivityVideoListResp, err error) {
 	o := orm.NewOrmUsingDB("hz_cygx")

+ 9 - 0
routers/commentsRouter.go

@@ -1258,6 +1258,15 @@ func init() {
             Filters: nil,
             Params: nil})
 
+    beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityVideoCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityVideoCoAntroller"],
+        beego.ControllerComments{
+            Method: "VoiceAndVideoCommentList",
+            Router: `/activity_voice_and_video/commentList`,
+            AllowHTTPMethods: []string{"get"},
+            MethodParams: param.Make(),
+            Filters: nil,
+            Params: nil})
+
     beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityVideoCoAntroller"] = append(beego.GlobalControllerRouter["hongze/hz_crm_api/controllers/cygx:ActivityVideoCoAntroller"],
         beego.ControllerComments{
             Method: "ActivityVoiceAndVideoList",