1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105 |
- package controllers
- import (
- "encoding/json"
- "errors"
- "fmt"
- "github.com/medivhzhan/weapp/v2"
- "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
- }
- listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var list []*models.TradeReportMapping
- categoryMap := make(map[int]int)
- for _, v := range listCategory {
- if categoryMap[v.CategoryId] > 0 {
- continue
- }
- categoryMap[v.CategoryId] = v.CategoryId
- list = append(list, v)
- }
- //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
- //if ChartPermissionId == utils.KE_JI_ID {
- // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
- //}
- //var condition string
- //var pars []interface{}
- for k, v := range list {
- //if v.PolymerizationId != "" {
- // condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
- //} else {
- // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
- //}
- pageSize := 1
- var listArticle []*models.ReportArticle
- if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
- //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
- listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.Msg = "GetHomeList,Err:" + err.Error()
- return
- }
- //for _, vAi := range listArticleAi {
- // listArticle = append(listArticle, &models.ReportArticle{
- // CategoryId: vAi.CategoryId,
- // PublishDate: vAi.PublishDate,
- // })
- //}
- } else {
- listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.Msg = "GetHomeList,Err:" + err.Error()
- return
- }
- }
- //listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
- if len(listArticle) > 0 {
- list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 }
- }
- }
- 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 != "" {
- 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)
- }
- list, err = services.HandleIndustryList(list, user)
- 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"
- // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
- // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
- // @Param ChapterId query int false "晨会精华段落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
- }
- showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
- isSendWx, _ := this.GetInt("IsSendWx")
- chapterId, _ := this.GetInt("ChapterId")
- detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var list []*models.IndustrialToArticleCategoryRep
- categoryMap := make(map[int]int)
- for _, v := range listCategory {
- if categoryMap[v.CategoryId] > 0 {
- continue
- }
- categoryMap[v.CategoryId] = v.CategoryId
- list = append(list, v)
- }
- // 用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- videoSimple := new(models.MicroVideoSimpleInfo)
- // 权限
- var au *models.UserPermissionAuthInfo
- video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
- if err != nil {
- if err.Error() != utils.ErrNoRow() {
- br.Msg = "获取产业视频失败"
- br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
- return
- }
- } else {
- videoSimple.Id = video.VideoId
- videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
- videoSimple.BackgroundImg = video.ImgUrl
- videoSimple.DetailImgUrl = video.DetailImgUrl
- if videoSimple.BackgroundImg == "" {
- // 获取默认图配置
- _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- br.Msg = "获取视频默认配置图失败"
- br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
- return
- }
- videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
- }
- videoSimple.PlaySeconds = video.VideoDuration
- videoSimple.ResourceUrl = video.VideoUrl
- au = new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- videoSimple.ResourceUrl = ""
- }
- }
- //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取信息失败,Err:" + err.Error()
- // return
- //}
- //时间线
- if showTimeLine == 1 {
- timeLineItem := models.IndustrialToArticleCategoryRep{
- CategoryId: 99999,
- MatchTypeName: "时间线",
- }
- timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- //查询用户今天是否看过时间线
- //haveMorningMeeting := false
- //var morningMeetingTime string
- //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
- //if err != nil {
- // br.Msg = "查询浏览记录数量失败"
- // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
- // return
- //}
- //var recordItem *models.CygxPageHistoryRecord
- //if count > 1 {
- // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
- // if err != nil {
- // br.Msg = "查询浏览记录失败"
- // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
- // return
- // }
- //}
- for _, v := range timeLineList {
- if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
- if v.SubCategoryName == "时间线" {
- //haveMorningMeeting = true
- //morningMeetingTime = v.PublishTime
- continue
- }
- timeLineItem.IsRed = true
- }
- }
- //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
- //timeLineRed := false
- //if count < 2 {
- // timeLineRed = true
- //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
- // timeLineRed = true
- //}
- //if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
- // timeLineItem.IsRed = true
- //}
- list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
- if chapterId > 0 && isSendWx == 1 {
- go services.AddCygxMorningMeetingReviewChapterHistory(user, chapterId, "微信")
- }
- }
- resp := new(models.IndustrialToArticleCategoryListRep)
- resp.List = list
- resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
- resp.IndustryName = detail.IndustryName
- resp.IndustrialManagementId = industrialManagementId
- resp.AuthInfo = au
- if videoSimple.Id > 0 {
- resp.IndustryVideo = videoSimple
- }
- if isSendWx == 1 {
- industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
- return
- }
- resp.IsFollowButton = industryUserFollowMap[industrialManagementId]
- resp.IsShowFollowButton = true
- }
- 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
- page := paging.GetPaging(currentIndex, pageSize, total)
- if categoryId < 1 {
- br.Msg = "请输入分类ID"
- return
- }
- if industrialManagementId < 1 {
- br.Msg = "请输入产业ID"
- return
- }
- if categoryId != 99999 {
- resp := new(models.TacticsListResp)
- list, total, err := models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- //对应分类的所图片
- 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
- }
- var articleIds []int
- 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)
- if item.Resource == 1 {
- articleIds = append(articleIds, item.ArticleId)
- }
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
- articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
- 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 v.Resource == 1 {
- v.Pv = articleMapPv[v.ArticleId]
- v.IsCollect = articleCollectMap[v.ArticleId]
- v.CollectNum = articleCollectNumMap[v.ArticleId]
- }
- if v.Resource == 2 {
- v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
- }
- }
- //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
- //resp.ChartPermissionId = detail.ChartPermissionId
- resp.List = list
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- } else {
- //获取该产业下所对应的行业图片
- //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
- categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- var timeLineCategoryId int
- if len(categoryList) > 0 {
- timeLineCategoryId = categoryList[0].CategoryId
- }
- var detail *models.ReportMapping
- var errCategory error
- if timeLineCategoryId > 0 {
- detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
- 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.GetTimeLineReportIndustrialCount(industrialManagementId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
- return
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
- return
- }
- //处理晨会精华关联的标的,以及要跳转的文章ID
- var meetingreviewchaptIds []int
- var articleIds []int
- mapchaptIdAndArticleId := make(map[int]int) // 晨会精华ID与跳转文章ID的映射关系
- mapchaptIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 晨会精华ID与标的列表的映射关系
- mapArticleIdListSubject := make(map[int][]*models.CygxIndustrialSubject) // 报告ID与标的列表的映射关系
- for _, v := range list {
- if v.Resource == 3 {
- meetingreviewchaptIds = append(meetingreviewchaptIds, v.Id)
- v.Content = services.AnnotationHtml(v.Content)
- }
- if v.Resource == 1 {
- articleIds = append(articleIds, v.Id)
- }
- }
- if len(meetingreviewchaptIds) > 0 {
- listMeet, err := services.GetCygxMorningMeetingReviewChapterListByIds(meetingreviewchaptIds)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "GetCygxMorningMeetingReviewChapterListByIds,Err:" + err.Error()
- }
- for _, v := range listMeet {
- mapchaptIdAndArticleId[v.Id] = v.LinkArticleId
- mapchaptIdListSubject[v.Id] = v.ListSubject
- }
- }
- if len(articleIds) > 0 {
- mapArticleIdListSubject = services.GetArticleGroupSubjectMapByIndustrialManagementId(articleIds, industrialManagementId)
- }
- //对应分类的所图片
- 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].Content, _ = services.GetReportContentTextSub(item.Content)
- // //list[i].Abstract = html.UnescapeString(item.Abstract)
- // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
- //}
- //查询用户今天是否看过时间线
- //count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
- //if err != nil {
- // br.Msg = "查询浏览记录数量失败"
- // br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
- // return
- //}
- //var recordItem *models.CygxPageHistoryRecord
- //if count > 1 {
- // recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
- // if err != nil {
- // br.Msg = "查询浏览记录失败"
- // br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
- // return
- // }
- //}
- for k, v := range list {
- if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
- list[k].IsRed = true
- }
- //timeLineRed := false
- //if count < 2 && v.SubCategoryName == "时间线" {
- // timeLineRed = true
- //} else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
- // timeLineRed = true
- //}
- //if v.SubCategoryName == "时间线" && timeLineRed {
- list[k].IsRed = true
- //}
- if v.VideoUrl != "" {
- list[k].IsHaveVideo = true
- }
- id := strconv.Itoa(timeLineCategoryId)
- list[k].ImgUrlPc = mapCategoryUrl[id]
- if mapCategoryUrl[id] == "" {
- if detail != nil {
- if detail.ChartPermissionId == utils.YI_YAO_ID {
- list[k].ImgUrlPc = utils.YI_YAO_QI_TA
- }
- }
- }
- if v.Resource == 3 {
- v.LinkArticleId = mapchaptIdAndArticleId[v.Id]
- v.ListSubject = mapchaptIdListSubject[v.Id]
- }
- if v.Resource == 1 {
- v.ListSubject = mapArticleIdListSubject[v.Id]
- }
- }
- resp := new(models.TimeLineReportListResp)
- //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
- go services.AddCygxTimelineLog(user, industrialManagementId)
- 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
- }
- item := new(models.CygxIndustryFllow)
- item.IndustrialManagementId = industrialManagementId
- item.UserId = uid
- item.Email = user.Email
- item.Mobile = user.Mobile
- item.RealName = user.RealName
- item.Source = utils.REGISTER_PLATFORM
- item.CompanyId = user.CompanyId
- item.CompanyName = user.CompanyName
- if count == 0 {
- 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 {
- item.Type = 2
- err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "取消关注失败,Err:" + err.Error()
- return
- }
- }
- go services.IndustryFllowWithTrack(industrialManagementId, count, uid) //处理是否关注全部赛道字段
- go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
- go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
- 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
- resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
- resp.IsShowQuestionnaire = services.GetQuestionnaireButtonIsShow() // 获取研选问卷调查按钮是否展示
- resp.IsShowResearchPoints = true
- if utils.RunMode == "release" { //是否展示关于我们的视频,测试环境审核做隐藏
- resp.IsShowAboutVideo = true
- } else {
- resp.IsShowMobileAndEmailButton = true //是否展示手机号跟邮箱按钮
- }
- //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.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
- }
- condition = ` AND publish_status = 1 `
- if user.CompanyId != utils.HZ_COMPANY_ID {
- condition += ` AND visible_range = 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"
- // @Param IsBestNew query bool false "是否获取最新的一篇报告"
- // @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
- }
- //if user.CompanyId != utils.HZ_COMPANY_ID {
- // br.Msg = "报告编辑中,请稍后"
- // br.IsSendEmail = false
- // return
- //}
- //uid := user.UserId
- articleId, _ := this.GetInt("ArticleId")
- isBestNew, _ := this.GetBool("IsBestNew")
- if isBestNew {
- tbdb := "cygx_report_selection"
- //reportTypeStr := "bgjx"
- condition := ` AND publish_status = 1 `
- var pars []interface{}
- list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- for _, v := range list {
- articleId = v.ArticleId
- }
- }
- if articleId < 1 {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
- 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
- }
- if detail.ReportLink != "" {
- articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
- detail.CeLueArticleId = articleIdLink
- }
- //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
- var isAllNew bool // 判断是否都打新的标签
- lastPeriods := detail.Periods - 1
- mapBodyChartSummary := make(map[int]string)
- mapLabel := make(map[int]string)
- if lastPeriods > 0 {
- detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
- return
- }
- if detailLast != nil {
- articleIdLast := detailLast.ArticleId
- listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- for _, v := range listLogLast {
- mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
- mapLabel[v.IndustrialSubjectId] = v.Label
- }
- }
- } else {
- isAllNew = true
- }
- detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
- existMap := make(map[int]int)
- var items []*models.ReportSelectionChartPermission
- var itemsSubject []*models.ReportSelectionChartLogPermission
- listLog, err := models.GetReportSelectionlogListAll(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
- return
- }
- detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
- //获取行业核心逻辑汇总
- listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败,Err:" + err.Error()
- return
- }
- mapChartLog := make(map[string]string)
- for _, v := range listChartLog {
- mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
- }
- for _, v := range listLog {
- item := new(models.ReportSelectionChartPermission)
- itemSubject := new(models.ReportSelectionChartLogPermission)
- itemSubject.PermissionName = v.PermissionName
- if existMap[v.ChartPermissionId] == 0 {
- //item.PermissionName = v.PermissionName + "领域深度报告和调研"
- 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 {
- var isNew bool
- if isAllNew {
- isNew = true
- } else {
- v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
- if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
- isNew = true
- }
- }
- if v2.IndustrialManagementId != "" {
- listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取信息失败,Err:" + err.Error()
- return
- }
- //v2.IsNew = isNew
- listSonLog[k2].List = listIndustrial
- if v2.Label != "" {
- v2.CompanyLabel = strings.Split(v2.Label, "{|}")
- }
- }
- isNew = false
- itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
- }
- item.BodyChartSummary = mapChartLog[v.PermissionName]
- item.List = listSonLog
- items = append(items, item)
- itemsSubject = append(itemsSubject, itemSubject)
- //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.ListPermissionSubject = itemsSubject
- 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()
- }
- detail, err := models.GetCygxResearchSummaryInfoById(articleId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
- return
- }
- PermissionNameMap, err := services.GetPermissionNameMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- PermissionIcoMap, err := services.GetPermissionNameIcoMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- //未设置全部可见的只能给弘则内部查看
- if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
- resp.IsShow = true
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 || !resp.IsShow {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- 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 {
- v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
- v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
- 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 = "市场QA汇总"
- 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)
- go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
- 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
- }
- PermissionNameMap, err := services.GetPermissionNameMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- PermissionIcoMap, err := services.GetPermissionNameIcoMap()
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
- return
- }
- //未设置全部可见的只能给弘则内部查看
- if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
- resp.IsShow = true
- }
- resp.HasPermission = hasPermission
- if hasPermission != 1 || !resp.IsShow {
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- 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 {
- v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
- v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
- 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)
- go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
- 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 {
- for k2, v2 := range listSonLog {
- if v2.ReportLink == "0" {
- listSonLog[k2].ReportLink = ""
- }
- }
- listLog[k].List = listSonLog
- }
- }
- //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
- }
- articleLyjhMap, _ := services.GetLyjhArticleMap()
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
- //`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.IsCollect = articleCollectMap[detail.ArticleId]
- detail.IsRoadShow = articleLyjhMap[detail.ArticleId]
- 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(user.UserId, 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(user.UserId, 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)
- }
- 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 conditionSpecial string // 研选专栏
- var sqlGroup string
- articleTypeIds, err := services.GetYanXuanArticleTypeIds()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
- return
- }
- if articleTypeIds == "" {
- br.Msg = "获取信息失败"
- br.ErrMsg = "研选分类ID不能为空"
- return
- }
- //匹配报告标题、
- //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 `
- condition = `AND ( a.title 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 `
- } else {
- sqlGroup += ` LIMIT 100 `
- }
- conditionSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%' )`
- ListYxReport, err := models.GetArticleAndYxSpecialList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition, conditionSpecial, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
- return
- }
- ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
- return
- }
- keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
- return
- }
- keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
- var keyWordIk string
- if len(keyWordArr) > 1 {
- keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
- var conditionIk string
- var sqlGroupIk string
- conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
- sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
- if pageSize > 0 {
- sqlGroupIk += ` LIMIT 5 `
- } else {
- sqlGroupIk += ` LIMIT 20 `
- }
- //conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.body NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
- conditionIk += ` AND ( a.title NOT LIKE '%` + keyWord + `%' AND a.annotation NOT LIKE '%` + keyWord + `%' AND a.abstract NOT LIKE '%` + keyWord + `%') `
- //研选的联想词列表
- ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
- return
- }
- if len(ListYxReportIk) > 0 {
- for _, v := range ListYxReportIk {
- ListYxReport = append(ListYxReport, v)
- }
- }
- //弘则的联想词列表
- ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
- return
- }
- if len(ListHzReportIk) > 0 {
- for _, v := range ListHzReportIk {
- ListHzReport = append(ListHzReport, v)
- }
- }
- }
- var articleIdsArr []int
- var articleIdsSpecialArr []int // 研选专栏ID
- for k, v := range ListHzReport {
- ListHzReport[k].Source = 1
- //if v.MyCollectNum > 0 {
- // ListHzReport[k].IsCollect = true
- //}
- articleIdsArr = append(articleIdsArr, v.ArticleId)
- }
- for k, v := range ListYxReport {
- ListYxReport[k].Source = 2
- //if v.MyCollectNum > 0 {
- // ListYxReport[k].IsCollect = true
- //}
- if v.ArticleTypeId == -1 {
- articleIdsSpecialArr = append(articleIdsSpecialArr, v.ArticleId)
- } else {
- articleIdsArr = append(articleIdsArr, v.ArticleId)
- }
- }
- var articleIds string
- for _, v := range ListHzReport {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIdsArr) //文章Pv
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
- articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIdsArr) //文章收藏的数量
- articleCollectYanxuanSpecialMap, _ := services.GetYanxuanSpecialCollectMap(user.UserId) //用户收藏的研选专栏
- for i, v := range ListYxReport {
- articleIds += strconv.Itoa(v.ArticleId) + ","
- if v.ArticleTypeId == -1 {
- v.ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
- v.IsCollect = articleCollectYanxuanSpecialMap[v.ArticleId]
- } else if v.ArticleTypeId > 0 {
- ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
- ListYxReport[i].Pv = articleMapPv[v.ArticleId]
- ListYxReport[i].CollectNum = articleCollectNumMap[v.ArticleId]
- ListYxReport[i].IsCollect = articleCollectMap[v.ArticleId]
- }
- if v.SpecialType == 1 {
- ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
- } else if ListYxReport[i].SpecialType == 2 {
- ListYxReport[i].Title = "【观点】" + ListYxReport[i].Title
- }
- if v.CompanyTags != "" {
- v.SpecialTags += v.CompanyTags
- }
- if v.IndustryTags != "" {
- if v.SpecialTags != "" {
- v.SpecialTags += ","
- }
- v.SpecialTags += v.IndustryTags
- }
- v.SpecialTags = v.SpecialTags
- }
- articleIds = strings.TrimRight(articleIds, ",")
- silcearticleIds := strings.Split(articleIds, ",")
- var parsindustrial []interface{}
- parsindustrial = make([]interface{}, 0)
- articleIdList := make([]string, 0)
- for _, v := range silcearticleIds {
- articleIdList = append(articleIdList, v)
- }
- conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
- parsindustrial = append(parsindustrial, articleIdList)
- industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
- if err != nil {
- return
- }
- industrialMap := make(map[int][]*models.IndustrialManagementResp)
- if len(industrialList) > 0 {
- for _, v := range industrialList {
- item := new(models.IndustrialManagementResp)
- //item.ArticleId = v.ArticleId
- item.IndustrialManagementId = v.IndustrialManagementId
- item.IndustryName = v.IndustryName
- item.ChartPermissionId = v.ChartPermissionId
- industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
- }
- }
- for k, v := range ListHzReport {
- if len(industrialMap[v.ArticleId]) > 0 {
- ListHzReport[k].List = industrialMap[v.ArticleId]
- } else {
- ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
- }
- v.Pv = articleMapPv[v.ArticleId]
- v.CollectNum = articleCollectNumMap[v.ArticleId]
- v.IsCollect = articleCollectMap[v.ArticleId]
- if v.ReportId > 0 {
- v.Resource = 3
- }
- }
- for k, v := range ListYxReport {
- if len(industrialMap[v.ArticleId]) > 0 {
- ListYxReport[k].List = industrialMap[v.ArticleId]
- } else {
- ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
- }
- }
- //获取文章关联的产业
- 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
- }
- }
- condition = ` AND a.publish_status = 1 AND a.article_type_id NOT IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
- listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- condition = ` AND a.publish_status = 1 AND a.article_type_id IN (` + articleTypeIds + `) AND (m.industry_name LIKE '%` + keyWord + `%' OR m.subject_names LIKE '%` + keyWord + `%' ) `
- hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
- if e != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
- return
- }
- listYxResource, err := models.GetSearchResourceList(user.UserId, 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)
- nowTime := time.Now().Local()
- threeMonBefore := nowTime.AddDate(0, -3, 0)
- mapHot := make(map[int]bool)
- //if themeType == 2 {
- mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
- return
- }
- //conditionOrder := ` ORDER BY sum_num DESC `
- //listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
- //if err != nil {
- // br.Msg = "获取信息失败"
- // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- // return
- //}
- for k, _ := range mapHot {
- industrialIdArr = append(industrialIdArr, k)
- }
- orderSrt := "man.recommended_index DESC,update_time DESC"
- for k, v := range listHzResource {
- // 关联报告发布时间均在3个月内则标记New
- if v.MinReportTime != "" {
- t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
- if e != nil {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- if t.After(threeMonBefore) {
- listHzResource[k].IsNew = true
- }
- }
- //弘则资源包不展示hot标签
- //if mapHot[v.IndustryName] > 0 {
- // listHzResource[k].IsHot = true
- //}
- listHzResource[k].Source = 1
- if fllowMap[v.IndustrialManagementId] > 0 {
- listHzResource[k].IsFollw = true
- }
- v.IsHot = hotMapindustrial[v.IndustrialManagementId]
- industrialIdSlice := make([]int, 0)
- articleIdArr := make([]int, 0)
- industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
- listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
- if err != nil && err.Error() != utils.ErrNoRow() {
- return
- }
- for _, v := range listUpdateTime {
- articleIdArr = append(articleIdArr, v.ArticleId)
- }
- if err != nil {
- return
- }
- mapHistroyArticleId := make(map[int]int)
- if user.UserId > 0 {
- listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
- if e != nil && e.Error() != utils.ErrNoRow() {
- err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
- return
- }
- for _, v := range listArticleHistory {
- mapHistroyArticleId[v.ArticleId] = v.ArticleId
- }
- }
- condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
- list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- mapUPdateTime := make(map[int]string)
- //获取这些产业下最新更新的文章
- //时间线的更新时间
- // maptimelineUPdateTime := make(map[int]string)
- listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
- return
- }
- for _, v := range listtimelinePublishdate {
- if mapUPdateTime[v.IndustrialManagementId] != "" {
- if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
- }
- }
- }
- //mapHistroyArticleId := make(map[int]int)
- //if userId > 0 {
- // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
- // if e != nil && e.Error() != utils.ErrNoRow() {
- // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
- // return
- // }
- // for _, v := range listArticleHistory {
- // mapHistroyArticleId[v.ArticleId] = v.ArticleId
- // }
- //}
- var industrialIds string
- for _, id := range industrialIdArr {
- industrialIds += strconv.Itoa(id) + ","
- }
- industrialIds = strings.TrimRight(industrialIds, ",")
- articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
- return
- }
- mapHistroyindustrialId := make(map[int]int)
- for _, v := range articleList {
- mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
- }
- //nowTime := time.Now().Local()
- //threeMonBefore := nowTime.AddDate(0, -3, 0)
- //查询用户今天是否看过时间线
- //haveMorningMeeting := false
- //var morningMeetingTime string
- recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
- return
- }
- var industrialManagementIdstr string
- industrialIdMap := make(map[string]time.Time)
- for _, v := range recrodList {
- industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
- if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
- if createTime.Before(v.CreateTime) {
- industrialIdMap[industrialManagementIdstr] = v.CreateTime
- }
- } else {
- industrialIdMap[industrialManagementIdstr] = v.CreateTime
- }
- }
- mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
- if err != nil {
- return
- }
- morningMeetingTimeMap := make(map[int]time.Time)
- for _, v := range mmList {
- morningMeetingTimeMap[v.IndustryId] = v.CreateTime
- }
- timeLineRedMap := make(map[int]bool, 0)
- for _, industrialId := range industrialIdArr {
- if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
- if createTime.Before(morningMeetingTimeMap[industrialId]) {
- timeLineRedMap[industrialId] = true
- }
- }
- }
- for k, v := range list {
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- if user.UserId > 0 {
- //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
- if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
- if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- }
- } else {
- if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- list[k].IsFollow = 0
- }
- list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
- if user.UserId > 0 {
- //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
- if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
- if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- }
- } else {
- if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
- list[k].IsRed = true
- }
- list[k].IsFollow = 0
- }
- }
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- for k, v := range listYxResource {
- // 关联报告发布时间均在3个月内则标记New
- if v.MinReportTime != "" {
- t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
- if e != nil {
- err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
- return
- }
- if t.After(threeMonBefore) {
- listYxResource[k].IsNew = true
- }
- }
- listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
- listYxResource[k].Source = 2
- if fllowMap[v.IndustrialManagementId] > 0 {
- listYxResource[k].IsFollw = true
- }
- v.IsHot = hotMapindustrial[v.IndustrialManagementId]
- industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
- }
- if len(industrialIdArr) > 0 {
- //查询产业视频
- industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
- // 获取默认图配置
- _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
- if e != nil {
- br.Msg = "获取视频默认配置图失败"
- br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
- return
- }
- videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
- if err != nil {
- br.Msg = "产业视频列表失败"
- br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
- return
- }
- for _, v := range videoList {
- tmp := &models.MicroVideoSimpleInfo{
- Id: v.VideoId,
- Title: "5min逻辑【" + v.IndustryName + "】解析",
- ResourceUrl: v.VideoUrl,
- BackgroundImg: v.ImgUrl,
- PlaySeconds: v.VideoDuration,
- DetailImgUrl: v.DetailImgUrl,
- ChartPermissionName: v.ChartPermissionName,
- ChartPermissionId: v.ChartPermissionId,
- }
- if tmp.BackgroundImg == "" {
- tmp.BackgroundImg = videoMap[v.ChartPermissionId]
- }
- industrialVideoMap[v.IndustryId] = tmp
- }
- //查询权限
- // 用户权限
- authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
- if e != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
- return
- }
- for k, v := range listHzResource {
- //展示产业视频
- if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
- au := new(models.UserPermissionAuthInfo)
- au.SellerName = authInfo.SellerName
- au.SellerMobile = authInfo.SellerMobile
- au.HasPermission = authInfo.HasPermission
- au.OperationMode = authInfo.OperationMode
- if au.HasPermission == 1 {
- // 非宏观权限进一步判断是否有权限
- if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
- au.HasPermission = 2
- }
- }
- // 无权限的弹框提示
- if au.HasPermission != 1 {
- if au.OperationMode == services.UserPermissionOperationModeCall {
- au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
- } else {
- au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
- }
- video.ResourceUrl = ""
- }
- listHzResource[k].AuthInfo = au
- listHzResource[k].IndustryVideo = video
- }
- }
- //合并产业关联的标的
- listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
- return
- }
- //严选的产业只关联研选下面的标的
- var yxcondition string
- var yxPer []interface{}
- yxcondition = ` AND ag.article_id >= ?`
- yxPer = append(yxPer, utils.SummaryArticleId)
- listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
- if err != nil && err.Error() != utils.ErrNoRow() {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
- return
- }
- mapYxSubject := make(map[int]int)
- for _, v := range listYxAticleSubject {
- mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
- }
- 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 && mapYxSubject[v.IndustrialSubjectId] > 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
- }
- // @Title 产业报告公司列表
- // @Description 获取产业报告公司列表接口
- // @Param ChartPermissionId query int true "行业id"
- // @Success 200 {object} models.IndustrialManagementList
- // @router /home/stockName [get]
- func (this *ReportController) StockNameList() {
- 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")
- list, err := models.GetSummaryArticle(chartPermissionId)
- if err != nil {
- br.Msg = "获取综述报告公司名称失败"
- br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
- return
- }
- var respList []*models.SummaryArticleStock
- for _, item := range list {
- sliceSubjects := strings.Split(item.Stock, "/")
- if len(sliceSubjects) > 0 {
- for i, vSubject := range sliceSubjects {
- sliceKuohao := strings.Split(vSubject, "(") //过滤括号
- sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
- subject := sliceXiahuaxian[0]
- if i > 0 {
- newItem := models.SummaryArticleStock{
- Id: item.Id,
- ArticleId: item.ArticleId,
- Stock: subject,
- }
- respList = append(respList, &newItem)
- } else {
- item.Stock = subject
- respList = append(respList, item)
- }
- }
- }
- //index := strings.Index(item.Stock, "(")
- //item.Stock = item.Stock[:index]
- //if strings.Contains(item.Stock, "-B"){
- // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
- //}
- //if strings.Contains(item.Stock, "-W"){
- // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
- //}
- }
- resp := new(models.SummaryArticleStockResp)
- resp.List = respList
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
- // @Title 文章留言接口
- // @Description 文章留言接口
- // @Param request body models.AddCygxActivityHelpAsk true "type json string"
- // @Success 200 {object} models.TacticsListResp
- // @router /commentAdd [post]
- func (this *ReportController) CommentAdd() {
- 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 req models.AddCygxArticleCommentReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- if req.ArticleId <= 0 {
- br.Msg = "文章不存在"
- br.ErrMsg = "文章不存在,文章ID错误"
- return
- }
- if req.Content == "" {
- br.Msg = "建议内容不可为空"
- return
- }
- content := req.Content
- itemToken, err := services.WxGetToken()
- if err != nil {
- br.Msg = "GetWxAccessToken Err:" + err.Error()
- return
- }
- if itemToken.AccessToken == "" {
- br.Msg = "accessToken is empty"
- return
- }
- commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
- if err != nil {
- br.Msg = "内容校验失败!"
- br.ErrMsg = "内容校验失败,Err:" + err.Error()
- return
- }
- if commerr.ErrCode != 0 {
- br.Msg = "内容违规,请重新提交!"
- br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
- return
- }
- articleId := req.ArticleId
- articleInfo, errInfo := models.GetArticleDetailById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
- if err != nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
- return
- }
- if companyDetail == nil {
- br.Msg = "提交失败!"
- br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
- return
- }
- item := models.CygxArticleComment{
- UserId: user.UserId,
- ArticleId: req.ArticleId,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: companyDetail.CompanyName,
- Content: content,
- Title: articleInfo.Title,
- }
- msgId, err := models.AddArticleComment(&item)
- if err != nil {
- br.Msg = "提交失败"
- br.ErrMsg = "提交留言失败,Err:" + err.Error()
- return
- }
- go services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
- go services.SendCommentWxTemplateMsgByYxCategory(req, user, articleInfo, int(msgId)) // 发送用户留言提醒(研选公众号类目模版消息)
- br.Ret = 200
- br.Success = true
- br.Msg = "提交成功"
- }
- // @Title 记录用户浏览音频回放接口
- // @Description 记录用户浏览音频回放接口
- // @Param request body models.ArticleIdReq true "type json string"
- // @Success Ret=200 操作成功
- // @router /voiceHistory/add [post]
- func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
- 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
- var req models.ArticleIdReq
- err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
- if err != nil {
- br.Msg = "参数解析异常!"
- br.ErrMsg = "参数解析失败,Err:" + err.Error()
- return
- }
- articleId := req.ArticleId
- playSeconds := req.PlaySeconds
- pageRouter := req.PageRouter
- if pageRouter == "本周研究汇总" {
- articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxResearchSummaryVoiceHistory{
- ArticleId: articleId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxResearchSummaryVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateResearchSummaryVoiceCounts(articleId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- }
- } else if pageRouter == "上周纪要汇总" {
- articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxMinutesSummaryVoiceHistory{
- ArticleId: articleId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxMinutesSummaryVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateMinutesSummaryVoiceCounts(articleId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- }
- } else if pageRouter == "报告精选" {
- articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
- if articleInfo == nil {
- br.Msg = "操作失败"
- br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
- return
- }
- if errInfo != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + errInfo.Error()
- return
- }
- var sellerName string
- sellerName, err = models.GetCompanySellerName(user.CompanyId)
- if err != nil {
- br.Msg = "报名失败!"
- br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
- return
- }
- item := models.CygxReportSelectionVoiceHistory{
- ArticleId: articleId,
- UserId: uid,
- CreateTime: time.Now(),
- Mobile: user.Mobile,
- Email: user.Email,
- CompanyId: user.CompanyId,
- CompanyName: user.CompanyName,
- RealName: user.RealName,
- SellerName: sellerName,
- PlaySeconds: strconv.Itoa(req.PlaySeconds),
- ModifyTime: time.Now(),
- }
- if playSeconds != 0 {
- lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
- return
- }
- } else {
- err = models.AddCygxReportSelectionVoiceHistory(&item)
- if err != nil {
- br.Msg = "操作失败"
- br.ErrMsg = "操作失败,Err:" + err.Error()
- return
- }
- err = models.UpdateReportSelectionVoiceCounts(articleId)
- if err != nil {
- br.Msg = "更新失败"
- br.ErrMsg = "更新失败,Err:" + err.Error()
- return
- }
- }
- }
- br.Ret = 200
- br.Success = true
- br.Msg = "操作成功"
- return
- }
- // @Title 周期行业报告分类列表接口
- // @Description 周期获取行业报告分类列表接口
- // @Success 200 {object} models.TradeReportMappingResp
- // @router /zhouqi_tradeList [get]
- func (this *ReportController) ZouqiTradeList() {
- 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
- }
- listCategory, err := models.GetCygxZhouqiArticleMapFirst()
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
- return
- }
- resp := new(models.TradeReportMappingResp)
- var list []*models.TradeReportMapping
- if len(listCategory) == 0 {
- list = make([]*models.TradeReportMapping, 0)
- } else {
- for _, v := range listCategory {
- item := new(models.TradeReportMapping)
- item.CategoryId = v.CategoryId
- item.MatchTypeName = v.MatchTypeName
- item.UpdateTime = v.ArticleUpdateTime
- //item.ListArticle = make([]*models.HomeArticle, 0)
- list = append(list, item)
- }
- }
- resp.List = list
- 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"
- // @Success 200 {object} models.TacticsListResp
- // @router /tactics/zhouqi_list [get]
- func (this *ReportController) ZhouqiTacticsList() {
- 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")
- var startSize int
- if pageSize <= 0 {
- pageSize = utils.PageSize20
- }
- if currentIndex <= 0 {
- currentIndex = 1
- }
- startSize = paging.StartIndex(currentIndex, pageSize)
- var total int
- var err error
- resp := new(models.TacticsListZhouqiResp)
- page := paging.GetPaging(currentIndex, pageSize, total)
- list := make([]*models.HomeArticle, 0)
- listCategory, err := models.GetCygxZhouqiArticleMapByParentId(categoryId)
- if err != nil {
- br.Msg = "获取信息失败"
- br.ErrMsg = "获取产业报告+晨会点评列表,Err:" + err.Error()
- return
- }
- var matchTypeName = []string{}
- var seriesName = []string{}
- for _, v := range listCategory {
- if v.MatchTypeName != "" {
- matchTypeName = append(matchTypeName, v.MatchTypeName)
- }
- if v.SeriesName != "" {
- seriesName = append(seriesName, v.SeriesName)
- }
- }
- var condition string
- //var pars []interface{}
- if len(seriesName) == 0 {
- condition = " AND field_name IN ('" + strings.Join(matchTypeName, "','") + "')"
- } else {
- condition = " AND ( field_name IN ('" + strings.Join(matchTypeName, "','") + "') OR series_name IN ('" + strings.Join(seriesName, "','") + "') )"
- }
- list, total, err = models.GetReportAndproductIndustrylListimgZhouqi(condition, startSize, pageSize)
- if err != nil {
- br.Msg = "获取信息失败"
- br.Msg = "GetReportAndproductIndustrylListimgZhouqi,Err:" + err.Error()
- return
- }
- listPublic, err := services.HandleArticleCategoryImg(list)
- if err != nil {
- br.Msg = "获取失败"
- br.ErrMsg = "获取报告封面图片失败, Err:" + err.Error()
- return
- }
- var articleIds []int
- for _, v := range listPublic {
- if v.Resource == 1 {
- articleIds = append(articleIds, v.ArticleId)
- }
- }
- articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
- articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
- articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
- listResp := make([]*models.HomeArticle, 0)
- for _, v := range listPublic {
- item := new(models.HomeArticle)
- item.ArticleId = v.ArticleId
- item.ReportId = v.ReportId
- item.Title = v.Title
- item.Annotation = v.Annotation
- item.Abstract = v.Abstract
- item.ImgUrlPc = v.ImgUrlPc
- item.PublishDate = v.PublishDate
- item.Resource = v.Resource
- if v.Resource == 1 {
- item.Pv = articleMapPv[v.ArticleId]
- item.IsCollect = articleCollectMap[v.ArticleId]
- item.CollectNum = articleCollectNumMap[v.ArticleId]
- }
- if v.ReportId > 0 {
- item.Resource = 3
- }
- listResp = append(listResp, item)
- }
- if len(listResp) == 0 {
- listResp = make([]*models.HomeArticle, 0)
- }
- page = paging.GetPaging(currentIndex, pageSize, total)
- resp.List = listResp
- resp.Paging = page
- br.Ret = 200
- br.Success = true
- br.Msg = "获取成功"
- br.Data = resp
- }
|