12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699 |
- package controllers
- import (
- "encoding/json"
- "fmt"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_cygx/models"
- "hongze/hongze_cygx/services"
- "hongze/hongze_cygx/utils"
- "html"
- "strconv"
- "strings"
- "time"
- )
- //报告
- type ReportController struct {
- BaseAuthController
- }
- type ReportCommonController struct {
- BaseCommonController
- }
- // @Title 行业报告分类列表接口
- // @Description 获取行业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /home/tradeList [get]
- func (this *ReportController) TradeList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- if ChartPermissionId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- list, err := models.GetTradeAll(ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
- count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
- list[k].IsRed = true
- }
- }
- resp := new(models.TradeReportMappingResp)
- resp.List = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业报告分类列表接口
- // @Description 获取产业报告分类列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
- // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
- // @Param KeyWord query string true "搜索关键词"
- // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
- // @Param DeepCover query int false "深度覆盖:0-否;1-是"
- // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /home/industryList [get]
- func (this *ReportController) IndustryList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- fmt.Println(uid)
- ChartPermissionId, _ := this.GetInt("ChartPermissionId")
- orderColumn := this.GetString("OrderColumn")
- orderColumnNew := this.GetString("OrderColumn")
- isNewLabel := this.GetString("IsNewLabel")
- isDeepLabel := this.GetString("IsDeepLabel")
- keyWord := this.GetString("KeyWord")
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- deepCover, _ := this.GetInt("DeepCover")
- recommendFocus, _ := this.GetInt("RecommendFocus")
- var orderSrt string
- var condition string
- var startSize int
- resp := new(models.IndustrialManagementList)
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- if isNewLabel == "1" {
- condition += ` AND is_new_label = ` + isNewLabel
- }
- if isDeepLabel == "1" {
- condition += ` AND is_deep_label = ` + isDeepLabel
- }
- if keyWord != "" {
- //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- // return
- //}
- //var conditionkeyWord string
- //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
- //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
- //keyWordLen := len(keyWordArr)
- //if keyWordLen <= 0 {
- // keyWordArr = append(keyWordArr, keyWord)
- // keyWordLen = len(keyWordArr)
- //}
- //for _, v := range keyWordArr {
- // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
- //}
- //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- // return
- //}
- //if industrialManagementIds == "" {
- // br.Ret = 200
- // br.Success = true
- // br.Msg = "获取成功"
- // br.Data = resp
- // return
- //}
- //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
- condition += ` AND subject_names LIKE '%` + keyWord + `%'`
- }
- var sqlChartPermissionId string
- if ChartPermissionId > 0 {
- sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
- condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
- }
- // 深度覆盖
- if deepCover == 1 {
- // 查询深标签产业报告数
- var deepCondition string
- var deepPars []interface{}
- deepCondition += ` AND man.is_deep_label = 1`
- if ChartPermissionId > 0 {
- deepCondition += ` AND man.chart_permission_id = ?`
- deepPars = append(deepPars, ChartPermissionId)
- }
- industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
- return
- }
- deepIdArr := make([]string, 0)
- for i := range industryCountList {
- if industryCountList[i].ArtNum > 10 {
- deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
- }
- }
- deepIds := strings.Join(deepIdArr, ",")
- if deepIds != "" {
- condition = `AND man.industrial_management_id IN (` + deepIds + `)`
- }
- }
- // 推荐关注
- if recommendFocus == 1 {
- condition += ` AND man.recommended_index >= 80`
- }
- // 列表总数据量
- var list []*models.IndustrialManagement
- total, err := models.GetIndustrialManagementAllCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取数量失败,Err:" + err.Error()
- return
- }
- page := paging.GetPaging(currentIndex, pageSize, total)
- if orderColumn == "" {
- orderColumn = "NewTime"
- }
- if orderColumn == "NewTime" {
- orderSrt = "update_time DESC"
- } else {
- orderSrt = "man.recommended_index DESC,update_time DESC"
- }
- if ChartPermissionId == 0 {
- ChartPermissionId = 20
- }
- // 阅读第三的产业详情
- //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + err.Error()
- // return
- //}
- list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- // 获取近一个月产业报告阅读次数最多的产业
- var topCond string
- var topPars []interface{}
- topReadIndustryId := 0
- if ChartPermissionId > 0 {
- topCond += ` AND chart_permission_id = ?`
- topPars = append(topPars, ChartPermissionId)
- }
- topReadIndustry, e := models.GetTopOneMonthArtReadNumIndustry(topCond, topPars)
- if e != nil && e.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取近一个月报告阅读次数最多的产业失败, Err: " + e.Error()
- return
- }
- if topReadIndustry != nil {
- topReadIndustryId = topReadIndustry.IndustrialManagementId
- }
- nowTime := time.Now().Local()
- threeMonBefore := nowTime.AddDate(0, -3, 0)
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
- return
- }
- if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
- list[k].IsRed = true
- }
- // 原:关联的报告阅读量大于等于阅读第三的产业,则标记热门
- //if v.ArticleReadNum >= detailHot3.ArticleReadNum {
- // list[k].IsHot = true
- //}
- // 近一个月报告阅读次数最多的产业标记Hot
- if topReadIndustryId > 0 && list[k].IndustrialManagementId == topReadIndustryId {
- list[k].IsHot = true
- }
- // 关联报告发布时间均在3个月内则标记New
- if v.MinReportTime != "" {
- t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告最早发布时间有误, Err: " + e.Error()
- return
- }
- if t.After(threeMonBefore) {
- list[k].IsNew = true
- }
- }
- }
- //记录用户搜索的筛选条件
- if orderColumnNew != "" {
- item := new(models.CygxReportIndustrialSeaarchHistory)
- item.UserId = user.UserId
- item.Mobile = user.Mobile
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.CreateTime = time.Now()
- item.IsDeepLabel = isDeepLabel
- item.IsNewLabel = isNewLabel
- item.ChartPermissionId = ChartPermissionId
- if orderColumnNew == "NewTime" {
- item.OrderColumn = "0"
- } else {
- item.OrderColumn = "1"
- }
- go models.AddCygxReportIndustrialSeaarchHistory(item)
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业下所关联的文章分类列表
- // @Description 产业下所关联的文章分类列表接口
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.IndustrialToArticleCategoryListRep
- // @router /toArticleCategoryList [get]
- func (this *ReportController) ArticleCategoryList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- if industrialManagementId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- list, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
- list[k].IsRed = true
- }
- }
- //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + err.Error()
- // return
- //}
- resp := new(models.IndustrialToArticleCategoryListRep)
- resp.List = list
- resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
- resp.IndustryName = detail.IndustryName
- resp.IndustrialManagementId = industrialManagementId
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口
- // @Description 获取产业文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param CategoryId query int true "分类ID"
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.TacticsListResp
- // @router /industry/ArticleList [get]
- func (this *ReportController) List() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- categoryId, _ := this.GetInt("CategoryId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.TacticsListResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- if categoryId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- if industrialManagementId < 1 {
- br.Msg = "请输入产业ID"
- return
- }
- //获取该产业下所对应的行业图片
- detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
- if errCategory != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
- return
- }
- //对应行业的图片
- detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
- mapChartPermission := make(map[string]string)
- var permissionName string
- var imgUrlChartPermission string
- for _, v := range chartPermissionUrlList {
- vslice := strings.Split(v, "_")
- permissionName = vslice[0]
- imgUrlChartPermission = vslice[len(vslice)-1]
- mapChartPermission[permissionName] = imgUrlChartPermission
- }
- total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- //对应分类的所图片
- detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
- if err != nil {
- br.Msg = "获取数据失败"
- br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
- return
- }
- categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
- mapCategoryUrl := make(map[string]string)
- var categoryIdStr string
- var imgUrlChart string
- for _, v := range categoryUrlList {
- vslice := strings.Split(v, "_")
- categoryIdStr = vslice[0]
- imgUrlChart = vslice[len(vslice)-1]
- mapCategoryUrl[categoryIdStr] = imgUrlChart
- }
- lenList := len(list)
- for i := 0; i < lenList; i++ {
- item := list[i]
- list[i].Body, _ = services.GetReportContentTextSub(item.Body)
- //list[i].Abstract = html.UnescapeString(item.Abstract)
- list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
- }
- for k, v := range list {
- if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
- list[k].IsRed = true
- }
- if v.VideoUrl != "" {
- list[k].IsHaveVideo = true
- }
- list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
- if mapCategoryUrl[v.CategoryId] == "" {
- if detail.ChartPermissionId == utils.YI_YAO_ID {
- list[k].ImgUrlPc = utils.YI_YAO_QI_TA
- }
- }
- }
- resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 置顶/取消置顶
- // @Description 置顶
- // @Param request body models.CygxIndustryTopRep true "type json string"
- // @Success 200
- // @router /top [post]
- func (this *ReportController) ArticleCollect() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxIndustryTopRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- industrialManagementId := req.IndustrialManagementId
- countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countIndustrial == 0 {
- br.Msg = "产业不存在!"
- br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
- return
- }
- count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.ArticleCollectResp)
- if count <= 0 {
- item := new(models.CygxIndustryTop)
- item.IndustrialManagementId = req.IndustrialManagementId
- item.UserId = uid
- item.CreateTime = time.Now()
- _, err = models.AddCygxIndustryTop(item)
- if err != nil {
- br.Msg = "置顶失败"
- br.ErrMsg = "置顶失败,Err:" + err.Error()
- return
- }
- br.Msg = "置顶成功"
- resp.Status = 1
- } else {
- err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
- if err != nil {
- br.Msg = "取消置顶失败"
- br.ErrMsg = "取消置顶失败,Err:" + err.Error()
- return
- }
- br.Msg = "已取消置顶"
- resp.Status = 2
- }
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 关注/取消关注产业
- // @Description 关注/取消关注 接口
- // @Param request body models.CygxIndustryFllowRep true "type json string"
- // @Success 200
- // @router /fllow [post]
- func (this *ReportController) Fllow() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxIndustryFllowRep
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- industrialManagementId := req.IndustrialManagementId
- var condition string
- countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countIndustrial == 0 {
- br.Msg = "产业不存在!"
- br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
- return
- }
- count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxIndustryFllowResp)
- countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
- if countUser == 0 {
- resp.GoFollow = true
- }
- if count == 0 {
- item := new(models.CygxIndustryFllow)
- item.IndustrialManagementId = industrialManagementId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.RealName = user.RealName
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.Type = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = models.AddCygxIndustryFllow(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.Status = 1
- } else {
- err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- }
- //处理是否关注全部赛道字段
- go services.IndustryFllowWithTrack(industrialManagementId, count, uid)
- br.Msg = "操作成功"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 产业报告分类关联作者列表接口
- // @Description 获取产业报告分类关联作者列表接口
- // @Param ChartPermissionId query int true "分类ID"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.CygxArticleDepartmentList
- // @router /industryListByDepartment [get]
- func (this *ReportController) IndustryListByDepartment() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- //chartPermissionId, _ := this.GetInt("ChartPermissionId")
- var startSize int
- var condition string
- //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
- condition = ` AND a.publish_status=1 `
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- total, err := models.GetArticleDepartmentCount(condition)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.CygxArticleDepartmentList)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- //获取作者信息,并排序
- list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- subjectNames, err := models.GetSubjectNames(v2.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v2.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- artList[k2].SubjectName = subjectNamesNew
- artList[k2].DepartmentId = v.DepartmentId
- if subjectNamesNew == "" {
- artList[k2].IndustryName = industryName
- } else {
- artList[k2].IndustryName = industryName + "-" + subjectNamesNew
- }
- if artList[k2].IsReport == "1" {
- artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
- } else {
- artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
- }
- }
- list[k].List = artList
- if v.FollowNum > 0 {
- list[k].IsMyFollow = true
- }
- }
- listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if len(listnNew) > 0 {
- for _, v := range listnNew {
- firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
- Management := new(models.IndustrialManagementIdInt)
- if firstStr == 0 {
- Management.IndustryName = v.IndustryName
- } else {
- listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- for _, v1 := range listSub {
- subjectNamesNew += v1.SubjectName + "/"
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- Management.IndustryName = subjectNamesNew
- }
- Management.IndustrialManagementId = v.IndustrialManagementId
- Management.ArticleId = v.ArticleId
- resp.ListnNew = append(resp.ListnNew, Management)
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 关注作者/取消关注作者
- // @Description 关注作者/取消关注作者 接口
- // @Param request body models.CygxArticleDepartmentId true "type json string"
- // @Success 200
- // @router /fllowDepartment [post]
- func (this *ReportController) FllowDepartment() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- var req models.CygxArticleDepartmentId
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- departmentId := req.DepartmentId
- var condition string
- countDepartment, err := models.GetDepartmentCount(departmentId)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if countDepartment == 0 {
- br.Msg = "作者不存在!"
- br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
- return
- }
- countUser, err := models.GetArticleDepartmentFollowByUid(uid)
- count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
- if err != nil {
- br.Msg = "获取数据失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- resp := new(models.CygxArticleDepartmentFollowResp)
- if countUser == 0 {
- resp.GoFollow = true
- }
- if count == 0 {
- item := new(models.CygxArticleDepartmentFollow)
- item.DepartmentId = departmentId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.RealName = user.RealName
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- item.Type = 1
- item.CreateTime = time.Now()
- item.ModifyTime = time.Now()
- _, err = models.AddArticleDepartmentFollow(item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- resp.Status = 1
- } else {
- var doType int
- condition = ` AND type = 1`
- count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
- if err != nil {
- br.Msg = "操作失败!"
- br.ErrMsg = "获取数据失败,Err:" + err.Error()
- return
- }
- if count == 1 {
- resp.Status = 2
- doType = 2
- } else {
- resp.Status = 1
- doType = 1
- }
- err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- }
- br.Msg = "操作成功"
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 研选文章列表接口
- // @Description 获取研选文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ArticleId query int true "文章id"
- // @Param DepartmentId query int true "作者ID"
- // @Param IndustrialManagementId query int true "产业ID"
- // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
- // @router /industry/reportList [get]
- func (this *ReportController) ReportList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- departmentId, _ := this.GetInt("DepartmentId")
- industrialManagementId, _ := this.GetInt("IndustrialManagementId")
- articleId, _ := this.GetInt("ArticleId")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.ReportArticleWhichIndustrialRepList)
- page := paging.GetPaging(currentIndex, pageSize, total)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- if departmentId > 0 {
- condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
- detail, err := models.GetArticleDepartmentDateilById(departmentId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- resp.NickName = detail.NickName
- }
- if industrialManagementId > 0 {
- condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
- }
- if articleId > 0 {
- detail, err := models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
- }
- total, err = models.GetWhichDepartmentCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
- list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.Readnum == 0 {
- list[k].IsRed = true
- }
- list[k].IsResearch = true
- subjectNames, err := models.GetSubjectNames(v.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- list[k].SubjectName = subjectNamesNew
- if subjectNamesNew != "" {
- list[k].IndustryName = industryName + "-" + subjectNamesNew
- } else {
- list[k].IndustryName = industryName
- }
- resp.IndustryName = industryName
- list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 研选最新主题关键词文章列表接口
- // @Description 获取研选最新主题关键词文章列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ArticleId query int true "文章id"
- // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
- // @router /industry/reportListNew [get]
- func (this *ReportController) ReportListNew() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- articleId, _ := this.GetInt("ArticleId")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.ReportArticleWhichIndustrialRepList)
- page := paging.GetPaging(currentIndex, pageSize, total)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- if articleId > 0 {
- detail, err := models.GetArticleDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
- if firstStr == 0 {
- condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
- } else {
- condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
- }
- }
- total, err = models.GetWhichDepartmentCount(condition)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
- list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if v.Readnum == 0 {
- list[k].IsRed = true
- }
- list[k].IsResearch = true
- list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
- subjectNames, err := models.GetSubjectNames(v.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- list[k].SubjectName = subjectNamesNew
- if subjectNamesNew != "" {
- list[k].IndustryName = industryName + "-" + subjectNamesNew
- } else {
- list[k].IndustryName = industryName
- }
- resp.IndustryName = industryName
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 是否展示绝密内参
- // @Description 获取是否展示绝密内参接口
- // @Param request body models.IsShow true "type json string"
- // @Success 200
- // @router /isShow [get]
- func (this *ReportController) IsShow() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- var resp models.IsShow
- IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
- return
- }
- resp.IsShowChart = true
- resp.IsShowResearch = true
- resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
- resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
- resp.YanXuan_Explain = true
- resp.IsShowFreeButton = IsShowFreeButton
- mobile := user.Mobile
- if mobile == "" {
- br.Ret = 200
- br.Success = true
- br.Data = resp
- return
- }
- total, _ := models.GetUserIsAdminCount(mobile)
- if total > 0 {
- resp.IsShowList = true
- }
- resp.SearchTxtList.SummarySearch = "全局搜索"
- resp.SearchTxtList.ReportSearch = "全局搜索"
- resp.SearchTxtList.YanXuanSearch = "全局搜索"
- resp.SearchTxtList.ActivitySearch = "全局搜索"
- resp.SearchTxtList.TabSearch = "请输入关键词"
- resp.IsShow = true
- br.Ret = 200
- br.Success = true
- br.Data = resp
- }
- // @Title 报告精选、本周研究汇总、上周纪要汇总列表
- // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
- // @Success 200 {object} models.CygxReportSelectionListPublicRep
- // @router /reportList/byType [get]
- func (this *ReportController) ReportListByType() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- reportType := this.GetString("ReportType")
- var condition string
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var pars []interface{}
- var total int
- resp := new(models.CygxReportSelectionListPublicRep)
- page := paging.GetPaging(currentIndex, pageSize, total)
- var tbdb string
- var readSql string
- var reportTypeStr string
- if reportType == "1" {
- tbdb = "cygx_report_selection"
- reportTypeStr = "bgjx"
- } else if reportType == "2" {
- tbdb = "cygx_research_summary"
- reportTypeStr = "bzyjhz"
- } else if reportType == "3" {
- tbdb = "cygx_minutes_summary"
- reportTypeStr = "szjyhz"
- } else {
- br.Msg = "请选择报告类型"
- return
- }
- fmt.Println(tbdb)
- condition = ` AND publish_status = 1 `
- total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- //研究汇总--报告精选 只显示最新一期,往期都隐藏
- if reportType == "1" {
- startSize = 0
- pageSize = 1
- total = 1
- }
- readSql = ` (SELECT COUNT(1) AS count FROM cygx_report_history_record AS h WHERE h.article_id = art.article_id AND report_type ='` + reportTypeStr + `' AND h.user_id = ` + strconv.Itoa(uid) + `) as read_num`
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- if reportType == "1" {
- list[k].Abstract = v.UpdateDescription
- }
- list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
- if v.ReadNum == 0 {
- list[k].IsRed = true
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取报告精选详情
- // @Description 获取报告精选详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ReportSelectionLetailResp
- // @router /reportSelection/detail [get]
- func (this *ReportController) Detail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ReportSelectionLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxReportSelectionInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- existMap := make(map[int]int)
- var items []*models.ReportSelectionChartPermission
- listLog, err := models.GetReportSelectionlogListAll(articleId)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- //var itemLogs []*models.CygxReportSelectionLogDetail
- for _, v := range listLog {
- item := new(models.ReportSelectionChartPermission)
- if existMap[v.ChartPermissionId] == 0 {
- item.PermissionName = v.PermissionName + "领域深度报告和调研"
- item.IcoLink = v.IcoLink
- listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSonLog {
- if v2.IndustrialManagementId != "" {
- listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listSonLog[k2].List = listIndustrial
- }
- }
- item.List = listSonLog
- items = append(items, item)
- //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
- }
- existMap[v.ChartPermissionId] = v.ChartPermissionId
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "bgjx"
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = items
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取本周研究汇总详情
- // @Description 获取本周研究汇总详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.ResearchSummaryLetailResp
- // @router /researchSummary/detail [get]
- func (this *ReportController) ResearchDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.ResearchSummaryLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetResearchSummarylogListFirst(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- listArticleType, err := models.GetCygxArticleTypeList()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for _, vType := range listArticleType {
- if v2.ChartPermissionId == vType.YanxPermissionId {
- listSecond[k2].IcoLink = vType.IcoLinkM
- listSecond[k2].PermissionName = vType.YanxPermissionName
- }
- }
- //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
- // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- // listSecond[k2].PermissionName = "买方研选纪要"
- //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
- // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- // listSecond[k2].PermissionName = "买方研选观点"
- //}
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "SDBG" {
- listFirst[k].ListName = "深度报告"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
- } else if v.Type == "BZCHJH" {
- listFirst[k].ListName = "本周晨会精华"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
- } else if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "SJDP" {
- listFirst[k].ListName = "事件点评"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "买方研选"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "bzyjhz"
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总内容详情
- // @Description 获取上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.MinutesSummaryLetailResp
- // @router /minutesSummary/detailv4 [get]
- func (this *ReportController) MinutesDetailV4() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.MinutesSummaryLetailRespV4)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listFirst {
- listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range listSecond {
- listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listThird) > 0 {
- for k3, v3 := range listThird {
- if v3.VideoUrl != "" {
- listThird[k3].IsHaveVideo = true
- }
- if v3.ReportLink == "0" {
- listThird[k3].ReportLink = ""
- }
- }
- listSecond[k2].List = listThird
- }
- }
- if len(listSecond) > 0 {
- listFirst[k].List = listSecond
- }
- //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
- if v.Type == "CYDYJY" {
- listFirst[k].ListName = "产业调研纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
- } else if v.Type == "SSGS" {
- listFirst[k].ListName = "上市公司调研纪要篇"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
- } else if v.Type == "YANX" {
- listFirst[k].ListName = "买方研选纪要"
- listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "szjyhz"
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listFirst
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 上周纪要汇总内容详情
- // @Description 获取上周纪要汇总内容详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.MinutesSummaryLetailResp
- // @router /minutesSummary/detail [get]
- func (this *ReportController) MinutesDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- if articleId < 0 {
- br.Msg = "参数错误"
- br.ErrMsg = "参数错误"
- return
- }
- resp := new(models.MinutesSummaryLetailResp)
- //判断用户权限
- hasPermission, err := services.GetUserhasPermission(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- listLog, err := models.GetMinutesSummarylogListAll(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for k, v := range listLog {
- listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- if len(listSonLog) > 0 {
- listLog[k].List = listSonLog
- for k2, v2 := range listSonLog {
- if v2.ReportLink == "0" {
- listSonLog[k2].ReportLink = ""
- }
- }
- }
- }
- historyRecord := new(models.CygxReportHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- historyRecord.ReportType = "szjyhz"
- sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
- return
- }
- historyRecord.RealName = user.RealName
- if sellerItem != nil {
- historyRecord.SellerName = sellerItem.RealName
- }
- go models.AddCygxReportHistoryRecord(historyRecord)
- resp.List = listLog
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 获取路演精华详情
- // @Description 获取路演精华详情接口
- // @Param ArticleId query int true "报告ID"
- // @Success 200 {object} models.RoadshowDetailResp
- // @router /roadshowEssence/detail [get]
- func (this *ReportController) RoadshowDetail() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请登录"
- br.ErrMsg = "请登录,用户信息为空"
- br.Ret = 408
- return
- }
- uid := user.UserId
- articleId, err := this.GetInt("ArticleId")
- if articleId <= 0 {
- br.Msg = "文章不存在"
- br.ErrMsg = "文章不存在,文章ID错误"
- return
- }
- detail := new(models.ReportDetailRoadshow)
- hasPermission := 0
- hasFree := 0
- //判断是否已经申请过
- applyCount, err := models.GetApplyRecordCount(uid)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
- return
- }
- //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
- if user.CompanyId > 1 {
- companyPermission, err := models.GetCompanyPermission(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
- return
- }
- detail, err = models.GetReportRoadshowDetailById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- detail.Body = html.UnescapeString(detail.Body)
- detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- if detail.ReportLink == "0" {
- detail.ReportLink = ""
- }
- if companyPermission == "" {
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 2
- }
- hasFree = 2
- goto Loop
- } else {
- hasFree = 1
- var articlePermissionPermissionName string
- articlePermissionPermissionName = detail.CategoryName
- var hasPersion bool
- slice := strings.Split(articlePermissionPermissionName, ",")
- for _, v := range slice {
- if strings.Contains(companyPermission, v) {
- hasPersion = true
- }
- }
- if hasPersion {
- hasPermission = 1
- historyRecord := new(models.CygxArticleHistoryRecord)
- historyRecord.UserId = uid
- historyRecord.ArticleId = articleId
- historyRecord.CreateTime = time.Now()
- historyRecord.Mobile = user.Mobile
- historyRecord.Email = user.Email
- historyRecord.CompanyId = user.CompanyId
- historyRecord.CompanyName = user.CompanyName
- go models.AddCygxArticleHistoryRecord(historyRecord)
- } else { //无该行业权限
- hasPermission = 3
- }
- if hasPermission == 1 {
- key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
- if !utils.Rc.IsExist(key) {
- //新增浏览记录
- record := new(models.CygxArticleViewRecord)
- record.UserId = uid
- record.ArticleId = articleId
- record.CreateTime = time.Now()
- record.Mobile = user.Mobile
- record.Email = user.Email
- record.CompanyId = user.CompanyId
- record.CompanyName = user.CompanyName
- go models.AddCygxArticleViewRecord(record)
- utils.Rc.Put(key, 1, 5*time.Second)
- models.ModifyReportLastViewTime(uid)
- }
- }
- }
- } else { //潜在客户
- if applyCount > 0 {
- hasPermission = 5
- } else {
- hasPermission = 4
- }
- }
- Loop:
- if hasPermission != 1 {
- detail.Body = ""
- detail.Abstract = ""
- }
- resp := new(models.RoadshowDetailResp)
- resp.HasPermission = hasPermission
- resp.HasFree = hasFree
- resp.Detail = detail
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口
- // @Description 获取产业文章列表接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.CygxIndustrySearchList
- // @router /industryAndArticle/list [get]
- func (this *ReportController) IndustryAndArticleList() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- keyWord := this.GetString("KeyWord")
- orderSrt := "update_time DESC"
- condition := ` AND subject_names LIKE '%` + keyWord + `%'`
- list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- }
- artList, err := models.GetCygxIndustryAndArticleList(keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- subjectNames, err := models.GetSubjectNames(v2.ArticleId)
- if err != nil {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- if len(subjectNames) > 0 {
- slice := strings.Split(subjectNames, "/")
- for k3, v3 := range slice {
- if k3 < 4 {
- subjectNamesNew += v3 + "/"
- }
- }
- }
- industryName, err := models.GetIndustrialNames(v2.ArticleId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- artList[k2].SubjectName = subjectNamesNew
- if subjectNamesNew == "" {
- artList[k2].IndustryName = industryName
- } else {
- artList[k2].IndustryName = industryName + "-" + subjectNamesNew
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp := new(models.CygxIndustrySearchList)
- resp.ArtList = artList
- resp.IndList = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业报告分类关联作者列表接口Pc端
- // @Description 获取产业报告分类关联作者列表接口Pc端
- // @Param ChartPermissionId query int true "分类ID"
- // @Param KeyWord query string true "搜索关键词"
- // @Param PageSize query int true "每页数据条数"
- // @Param CurrentIndex query int true "当前页页码,从1开始"
- // @Success 200 {object} models.CygxArticleDepartmentListPc
- // @router /industryListByDepartmentPc [get]
- func (this *ReportController) IndustryListByDepartmentPc() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- pageSize, _ := this.GetInt("PageSize")
- currentIndex, _ := this.GetInt("CurrentIndex")
- chartPermissionId, _ := this.GetInt("ChartPermissionId")
- keyWord := this.GetString("KeyWord")
- var startSize int
- var condition string
- condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- var articleIdGroup string
- if keyWord != "" {
- //获取标的关联的文章ID
- articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- //获取产业关联的标的
- articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
- return
- }
- if articleIdSub != "" && articleIdInd != "" {
- articleIdGroup = articleIdSub + "," + articleIdInd
- } else if articleIdSub != "" && articleIdInd == "" {
- articleIdGroup = articleIdSub
- } else if articleIdSub == "" && articleIdInd != "" {
- articleIdGroup = articleIdInd
- }
- slice := strings.Split(keyWord, "/")
- if len(slice) > 1 {
- var subjectIds string
- for _, v := range slice {
- subjectId, err := models.GetcygxIndustrialSubjectByName(v)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
- return
- }
- if subjectId != "" {
- subjectIds += subjectId + ","
- }
- }
- subjectIds = strings.TrimRight(subjectIds, ",")
- if len(subjectIds) > 0 {
- articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
- return
- }
- if articleIdGroup != "" {
- if articleBySub != "" {
- articleIdGroup += "," + articleBySub
- }
- } else {
- articleIdGroup = articleBySub
- }
- }
- }
- }
- if articleIdGroup != "" {
- condition += ` AND a.article_id IN (` + articleIdGroup + `)`
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- total, err := models.GetArticleDepartmentCount(condition)
- page := paging.GetPaging(currentIndex, pageSize, total)
- resp := new(models.CygxArticleDepartmentListPc)
- userType, _, err := services.GetUserType(user.CompanyId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
- return
- }
- if userType == 1 {
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- return
- }
- resp.HaveResearch = true
- //获取作者信息,并排序
- list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- if artList[k2].IsReport == "1" {
- artList[k2].Title = v2.Title
- } else {
- artList[k2].Title = v2.Title
- }
- artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
- }
- list[k].List = artList
- if v.FollowNum > 0 {
- list[k].IsMyFollow = true
- }
- }
- listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- if len(listnNew) > 0 {
- for _, v := range listnNew {
- firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
- Management := new(models.IndustrialManagementIdInt)
- if firstStr == 0 {
- Management.IndustryName = v.IndustryName
- } else {
- listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
- return
- }
- var subjectNamesNew string
- for _, v1 := range listSub {
- subjectNamesNew += v1.SubjectName + "/"
- }
- subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
- Management.IndustryName = subjectNamesNew
- }
- Management.IndustrialManagementId = v.IndustrialManagementId
- Management.ArticleId = v.ArticleId
- resp.ListnNew = append(resp.ListnNew, Management)
- }
- }
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 产业文章列表接口Pc端
- // @Description 获取产业文章列表接口Pc端
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.CygxIndustrySearchListPc
- // @router /industryAndArticle/listPc [get]
- func (this *ReportController) IndustryAndArticleListPc() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- keyWord := this.GetString("KeyWord")
- resp := new(models.CygxIndustrySearchListPc)
- orderSrt := "update_time DESC"
- condition := ` AND subject_names LIKE '%` + keyWord + `%'`
- list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range list {
- industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].IndustrialSubjectList = industrialSubjectList
- //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
- newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
- }
- artList, err := models.GetCygxIndustryAndArticleList(keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- if len(artList) > 0 {
- var articleIds string
- for _, v := range artList {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- articleIds = strings.TrimRight(articleIds, ",")
- if articleIds != "" {
- condition = ` AND a.article_id IN (` + articleIds + `)`
- DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- for k, v := range DepartmentList {
- artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
- return
- }
- for k2, v2 := range artList {
- if artList[k2].IsReport == "1" {
- artList[k2].Title = v2.Title
- } else {
- artList[k2].Title = v2.Title
- }
- artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
- }
- DepartmentList[k].List = artList
- if v.FollowNum > 0 {
- DepartmentList[k].IsMyFollow = true
- }
- }
- resp.DepartmentList = DepartmentList
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- }
- resp.IndList = list
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告搜索
- // @Description 报告搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.ReoprtSearchResp
- // @router /searchReport [get]
- func (this *ReportController) SearchReport() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- keyWord := this.GetString("KeyWord")
- var condition string
- var sqlGroup string
- //匹配报告标题、
- condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
- sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
- //对应产业名称、标的名称。
- listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range listYx {
- listYx[k].Source = 2
- if v.MyCollectNum > 0 {
- listYx[k].IsCollect = true
- }
- }
- listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range listHz {
- listHz[k].Source = 1
- if v.MyCollectNum > 0 {
- listHz[k].IsCollect = true
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- go services.AddUserSearchLog(user, keyWord, 5)
- }
- if len(listYx) == 0 {
- listYx = make([]*models.ArticleCollectionResp, 0)
- }
- if len(listHz) == 0 {
- listHz = make([]*models.ArticleCollectionResp, 0)
- }
- resp := new(models.ReoprtSearchResp)
- resp.ListYx = listYx
- resp.ListHz = listHz
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 资源包搜索
- // @Description 资源包搜索接口
- // @Param KeyWord query string true "搜索关键词"
- // @Success 200 {object} models.SearchResourceResp
- // @router /searchResource [get]
- func (this *ReportController) SearchResource() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- fllowList, err := models.GetUserFllowIndustrialList(uid)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- keyWord := this.GetString("KeyWord")
- var condition string
- var conditionOr string
- //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
- listHz, err := models.GetSearchResourceList(condition, 0, 0)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
- listYx, err := models.GetSearchResourceList(condition, 0, 0)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- //合并产业关联的标的
- listSubjcet, err := models.GetThemeHeatSubjectList("")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- industrialIdArr := make([]int, 0)
- for k, v := range listHz {
- listHz[k].Source = 1
- if fllowMap[v.IndustrialManagementId] > 0 {
- listHz[k].IsFollw = true
- }
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- for k, v := range listYx {
- listYx[k].Source = 2
- if fllowMap[v.IndustrialManagementId] > 0 {
- listYx[k].IsFollw = true
- }
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- if len(industrialIdArr) > 0 {
- //合并产业关联的标的
- listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- mapIndustrial := make(map[string]int)
- for _, v := range listSubjcet {
- for k2, v2 := range listYx {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
- listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- for k2, v2 := range listHz {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
- listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- }
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- go services.AddUserSearchLog(user, keyWord, 4)
- }
- resp := new(models.SearchResourceResp)
- if len(listYx) == 0 {
- listYx = make([]*models.IndustrialManagementHotResp, 0)
- }
- if len(listHz) == 0 {
- listHz = make([]*models.IndustrialManagementHotResp, 0)
- }
- resp.ListYx = listYx
- resp.ListHz = listHz
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 报告搜索、资源包搜索接口
- // @Description 报告搜索、资源包搜索接口接口
- // @Param KeyWord query string true "搜索关键词"
- // @Param PageSize query int true "每页数据条数"
- // @Success 200 {object} models.SearchReportAndResourceResp
- // @router /searchReportAndResource [get]
- func (this *ReportController) SearchReportAndResource() {
- br := new(models.BaseResponse).Init()
- defer func() {
- this.Data["json"] = br
- this.ServeJSON()
- }()
- user := this.User
- if user == nil {
- br.Msg = "请重新登录"
- br.Ret = 408
- return
- }
- uid := user.UserId
- keyWord := this.GetString("KeyWord")
- pageSize, _ := this.GetInt("PageSize")
- var condition string
- var sqlGroup string
- //匹配报告标题、
- condition = `AND ( a.title LIKE '%` + keyWord + `%' OR a.body LIKE '%` + keyWord + `%' OR a.annotation LIKE '%` + keyWord + `%' OR a.abstract LIKE '%` + keyWord + `%') AND a.publish_status = 1 `
- sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
- if pageSize > 0 {
- sqlGroup += ` LIMIT 5 `
- }
- ListYxReport, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range ListYxReport {
- ListYxReport[k].Source = 2
- if v.MyCollectNum > 0 {
- ListYxReport[k].IsCollect = true
- }
- }
- ListHzReport, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- for k, v := range ListHzReport {
- ListHzReport[k].Source = 1
- if v.MyCollectNum > 0 {
- ListHzReport[k].IsCollect = true
- }
- }
- if len(ListYxReport) == 0 {
- ListYxReport = make([]*models.ArticleCollectionResp, 0)
- }
- if len(ListHzReport) == 0 {
- ListHzReport = make([]*models.ArticleCollectionResp, 0)
- }
- fllowList, err := models.GetUserFllowIndustrialList(uid)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
- return
- }
- fllowMap := make(map[int]int)
- if len(fllowList) > 0 {
- for _, v := range fllowList {
- fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
- }
- }
- var conditionOr string
- conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
- listHzResource, err := models.GetSearchResourceList(condition, 0, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
- condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
- listYxResource, err := models.GetSearchResourceList(condition, 0, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
- return
- }
- //合并产业关联的标的
- listSubjcet, err := models.GetThemeHeatSubjectList("")
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- industrialIdArr := make([]int, 0)
- for k, v := range listHzResource {
- listHzResource[k].Source = 1
- if fllowMap[v.IndustrialManagementId] > 0 {
- listHzResource[k].IsFollw = true
- }
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- for k, v := range listYxResource {
- listYxResource[k].Source = 2
- if fllowMap[v.IndustrialManagementId] > 0 {
- listYxResource[k].IsFollw = true
- }
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- if len(industrialIdArr) > 0 {
- //合并产业关联的标的
- listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- mapIndustrial := make(map[string]int)
- for _, v := range listSubjcet {
- for k2, v2 := range listYxResource {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
- listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- for k2, v2 := range listHzResource {
- if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
- listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
- mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
- }
- }
- }
- }
- resp := new(models.SearchReportAndResourceResp)
- if len(listYxResource) == 0 {
- listYxResource = make([]*models.IndustrialManagementHotResp, 0)
- }
- if len(listHzResource) == 0 {
- listHzResource = make([]*models.IndustrialManagementHotResp, 0)
- }
- if keyWord != "" {
- keyWordItem := new(models.CygxUserSearchKeyWord)
- keyWordItem.UserId = user.UserId
- keyWordItem.KeyWord = keyWord
- keyWordItem.PageType = "ReortSearch"
- keyWordItem.CreateTime = time.Now()
- go models.AddUserSearchKeyWord(keyWordItem)
- go services.AddUserSearchLog(user, keyWord, 5)
- }
- resp.ListHzResource = listHzResource
- resp.ListYxResource = listYxResource
- resp.ListYxReport = ListYxReport
- resp.ListHzReport = ListHzReport
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|