package cygx import ( "encoding/json" "fmt" "github.com/rdlucklib/rdluck_tools/paging" "github.com/tealeg/xlsx" "hongze/hz_crm_api/controllers" "hongze/hz_crm_api/models" "hongze/hz_crm_api/models/company" "hongze/hz_crm_api/models/cygx" "hongze/hz_crm_api/models/system" "hongze/hz_crm_api/services" cygxService "hongze/hz_crm_api/services/cygx" "hongze/hz_crm_api/services/elastic" "hongze/hz_crm_api/utils" "os" "path/filepath" "strconv" "strings" "time" ) // 纪要管理 type SummaryManage struct { controllers.BaseAuthController } // @Title 文章内容的保存与发布 // @Description 文章内容的保存与发布接口 // @Param request body cygx.SummaryManageAddRep true "type json string" // @Success 200 操作成功 // @router /summaryManage/PreserveAndPublish [post] func (this *SummaryManage) PreserveAndPublish() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req cygx.SummaryManageAddRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } if req.Title == "" { br.Msg = "标题不可为空" br.ErrMsg = "标题不可为空" return } if req.Abstract == "" { br.Msg = "摘要不可为空" br.ErrMsg = "摘要不可为空" return } if req.PublishDate == "" { br.Msg = "发布时间不可为空" return } var articleIdNew int //最新的文章id var haveResearch bool var permissionName string industryName := req.IndustryName subjectName := req.SubjectName publishDate := req.PublishDate reportLink := req.ReportLink chartPermissionIds := "31" //31研选 industrialManagementIds := req.IndustrialManagementIds industrialSubjectIds := req.IndustrialSubjectIds articleId := req.ArticleId articleTypeId := req.ArticleTypeId // 产业ID校验 industryIds := make([]int, 0) industrialManagementIdList := strings.Split(industrialManagementIds, ",") for _, v := range industrialManagementIdList { i, err := strconv.Atoi(v) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "产业ID不规范,Err:" + err.Error() + industrialManagementIds return } industryIds = append(industryIds, i) } if industrialSubjectIds != "" { industrialSubjectIdList := strings.Split(industrialSubjectIds, ",") for _, v := range industrialSubjectIdList { _, err := strconv.Atoi(v) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "标的ID不规范,Err:" + err.Error() + industrialSubjectIds return } } } chartPermissionIdsList := strings.Split(chartPermissionIds, ",") for _, v := range chartPermissionIdsList { chartPermissionId, err := strconv.Atoi(v) if err != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败,Err:" + err.Error() return } charInfo, errCategory := cygx.GetCategoryInfoById(chartPermissionId) if errCategory != nil { br.Msg = "获取品种信息失败" br.ErrMsg = "获取品种信息失败,Err:" + errCategory.Error() return } if strings.Contains(charInfo.PermissionName, "研选") { haveResearch = true } permissionName += charInfo.PermissionName + "," } permissionName = strings.TrimRight(permissionName, ",") if articleId == 0 { maxArticleIdArticleInfo, errMax := cygx.GetMaxArticleIdInfo() if errMax != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败,Err:" + errMax.Error() return } if maxArticleIdArticleInfo.ArticleId < utils.SummaryArticleId { articleIdNew = utils.SummaryArticleId } else { articleIdNew = maxArticleIdArticleInfo.ArticleId + 1 } } //处理文章类型信息 articleTypeInfo, err := cygx.GetCygxArticleTypeDetailById(articleTypeId) if err != nil { br.Msg = "请选择报告类型" br.ErrMsg = "获取报告类型信息失败,Err:" + err.Error() return } //处理作者内容的格式信息 department := req.SellerAndMobile itemDepartment := new(cygx.CygxArticleDepartment) if !strings.Contains(department, "-") { br.Msg = "作者格式错误" return } slice := strings.Split(department, "-") if len(slice) < 2 { br.Msg = "作者格式错误" return } strnum := strings.Index(department, "-") itemDepartment.NickName = department[0:strnum] itemDepartment.CreateTime = time.Now() itemDepartment.Remark = department[strnum+1:] itemDepartment.Content = req.SellerAndMobile remarks := itemDepartment.Remark remarks = strings.Replace(remarks, ",", "", -1) remarks = strings.Replace(remarks, ",", "", -1) remarks = strings.Replace(remarks, " ", "", -1) itemDepartment.Remarks = remarks total, _ := cygx.GetArticleDepartmentCount(itemDepartment.NickName, itemDepartment.Remarks) var newDepartmentId int64 if total == 0 { detail, err := cygx.GetCygxConfigDetailByCode("department_img_url") if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } sliceDepart := strings.Split(detail.ConfigValue, "{|}") totalDepart, err := cygx.GetArticleDepartmentCountAll() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } itemDepartment.ImgUrl = sliceDepart[totalDepart%10] //避免代码冗余,放弃插入事务处理 newDepartmentId, err = cygx.AddCygxArticleDepartment(itemDepartment) if err != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error() return } } else { departmentDetail, err := cygx.GetArticleDepartmentDateil(itemDepartment.NickName, itemDepartment.Remarks) if err != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败作者信息查询错误,Err:" + err.Error() return } newDepartmentId = int64(departmentDetail.DepartmentId) } expertNumStr, expertContentStr, interviewDateStr, fileLink := cygx.BodyAnalysis(req.Body) item := new(cygx.CygxArticle) item.AdminId = AdminUser.AdminId item.AdminName = AdminUser.RealName item.Title = req.Title item.Body = req.Body item.BodyText, _ = cygxService.GetReportContentTextSubNew(req.Body) item.Abstract = req.Abstract item.CategoryName = permissionName item.ArticleId = articleId item.CreateDate = time.Now() item.LastUpdatedTime = time.Now() if articleTypeInfo.IsSendEs == 1 { item.IsSummary = 1 } else { item.IsReport = 1 } item.Source = 1 item.ArticleIdMd5 = utils.MD5(strconv.Itoa(articleIdNew)) item.UpdateFrequency = "unknow" item.SellerAndMobile = req.SellerAndMobile item.ExpertBackground = expertContentStr item.ExpertNumber = expertNumStr item.InterviewDate = interviewDateStr item.FileLink = fileLink item.ChartPermissionIds = chartPermissionIds item.DepartmentId = int(newDepartmentId) item.ArticleTypeId = articleTypeId item.ArticleTypeName = articleTypeInfo.ArticleTypeName publishDateSlice := strings.Split(publishDate, " ") //过滤前端传过来的时分秒 item.PublishDate = utils.StrTimeToTime(publishDateSlice[0] + " 00:00:00") item.ReportLink = reportLink if haveResearch { item.Department = "机构投资者" } else { item.Department = "弘则权益研究" br.Msg = "请选择研选行业" return } charInfo, err := cygx.GetCategoryInfoByName(utils.CHART_PERMISSION_NAME_MF_YANXUAN) if err != nil { br.Msg = "操作失败" br.ErrMsg = "获取所属行业信息失败,Err:" + err.Error() return } if req.DoType == 1 { item.PublishStatus = 1 } //industrialManagementId, _ := strconv.Atoi(industrialManagementIds) //industrialDetail, _ := cygx.GetIndustrialManagemenDetailById(industrialManagementId) var errArt error if articleId == 0 { item.ArticleId = articleIdNew //需求修改纪要的新增与修改与报告一致 _, err := cygx.AddAReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, itemDepartment, industrialManagementIds, industrialSubjectIds) errArt = err if errArt == nil { //articleInfo, err := cygx.GetArticleIdInfoBySummaryManageIdEdit(int(artNewId)) if err == nil && req.DoType == 1 { go cygxService.DoArticleOnenIdWxTemplateMsg(articleIdNew, 1) } } } else { articleInfo, errInfo := cygx.GetArticleIdInfoByArticleId(articleId) if articleInfo == nil { br.Msg = "文章不存在" return } if errInfo != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败,Err:" + errInfo.Error() return } if item.PublishStatus == 0 { item.PublishStatus = articleInfo.PublishStatus } item.ArticleId = articleId err := cygx.EditReportrticle(item, charInfo.ChartPermissionId, industryName, subjectName, articleInfo.PublishStatus, itemDepartment, industrialManagementIds, industrialSubjectIds) errArt = err if errArt == nil && req.DoType == 1 { go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1) } } if errArt != nil { br.Msg = "发布失败" br.ErrMsg = "发布失败,Err:" + errArt.Error() return } // 查研观向7.4-这里暂时注释掉, 目前article和industry有关联表处理, 此处应该是没有在用了 //var subjectIds string //subjectIds, _ = cygx.GetSubjectIds(articleId) //{|1|}表示报告类型,{|2|}表示纪要类型 //cygx.UpdateSubjecIds(subjectIds+"—"+strconv.Itoa(industrialDetail.IndustrialManagementId)+"{|2|}", industrialDetail.IndustrialManagementId, articleId) if item.PublishStatus == 1 && articleTypeInfo.IsSendEs == 1 { services.EsAddOrEditData(item) } ////同步数据到最新表 //if req.ArticleId == 0 { // if item.PublishStatus == 1 { // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime)) // } //} else { // if item.PublishStatus == 1 { // go cygxService.UpdateResourceData(item.ArticleId, "article", "update", time.Now().Format(utils.FormatDateTime)) // } // if req.DoType == 1 { // go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime)) // } //} if len(industryIds) > 0 { go cygxService.UpdateIndustryLayoutTime(industryIds, false) // 查研观向7.4-更新产业布局时间 go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包 } go elastic.AddComprehensiveArticle(item.ArticleId) // ES添加文章:报告、纪要 go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表 go cygxService.MakeArticleMomentsImg(item.ArticleId) //生成文章分享到朋友圈的图片 br.Ret = 200 br.Success = true br.Msg = "操作成功" br.IsAddLog = true } // @Title 文章的发布与取消发布 // @Description 文章的发布与取消发布接口 // @Param request body cygx.SummaryManageIdRep true "type json string" // @Success 200 操作成功 // @router /summaryManage/PublishAndCancel [post] func (this *SummaryManage) PublishAndCancel() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser indexName := utils.IndexName if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req cygx.SummaryManageIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } articleId := req.ArticleId item := new(cygx.CygxArticle) articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "纪要ID错误" return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } item.ArticleId = articleId item.Title = articleInfo.Title item.BodyText = articleInfo.BodyText item.Body = articleInfo.Body item.PublishDate = articleInfo.PublishDate item.ExpertBackground = articleInfo.ExpertBackground item.CategoryId = articleInfo.CategoryId //item.Annotation, _ = GetReportContentTextSubNew(v.Annotation) //item.Abstract, _ = GetReportContentTextSubNew(v.Abstract) if articleInfo.PublishStatus == 0 { item.PublishStatus = 1 item.AdminId = AdminUser.AdminId item.AdminName = AdminUser.RealName services.EsAddOrEditData(item) //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime)) } else { item.AdminId = articleInfo.AdminId item.AdminName = articleInfo.AdminName item.PublishStatus = 0 services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId)) //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime)) } err = cygx.PublishAndCancel(item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } //专项调研类型的报告单独走发送 if articleInfo.SubCategoryName == "专项调研" { if item.PublishStatus == 1 { cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId) } } else { if item.PublishStatus == 1 { articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId) if articleIndustrial.ArticleId > 0 { go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1) } go elastic.AddComprehensiveIndustrialSource("Yx", item.ArticleId) // 查研观向10.6 更新搜索引擎的产业资源包 } } go elastic.AddComprehensiveArticle(articleId) // ES添加文章:报告、纪要 go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表 br.Ret = 200 br.Success = true br.Msg = "操作成功" br.IsAddLog = true } // @Title 文章详情 // @Description 获取文章详情接口 // @Param ArticleId query int true "文章ID" // @Success Ret=200 {object} cygx.SummaryManageEditDetail // @router /summaryManage/detail [get] func (this *SummaryManage) Detail() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } articleId, _ := this.GetInt("ArticleId") if articleId < 1 { br.Msg = "请输入文章ID" return } articleInfo, err := cygx.GetArticleIdInfoByreportIdEdit(articleId) if err != nil { br.Msg = "文章内容不存在" br.ErrMsg = "纪要ID错误,Err:" + err.Error() return } detail, _ := cygx.GetArticleDepartmentDateilByDepartmentId(articleInfo.DepartmentId) industrialList, err := cygx.GetIndustrialArticleGroupManagementList(articleInfo.ArticleId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "获取活动关联的产业列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId) return } subjectList, err := cygx.GetSubjectArticleGroupManagementList(articleInfo.ArticleId) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取信息失败" br.ErrMsg = "获取活动关联的标的列表信息失败,Err:" + err.Error() + "activityId:" + strconv.Itoa(articleInfo.ArticleId) return } articleInfo.ListIndustrial = industrialList articleInfo.ListSubject = subjectList resp := cygx.ArticleDetailResp{ ArticleId: articleInfo.ArticleId, Title: articleInfo.Title, Abstract: articleInfo.Abstract, Body: articleInfo.Body, PublishStatus: articleInfo.PublishStatus, PublishDate: articleInfo.PublishDate, CreateDate: articleInfo.CreateDate, LastUpdatedTime: articleInfo.LastUpdatedTime, ArticleIdMd5: articleInfo.ArticleIdMd5, SellerAndMobile: articleInfo.SellerAndMobile, SubjectName: articleInfo.SubjectName, IndustryName: articleInfo.IndustryName, DepartmentId: articleInfo.DepartmentId, ChartPermissionIds: articleInfo.ChartPermissionIds, ArticleTypeId: articleInfo.ArticleTypeId, ArticleTypeName: articleInfo.ArticleTypeName, ListIndustrial: articleInfo.ListIndustrial, ListSubject: articleInfo.ListSubject, ReportLink: articleInfo.ReportLink, ImgUrl: detail.ImgUrl, NickName: detail.NickName, } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 删除纪要 // @Description 删除纪要接口 // @Param request body cygx.SummaryManageIdRep true "type json string" // @Success Ret=200 // @router /summaryManage/delete [post] func (this *SummaryManage) Delete() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() sysUser := this.SysUser indexName := utils.IndexName if sysUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } var req cygx.SummaryManageIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } articleId := req.ArticleId if articleId < 1 { br.Msg = "请输入产业ID" return } articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "纪要ID错误" return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId)) err = cygx.DeleteArticleReport(articleInfo.ArticleId) if err != nil { br.Msg = "删除信息失败" br.ErrMsg = "删除信息失败,Err:" + err.Error() return } //go cygxService.UpdateResourceData(articleInfo.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime)) go cygxService.UpdateArticleResourceData(articleInfo.ArticleId) //写入首页最新 cygx_resource_data 表 br.Ret = 200 br.Success = true br.Msg = "已删除" br.IsAddLog = true } // @Title 纪要列表 // @Description 获取纪要列表接口 // @Param PageSize query int true "每页数据条数" // @Param CurrentIndex query int true "当前页页码,从1开始" // @Param PublishStatus query int true "发布状态 ,0未发布,1已发布,传2查询所有" // @Param CategoryName query string true "行业名称" // @Param StartDate query string true "开始时间 ,列如2021-03-06 " // @Param EndDate query string true "结束时间,列如2021-03-06 " // @Param KeyWord query string true "搜索关键词" // @Param Label query string true "搜索报告标签" // @Param NickName query string true "作者昵称" // @Param Departmentİd query int false "作者İd" // @Param ArticleTypeId query int false `"文章类型ID" // @Success 200 {object} cygx.GetSummaryManageListRep // @router /summaryManage/list [get] func (this *SummaryManage) SummaryManageList() { 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 } pageSize, _ := this.GetInt("PageSize") currentIndex, _ := this.GetInt("CurrentIndex") publishStatus, _ := this.GetInt("PublishStatus") categoryName := this.GetString("CategoryName") startDate := this.GetString("StartDate") endDate := this.GetString("EndDate") keyWord := this.GetString("KeyWord") label := this.GetString("Label") nickName := this.GetString("NickName") departmentİd, _ := this.GetInt("Departmentİd") articleTypeId, _ := this.GetInt("ArticleTypeId") resp := new(cygx.GetSummaryManageListRep) var startSize int if pageSize <= 0 { pageSize = utils.PageSize20 } if currentIndex <= 0 { currentIndex = 1 } startSize = utils.StartIndex(currentIndex, pageSize) var condition string var pars []interface{} condition += ` WHERE art.article_type_id >0 ` if articleTypeId > 0 { condition += ` AND art.article_type_id = ` + strconv.Itoa(articleTypeId) } if keyWord != "" { condition += ` AND (art.title LIKE '%` + keyWord + `%' ) ` } if nickName != "" { condition += ` AND (art.seller_and_mobile LIKE '%` + nickName + `%' ) ` } if departmentİd > 0 { condition += ` AND art.department_id = ` + strconv.Itoa(departmentİd) } //行业名称 if categoryName != "" { condition += ` AND art.category_name LIKE '%` + categoryName + `%' ` } if startDate != "" { condition += ` AND art.publish_date >= ` + "'" + startDate + " 00:00:00'" } if endDate != "" { condition += ` AND art.publish_date <= ` + "'" + endDate + " 23:59:59'" } if startDate != "" || endDate != "" { condition += ` AND art.publish_status =1 ` } if publishStatus == 0 || publishStatus == 1 { condition += ` AND art.publish_status = ` + strconv.Itoa(publishStatus) } //如果标签列表不为空则作以下关联搜索 if label != "" { managementIds, err := cygx.GetManagementIdsByNameLike(label) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取产业信息失败,Err:" + err.Error() return } subjectIds, err := cygx.GetIndustrialSubjectIdsByNameLike(label) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取标的信息失败,Err:" + err.Error() return } var articleIdmanagement string var articleIdsubject string var articleIds string if managementIds != "" { articleIdmanagement, err = cygx.GetArticleIdsByIndustrialManagementId(managementIds) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error() return } } if subjectIds != "" { articleIdsubject, err = cygx.GetArticleIdsBySubjectId(subjectIds) if err != nil { br.Msg = "获取信息失败" br.ErrMsg = "获取活动ID信息失败,Err:" + err.Error() return } } if articleIdmanagement != "" && articleIdsubject != "" { articleIds = articleIdmanagement + "," + articleIdsubject } else if articleIdmanagement != "" && articleIdsubject == "" { articleIds = articleIdmanagement } else if articleIdmanagement == "" && articleIdsubject != "" { articleIds = articleIdsubject } if articleIds != "" { condition += ` AND art.article_id IN (` + articleIds + `)` } else { // 如果标签关联的报告为空,那么就直接返回空 page := paging.GetPaging(currentIndex, pageSize, 0) resp.List = make([]*cygx.CygxArticleList, 0) resp.Paging = page br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp return } } total, err := cygx.GetASummaryManageCount(condition, pars) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } condition += ` GROUP BY art.article_id ` condition += ` ORDER BY art.top_time DESC , art.publish_date DESC ` list, errList := cygx.GetSummaryManageList(condition, pars, startSize, pageSize) if errList != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errList.Error() return } var articleIdStr string for _, v := range list { articleIdStr += strconv.Itoa(v.ArticleId) + "," } articleIdStr = strings.TrimRight(articleIdStr, ",") // 查研观向7.4-报告关联多个产业 mapIndustrial := make(map[int]string) mapSubject := make(map[string]string) if articleIdStr != "" { industrialList, err := cygx.GetIndustrialArticleGroupListByarticleIds(articleIdStr) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,GetIndustrialArticleGroupListByarticleIds Err:" + err.Error() return } subjectList, err := cygx.GetSubjectArticleGroupListByarticleIds(articleIdStr) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,GetSubjectArticleGroupListByarticleIds Err:" + err.Error() return } //合并活动对应的多个标的 for _, v := range subjectList { mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] += v.SubjectName + "/" } //活动对应的产业 for _, v := range industrialList { var labelSubject string labelSubject = mapSubject[fmt.Sprint(v.ArticleId, "_", v.IndustrialManagementId)] if labelSubject != "" { mapIndustrial[v.ArticleId] += v.IndustryName + "--" + strings.TrimRight(labelSubject, "/") + "," } else { mapIndustrial[v.ArticleId] += v.IndustryName + "," } } } for k, v := range list { if v.PublishStatus == 0 { list[k].PublishDate = "" } else { list[k].PublishDate = utils.TimeRemoveHms2(v.PublishDate) } if mapIndustrial[v.ArticleId] != "" { list[k].IndustryName = strings.TrimRight(mapIndustrial[v.ArticleId], ",") } } page := paging.GetPaging(currentIndex, pageSize, total) resp.List = list resp.Paging = page br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 敏捷搜索关键词的列表 // @Description 获取敏捷搜索关键词的列表接口 // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp // @router /summaryManage/fastSearchKeWord [get] func (this *SummaryManage) FastSearch() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } resp := new(cygx.SummaryFastsearchKeywordsListResp) list, err := cygx.GetSummaryFastsearchKeywordsList() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 新增和修改敏捷搜索关键词的列表 // @Description 新增和修改敏捷搜索关键词的列表接口 // @Param request body cygx.SummaryFastsearchKeywordsResp true "type json string" // @Success Ret=200 // @router /summaryManage/editFastSearchKeWord [post] func (this *SummaryManage) EditFastSearch() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } req := new(cygx.SummaryFastsearchKeywordsResp) err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } keyWord := req.KeyWord slicekeyWord := strings.Split(keyWord, ",") var items []*cygx.CygxSummaryFastsearchKeywords for _, v := range slicekeyWord { var item = new(cygx.CygxSummaryFastsearchKeywords) item.CreateTime = time.Now() item.KeyWord = v items = append(items, item) fmt.Println(v) } _, err = cygx.AddSummaryFastsearchKeywords(items) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "操作成功" } // @Title 永续客户是否展示 // @Description 获取永续客户是否展示详情接口 // @Success 200 {object} cygx.SummaryFastsearchKeywordsListResp // @router /summaryManage/sustainableDetail [get] func (this *SummaryManage) Sustainable() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } detail, err := cygx.GetCygxConfigDetail() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } if detail.ConfigValue == "1" { detail.OperationButton = true } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = detail } // @Title 修改永续客户是否展示 // @Description 修改永续客户是否展示接口 // @Success Ret=200 // @router /summaryManage/sustainableEdit [post] func (this *SummaryManage) EditSustainable() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" br.Ret = 408 return } var newValue int detail, err := cygx.GetCygxConfigDetail() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } if detail.ConfigValue == "1" { newValue = 0 } else { newValue = 1 } err = cygx.CygxConfigUpdate(newValue) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "操作成功" } // @Title 提问列表详情 // @Description 获取提问列表详情接口 // @Param ArticleId query int true "文章ID" // @Success 200 {object} cygx.ActivityHelpAskListResp // @router /summaryManage/askList [get] func (this *SummaryManage) AskList() { 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 } articleId, _ := this.GetInt("ArticleId") articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "报告ID错误" return } list, err := cygx.GetArticleAskList(articleInfo.ArticleId) resp := new(cygx.ArticleAskListResp) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 提问详情excel表格下载 // @Description 提问详情excel表格下载接口 // @Param SummaryManageId query int true "纪要ID" // @Success 200 导出成功 // @router /summaryManage/askListExport [get] func (this *SummaryManage) AskListExport() { 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 } articleId, _ := this.GetInt("ArticleId") articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "报告ID错误" return } list, err := cygx.GetArticleAskList(articleInfo.ArticleId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } //创建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 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 } randStr := time.Now().Format(utils.FormatDateTimeUnSpace) downloadFileName := "问题列表" + randStr + ".xlsx" this.Ctx.Output.Download(downLoadnFilePath, downloadFileName) defer func() { os.Remove(downLoadnFilePath) }() br.Success = true br.Ret = 200 br.Msg = "导出成功" } // @Title 作者关注详情 // @Description 获取作者关注详情列表接口 // @Param DepartmentId query int true "作者ID" // @Success 200 {object} cygx.GetFailSignupListRep // @router /summaryManage/department/followList [get] func (this *SummaryManage) FepartmentfollowList() { 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 } departmentId, _ := this.GetInt("DepartmentId") detail, _ := cygx.GetArticleDepartmentDateilById(departmentId) if detail == nil { br.Msg = "作者不存在" br.ErrMsg = "获取信息失败,Err:DepartmentId:" + strconv.Itoa(departmentId) return } list, err := cygx.GetCygxDepartmentFllowList(departmentId) resp := new(cygx.CygxDepartmentFllowRep) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取列表失败,Err:" + err.Error() return } resp.NickName = detail.Content resp.FllowNum = len(list) resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 文章收藏详情 // @Description 获取文章收藏详情列表接口 // @Param ArticleId query int true "文章ID" // @Success 200 {object} cygx.GetFailSignupListRep // @router /summaryManage/articleCollection [get] func (this *SummaryManage) ArticleCollection() { 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 } articleId, _ := this.GetInt("ArticleId") _, err := cygx.GetArticleIdInfoByArticleId(articleId) if err != nil { br.Msg = "报告不存在" br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId) return } list, err := cygx.GetCygxArticleCollectionList(articleId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取列表失败,Err:" + err.Error() return } //获取对应销售名称 if len(list) > 0 { var companyIds []int for _, v := range list { companyIds = append(companyIds, v.CompanyId) } listCompanyProduct, err := company.GetCompanyProductListByCompanyIds(companyIds, 2) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取销售列表失败,Err:" + err.Error() return } mapSellName := make(map[int]string) for _, v := range listCompanyProduct { mapSellName[v.CompanyId] = v.SellerName } for _, v := range list { v.SellerName = mapSellName[v.CompanyId] } } br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = list } // @Title 阅读明细下载 // @Description 获取阅读明细下载接口 // @Param ArticleId query int true "文章ID" // @Success 200 导出成功 // @router /summaryManage/articleHistoryExport [get] func (this *SummaryManage) ArticleHistoryExport() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,SysUser Is Empty" return } articleId, _ := this.GetInt("ArticleId") articleInfo, err := cygx.GetArticleIdInfoByArticleId(articleId) if err != nil { br.Msg = "报告不存在" br.ErrMsg = "查询失败,Err:" + err.Error() + strconv.Itoa(articleId) return } resp := new(cygx.CanDownload) adminInfo, errAdmin := system.GetSysUserById(AdminUser.AdminId) if errAdmin != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + errAdmin.Error() return } if adminInfo.Role == "admin" || adminInfo.Role == "researcher" || adminInfo.RealName == "汪洋" { resp.IsCanDownload = true } var condition string if resp.IsCanDownload == false { //权益申请销售只能看到自己名下的客户的申请 companyIds, err := cygxService.GetAdminLookUserCompanyIds(AdminUser) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,GetAdminLookUserCompanyIds Err:" + err.Error() return } var companyIdstr []string for _, v := range companyIds { companyIdstr = append(companyIdstr, strconv.Itoa(v)) } condition = ` AND h.company_id IN (` + strings.Join(companyIdstr, ",") + `) ` } mapMobileSellWithUser := make(map[string]string) if condition != "" { mobileList, err := cygx.GetSellerUserMobileList(condition) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error() return } if len(mobileList) > 0 { for _, v := range mobileList { mapMobileSellWithUser[v.Mobile] = v.Mobile } } } condition += ` AND h.company_id != ` + strconv.Itoa(utils.HZ_COMPANY_ID) // 过滤弘则 list, err := cygx.GetArticleHistoryList(articleId, condition) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } listClPv, err := cygx.GetCygxCelueArticleHistoryRecordPvAll(strconv.Itoa(articleId)) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取策略品台数据失败,Err:" + err.Error() return } var mobilesCl string if len(listClPv) > 0 { for _, v := range listClPv { if v.Mobile != "" { mobilesCl += v.Mobile + "," } } } mapMobileCompany := make(map[string]string) mapMobileSellName := make(map[string]string) mobilesCl = strings.TrimRight(mobilesCl, ",") if mobilesCl != "" { listClCompanyName, err := cygx.GetCygxCelueArticleComapnyName(mobilesCl) if err != nil && err.Error() != utils.ErrNoRow() { br.Msg = "获取失败" br.ErrMsg = "获取策略品台关联查研观向的用户信息失败,Err:" + err.Error() return } if len(listClCompanyName) > 0 { for _, v := range listClCompanyName { mapMobileCompany[v.Mobile] = v.CompanyName mapMobileSellName[v.Mobile] = v.RealName } } } for k, v := range listClPv { if v.Mobile != "" { if mapMobileCompany[v.Mobile] != "" { listClPv[k].CompanyName = mapMobileCompany[v.Mobile] } if mapMobileSellName[v.Mobile] != "" { listClPv[k].SellerName = mapMobileSellName[v.Mobile] } } } var listClPvPower []*cygx.ArticleHistoryRep if len(mapMobileSellWithUser) != 0 { for _, v := range listClPv { if mapMobileSellWithUser[v.Mobile] != "" { listClPvPower = append(listClPvPower, v) } } } else { listClPvPower = listClPv } //创建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 for pidIndex := 0; pidIndex <= 1; pidIndex++ { var sheetName string var listDate []*cygx.ArticleHistoryRep if pidIndex == 0 { sheetName = "查研观向" listDate = list } else { sheetName = "策略平台" listDate = listClPvPower } sheet, err := xlsxFile.AddSheet(sheetName) 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 = "所属权益销售" cellE := rowTitle.AddCell() cellE.Value = "阅读时长(秒)" cellF := rowTitle.AddCell() cellF.Value = "阅读时间" for _, item := range listDate { row := sheet.AddRow() cellA := row.AddCell() cellA.Value = item.RealName cellB := row.AddCell() cellB.Value = item.Mobile cellC := row.AddCell() cellC.Value = item.CompanyName cellD := row.AddCell() cellD.Value = item.SellerName cellE := row.AddCell() cellE.Value = item.StopTime cellF := row.AddCell() cellF.Value = item.CreateTime } } err = xlsxFile.Save(downLoadnFilePath) if err != nil { br.Msg = "保存文件失败" br.ErrMsg = "保存文件失败" return } //randStr := time.Now().Format(utils.FormatDateTimeUnSpace) downloadFileName := articleInfo.Title + ".xlsx" this.Ctx.Output.Download(downLoadnFilePath, downloadFileName) defer func() { os.Remove(downLoadnFilePath) }() br.Success = true br.Ret = 200 br.Msg = "导出成功" } // @Title 文章类型列表 // @Description 文章类型列表接口 // @Success 200 {object} cygx.ArticleTypeListResp // @router /summaryManage/articleType/list [get] func (this *ActivityTypeCoAntroller) ArticleTypeList() { 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" br.Ret = 408 return } resp := new(cygx.ArticleTypeListResp) list, err := cygx.GetCygxArticleTypeList() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } typelist, err := cygx.GetArticleTypeAndAbstract() if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } resp.AbstractList = typelist resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 新增文章类型 // @Description 新增文章类型接口 // @Param request body cygx.CygxArticleReq true "type json string" // @Success Ret=200 // @router /summaryManage/articleType/add [post] func (this *SummaryManage) ArticleTypeListAdd() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } req := new(cygx.CygxArticleReq) err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } name := req.ArticleTypeName if name == "" { br.Msg = "内容不能为空!" return } var condition string condition = ` AND article_type_name = '` + name + `'` count, err := cygx.GetCygxArticleTypeCount(condition) if err != nil { br.Msg = "操作失败!" br.ErrMsg = "获取数量失败,Err:" + err.Error() return } if count > 0 { br.Msg = "该类型已存在,请重新填写!" return } count, err = cygx.GetCygxArticleTypeCount("") if err != nil { br.Msg = "操作失败!" br.ErrMsg = "获取已添加的数量失败,Err:" + err.Error() return } item := new(cygx.CygxArticleType) item.ArticleTypeName = name item.YanxPermissionName = utils.CHART_PERMISSION_NAME_MF_YANXUAN + name item.IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png" item.IcoLinkM = "https://hzstatic.hzinsights.com/static/temp/20220707202207/20220707/FEvPxfalkGKllLIlBMKumm47zhEx.png" item.YanxPermissionId = 1001 + count // id 数量从一千开始计算 item.CreateTime = time.Now() item.ModifyTime = time.Now() _, err = cygx.AddCygxArticleType(item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "操作成功" br.IsAddLog = true } // @Title 留言列表详情 // @Description 获取留言列表详情接口 // @Param ArticleId query int true "文章ID" // @Success 200 {object} cygx.ArticleCommentListResp // @router /summaryManage/commentList [get] func (this *SummaryManage) CommentList() { 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 } articleId, _ := this.GetInt("ArticleId") articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "报告ID错误" return } list, err := cygx.GetArticleCommentList(articleInfo.ArticleId) resp := new(cygx.ArticleCommentListResp) if err != nil { br.Msg = "获取留言失败" br.ErrMsg = "获取留言失败,Err:" + err.Error() return } resp.List = list br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp } // @Title 提问详情excel表格下载 // @Description 提问详情excel表格下载接口 // @Param SummaryManageId query int true "纪要ID" // @Success 200 导出成功 // @router /summaryManage/commentListExport [get] func (this *SummaryManage) CommentListExport() { 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 } articleId, _ := this.GetInt("ArticleId") articleInfo, _ := cygx.GetArticleIdInfoByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "报告ID错误" return } list, err := cygx.GetArticleCommentList(articleInfo.ArticleId) if err != nil { br.Msg = "获取失败" br.ErrMsg = "获取失败,Err:" + err.Error() return } //创建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 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 } randStr := time.Now().Format(utils.FormatDateTimeUnSpace) downloadFileName := "留言列表" + randStr + ".xlsx" this.Ctx.Output.Download(downLoadnFilePath, downloadFileName) defer func() { os.Remove(downLoadnFilePath) }() br.Success = true br.Ret = 200 br.Msg = "导出成功" } // @Title 文章的见范围修改 // @Description 文章的见范围修改接口 // @Param request body cygx.SummaryManageIdRep true "type json string" // @Success 200 操作成功 // @router /summaryManage/visibleRange [post] func (this *SummaryManage) VisibleRange() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser indexName := utils.IndexName if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req cygx.SummaryManageIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } articleId := req.ArticleId item := new(cygx.CygxArticle) articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "纪要ID错误" return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } item.ArticleId = articleId item.Title = articleInfo.Title item.BodyText = articleInfo.BodyText item.Body = articleInfo.Body item.PublishDate = articleInfo.PublishDate item.ExpertBackground = articleInfo.ExpertBackground item.CategoryId = articleInfo.CategoryId if articleInfo.VisibleRange == 0 { item.VisibleRange = 1 item.AdminId = AdminUser.AdminId item.AdminName = AdminUser.RealName services.EsAddOrEditData(item) //go cygxService.UpdateResourceData(item.ArticleId, "article", "add", time.Now().Format(utils.FormatDateTime)) } else { item.AdminId = articleInfo.AdminId item.AdminName = articleInfo.AdminName item.PublishStatus = 0 services.EsDeleteData(indexName, strconv.Itoa(articleInfo.ArticleId)) //go cygxService.UpdateResourceData(item.ArticleId, "article", "delete", time.Now().Format(utils.FormatDateTime)) } err = cygx.ArticleVisibleRange(item) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } //专项调研类型的报告单独走发送 if articleInfo.SubCategoryName == "专项调研" { if item.PublishStatus == 1 { cygxService.SendWxMsgWithCygxActivitySpecialArticle(item.ArticleId) } } else { if item.PublishStatus == 1 { articleIndustrial, _ := cygx.GetIndustrialManagemenDetailByAaticle(articleInfo.ArticleId) if articleIndustrial.ArticleId > 0 { go cygxService.DoArticleOnenIdWxTemplateMsg(articleId, 1) } } } go cygxService.UpdateArticleResourceData(item.ArticleId) //写入首页最新 cygx_resource_data 表 br.Ret = 200 br.Success = true br.Msg = "操作成功" br.IsAddLog = true } // @Title 文章的置顶与取消置顶 // @Description 活动的发布与取消发布接口 // @Param request body cygx.ActivityIdRep true "type json string" // @Success 200 操作成功 // @router /summaryManage/top_change [post] func (this *SummaryManage) TopeChange() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() AdminUser := this.SysUser if AdminUser == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } var req cygx.SummaryManageIdRep err := json.Unmarshal(this.Ctx.Input.RequestBody, &req) if err != nil { br.Msg = "参数解析异常!" br.ErrMsg = "参数解析失败,Err:" + err.Error() return } articleId := req.ArticleId articleInfo, errInfo := cygx.GetArticleInfoOtherByArticleId(articleId) if articleInfo == nil { br.Msg = "操作失败" br.ErrMsg = "纪要ID错误" return } if errInfo != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + errInfo.Error() return } var topTime int //如果有置顶时间就设为取消置顶,如果没有就写入当前置顶时间 if articleInfo.TopTime == 0 { topTime = int(time.Now().Unix()) } err = cygx.UpdateArticleTopTime(articleId, topTime) if err != nil { br.Msg = "操作失败" br.ErrMsg = "操作失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "操作成功" br.IsAddLog = true }