report.go 123 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. "github.com/medivhzhan/weapp/v2"
  7. "github.com/rdlucklib/rdluck_tools/paging"
  8. "hongze/hongze_cygx/models"
  9. "hongze/hongze_cygx/services"
  10. "hongze/hongze_cygx/utils"
  11. "html"
  12. "strconv"
  13. "strings"
  14. "time"
  15. )
  16. // 报告
  17. type ReportController struct {
  18. BaseAuthController
  19. }
  20. type ReportCommonController struct {
  21. BaseCommonController
  22. }
  23. // @Title 行业报告分类列表接口
  24. // @Description 获取行业报告分类列表接口
  25. // @Param ChartPermissionId query int true "分类ID"
  26. // @Success 200 {object} models.IndustrialManagementList
  27. // @router /home/tradeList [get]
  28. func (this *ReportController) TradeList() {
  29. br := new(models.BaseResponse).Init()
  30. defer func() {
  31. this.Data["json"] = br
  32. this.ServeJSON()
  33. }()
  34. user := this.User
  35. if user == nil {
  36. br.Msg = "请重新登录"
  37. br.Ret = 408
  38. return
  39. }
  40. //uid := user.UserId
  41. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  42. if ChartPermissionId < 1 {
  43. br.Msg = "请输入分类ID"
  44. return
  45. }
  46. listCategory, err := models.GetTradeArticleAndProductInterior(ChartPermissionId)
  47. if err != nil {
  48. br.Msg = "获取信息失败"
  49. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  50. return
  51. }
  52. var list []*models.TradeReportMapping
  53. categoryMap := make(map[int]int)
  54. for _, v := range listCategory {
  55. if categoryMap[v.CategoryId] > 0 {
  56. continue
  57. }
  58. categoryMap[v.CategoryId] = v.CategoryId
  59. list = append(list, v)
  60. }
  61. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  62. //if ChartPermissionId == utils.KE_JI_ID {
  63. // list = append(list, &models.TradeReportMapping{MatchTypeName: "AI前沿", CategoryId: utils.ACTEGORY_ID_AI_QY})
  64. //}
  65. //var condition string
  66. //var pars []interface{}
  67. for k, v := range list {
  68. //if v.PolymerizationId != "" {
  69. // condition = ` AND a.category_id IN(` + v.PolymerizationId + `)`
  70. //} else {
  71. // condition = ` AND a.category_id IN(` + strconv.Itoa(v.CategoryId) + `)`
  72. //}
  73. pageSize := 1
  74. var listArticle []*models.ReportArticle
  75. if v.CategoryId == utils.ACTEGORY_ID_AI_QY {
  76. //加了一个需求,现有数据结构不支持,手动添加 2023-06-12
  77. listArticle, _, err = services.GetAiQianYanArtilceList(0, pageSize)
  78. if err != nil && err.Error() != utils.ErrNoRow() {
  79. br.Msg = "获取信息失败"
  80. br.Msg = "GetHomeList,Err:" + err.Error()
  81. return
  82. }
  83. //for _, vAi := range listArticleAi {
  84. // listArticle = append(listArticle, &models.ReportArticle{
  85. // CategoryId: vAi.CategoryId,
  86. // PublishDate: vAi.PublishDate,
  87. // })
  88. //}
  89. } else {
  90. listArticle, _, err = models.GetReportAndproductIndustrylList(v.CategoryId, 0, pageSize)
  91. if err != nil && err.Error() != utils.ErrNoRow() {
  92. br.Msg = "获取信息失败"
  93. br.Msg = "GetHomeList,Err:" + err.Error()
  94. return
  95. }
  96. }
  97. //listArticle, _, err := models.GetReportAndproductIndustrylList(v.CategoryId, 0, 1)
  98. if len(listArticle) > 0 {
  99. list[k].UpdateTime = utils.StrTimeToTime(listArticle[0].PublishDate).Format(utils.FormatDate) //时间字符串格式转时间格式 }
  100. }
  101. }
  102. resp := new(models.TradeReportMappingResp)
  103. resp.List = list
  104. br.Ret = 200
  105. br.Success = true
  106. br.Msg = "获取成功"
  107. br.Data = resp
  108. }
  109. // @Title 产业报告分类列表接口
  110. // @Description 获取产业报告分类列表接口
  111. // @Param ChartPermissionId query int true "分类ID"
  112. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  113. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  114. // @Param KeyWord query string true "搜索关键词"
  115. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  116. // @Param DeepCover query int false "深度覆盖:0-否;1-是"
  117. // @Param RecommendFocus query int false "推荐关注:0-否;1-是"
  118. // @Param PageSize query int true "每页数据条数"
  119. // @Param CurrentIndex query int true "当前页页码,从1开始"
  120. // @Success 200 {object} models.IndustrialManagementList
  121. // @router /home/industryList [get]
  122. func (this *ReportController) IndustryList() {
  123. br := new(models.BaseResponse).Init()
  124. defer func() {
  125. this.Data["json"] = br
  126. this.ServeJSON()
  127. }()
  128. user := this.User
  129. if user == nil {
  130. br.Msg = "请重新登录"
  131. br.Ret = 408
  132. return
  133. }
  134. uid := user.UserId
  135. fmt.Println(uid)
  136. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  137. orderColumn := this.GetString("OrderColumn")
  138. orderColumnNew := this.GetString("OrderColumn")
  139. isNewLabel := this.GetString("IsNewLabel")
  140. isDeepLabel := this.GetString("IsDeepLabel")
  141. keyWord := this.GetString("KeyWord")
  142. pageSize, _ := this.GetInt("PageSize")
  143. currentIndex, _ := this.GetInt("CurrentIndex")
  144. deepCover, _ := this.GetInt("DeepCover")
  145. recommendFocus, _ := this.GetInt("RecommendFocus")
  146. var orderSrt string
  147. var condition string
  148. var startSize int
  149. resp := new(models.IndustrialManagementList)
  150. if pageSize <= 0 {
  151. pageSize = utils.PageSize20
  152. }
  153. if currentIndex <= 0 {
  154. currentIndex = 1
  155. }
  156. startSize = paging.StartIndex(currentIndex, pageSize)
  157. if isNewLabel == "1" {
  158. condition += ` AND is_new_label = ` + isNewLabel
  159. }
  160. if isDeepLabel == "1" {
  161. condition += ` AND is_deep_label = ` + isDeepLabel
  162. }
  163. if keyWord != "" {
  164. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  165. }
  166. var sqlChartPermissionId string
  167. if ChartPermissionId > 0 {
  168. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  169. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  170. }
  171. // 深度覆盖
  172. if deepCover == 1 {
  173. // 查询深标签产业报告数
  174. var deepCondition string
  175. var deepPars []interface{}
  176. deepCondition += ` AND man.is_deep_label = 1`
  177. if ChartPermissionId > 0 {
  178. deepCondition += ` AND man.chart_permission_id = ?`
  179. deepPars = append(deepPars, ChartPermissionId)
  180. }
  181. industryCountList, e := models.GetIndustryArtCountByCondition(deepCondition, deepPars)
  182. if e != nil {
  183. br.Msg = "获取信息失败"
  184. br.ErrMsg = "获取深标签产业报告数失败, Err: " + e.Error()
  185. return
  186. }
  187. deepIdArr := make([]string, 0)
  188. for i := range industryCountList {
  189. if industryCountList[i].ArtNum > 10 {
  190. deepIdArr = append(deepIdArr, strconv.Itoa(industryCountList[i].IndustrialManagementId))
  191. }
  192. }
  193. deepIds := strings.Join(deepIdArr, ",")
  194. if deepIds != "" {
  195. condition = `AND man.industrial_management_id IN (` + deepIds + `)`
  196. }
  197. }
  198. // 推荐关注
  199. if recommendFocus == 1 {
  200. condition += ` AND man.recommended_index >= 80`
  201. }
  202. // 列表总数据量
  203. var list []*models.IndustrialManagement
  204. total, err := models.GetIndustrialManagementAllCount(condition)
  205. if err != nil {
  206. br.Msg = "获取信息失败"
  207. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  208. return
  209. }
  210. page := paging.GetPaging(currentIndex, pageSize, total)
  211. if orderColumn == "" {
  212. orderColumn = "NewTime"
  213. }
  214. if orderColumn == "NewTime" {
  215. orderSrt = "update_time DESC"
  216. } else {
  217. orderSrt = "man.recommended_index DESC,update_time DESC"
  218. }
  219. if ChartPermissionId == 0 {
  220. ChartPermissionId = 20
  221. }
  222. // 阅读第三的产业详情
  223. //detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  224. //if err != nil {
  225. // br.Msg = "获取信息失败"
  226. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  227. // return
  228. //}
  229. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  230. if err != nil {
  231. br.Msg = "获取信息失败"
  232. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  233. return
  234. }
  235. // 获取近一个月产业报告阅读次数最多的产业
  236. var topCond string
  237. var topPars []interface{}
  238. //topReadIndustryId := 0
  239. if ChartPermissionId > 0 {
  240. topCond += ` AND chart_permission_id = ?`
  241. topPars = append(topPars, ChartPermissionId)
  242. }
  243. list, err = services.HandleIndustryList(list, user)
  244. if orderColumnNew != "" {
  245. item := new(models.CygxReportIndustrialSeaarchHistory)
  246. item.UserId = user.UserId
  247. item.Mobile = user.Mobile
  248. item.CompanyId = user.CompanyId
  249. item.CompanyName = user.CompanyName
  250. item.CreateTime = time.Now()
  251. item.IsDeepLabel = isDeepLabel
  252. item.IsNewLabel = isNewLabel
  253. item.ChartPermissionId = ChartPermissionId
  254. if orderColumnNew == "NewTime" {
  255. item.OrderColumn = "0"
  256. } else {
  257. item.OrderColumn = "1"
  258. }
  259. go models.AddCygxReportIndustrialSeaarchHistory(item)
  260. }
  261. resp.List = list
  262. resp.Paging = page
  263. br.Ret = 200
  264. br.Success = true
  265. br.Msg = "获取成功"
  266. br.Data = resp
  267. }
  268. // @Title 产业下所关联的文章分类列表
  269. // @Description 产业下所关联的文章分类列表接口
  270. // @Param IndustrialManagementId query int true "产业ID"
  271. // @Param ShowTimeLine query int true "是否展示时间线 0不展示,1展示"
  272. // @Param IsSendWx query int false "是否是通过微信模版进来的 1是,其它否"
  273. // @Param ChapterId query int false "晨会精华段落ID"
  274. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  275. // @router /toArticleCategoryList [get]
  276. func (this *ReportController) ArticleCategoryList() {
  277. br := new(models.BaseResponse).Init()
  278. defer func() {
  279. this.Data["json"] = br
  280. this.ServeJSON()
  281. }()
  282. user := this.User
  283. if user == nil {
  284. br.Msg = "请重新登录"
  285. br.Ret = 408
  286. return
  287. }
  288. //uid := user.UserId
  289. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  290. if industrialManagementId < 1 {
  291. br.Msg = "请输入分类ID"
  292. return
  293. }
  294. showTimeLine, _ := this.GetInt("ShowTimeLine", 0)
  295. isSendWx, _ := this.GetInt("IsSendWx")
  296. chapterId, _ := this.GetInt("ChapterId")
  297. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  298. if err != nil {
  299. br.Msg = "获取信息失败"
  300. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  301. return
  302. }
  303. listCategory, err := models.IndustrialToArticleAndProductInteriorCategoryNew(industrialManagementId)
  304. if err != nil {
  305. br.Msg = "获取信息失败"
  306. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  307. return
  308. }
  309. var list []*models.IndustrialToArticleCategoryRep
  310. categoryMap := make(map[int]int)
  311. for _, v := range listCategory {
  312. if categoryMap[v.CategoryId] > 0 {
  313. continue
  314. }
  315. categoryMap[v.CategoryId] = v.CategoryId
  316. list = append(list, v)
  317. }
  318. // 用户权限
  319. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  320. if e != nil {
  321. br.Msg = "获取失败"
  322. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  323. return
  324. }
  325. videoSimple := new(models.MicroVideoSimpleInfo)
  326. // 权限
  327. var au *models.UserPermissionAuthInfo
  328. video, err := models.GetMicroRoadshowVideoByIndustryId(industrialManagementId)
  329. if err != nil {
  330. if err.Error() != utils.ErrNoRow() {
  331. br.Msg = "获取产业视频失败"
  332. br.ErrMsg = "获取产业视频失败,Err:" + err.Error()
  333. return
  334. }
  335. } else {
  336. videoSimple.Id = video.VideoId
  337. videoSimple.Title = "5min逻辑【" + video.IndustryName + "】解析"
  338. videoSimple.BackgroundImg = video.ImgUrl
  339. videoSimple.DetailImgUrl = video.DetailImgUrl
  340. if videoSimple.BackgroundImg == "" {
  341. // 获取默认图配置
  342. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  343. if e != nil {
  344. br.Msg = "获取视频默认配置图失败"
  345. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  346. return
  347. }
  348. videoSimple.BackgroundImg = videoMap[video.ChartPermissionId]
  349. }
  350. videoSimple.PlaySeconds = video.VideoDuration
  351. videoSimple.ResourceUrl = video.VideoUrl
  352. au = new(models.UserPermissionAuthInfo)
  353. au.SellerName = authInfo.SellerName
  354. au.SellerMobile = authInfo.SellerMobile
  355. au.HasPermission = authInfo.HasPermission
  356. au.OperationMode = authInfo.OperationMode
  357. if au.HasPermission == 1 {
  358. // 非宏观权限进一步判断是否有权限
  359. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  360. au.HasPermission = 2
  361. }
  362. }
  363. // 无权限的弹框提示
  364. if au.HasPermission != 1 {
  365. if au.OperationMode == services.UserPermissionOperationModeCall {
  366. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  367. } else {
  368. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  369. }
  370. videoSimple.ResourceUrl = ""
  371. }
  372. }
  373. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  374. //if err != nil {
  375. // br.Msg = "获取信息失败"
  376. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  377. // return
  378. //}
  379. //时间线
  380. if showTimeLine == 1 {
  381. timeLineItem := models.IndustrialToArticleCategoryRep{
  382. CategoryId: 99999,
  383. MatchTypeName: "时间线",
  384. }
  385. timeLineList, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, 0, 30)
  386. if err != nil {
  387. br.Msg = "获取信息失败"
  388. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  389. return
  390. }
  391. //查询用户今天是否看过时间线
  392. haveMorningMeeting := false
  393. var morningMeetingTime string
  394. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  395. if err != nil {
  396. br.Msg = "查询浏览记录数量失败"
  397. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  398. return
  399. }
  400. var recordItem *models.CygxPageHistoryRecord
  401. if count > 1 {
  402. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  403. if err != nil {
  404. br.Msg = "查询浏览记录失败"
  405. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  406. return
  407. }
  408. }
  409. for _, v := range timeLineList {
  410. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  411. if v.SubCategoryName == "时间线" {
  412. haveMorningMeeting = true
  413. morningMeetingTime = v.PublishTime
  414. continue
  415. }
  416. timeLineItem.IsRed = true
  417. }
  418. }
  419. //因为无法记录用户是否看过晨会点评,所以用用户今天是否看过时间线来判断是否显示小红点,这里是判断分类的小红点
  420. timeLineRed := false
  421. if count < 2 {
  422. timeLineRed = true
  423. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(morningMeetingTime)) {
  424. timeLineRed = true
  425. }
  426. if !timeLineItem.IsRed && timeLineRed && haveMorningMeeting {
  427. timeLineItem.IsRed = true
  428. }
  429. list = append([]*models.IndustrialToArticleCategoryRep{&timeLineItem}, list...)
  430. if chapterId > 0 && isSendWx == 1 {
  431. go services.AddCygxMorningMeetingReviewChapterHistory(user, chapterId, "微信")
  432. }
  433. }
  434. resp := new(models.IndustrialToArticleCategoryListRep)
  435. resp.List = list
  436. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  437. resp.IndustryName = detail.IndustryName
  438. resp.IndustrialManagementId = industrialManagementId
  439. resp.AuthInfo = au
  440. if videoSimple.Id > 0 {
  441. resp.IndustryVideo = videoSimple
  442. }
  443. if isSendWx == 1 {
  444. industryUserFollowMap, err := services.GetIndustryUserFollowMap(user)
  445. if err != nil {
  446. br.Msg = "获取信息失败"
  447. br.ErrMsg = "GetActivitySignupResp,Err:" + err.Error()
  448. return
  449. }
  450. resp.IsFollowButton = industryUserFollowMap[industrialManagementId]
  451. resp.IsShowFollowButton = true
  452. }
  453. br.Ret = 200
  454. br.Success = true
  455. br.Msg = "获取成功"
  456. br.Data = resp
  457. }
  458. // @Title 产业文章列表接口
  459. // @Description 获取产业文章列表接口
  460. // @Param PageSize query int true "每页数据条数"
  461. // @Param CurrentIndex query int true "当前页页码,从1开始"
  462. // @Param CategoryId query int true "分类ID"
  463. // @Param IndustrialManagementId query int true "产业ID"
  464. // @Success 200 {object} models.TacticsListResp
  465. // @router /industry/ArticleList [get]
  466. func (this *ReportController) List() {
  467. br := new(models.BaseResponse).Init()
  468. defer func() {
  469. this.Data["json"] = br
  470. this.ServeJSON()
  471. }()
  472. user := this.User
  473. if user == nil {
  474. br.Msg = "请重新登录"
  475. br.Ret = 408
  476. return
  477. }
  478. uid := user.UserId
  479. pageSize, _ := this.GetInt("PageSize")
  480. currentIndex, _ := this.GetInt("CurrentIndex")
  481. categoryId, _ := this.GetInt("CategoryId")
  482. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  483. var startSize int
  484. if pageSize <= 0 {
  485. pageSize = utils.PageSize20
  486. }
  487. if currentIndex <= 0 {
  488. currentIndex = 1
  489. }
  490. startSize = paging.StartIndex(currentIndex, pageSize)
  491. var pars []interface{}
  492. var total int
  493. page := paging.GetPaging(currentIndex, pageSize, total)
  494. if categoryId < 1 {
  495. br.Msg = "请输入分类ID"
  496. return
  497. }
  498. if industrialManagementId < 1 {
  499. br.Msg = "请输入产业ID"
  500. return
  501. }
  502. if categoryId != 99999 {
  503. resp := new(models.TacticsListResp)
  504. list, total, err := models.GetReportAndproductInteriorIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  505. if err != nil {
  506. br.Msg = "获取信息失败"
  507. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  508. return
  509. }
  510. page = paging.GetPaging(currentIndex, pageSize, total)
  511. //对应分类的所图片
  512. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  513. if err != nil {
  514. br.Msg = "获取数据失败"
  515. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  516. return
  517. }
  518. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  519. mapCategoryUrl := make(map[string]string)
  520. var categoryIdStr string
  521. var imgUrlChart string
  522. for _, v := range categoryUrlList {
  523. vslice := strings.Split(v, "_")
  524. categoryIdStr = vslice[0]
  525. imgUrlChart = vslice[len(vslice)-1]
  526. mapCategoryUrl[categoryIdStr] = imgUrlChart
  527. }
  528. var articleIds []int
  529. lenList := len(list)
  530. for i := 0; i < lenList; i++ {
  531. item := list[i]
  532. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  533. //list[i].Abstract = html.UnescapeString(item.Abstract)
  534. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  535. if item.Resource == 1 {
  536. articleIds = append(articleIds, item.ArticleId)
  537. }
  538. }
  539. articleMapPv := services.GetArticleHistoryByArticleId(articleIds) //文章Pv
  540. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId) //用户收藏的文章
  541. articleCollectNumMap, _ := services.GetCygxArticleCollectNumMapByArtcileIds(articleIds) //文章收藏的数量
  542. for k, v := range list {
  543. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  544. list[k].IsRed = true
  545. }
  546. if v.VideoUrl != "" {
  547. list[k].IsHaveVideo = true
  548. }
  549. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  550. if v.Resource == 1 {
  551. v.Pv = articleMapPv[v.ArticleId]
  552. v.IsCollect = articleCollectMap[v.ArticleId]
  553. v.CollectNum = articleCollectNumMap[v.ArticleId]
  554. }
  555. if v.Resource == 2 {
  556. v.PublishDate = utils.TimeRemoveHms2(v.PublishDate)
  557. }
  558. }
  559. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  560. //resp.ChartPermissionId = detail.ChartPermissionId
  561. resp.List = list
  562. resp.Paging = page
  563. br.Ret = 200
  564. br.Success = true
  565. br.Msg = "获取成功"
  566. br.Data = resp
  567. } else {
  568. //获取该产业下所对应的行业图片
  569. //因为时间线不属于数据表里的二级分类,所以图片Id用产业id查到的list中的任意一个categoryId取到的图片替代
  570. categoryList, err := models.IndustrialToArticleCategoryNew(industrialManagementId)
  571. if err != nil {
  572. br.Msg = "获取信息失败"
  573. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  574. return
  575. }
  576. var timeLineCategoryId int
  577. if len(categoryList) > 0 {
  578. timeLineCategoryId = categoryList[0].CategoryId
  579. }
  580. var detail *models.ReportMapping
  581. var errCategory error
  582. if timeLineCategoryId > 0 {
  583. detail, errCategory = models.GetdetailByCategoryIdOne(timeLineCategoryId)
  584. if errCategory != nil {
  585. br.Msg = "获取信息失败"
  586. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  587. return
  588. }
  589. }
  590. //对应行业的图片
  591. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  592. if err != nil {
  593. br.Msg = "获取数据失败"
  594. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  595. return
  596. }
  597. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  598. mapChartPermission := make(map[string]string)
  599. var permissionName string
  600. var imgUrlChartPermission string
  601. for _, v := range chartPermissionUrlList {
  602. vslice := strings.Split(v, "_")
  603. permissionName = vslice[0]
  604. imgUrlChartPermission = vslice[len(vslice)-1]
  605. mapChartPermission[permissionName] = imgUrlChartPermission
  606. }
  607. total, err := models.GetTimeLineReportIndustrialCount(industrialManagementId)
  608. if err != nil {
  609. br.Msg = "获取信息失败"
  610. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  611. return
  612. }
  613. page = paging.GetPaging(currentIndex, pageSize, total)
  614. list, err := models.GetTimeLineReportIndustrialList(user.UserId, industrialManagementId, startSize, pageSize)
  615. if err != nil {
  616. br.Msg = "获取信息失败"
  617. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  618. return
  619. }
  620. //对应分类的所图片
  621. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  622. if err != nil {
  623. br.Msg = "获取数据失败"
  624. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  625. return
  626. }
  627. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  628. mapCategoryUrl := make(map[string]string)
  629. var categoryIdStr string
  630. var imgUrlChart string
  631. for _, v := range categoryUrlList {
  632. vslice := strings.Split(v, "_")
  633. categoryIdStr = vslice[0]
  634. imgUrlChart = vslice[len(vslice)-1]
  635. mapCategoryUrl[categoryIdStr] = imgUrlChart
  636. }
  637. //lenList := len(list)
  638. //for i := 0; i < lenList; i++ {
  639. // item := list[i]
  640. // list[i].Content, _ = services.GetReportContentTextSub(item.Content)
  641. // //list[i].Abstract = html.UnescapeString(item.Abstract)
  642. // //list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  643. //}
  644. //查询用户今天是否看过时间线
  645. count, err := models.GetTimeLineRecordCount(user.UserId, industrialManagementId)
  646. if err != nil {
  647. br.Msg = "查询浏览记录数量失败"
  648. br.ErrMsg = "查询浏览记录数量失败,Err:" + err.Error()
  649. return
  650. }
  651. var recordItem *models.CygxPageHistoryRecord
  652. if count > 1 {
  653. recordItem, err = models.GetTimeLineRecordItem(user.UserId, industrialManagementId)
  654. if err != nil {
  655. br.Msg = "查询浏览记录失败"
  656. br.ErrMsg = "查询浏览记录失败,Err:" + err.Error()
  657. return
  658. }
  659. }
  660. for k, v := range list {
  661. if v.SubCategoryName != "时间线" && v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishTime)) {
  662. list[k].IsRed = true
  663. }
  664. timeLineRed := false
  665. if count < 2 && v.SubCategoryName == "时间线" {
  666. timeLineRed = true
  667. } else if count > 1 && recordItem.CreateTime.Before(utils.StrTimeToTime(v.PublishTime)) {
  668. timeLineRed = true
  669. }
  670. if v.SubCategoryName == "时间线" && timeLineRed {
  671. list[k].IsRed = true
  672. }
  673. if v.VideoUrl != "" {
  674. list[k].IsHaveVideo = true
  675. }
  676. id := strconv.Itoa(timeLineCategoryId)
  677. list[k].ImgUrlPc = mapCategoryUrl[id]
  678. if mapCategoryUrl[id] == "" {
  679. if detail != nil {
  680. if detail.ChartPermissionId == utils.YI_YAO_ID {
  681. list[k].ImgUrlPc = utils.YI_YAO_QI_TA
  682. }
  683. }
  684. }
  685. }
  686. resp := new(models.TimeLineReportListResp)
  687. //resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  688. resp.List = list
  689. resp.Paging = page
  690. br.Ret = 200
  691. br.Success = true
  692. br.Msg = "获取成功"
  693. br.Data = resp
  694. }
  695. }
  696. // @Title 置顶/取消置顶
  697. // @Description 置顶
  698. // @Param request body models.CygxIndustryTopRep true "type json string"
  699. // @Success 200
  700. // @router /top [post]
  701. func (this *ReportController) ArticleCollect() {
  702. br := new(models.BaseResponse).Init()
  703. defer func() {
  704. this.Data["json"] = br
  705. this.ServeJSON()
  706. }()
  707. user := this.User
  708. if user == nil {
  709. br.Msg = "请重新登录"
  710. br.Ret = 408
  711. return
  712. }
  713. uid := user.UserId
  714. var req models.CygxIndustryTopRep
  715. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  716. if err != nil {
  717. br.Msg = "参数解析异常!"
  718. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  719. return
  720. }
  721. industrialManagementId := req.IndustrialManagementId
  722. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  723. if err != nil {
  724. br.Msg = "获取数据失败!"
  725. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  726. return
  727. }
  728. if countIndustrial == 0 {
  729. br.Msg = "产业不存在!"
  730. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  731. return
  732. }
  733. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  734. if err != nil {
  735. br.Msg = "获取数据失败!"
  736. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  737. return
  738. }
  739. resp := new(models.ArticleCollectResp)
  740. if count <= 0 {
  741. item := new(models.CygxIndustryTop)
  742. item.IndustrialManagementId = req.IndustrialManagementId
  743. item.UserId = uid
  744. item.CreateTime = time.Now()
  745. _, err = models.AddCygxIndustryTop(item)
  746. if err != nil {
  747. br.Msg = "置顶失败"
  748. br.ErrMsg = "置顶失败,Err:" + err.Error()
  749. return
  750. }
  751. br.Msg = "置顶成功"
  752. resp.Status = 1
  753. } else {
  754. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  755. if err != nil {
  756. br.Msg = "取消置顶失败"
  757. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  758. return
  759. }
  760. br.Msg = "已取消置顶"
  761. resp.Status = 2
  762. }
  763. br.Ret = 200
  764. br.Success = true
  765. br.Data = resp
  766. }
  767. // @Title 关注/取消关注产业
  768. // @Description 关注/取消关注 接口
  769. // @Param request body models.CygxIndustryFllowRep true "type json string"
  770. // @Success 200
  771. // @router /fllow [post]
  772. func (this *ReportController) Fllow() {
  773. br := new(models.BaseResponse).Init()
  774. defer func() {
  775. this.Data["json"] = br
  776. this.ServeJSON()
  777. }()
  778. user := this.User
  779. if user == nil {
  780. br.Msg = "请重新登录"
  781. br.Ret = 408
  782. return
  783. }
  784. uid := user.UserId
  785. var req models.CygxIndustryFllowRep
  786. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  787. if err != nil {
  788. br.Msg = "参数解析异常!"
  789. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  790. return
  791. }
  792. industrialManagementId := req.IndustrialManagementId
  793. var condition string
  794. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  795. if err != nil {
  796. br.Msg = "获取数据失败!"
  797. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  798. return
  799. }
  800. if countIndustrial == 0 {
  801. br.Msg = "产业不存在!"
  802. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  803. return
  804. }
  805. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  806. if err != nil {
  807. br.Msg = "获取数据失败!"
  808. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  809. return
  810. }
  811. resp := new(models.CygxIndustryFllowResp)
  812. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  813. if countUser == 0 {
  814. resp.GoFollow = true
  815. }
  816. item := new(models.CygxIndustryFllow)
  817. item.IndustrialManagementId = industrialManagementId
  818. item.UserId = uid
  819. item.Email = user.Email
  820. item.Mobile = user.Mobile
  821. item.RealName = user.RealName
  822. item.Source = utils.REGISTER_PLATFORM
  823. item.CompanyId = user.CompanyId
  824. item.CompanyName = user.CompanyName
  825. if count == 0 {
  826. item.Type = 1
  827. item.CreateTime = time.Now()
  828. item.ModifyTime = time.Now()
  829. _, err = models.AddCygxIndustryFllow(item)
  830. if err != nil {
  831. br.Msg = "操作失败"
  832. br.ErrMsg = "操作失败,Err:" + err.Error()
  833. return
  834. }
  835. resp.Status = 1
  836. } else {
  837. item.Type = 2
  838. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId)
  839. if err != nil {
  840. br.Msg = "操作失败"
  841. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  842. return
  843. }
  844. }
  845. go services.IndustryFllowWithTrack(industrialManagementId, count, uid) //处理是否关注全部赛道字段
  846. go services.IndustryFllowUserLabelLogAdd(industrialManagementId, count, uid) //处理用户标签
  847. go services.AddCygxIndustryFllowLog(item) //添加操作日志记录
  848. br.Msg = "操作成功"
  849. br.Ret = 200
  850. br.Success = true
  851. br.Data = resp
  852. }
  853. // @Title 产业报告分类关联作者列表接口
  854. // @Description 获取产业报告分类关联作者列表接口
  855. // @Param ChartPermissionId query int true "分类ID"
  856. // @Param PageSize query int true "每页数据条数"
  857. // @Param CurrentIndex query int true "当前页页码,从1开始"
  858. // @Success 200 {object} models.CygxArticleDepartmentList
  859. // @router /industryListByDepartment [get]
  860. func (this *ReportController) IndustryListByDepartment() {
  861. br := new(models.BaseResponse).Init()
  862. defer func() {
  863. this.Data["json"] = br
  864. this.ServeJSON()
  865. }()
  866. user := this.User
  867. if user == nil {
  868. br.Msg = "请重新登录"
  869. br.Ret = 408
  870. return
  871. }
  872. uid := user.UserId
  873. pageSize, _ := this.GetInt("PageSize")
  874. currentIndex, _ := this.GetInt("CurrentIndex")
  875. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  876. var startSize int
  877. var condition string
  878. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  879. condition = ` AND a.publish_status=1 `
  880. if pageSize <= 0 {
  881. pageSize = utils.PageSize20
  882. }
  883. if currentIndex <= 0 {
  884. currentIndex = 1
  885. }
  886. startSize = paging.StartIndex(currentIndex, pageSize)
  887. total, err := models.GetArticleDepartmentCount(condition)
  888. page := paging.GetPaging(currentIndex, pageSize, total)
  889. resp := new(models.CygxArticleDepartmentList)
  890. userType, _, err := services.GetUserType(user.CompanyId)
  891. if err != nil {
  892. br.Msg = "获取信息失败"
  893. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  894. return
  895. }
  896. if userType == 1 {
  897. resp.Paging = page
  898. br.Ret = 200
  899. br.Success = true
  900. br.Msg = "获取成功"
  901. br.Data = resp
  902. return
  903. }
  904. resp.HaveResearch = true
  905. //获取作者信息,并排序
  906. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  907. if err != nil {
  908. br.Msg = "获取信息失败"
  909. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  910. return
  911. }
  912. for k, v := range list {
  913. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  914. if err != nil {
  915. br.Msg = "获取信息失败"
  916. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  917. return
  918. }
  919. for k2, v2 := range artList {
  920. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  921. if err != nil {
  922. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  923. br.ErrMsg = "获取失败,Err:" + err.Error()
  924. return
  925. }
  926. var subjectNamesNew string
  927. if len(subjectNames) > 0 {
  928. slice := strings.Split(subjectNames, "/")
  929. for k3, v3 := range slice {
  930. if k3 < 4 {
  931. subjectNamesNew += v3 + "/"
  932. }
  933. }
  934. }
  935. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  936. if err != nil && err.Error() != utils.ErrNoRow() {
  937. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  938. br.ErrMsg = "获取失败,Err:" + err.Error()
  939. return
  940. }
  941. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  942. artList[k2].SubjectName = subjectNamesNew
  943. artList[k2].DepartmentId = v.DepartmentId
  944. if subjectNamesNew == "" {
  945. artList[k2].IndustryName = industryName
  946. } else {
  947. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  948. }
  949. if artList[k2].IsReport == "1" {
  950. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  951. } else {
  952. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  953. }
  954. }
  955. list[k].List = artList
  956. if v.FollowNum > 0 {
  957. list[k].IsMyFollow = true
  958. }
  959. }
  960. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  961. if err != nil {
  962. br.Msg = "获取信息失败"
  963. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  964. return
  965. }
  966. if len(listnNew) > 0 {
  967. for _, v := range listnNew {
  968. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  969. Management := new(models.IndustrialManagementIdInt)
  970. if firstStr == 0 {
  971. Management.IndustryName = v.IndustryName
  972. } else {
  973. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  974. if err != nil {
  975. br.Msg = "获取信息失败"
  976. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  977. return
  978. }
  979. var subjectNamesNew string
  980. for _, v1 := range listSub {
  981. subjectNamesNew += v1.SubjectName + "/"
  982. }
  983. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  984. Management.IndustryName = subjectNamesNew
  985. }
  986. Management.IndustrialManagementId = v.IndustrialManagementId
  987. Management.ArticleId = v.ArticleId
  988. resp.ListnNew = append(resp.ListnNew, Management)
  989. }
  990. }
  991. resp.List = list
  992. resp.Paging = page
  993. br.Ret = 200
  994. br.Success = true
  995. br.Msg = "获取成功"
  996. br.Data = resp
  997. }
  998. // @Title 关注作者/取消关注作者
  999. // @Description 关注作者/取消关注作者 接口
  1000. // @Param request body models.CygxArticleDepartmentId true "type json string"
  1001. // @Success 200
  1002. // @router /fllowDepartment [post]
  1003. func (this *ReportController) FllowDepartment() {
  1004. br := new(models.BaseResponse).Init()
  1005. defer func() {
  1006. this.Data["json"] = br
  1007. this.ServeJSON()
  1008. }()
  1009. user := this.User
  1010. if user == nil {
  1011. br.Msg = "请重新登录"
  1012. br.Ret = 408
  1013. return
  1014. }
  1015. uid := user.UserId
  1016. var req models.CygxArticleDepartmentId
  1017. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  1018. if err != nil {
  1019. br.Msg = "参数解析异常!"
  1020. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  1021. return
  1022. }
  1023. departmentId := req.DepartmentId
  1024. var condition string
  1025. countDepartment, err := models.GetDepartmentCount(departmentId)
  1026. if err != nil {
  1027. br.Msg = "获取数据失败!"
  1028. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1029. return
  1030. }
  1031. if countDepartment == 0 {
  1032. br.Msg = "作者不存在!"
  1033. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  1034. return
  1035. }
  1036. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  1037. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1038. if err != nil {
  1039. br.Msg = "获取数据失败!"
  1040. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1041. return
  1042. }
  1043. resp := new(models.CygxArticleDepartmentFollowResp)
  1044. if countUser == 0 {
  1045. resp.GoFollow = true
  1046. }
  1047. if count == 0 {
  1048. item := new(models.CygxArticleDepartmentFollow)
  1049. item.DepartmentId = departmentId
  1050. item.UserId = uid
  1051. item.Email = user.Email
  1052. item.Mobile = user.Mobile
  1053. item.RealName = user.RealName
  1054. item.CompanyId = user.CompanyId
  1055. item.CompanyName = user.CompanyName
  1056. item.Type = 1
  1057. item.CreateTime = time.Now()
  1058. item.ModifyTime = time.Now()
  1059. _, err = models.AddArticleDepartmentFollow(item)
  1060. if err != nil {
  1061. br.Msg = "操作失败"
  1062. br.ErrMsg = "操作失败,Err:" + err.Error()
  1063. return
  1064. }
  1065. resp.Status = 1
  1066. } else {
  1067. var doType int
  1068. condition = ` AND type = 1`
  1069. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  1070. if err != nil {
  1071. br.Msg = "操作失败!"
  1072. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  1073. return
  1074. }
  1075. if count == 1 {
  1076. resp.Status = 2
  1077. doType = 2
  1078. } else {
  1079. resp.Status = 1
  1080. doType = 1
  1081. }
  1082. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  1083. if err != nil {
  1084. br.Msg = "操作失败"
  1085. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  1086. return
  1087. }
  1088. }
  1089. br.Msg = "操作成功"
  1090. br.Ret = 200
  1091. br.Success = true
  1092. br.Data = resp
  1093. }
  1094. // @Title 研选文章列表接口
  1095. // @Description 获取研选文章列表接口
  1096. // @Param PageSize query int true "每页数据条数"
  1097. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1098. // @Param ArticleId query int true "文章id"
  1099. // @Param DepartmentId query int true "作者ID"
  1100. // @Param IndustrialManagementId query int true "产业ID"
  1101. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1102. // @router /industry/reportList [get]
  1103. func (this *ReportController) ReportList() {
  1104. br := new(models.BaseResponse).Init()
  1105. defer func() {
  1106. this.Data["json"] = br
  1107. this.ServeJSON()
  1108. }()
  1109. user := this.User
  1110. if user == nil {
  1111. br.Msg = "请重新登录"
  1112. br.Ret = 408
  1113. return
  1114. }
  1115. uid := user.UserId
  1116. pageSize, _ := this.GetInt("PageSize")
  1117. currentIndex, _ := this.GetInt("CurrentIndex")
  1118. departmentId, _ := this.GetInt("DepartmentId")
  1119. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  1120. articleId, _ := this.GetInt("ArticleId")
  1121. var condition string
  1122. var startSize int
  1123. if pageSize <= 0 {
  1124. pageSize = utils.PageSize20
  1125. }
  1126. if currentIndex <= 0 {
  1127. currentIndex = 1
  1128. }
  1129. startSize = paging.StartIndex(currentIndex, pageSize)
  1130. var pars []interface{}
  1131. var total int
  1132. resp := new(models.ReportArticleWhichIndustrialRepList)
  1133. page := paging.GetPaging(currentIndex, pageSize, total)
  1134. userType, _, err := services.GetUserType(user.CompanyId)
  1135. if err != nil {
  1136. br.Msg = "获取信息失败"
  1137. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1138. return
  1139. }
  1140. if userType == 1 {
  1141. resp.Paging = page
  1142. br.Ret = 200
  1143. br.Success = true
  1144. br.Msg = "获取成功"
  1145. br.Data = resp
  1146. return
  1147. }
  1148. resp.HaveResearch = true
  1149. if departmentId > 0 {
  1150. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  1151. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  1152. if err != nil {
  1153. br.Msg = "获取信息失败"
  1154. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1155. return
  1156. }
  1157. resp.NickName = detail.NickName
  1158. }
  1159. if industrialManagementId > 0 {
  1160. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  1161. }
  1162. if articleId > 0 {
  1163. detail, err := models.GetArticleDetailById(articleId)
  1164. if err != nil {
  1165. br.Msg = "获取信息失败"
  1166. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1167. return
  1168. }
  1169. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  1170. }
  1171. total, err = models.GetWhichDepartmentCount(condition)
  1172. if err != nil {
  1173. br.Msg = "获取信息失败"
  1174. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1175. return
  1176. }
  1177. page = paging.GetPaging(currentIndex, pageSize, total)
  1178. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1179. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1180. if err != nil {
  1181. br.Msg = "获取失败"
  1182. br.ErrMsg = "获取失败,Err:" + err.Error()
  1183. return
  1184. }
  1185. for k, v := range list {
  1186. if v.Readnum == 0 {
  1187. list[k].IsRed = true
  1188. }
  1189. list[k].IsResearch = true
  1190. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1191. if err != nil {
  1192. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1193. br.ErrMsg = "获取失败,Err:" + err.Error()
  1194. return
  1195. }
  1196. var subjectNamesNew string
  1197. if len(subjectNames) > 0 {
  1198. slice := strings.Split(subjectNames, "/")
  1199. for k3, v3 := range slice {
  1200. if k3 < 4 {
  1201. subjectNamesNew += v3 + "/"
  1202. }
  1203. }
  1204. }
  1205. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1206. if err != nil && err.Error() != utils.ErrNoRow() {
  1207. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1208. br.ErrMsg = "获取失败,Err:" + err.Error()
  1209. return
  1210. }
  1211. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1212. list[k].SubjectName = subjectNamesNew
  1213. if subjectNamesNew != "" {
  1214. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1215. } else {
  1216. list[k].IndustryName = industryName
  1217. }
  1218. resp.IndustryName = industryName
  1219. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1220. }
  1221. resp.List = list
  1222. resp.Paging = page
  1223. br.Ret = 200
  1224. br.Success = true
  1225. br.Msg = "获取成功"
  1226. br.Data = resp
  1227. }
  1228. // @Title 研选最新主题关键词文章列表接口
  1229. // @Description 获取研选最新主题关键词文章列表接口
  1230. // @Param PageSize query int true "每页数据条数"
  1231. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1232. // @Param ArticleId query int true "文章id"
  1233. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  1234. // @router /industry/reportListNew [get]
  1235. func (this *ReportController) ReportListNew() {
  1236. br := new(models.BaseResponse).Init()
  1237. defer func() {
  1238. this.Data["json"] = br
  1239. this.ServeJSON()
  1240. }()
  1241. user := this.User
  1242. if user == nil {
  1243. br.Msg = "请重新登录"
  1244. br.Ret = 408
  1245. return
  1246. }
  1247. uid := user.UserId
  1248. pageSize, _ := this.GetInt("PageSize")
  1249. currentIndex, _ := this.GetInt("CurrentIndex")
  1250. articleId, _ := this.GetInt("ArticleId")
  1251. var condition string
  1252. var startSize int
  1253. if pageSize <= 0 {
  1254. pageSize = utils.PageSize20
  1255. }
  1256. if currentIndex <= 0 {
  1257. currentIndex = 1
  1258. }
  1259. startSize = paging.StartIndex(currentIndex, pageSize)
  1260. var pars []interface{}
  1261. var total int
  1262. resp := new(models.ReportArticleWhichIndustrialRepList)
  1263. page := paging.GetPaging(currentIndex, pageSize, total)
  1264. userType, _, err := services.GetUserType(user.CompanyId)
  1265. if err != nil {
  1266. br.Msg = "获取信息失败"
  1267. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1268. return
  1269. }
  1270. if userType == 1 {
  1271. resp.Paging = page
  1272. br.Ret = 200
  1273. br.Success = true
  1274. br.Msg = "获取成功"
  1275. br.Data = resp
  1276. return
  1277. }
  1278. resp.HaveResearch = true
  1279. if articleId > 0 {
  1280. detail, err := models.GetArticleDetailById(articleId)
  1281. if err != nil {
  1282. br.Msg = "获取信息失败"
  1283. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1284. return
  1285. }
  1286. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1287. if firstStr == 0 {
  1288. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1289. } else {
  1290. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1291. }
  1292. }
  1293. total, err = models.GetWhichDepartmentCount(condition)
  1294. if err != nil {
  1295. br.Msg = "获取信息失败"
  1296. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1297. return
  1298. }
  1299. page = paging.GetPaging(currentIndex, pageSize, total)
  1300. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1301. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1302. if err != nil {
  1303. br.Msg = "获取失败"
  1304. br.ErrMsg = "获取失败,Err:" + err.Error()
  1305. return
  1306. }
  1307. for k, v := range list {
  1308. if v.Readnum == 0 {
  1309. list[k].IsRed = true
  1310. }
  1311. list[k].IsResearch = true
  1312. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1313. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1314. if err != nil {
  1315. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1316. br.ErrMsg = "获取失败,Err:" + err.Error()
  1317. return
  1318. }
  1319. var subjectNamesNew string
  1320. if len(subjectNames) > 0 {
  1321. slice := strings.Split(subjectNames, "/")
  1322. for k3, v3 := range slice {
  1323. if k3 < 4 {
  1324. subjectNamesNew += v3 + "/"
  1325. }
  1326. }
  1327. }
  1328. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1329. if err != nil && err.Error() != utils.ErrNoRow() {
  1330. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1331. br.ErrMsg = "获取失败,Err:" + err.Error()
  1332. return
  1333. }
  1334. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1335. list[k].SubjectName = subjectNamesNew
  1336. if subjectNamesNew != "" {
  1337. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1338. } else {
  1339. list[k].IndustryName = industryName
  1340. }
  1341. resp.IndustryName = industryName
  1342. }
  1343. resp.List = list
  1344. resp.Paging = page
  1345. br.Ret = 200
  1346. br.Success = true
  1347. br.Msg = "获取成功"
  1348. br.Data = resp
  1349. }
  1350. // @Title 是否展示绝密内参
  1351. // @Description 获取是否展示绝密内参接口
  1352. // @Param request body models.IsShow true "type json string"
  1353. // @Success 200
  1354. // @router /isShow [get]
  1355. func (this *ReportController) IsShow() {
  1356. br := new(models.BaseResponse).Init()
  1357. defer func() {
  1358. this.Data["json"] = br
  1359. this.ServeJSON()
  1360. }()
  1361. user := this.User
  1362. if user == nil {
  1363. br.Msg = "请重新登录"
  1364. br.Ret = 408
  1365. return
  1366. }
  1367. var resp models.IsShow
  1368. IsShowFreeButton, err := services.GetfreeButtonIsShow(user)
  1369. if err != nil {
  1370. br.Msg = "获取失败"
  1371. br.ErrMsg = "获取失败,GetfreeButtonIsShow Err:" + err.Error()
  1372. return
  1373. }
  1374. resp.IsShowChart = true
  1375. //resp.IsShowResearch = true
  1376. resp.LinkWxExplain = utils.LINK_WX_EXPLAIN
  1377. resp.ActivitySpecialExplain = utils.ACTIVITY_SPECIAL_EXPLAIN
  1378. //resp.YanXuan_Explain = true
  1379. resp.IsShowFreeButton = IsShowFreeButton
  1380. resp.IsBelongRai = services.GetBelongingRai(user.Mobile)
  1381. resp.IsShowQuestionnaire = services.GetQuestionnaireButtonIsShow() // 获取研选问卷调查按钮是否展示
  1382. resp.IsShowResearchPoints = true
  1383. if utils.RunMode == "release" { //是否展示关于我们的视频,测试环境审核做隐藏
  1384. resp.IsShowAboutVideo = true
  1385. }
  1386. //mobile := user.Mobile
  1387. //if mobile == "" {
  1388. // br.Ret = 200
  1389. // br.Success = true
  1390. // br.Data = resp
  1391. // return
  1392. //}
  1393. //total, _ := models.GetUserIsAdminCount(mobile)
  1394. //if total > 0 {
  1395. // resp.IsShowList = true
  1396. //}
  1397. resp.IsShowList = true
  1398. resp.SearchTxtList.SummarySearch = "全局搜索"
  1399. resp.SearchTxtList.ReportSearch = "全局搜索"
  1400. resp.SearchTxtList.YanXuanSearch = "全局搜索"
  1401. resp.SearchTxtList.ActivitySearch = "全局搜索"
  1402. resp.SearchTxtList.TabSearch = "请输入关键词"
  1403. resp.IsShow = true
  1404. br.Ret = 200
  1405. br.Success = true
  1406. br.Data = resp
  1407. }
  1408. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1409. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1410. // @Param PageSize query int true "每页数据条数"
  1411. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1412. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1413. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1414. // @router /reportList/byType [get]
  1415. func (this *ReportController) ReportListByType() {
  1416. br := new(models.BaseResponse).Init()
  1417. defer func() {
  1418. this.Data["json"] = br
  1419. this.ServeJSON()
  1420. }()
  1421. user := this.User
  1422. if user == nil {
  1423. br.Msg = "请重新登录"
  1424. br.Ret = 408
  1425. return
  1426. }
  1427. uid := user.UserId
  1428. pageSize, _ := this.GetInt("PageSize")
  1429. currentIndex, _ := this.GetInt("CurrentIndex")
  1430. reportType := this.GetString("ReportType")
  1431. var condition string
  1432. var startSize int
  1433. if pageSize <= 0 {
  1434. pageSize = utils.PageSize20
  1435. }
  1436. if currentIndex <= 0 {
  1437. currentIndex = 1
  1438. }
  1439. startSize = paging.StartIndex(currentIndex, pageSize)
  1440. var pars []interface{}
  1441. var total int
  1442. resp := new(models.CygxReportSelectionListPublicRep)
  1443. page := paging.GetPaging(currentIndex, pageSize, total)
  1444. var tbdb string
  1445. var readSql string
  1446. var reportTypeStr string
  1447. if reportType == "1" {
  1448. tbdb = "cygx_report_selection"
  1449. reportTypeStr = "bgjx"
  1450. } else if reportType == "2" {
  1451. tbdb = "cygx_research_summary"
  1452. reportTypeStr = "bzyjhz"
  1453. } else if reportType == "3" {
  1454. tbdb = "cygx_minutes_summary"
  1455. reportTypeStr = "szjyhz"
  1456. } else {
  1457. br.Msg = "请选择报告类型"
  1458. return
  1459. }
  1460. condition = ` AND publish_status = 1 `
  1461. if user.CompanyId != utils.HZ_COMPANY_ID {
  1462. condition += ` AND visible_range = 1 `
  1463. }
  1464. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1465. if err != nil {
  1466. br.Msg = "获取信息失败"
  1467. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1468. return
  1469. }
  1470. //研究汇总--报告精选 只显示最新一期,往期都隐藏
  1471. if reportType == "1" {
  1472. startSize = 0
  1473. pageSize = 1
  1474. total = 1
  1475. }
  1476. 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`
  1477. page = paging.GetPaging(currentIndex, pageSize, total)
  1478. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1479. if err != nil {
  1480. br.Msg = "获取失败"
  1481. br.ErrMsg = "获取失败,Err:" + err.Error()
  1482. return
  1483. }
  1484. for k, v := range list {
  1485. if reportType == "1" {
  1486. list[k].Abstract = v.UpdateDescription
  1487. }
  1488. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1489. if v.ReadNum == 0 {
  1490. list[k].IsRed = true
  1491. }
  1492. }
  1493. resp.List = list
  1494. resp.Paging = page
  1495. br.Ret = 200
  1496. br.Success = true
  1497. br.Msg = "获取成功"
  1498. br.Data = resp
  1499. }
  1500. // @Title 获取报告精选详情
  1501. // @Description 获取报告精选详情接口
  1502. // @Param ArticleId query int true "报告ID"
  1503. // @Param IsBestNew query bool false "是否获取最新的一篇报告"
  1504. // @Success 200 {object} models.ReportSelectionLetailResp
  1505. // @router /reportSelection/detail [get]
  1506. func (this *ReportController) Detail() {
  1507. br := new(models.BaseResponse).Init()
  1508. defer func() {
  1509. this.Data["json"] = br
  1510. this.ServeJSON()
  1511. }()
  1512. user := this.User
  1513. if user == nil {
  1514. br.Msg = "请重新登录"
  1515. br.Ret = 408
  1516. return
  1517. }
  1518. //if user.CompanyId != utils.HZ_COMPANY_ID {
  1519. // br.Msg = "报告编辑中,请稍后"
  1520. // br.IsSendEmail = false
  1521. // return
  1522. //}
  1523. //uid := user.UserId
  1524. articleId, _ := this.GetInt("ArticleId")
  1525. isBestNew, _ := this.GetBool("IsBestNew")
  1526. if isBestNew {
  1527. tbdb := "cygx_report_selection"
  1528. //reportTypeStr := "bgjx"
  1529. condition := ` AND publish_status = 1 `
  1530. var pars []interface{}
  1531. list, err := models.GetReportSelectionListPublic(condition, "1", tbdb, pars, 0, 1)
  1532. if err != nil {
  1533. br.Msg = "获取失败"
  1534. br.ErrMsg = "获取失败,Err:" + err.Error()
  1535. return
  1536. }
  1537. for _, v := range list {
  1538. articleId = v.ArticleId
  1539. }
  1540. }
  1541. if articleId < 1 {
  1542. br.Msg = "获取信息失败"
  1543. br.ErrMsg = "报告ID错误" + strconv.Itoa(articleId)
  1544. return
  1545. }
  1546. resp := new(models.ReportSelectionLetailResp)
  1547. //判断用户权限
  1548. hasPermission, err := services.GetUserhasPermission(user)
  1549. if err != nil {
  1550. br.Msg = "获取信息失败"
  1551. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1552. }
  1553. resp.HasPermission = hasPermission
  1554. if hasPermission != 1 {
  1555. br.Ret = 200
  1556. br.Success = true
  1557. br.Msg = "获取成功"
  1558. br.Data = resp
  1559. return
  1560. }
  1561. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1562. if err != nil {
  1563. br.Msg = "获取信息失败"
  1564. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1565. return
  1566. }
  1567. if detail.ReportLink != "" {
  1568. articleIdLink, _ := services.GetReportLinkToArticleid(detail.ReportLink)
  1569. detail.CeLueArticleId = articleIdLink
  1570. }
  1571. //较上一期有观点变化(后台填写的核心逻辑汇总内容、标签内容有更新),或者新增的公司,显示new标签
  1572. var isAllNew bool // 判断是否都打新的标签
  1573. lastPeriods := detail.Periods - 1
  1574. mapBodyChartSummary := make(map[int]string)
  1575. mapLabel := make(map[int]string)
  1576. if lastPeriods > 0 {
  1577. detailLast, err := models.GetCygxReportSelectionInfoByperiods(lastPeriods)
  1578. if err != nil && err.Error() != utils.ErrNoRow() {
  1579. br.Msg = "获取信息失败"
  1580. br.ErrMsg = "报告不存在,Err:" + err.Error() + "Periods:" + strconv.Itoa(lastPeriods)
  1581. return
  1582. }
  1583. if detailLast != nil {
  1584. articleIdLast := detailLast.ArticleId
  1585. listLogLast, err := models.GetReportSelectionlogListAll(articleIdLast)
  1586. if err != nil {
  1587. br.Msg = "获取失败"
  1588. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1589. return
  1590. }
  1591. for _, v := range listLogLast {
  1592. mapBodyChartSummary[v.IndustrialSubjectId], _ = services.GetReportContentTextSubNew(v.Body)
  1593. mapLabel[v.IndustrialSubjectId] = v.Label
  1594. }
  1595. }
  1596. } else {
  1597. isAllNew = true
  1598. }
  1599. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1600. existMap := make(map[int]int)
  1601. var items []*models.ReportSelectionChartPermission
  1602. var itemsSubject []*models.ReportSelectionChartLogPermission
  1603. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1604. if err != nil {
  1605. br.Msg = "获取失败"
  1606. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1607. return
  1608. }
  1609. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1610. //获取行业核心逻辑汇总
  1611. listChartLog, err := models.GetCygxReportSelectionChartLogRepList(articleId)
  1612. if err != nil {
  1613. br.Msg = "获取失败"
  1614. br.ErrMsg = "获取失败,Err:" + err.Error()
  1615. return
  1616. }
  1617. mapChartLog := make(map[string]string)
  1618. for _, v := range listChartLog {
  1619. mapChartLog[v.ChartPermissionName] = v.BodyChartSummary
  1620. }
  1621. for _, v := range listLog {
  1622. item := new(models.ReportSelectionChartPermission)
  1623. itemSubject := new(models.ReportSelectionChartLogPermission)
  1624. itemSubject.PermissionName = v.PermissionName
  1625. if existMap[v.ChartPermissionId] == 0 {
  1626. //item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1627. item.PermissionName = v.PermissionName
  1628. item.IcoLink = v.IcoLink
  1629. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1630. if err != nil && err.Error() != utils.ErrNoRow() {
  1631. br.Msg = "获取信息失败"
  1632. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1633. return
  1634. }
  1635. for k2, v2 := range listSonLog {
  1636. var isNew bool
  1637. if isAllNew {
  1638. isNew = true
  1639. } else {
  1640. v2Body, _ := services.GetReportContentTextSubNew(v2.Body)
  1641. if mapBodyChartSummary[v2.IndustrialSubjectId] != v2Body || mapLabel[v2.IndustrialSubjectId] != v2.Label {
  1642. isNew = true
  1643. }
  1644. }
  1645. if v2.IndustrialManagementId != "" {
  1646. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1647. if err != nil && err.Error() != utils.ErrNoRow() {
  1648. br.Msg = "获取信息失败"
  1649. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1650. return
  1651. }
  1652. //v2.IsNew = isNew
  1653. listSonLog[k2].List = listIndustrial
  1654. if v2.Label != "" {
  1655. v2.CompanyLabel = strings.Split(v2.Label, "{|}")
  1656. }
  1657. }
  1658. isNew = false
  1659. itemSubject.ListSubject = append(itemSubject.ListSubject, &models.ReportSelectionChartLogSubjectName{SubjectName: v2.SubjectName, IsNew: isNew, IndustrialSubjectId: v2.IndustrialSubjectId})
  1660. }
  1661. item.BodyChartSummary = mapChartLog[v.PermissionName]
  1662. item.List = listSonLog
  1663. items = append(items, item)
  1664. itemsSubject = append(itemsSubject, itemSubject)
  1665. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1666. }
  1667. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1668. }
  1669. //historyRecord := new(models.CygxReportHistoryRecord)
  1670. //historyRecord.UserId = uid
  1671. //historyRecord.ArticleId = articleId
  1672. //historyRecord.CreateTime = time.Now()
  1673. //historyRecord.Mobile = user.Mobile
  1674. //historyRecord.Email = user.Email
  1675. //historyRecord.CompanyId = user.CompanyId
  1676. //historyRecord.CompanyName = user.CompanyName
  1677. //historyRecord.ReportType = "bgjx"
  1678. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1679. //if err != nil && err.Error() != utils.ErrNoRow() {
  1680. // br.Msg = "获取信息失败"
  1681. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1682. // return
  1683. //}
  1684. //historyRecord.RealName = user.RealName
  1685. //if sellerItem != nil {
  1686. // historyRecord.SellerName = sellerItem.RealName
  1687. //}
  1688. //
  1689. //go models.AddCygxReportHistoryRecord(historyRecord)
  1690. resp.List = items
  1691. resp.ListPermissionSubject = itemsSubject
  1692. resp.Detail = detail
  1693. br.Ret = 200
  1694. br.Success = true
  1695. br.Msg = "获取成功"
  1696. br.Data = resp
  1697. }
  1698. // @Title 获取本周研究汇总详情
  1699. // @Description 获取本周研究汇总详情接口
  1700. // @Param ArticleId query int true "报告ID"
  1701. // @Success 200 {object} models.ResearchSummaryLetailResp
  1702. // @router /researchSummary/detail [get]
  1703. func (this *ReportController) ResearchDetail() {
  1704. br := new(models.BaseResponse).Init()
  1705. defer func() {
  1706. this.Data["json"] = br
  1707. this.ServeJSON()
  1708. }()
  1709. user := this.User
  1710. if user == nil {
  1711. br.Msg = "请重新登录"
  1712. br.Ret = 408
  1713. return
  1714. }
  1715. //uid := user.UserId
  1716. articleId, _ := this.GetInt("ArticleId")
  1717. if articleId < 0 {
  1718. br.Msg = "参数错误"
  1719. br.ErrMsg = "参数错误"
  1720. return
  1721. }
  1722. resp := new(models.ResearchSummaryLetailResp)
  1723. //判断用户权限
  1724. hasPermission, err := services.GetUserhasPermission(user)
  1725. if err != nil {
  1726. br.Msg = "获取信息失败"
  1727. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1728. }
  1729. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1730. if err != nil {
  1731. br.Msg = "获取信息失败"
  1732. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1733. return
  1734. }
  1735. PermissionNameMap, err := services.GetPermissionNameMap()
  1736. if err != nil {
  1737. br.Msg = "获取失败"
  1738. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1739. return
  1740. }
  1741. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1742. if err != nil {
  1743. br.Msg = "获取失败"
  1744. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1745. return
  1746. }
  1747. //未设置全部可见的只能给弘则内部查看
  1748. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1749. resp.IsShow = true
  1750. }
  1751. resp.HasPermission = hasPermission
  1752. if hasPermission != 1 || !resp.IsShow {
  1753. br.Ret = 200
  1754. br.Success = true
  1755. br.Msg = "获取成功"
  1756. br.Data = resp
  1757. return
  1758. }
  1759. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1760. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1761. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1762. if err != nil {
  1763. br.Msg = "获取失败"
  1764. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1765. return
  1766. }
  1767. listArticleType, err := models.GetCygxArticleTypeList()
  1768. if err != nil {
  1769. br.Msg = "获取失败"
  1770. br.ErrMsg = "获取文章类型数据失败,Err:" + err.Error()
  1771. return
  1772. }
  1773. for k, v := range listFirst {
  1774. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1775. if err != nil && err.Error() != utils.ErrNoRow() {
  1776. br.Msg = "获取信息失败"
  1777. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1778. return
  1779. }
  1780. for k2, v2 := range listSecond {
  1781. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1782. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1783. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1784. if err != nil && err.Error() != utils.ErrNoRow() {
  1785. br.Msg = "获取信息失败"
  1786. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1787. return
  1788. }
  1789. for _, vType := range listArticleType {
  1790. if v2.ChartPermissionId == vType.YanxPermissionId {
  1791. listSecond[k2].IcoLink = vType.IcoLinkM
  1792. listSecond[k2].PermissionName = vType.YanxPermissionName
  1793. }
  1794. }
  1795. //if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1796. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1797. // listSecond[k2].PermissionName = "买方研选纪要"
  1798. //} else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1799. // listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1800. // listSecond[k2].PermissionName = "买方研选观点"
  1801. //}
  1802. if len(listThird) > 0 {
  1803. for k3, v3 := range listThird {
  1804. if v3.VideoUrl != "" {
  1805. listThird[k3].IsHaveVideo = true
  1806. }
  1807. if v3.ReportLink == "0" {
  1808. listThird[k3].ReportLink = ""
  1809. }
  1810. }
  1811. listSecond[k2].List = listThird
  1812. }
  1813. }
  1814. if len(listSecond) > 0 {
  1815. listFirst[k].List = listSecond
  1816. }
  1817. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1818. if v.Type == "SDBG" {
  1819. listFirst[k].ListName = "深度报告"
  1820. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1821. } else if v.Type == "BZCHJH" {
  1822. listFirst[k].ListName = "本周晨会精华"
  1823. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1824. } else if v.Type == "CYDYJY" {
  1825. listFirst[k].ListName = "产业调研纪要"
  1826. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1827. } else if v.Type == "SSGS" {
  1828. listFirst[k].ListName = "上市公司调研纪要篇"
  1829. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1830. } else if v.Type == "SJDP" {
  1831. listFirst[k].ListName = "市场QA汇总"
  1832. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1833. } else if v.Type == "YANX" {
  1834. listFirst[k].ListName = "买方研选"
  1835. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1836. }
  1837. }
  1838. //historyRecord := new(models.CygxReportHistoryRecord)
  1839. //historyRecord.UserId = uid
  1840. //historyRecord.ArticleId = articleId
  1841. //historyRecord.CreateTime = time.Now()
  1842. //historyRecord.Mobile = user.Mobile
  1843. //historyRecord.Email = user.Email
  1844. //historyRecord.CompanyId = user.CompanyId
  1845. //historyRecord.CompanyName = user.CompanyName
  1846. //historyRecord.ReportType = "bzyjhz"
  1847. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1848. //if err != nil && err.Error() != utils.ErrNoRow() {
  1849. // br.Msg = "获取信息失败"
  1850. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1851. // return
  1852. //}
  1853. //historyRecord.RealName = user.RealName
  1854. //if sellerItem != nil {
  1855. // historyRecord.SellerName = sellerItem.RealName
  1856. //}
  1857. //go models.AddCygxReportHistoryRecord(historyRecord)
  1858. go services.ResearchSummaryHistoryUserRmind(user, articleId) // 本周研究汇总用户阅读操作操作行为,模板消息推送
  1859. resp.List = listFirst
  1860. resp.Detail = detail
  1861. br.Ret = 200
  1862. br.Success = true
  1863. br.Msg = "获取成功"
  1864. br.Data = resp
  1865. }
  1866. // @Title 上周纪要汇总内容详情
  1867. // @Description 获取上周纪要汇总内容详情接口
  1868. // @Param ArticleId query int true "报告ID"
  1869. // @Success 200 {object} models.MinutesSummaryLetailResp
  1870. // @router /minutesSummary/detailv4 [get]
  1871. func (this *ReportController) MinutesDetailV4() {
  1872. br := new(models.BaseResponse).Init()
  1873. defer func() {
  1874. this.Data["json"] = br
  1875. this.ServeJSON()
  1876. }()
  1877. user := this.User
  1878. if user == nil {
  1879. br.Msg = "请重新登录"
  1880. br.Ret = 408
  1881. return
  1882. }
  1883. //uid := user.UserId
  1884. articleId, _ := this.GetInt("ArticleId")
  1885. if articleId < 0 {
  1886. br.Msg = "参数错误"
  1887. br.ErrMsg = "参数错误"
  1888. return
  1889. }
  1890. resp := new(models.MinutesSummaryLetailRespV4)
  1891. //判断用户权限
  1892. hasPermission, err := services.GetUserhasPermission(user)
  1893. if err != nil {
  1894. br.Msg = "获取信息失败"
  1895. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1896. }
  1897. //resp.HasPermission = hasPermission
  1898. //if hasPermission != 1 {
  1899. // br.Ret = 200
  1900. // br.Success = true
  1901. // br.Msg = "获取成功"
  1902. // br.Data = resp
  1903. // return
  1904. //}
  1905. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1906. if err != nil {
  1907. br.Msg = "获取信息失败"
  1908. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1909. return
  1910. }
  1911. PermissionNameMap, err := services.GetPermissionNameMap()
  1912. if err != nil {
  1913. br.Msg = "获取失败"
  1914. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1915. return
  1916. }
  1917. PermissionIcoMap, err := services.GetPermissionNameIcoMap()
  1918. if err != nil {
  1919. br.Msg = "获取失败"
  1920. br.ErrMsg = "获取失败 GetPermissionNameMap,Err:" + err.Error()
  1921. return
  1922. }
  1923. //未设置全部可见的只能给弘则内部查看
  1924. if detail.VisibleRange == 1 || user.CompanyId == utils.HZ_COMPANY_ID {
  1925. resp.IsShow = true
  1926. }
  1927. resp.HasPermission = hasPermission
  1928. if hasPermission != 1 || !resp.IsShow {
  1929. br.Ret = 200
  1930. br.Success = true
  1931. br.Msg = "获取成功"
  1932. br.Data = resp
  1933. return
  1934. }
  1935. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1936. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1937. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1938. if err != nil {
  1939. br.Msg = "获取失败"
  1940. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1941. return
  1942. }
  1943. for k, v := range listFirst {
  1944. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1945. if err != nil && err.Error() != utils.ErrNoRow() {
  1946. br.Msg = "获取信息失败"
  1947. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1948. return
  1949. }
  1950. for k2, v2 := range listSecond {
  1951. v2.PermissionName = PermissionNameMap[v2.ChartPermissionId]
  1952. v2.IcoLink = PermissionIcoMap[v2.ChartPermissionId]
  1953. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1954. if err != nil && err.Error() != utils.ErrNoRow() {
  1955. br.Msg = "获取信息失败"
  1956. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1957. return
  1958. }
  1959. if len(listThird) > 0 {
  1960. for k3, v3 := range listThird {
  1961. if v3.VideoUrl != "" {
  1962. listThird[k3].IsHaveVideo = true
  1963. }
  1964. if v3.ReportLink == "0" {
  1965. listThird[k3].ReportLink = ""
  1966. }
  1967. }
  1968. listSecond[k2].List = listThird
  1969. }
  1970. }
  1971. if len(listSecond) > 0 {
  1972. listFirst[k].List = listSecond
  1973. }
  1974. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1975. if v.Type == "CYDYJY" {
  1976. listFirst[k].ListName = "产业调研纪要"
  1977. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1978. } else if v.Type == "SSGS" {
  1979. listFirst[k].ListName = "上市公司调研纪要篇"
  1980. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1981. } else if v.Type == "YANX" {
  1982. listFirst[k].ListName = "买方研选纪要"
  1983. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1984. }
  1985. }
  1986. //historyRecord := new(models.CygxReportHistoryRecord)
  1987. //historyRecord.UserId = uid
  1988. //historyRecord.ArticleId = articleId
  1989. //historyRecord.CreateTime = time.Now()
  1990. //historyRecord.Mobile = user.Mobile
  1991. //historyRecord.Email = user.Email
  1992. //historyRecord.CompanyId = user.CompanyId
  1993. //historyRecord.CompanyName = user.CompanyName
  1994. //historyRecord.ReportType = "szjyhz"
  1995. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  1996. //if err != nil && err.Error() != utils.ErrNoRow() {
  1997. // br.Msg = "获取信息失败"
  1998. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  1999. // return
  2000. //}
  2001. //historyRecord.RealName = user.RealName
  2002. //if sellerItem != nil {
  2003. // historyRecord.SellerName = sellerItem.RealName
  2004. //}
  2005. //go models.AddCygxReportHistoryRecord(historyRecord)
  2006. go services.MinutesSummaryHistoryUserRmind(user, articleId) // 上周纪要汇总用户阅读,给销售发消息提醒
  2007. resp.List = listFirst
  2008. resp.Detail = detail
  2009. br.Ret = 200
  2010. br.Success = true
  2011. br.Msg = "获取成功"
  2012. br.Data = resp
  2013. }
  2014. // @Title 上周纪要汇总内容详情
  2015. // @Description 获取上周纪要汇总内容详情接口
  2016. // @Param ArticleId query int true "报告ID"
  2017. // @Success 200 {object} models.MinutesSummaryLetailResp
  2018. // @router /minutesSummary/detail [get]
  2019. func (this *ReportController) MinutesDetail() {
  2020. br := new(models.BaseResponse).Init()
  2021. defer func() {
  2022. this.Data["json"] = br
  2023. this.ServeJSON()
  2024. }()
  2025. user := this.User
  2026. if user == nil {
  2027. br.Msg = "请重新登录"
  2028. br.Ret = 408
  2029. return
  2030. }
  2031. //uid := user.UserId
  2032. articleId, _ := this.GetInt("ArticleId")
  2033. if articleId < 0 {
  2034. br.Msg = "参数错误"
  2035. br.ErrMsg = "参数错误"
  2036. return
  2037. }
  2038. resp := new(models.MinutesSummaryLetailResp)
  2039. //判断用户权限
  2040. hasPermission, err := services.GetUserhasPermission(user)
  2041. if err != nil {
  2042. br.Msg = "获取信息失败"
  2043. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  2044. }
  2045. resp.HasPermission = hasPermission
  2046. if hasPermission != 1 {
  2047. br.Ret = 200
  2048. br.Success = true
  2049. br.Msg = "获取成功"
  2050. br.Data = resp
  2051. return
  2052. }
  2053. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  2054. if err != nil {
  2055. br.Msg = "获取信息失败"
  2056. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  2057. return
  2058. }
  2059. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2060. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2061. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  2062. if err != nil {
  2063. br.Msg = "获取失败"
  2064. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  2065. return
  2066. }
  2067. for k, v := range listLog {
  2068. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  2069. if err != nil && err.Error() != utils.ErrNoRow() {
  2070. br.Msg = "获取信息失败"
  2071. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2072. return
  2073. }
  2074. if len(listSonLog) > 0 {
  2075. for k2, v2 := range listSonLog {
  2076. if v2.ReportLink == "0" {
  2077. listSonLog[k2].ReportLink = ""
  2078. }
  2079. }
  2080. listLog[k].List = listSonLog
  2081. }
  2082. }
  2083. //historyRecord := new(models.CygxReportHistoryRecord)
  2084. //historyRecord.UserId = uid
  2085. //historyRecord.ArticleId = articleId
  2086. //historyRecord.CreateTime = time.Now()
  2087. //historyRecord.Mobile = user.Mobile
  2088. //historyRecord.Email = user.Email
  2089. //historyRecord.CompanyId = user.CompanyId
  2090. //historyRecord.CompanyName = user.CompanyName
  2091. //historyRecord.ReportType = "szjyhz"
  2092. //sellerItem, err := models.GetSellerByCompanyIdCheckFicc(user.CompanyId, 2)
  2093. //if err != nil && err.Error() != utils.ErrNoRow() {
  2094. // br.Msg = "获取信息失败"
  2095. // br.ErrMsg = "获取销售信息失败,Err:" + err.Error()
  2096. // return
  2097. //}
  2098. //historyRecord.RealName = user.RealName
  2099. //if sellerItem != nil {
  2100. // historyRecord.SellerName = sellerItem.RealName
  2101. //}
  2102. //go models.AddCygxReportHistoryRecord(historyRecord)
  2103. resp.List = listLog
  2104. resp.Detail = detail
  2105. br.Ret = 200
  2106. br.Success = true
  2107. br.Msg = "获取成功"
  2108. br.Data = resp
  2109. }
  2110. // @Title 获取路演精华详情
  2111. // @Description 获取路演精华详情接口
  2112. // @Param ArticleId query int true "报告ID"
  2113. // @Success 200 {object} models.RoadshowDetailResp
  2114. // @router /roadshowEssence/detail [get]
  2115. func (this *ReportController) RoadshowDetail() {
  2116. br := new(models.BaseResponse).Init()
  2117. defer func() {
  2118. this.Data["json"] = br
  2119. this.ServeJSON()
  2120. }()
  2121. user := this.User
  2122. if user == nil {
  2123. br.Msg = "请登录"
  2124. br.ErrMsg = "请登录,用户信息为空"
  2125. br.Ret = 408
  2126. return
  2127. }
  2128. uid := user.UserId
  2129. articleId, err := this.GetInt("ArticleId")
  2130. if articleId <= 0 {
  2131. br.Msg = "文章不存在"
  2132. br.ErrMsg = "文章不存在,文章ID错误"
  2133. return
  2134. }
  2135. detail := new(models.ReportDetailRoadshow)
  2136. hasPermission := 0
  2137. hasFree := 0
  2138. //判断是否已经申请过
  2139. applyCount, err := models.GetApplyRecordCount(uid)
  2140. if err != nil && err.Error() != utils.ErrNoRow() {
  2141. br.Msg = "获取信息失败"
  2142. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  2143. return
  2144. }
  2145. articleLyjhMap, _ := services.GetLyjhArticleMap()
  2146. articleCollectMap, _ := services.GetCygxArticleCollectMap(user.UserId)
  2147. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  2148. if user.CompanyId > 1 {
  2149. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  2150. if err != nil {
  2151. br.Msg = "获取信息失败"
  2152. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  2153. return
  2154. }
  2155. detail, err = models.GetReportRoadshowDetailById(articleId)
  2156. if err != nil {
  2157. br.Msg = "获取信息失败"
  2158. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  2159. return
  2160. }
  2161. detail.IsCollect = articleCollectMap[detail.ArticleId]
  2162. detail.IsRoadShow = articleLyjhMap[detail.ArticleId]
  2163. detail.Body = html.UnescapeString(detail.Body)
  2164. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  2165. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  2166. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  2167. if detail.ReportLink == "0" {
  2168. detail.ReportLink = ""
  2169. }
  2170. if companyPermission == "" {
  2171. if applyCount > 0 {
  2172. hasPermission = 5
  2173. } else {
  2174. hasPermission = 2
  2175. }
  2176. hasFree = 2
  2177. goto Loop
  2178. } else {
  2179. hasFree = 1
  2180. var articlePermissionPermissionName string
  2181. articlePermissionPermissionName = detail.CategoryName
  2182. var hasPersion bool
  2183. slice := strings.Split(articlePermissionPermissionName, ",")
  2184. for _, v := range slice {
  2185. if strings.Contains(companyPermission, v) {
  2186. hasPersion = true
  2187. }
  2188. }
  2189. if hasPersion {
  2190. hasPermission = 1
  2191. historyRecord := new(models.CygxArticleHistoryRecord)
  2192. historyRecord.UserId = uid
  2193. historyRecord.ArticleId = articleId
  2194. historyRecord.CreateTime = time.Now()
  2195. historyRecord.Mobile = user.Mobile
  2196. historyRecord.Email = user.Email
  2197. historyRecord.CompanyId = user.CompanyId
  2198. historyRecord.CompanyName = user.CompanyName
  2199. go models.AddCygxArticleHistoryRecord(historyRecord)
  2200. } else { //无该行业权限
  2201. hasPermission = 3
  2202. }
  2203. if hasPermission == 1 {
  2204. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  2205. if !utils.Rc.IsExist(key) {
  2206. //新增浏览记录
  2207. record := new(models.CygxArticleViewRecord)
  2208. record.UserId = uid
  2209. record.ArticleId = articleId
  2210. record.CreateTime = time.Now()
  2211. record.Mobile = user.Mobile
  2212. record.Email = user.Email
  2213. record.CompanyId = user.CompanyId
  2214. record.CompanyName = user.CompanyName
  2215. go models.AddCygxArticleViewRecord(record)
  2216. utils.Rc.Put(key, 1, 5*time.Second)
  2217. models.ModifyReportLastViewTime(uid)
  2218. }
  2219. }
  2220. }
  2221. } else { //潜在客户
  2222. if applyCount > 0 {
  2223. hasPermission = 5
  2224. } else {
  2225. hasPermission = 4
  2226. }
  2227. }
  2228. Loop:
  2229. if hasPermission != 1 {
  2230. detail.Body = ""
  2231. detail.Abstract = ""
  2232. }
  2233. resp := new(models.RoadshowDetailResp)
  2234. resp.HasPermission = hasPermission
  2235. resp.HasFree = hasFree
  2236. resp.Detail = detail
  2237. br.Ret = 200
  2238. br.Success = true
  2239. br.Msg = "获取成功"
  2240. br.Data = resp
  2241. }
  2242. // @Title 产业文章列表接口
  2243. // @Description 获取产业文章列表接口
  2244. // @Param KeyWord query string true "搜索关键词"
  2245. // @Success 200 {object} models.CygxIndustrySearchList
  2246. // @router /industryAndArticle/list [get]
  2247. func (this *ReportController) IndustryAndArticleList() {
  2248. br := new(models.BaseResponse).Init()
  2249. defer func() {
  2250. this.Data["json"] = br
  2251. this.ServeJSON()
  2252. }()
  2253. user := this.User
  2254. if user == nil {
  2255. br.Msg = "请重新登录"
  2256. br.Ret = 408
  2257. return
  2258. }
  2259. uid := user.UserId
  2260. keyWord := this.GetString("KeyWord")
  2261. orderSrt := "update_time DESC"
  2262. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2263. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2264. if err != nil {
  2265. br.Msg = "获取信息失败"
  2266. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2267. return
  2268. }
  2269. for k, v := range list {
  2270. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2271. if err != nil {
  2272. br.Msg = "获取信息失败"
  2273. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2274. return
  2275. }
  2276. list[k].IndustrialSubjectList = industrialSubjectList
  2277. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2278. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2279. if err != nil {
  2280. br.Msg = "获取信息失败"
  2281. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2282. return
  2283. }
  2284. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2285. }
  2286. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2287. if err != nil {
  2288. br.Msg = "获取失败"
  2289. br.ErrMsg = "获取失败,Err:" + err.Error()
  2290. return
  2291. }
  2292. for k2, v2 := range artList {
  2293. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  2294. if err != nil {
  2295. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2296. br.ErrMsg = "获取失败,Err:" + err.Error()
  2297. return
  2298. }
  2299. var subjectNamesNew string
  2300. if len(subjectNames) > 0 {
  2301. slice := strings.Split(subjectNames, "/")
  2302. for k3, v3 := range slice {
  2303. if k3 < 4 {
  2304. subjectNamesNew += v3 + "/"
  2305. }
  2306. }
  2307. }
  2308. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  2309. if err != nil && err.Error() != utils.ErrNoRow() {
  2310. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  2311. br.ErrMsg = "获取失败,Err:" + err.Error()
  2312. return
  2313. }
  2314. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2315. artList[k2].SubjectName = subjectNamesNew
  2316. if subjectNamesNew == "" {
  2317. artList[k2].IndustryName = industryName
  2318. } else {
  2319. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  2320. }
  2321. }
  2322. if keyWord != "" {
  2323. keyWordItem := new(models.CygxUserSearchKeyWord)
  2324. keyWordItem.UserId = user.UserId
  2325. keyWordItem.KeyWord = keyWord
  2326. keyWordItem.PageType = "ReortSearch"
  2327. keyWordItem.CreateTime = time.Now()
  2328. go models.AddUserSearchKeyWord(keyWordItem)
  2329. }
  2330. resp := new(models.CygxIndustrySearchList)
  2331. resp.ArtList = artList
  2332. resp.IndList = list
  2333. br.Ret = 200
  2334. br.Success = true
  2335. br.Msg = "获取成功"
  2336. br.Data = resp
  2337. }
  2338. // @Title 产业报告分类关联作者列表接口Pc端
  2339. // @Description 获取产业报告分类关联作者列表接口Pc端
  2340. // @Param ChartPermissionId query int true "分类ID"
  2341. // @Param KeyWord query string true "搜索关键词"
  2342. // @Param PageSize query int true "每页数据条数"
  2343. // @Param CurrentIndex query int true "当前页页码,从1开始"
  2344. // @Success 200 {object} models.CygxArticleDepartmentListPc
  2345. // @router /industryListByDepartmentPc [get]
  2346. func (this *ReportController) IndustryListByDepartmentPc() {
  2347. br := new(models.BaseResponse).Init()
  2348. defer func() {
  2349. this.Data["json"] = br
  2350. this.ServeJSON()
  2351. }()
  2352. user := this.User
  2353. if user == nil {
  2354. br.Msg = "请重新登录"
  2355. br.Ret = 408
  2356. return
  2357. }
  2358. uid := user.UserId
  2359. pageSize, _ := this.GetInt("PageSize")
  2360. currentIndex, _ := this.GetInt("CurrentIndex")
  2361. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  2362. keyWord := this.GetString("KeyWord")
  2363. var startSize int
  2364. var condition string
  2365. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  2366. if pageSize <= 0 {
  2367. pageSize = utils.PageSize20
  2368. }
  2369. if currentIndex <= 0 {
  2370. currentIndex = 1
  2371. }
  2372. var articleIdGroup string
  2373. if keyWord != "" {
  2374. //获取标的关联的文章ID
  2375. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  2376. if err != nil {
  2377. br.Msg = "获取信息失败"
  2378. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2379. return
  2380. }
  2381. //获取产业关联的标的
  2382. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  2383. if err != nil {
  2384. br.Msg = "获取信息失败"
  2385. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  2386. return
  2387. }
  2388. if articleIdSub != "" && articleIdInd != "" {
  2389. articleIdGroup = articleIdSub + "," + articleIdInd
  2390. } else if articleIdSub != "" && articleIdInd == "" {
  2391. articleIdGroup = articleIdSub
  2392. } else if articleIdSub == "" && articleIdInd != "" {
  2393. articleIdGroup = articleIdInd
  2394. }
  2395. slice := strings.Split(keyWord, "/")
  2396. if len(slice) > 1 {
  2397. var subjectIds string
  2398. for _, v := range slice {
  2399. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  2400. if err != nil && err.Error() != utils.ErrNoRow() {
  2401. br.Msg = "获取信息失败"
  2402. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  2403. return
  2404. }
  2405. if subjectId != "" {
  2406. subjectIds += subjectId + ","
  2407. }
  2408. }
  2409. subjectIds = strings.TrimRight(subjectIds, ",")
  2410. if len(subjectIds) > 0 {
  2411. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  2412. if err != nil {
  2413. br.Msg = "获取信息失败"
  2414. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  2415. return
  2416. }
  2417. if articleIdGroup != "" {
  2418. if articleBySub != "" {
  2419. articleIdGroup += "," + articleBySub
  2420. }
  2421. } else {
  2422. articleIdGroup = articleBySub
  2423. }
  2424. }
  2425. }
  2426. }
  2427. if articleIdGroup != "" {
  2428. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  2429. }
  2430. startSize = paging.StartIndex(currentIndex, pageSize)
  2431. total, err := models.GetArticleDepartmentCount(condition)
  2432. page := paging.GetPaging(currentIndex, pageSize, total)
  2433. resp := new(models.CygxArticleDepartmentListPc)
  2434. userType, _, err := services.GetUserType(user.CompanyId)
  2435. if err != nil {
  2436. br.Msg = "获取信息失败"
  2437. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  2438. return
  2439. }
  2440. if userType == 1 {
  2441. resp.Paging = page
  2442. br.Ret = 200
  2443. br.Success = true
  2444. br.Msg = "获取成功"
  2445. br.Data = resp
  2446. return
  2447. }
  2448. resp.HaveResearch = true
  2449. //获取作者信息,并排序
  2450. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  2451. if err != nil {
  2452. br.Msg = "获取信息失败"
  2453. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2454. return
  2455. }
  2456. for k, v := range list {
  2457. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  2458. if err != nil {
  2459. br.Msg = "获取信息失败"
  2460. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2461. return
  2462. }
  2463. for k2, v2 := range artList {
  2464. if artList[k2].IsReport == "1" {
  2465. artList[k2].Title = v2.Title
  2466. } else {
  2467. artList[k2].Title = v2.Title
  2468. }
  2469. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2470. }
  2471. list[k].List = artList
  2472. if v.FollowNum > 0 {
  2473. list[k].IsMyFollow = true
  2474. }
  2475. }
  2476. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2477. if err != nil {
  2478. br.Msg = "获取信息失败"
  2479. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2480. return
  2481. }
  2482. if len(listnNew) > 0 {
  2483. for _, v := range listnNew {
  2484. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2485. Management := new(models.IndustrialManagementIdInt)
  2486. if firstStr == 0 {
  2487. Management.IndustryName = v.IndustryName
  2488. } else {
  2489. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2490. if err != nil {
  2491. br.Msg = "获取信息失败"
  2492. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2493. return
  2494. }
  2495. var subjectNamesNew string
  2496. for _, v1 := range listSub {
  2497. subjectNamesNew += v1.SubjectName + "/"
  2498. }
  2499. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2500. Management.IndustryName = subjectNamesNew
  2501. }
  2502. Management.IndustrialManagementId = v.IndustrialManagementId
  2503. Management.ArticleId = v.ArticleId
  2504. resp.ListnNew = append(resp.ListnNew, Management)
  2505. }
  2506. }
  2507. resp.List = list
  2508. resp.Paging = page
  2509. br.Ret = 200
  2510. br.Success = true
  2511. br.Msg = "获取成功"
  2512. br.Data = resp
  2513. }
  2514. // @Title 产业文章列表接口Pc端
  2515. // @Description 获取产业文章列表接口Pc端
  2516. // @Param KeyWord query string true "搜索关键词"
  2517. // @Success 200 {object} models.CygxIndustrySearchListPc
  2518. // @router /industryAndArticle/listPc [get]
  2519. func (this *ReportController) IndustryAndArticleListPc() {
  2520. br := new(models.BaseResponse).Init()
  2521. defer func() {
  2522. this.Data["json"] = br
  2523. this.ServeJSON()
  2524. }()
  2525. user := this.User
  2526. if user == nil {
  2527. br.Msg = "请重新登录"
  2528. br.Ret = 408
  2529. return
  2530. }
  2531. uid := user.UserId
  2532. keyWord := this.GetString("KeyWord")
  2533. resp := new(models.CygxIndustrySearchListPc)
  2534. orderSrt := "update_time DESC"
  2535. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2536. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2537. if err != nil {
  2538. br.Msg = "获取信息失败"
  2539. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2540. return
  2541. }
  2542. for k, v := range list {
  2543. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2544. if err != nil {
  2545. br.Msg = "获取信息失败"
  2546. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2547. return
  2548. }
  2549. list[k].IndustrialSubjectList = industrialSubjectList
  2550. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2551. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2552. if err != nil {
  2553. br.Msg = "获取信息失败"
  2554. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2555. return
  2556. }
  2557. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2558. }
  2559. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2560. if err != nil {
  2561. br.Msg = "获取失败"
  2562. br.ErrMsg = "获取失败,Err:" + err.Error()
  2563. return
  2564. }
  2565. if len(artList) > 0 {
  2566. var articleIds string
  2567. for _, v := range artList {
  2568. articleIds += strconv.Itoa(v.ArticleId) + ","
  2569. }
  2570. articleIds = strings.TrimRight(articleIds, ",")
  2571. if articleIds != "" {
  2572. condition = ` AND a.article_id IN (` + articleIds + `)`
  2573. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2574. if err != nil {
  2575. br.Msg = "获取信息失败"
  2576. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2577. return
  2578. }
  2579. for k, v := range DepartmentList {
  2580. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2581. if err != nil {
  2582. br.Msg = "获取信息失败"
  2583. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2584. return
  2585. }
  2586. for k2, v2 := range artList {
  2587. if artList[k2].IsReport == "1" {
  2588. artList[k2].Title = v2.Title
  2589. } else {
  2590. artList[k2].Title = v2.Title
  2591. }
  2592. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2593. }
  2594. DepartmentList[k].List = artList
  2595. if v.FollowNum > 0 {
  2596. DepartmentList[k].IsMyFollow = true
  2597. }
  2598. }
  2599. resp.DepartmentList = DepartmentList
  2600. }
  2601. }
  2602. if keyWord != "" {
  2603. keyWordItem := new(models.CygxUserSearchKeyWord)
  2604. keyWordItem.UserId = user.UserId
  2605. keyWordItem.KeyWord = keyWord
  2606. keyWordItem.PageType = "ReortSearch"
  2607. keyWordItem.CreateTime = time.Now()
  2608. go models.AddUserSearchKeyWord(keyWordItem)
  2609. }
  2610. resp.IndList = list
  2611. br.Ret = 200
  2612. br.Success = true
  2613. br.Msg = "获取成功"
  2614. br.Data = resp
  2615. }
  2616. // @Title 报告搜索
  2617. // @Description 报告搜索接口
  2618. // @Param KeyWord query string true "搜索关键词"
  2619. // @Success 200 {object} models.ReoprtSearchResp
  2620. // @router /searchReport [get]
  2621. func (this *ReportController) SearchReport() {
  2622. br := new(models.BaseResponse).Init()
  2623. defer func() {
  2624. this.Data["json"] = br
  2625. this.ServeJSON()
  2626. }()
  2627. user := this.User
  2628. if user == nil {
  2629. br.Msg = "请重新登录"
  2630. br.Ret = 408
  2631. return
  2632. }
  2633. keyWord := this.GetString("KeyWord")
  2634. var condition string
  2635. var sqlGroup string
  2636. //匹配报告标题、
  2637. 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 `
  2638. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2639. //对应产业名称、标的名称。
  2640. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition+sqlGroup, user.UserId)
  2641. if err != nil {
  2642. br.Msg = "获取信息失败"
  2643. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2644. return
  2645. }
  2646. for k, v := range listYx {
  2647. listYx[k].Source = 2
  2648. if v.MyCollectNum > 0 {
  2649. listYx[k].IsCollect = true
  2650. }
  2651. }
  2652. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition+` OR ( article_type = 'lyjh' `+condition+` ) `+sqlGroup, user.UserId)
  2653. if err != nil {
  2654. br.Msg = "获取信息失败"
  2655. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2656. return
  2657. }
  2658. for k, v := range listHz {
  2659. listHz[k].Source = 1
  2660. if v.MyCollectNum > 0 {
  2661. listHz[k].IsCollect = true
  2662. }
  2663. }
  2664. if keyWord != "" {
  2665. keyWordItem := new(models.CygxUserSearchKeyWord)
  2666. keyWordItem.UserId = user.UserId
  2667. keyWordItem.KeyWord = keyWord
  2668. keyWordItem.PageType = "ReortSearch"
  2669. keyWordItem.CreateTime = time.Now()
  2670. go models.AddUserSearchKeyWord(keyWordItem)
  2671. //go services.AddUserSearchLog(user, keyWord, 5)
  2672. }
  2673. if len(listYx) == 0 {
  2674. listYx = make([]*models.ArticleCollectionResp, 0)
  2675. }
  2676. if len(listHz) == 0 {
  2677. listHz = make([]*models.ArticleCollectionResp, 0)
  2678. }
  2679. resp := new(models.ReoprtSearchResp)
  2680. resp.ListYx = listYx
  2681. resp.ListHz = listHz
  2682. br.Ret = 200
  2683. br.Success = true
  2684. br.Msg = "获取成功"
  2685. br.Data = resp
  2686. }
  2687. // @Title 资源包搜索
  2688. // @Description 资源包搜索接口
  2689. // @Param KeyWord query string true "搜索关键词"
  2690. // @Success 200 {object} models.SearchResourceResp
  2691. // @router /searchResource [get]
  2692. func (this *ReportController) SearchResource() {
  2693. br := new(models.BaseResponse).Init()
  2694. defer func() {
  2695. this.Data["json"] = br
  2696. this.ServeJSON()
  2697. }()
  2698. user := this.User
  2699. if user == nil {
  2700. br.Msg = "请重新登录"
  2701. br.Ret = 408
  2702. return
  2703. }
  2704. uid := user.UserId
  2705. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2706. if err != nil {
  2707. br.Msg = "获取失败"
  2708. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2709. return
  2710. }
  2711. fllowMap := make(map[int]int)
  2712. if len(fllowList) > 0 {
  2713. for _, v := range fllowList {
  2714. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  2715. }
  2716. }
  2717. keyWord := this.GetString("KeyWord")
  2718. var condition string
  2719. var conditionOr string
  2720. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2721. conditionOr += ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2722. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id < ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2723. listHz, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2724. if err != nil {
  2725. br.Msg = "获取信息失败"
  2726. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2727. return
  2728. }
  2729. //conditionOr = ` OR ( a.title LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2730. conditionOr = ` OR ( m.subject_names LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + ` AND publish_status = 1 ) `
  2731. condition = ` AND m.industry_name LIKE '%` + keyWord + `%' AND a.article_id >= ` + strconv.Itoa(utils.SummaryArticleId) + conditionOr
  2732. listYx, err := models.GetSearchResourceList(user.UserId, condition, 0, 0)
  2733. if err != nil {
  2734. br.Msg = "获取信息失败"
  2735. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2736. return
  2737. }
  2738. //合并产业关联的标的
  2739. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2740. if err != nil {
  2741. br.Msg = "获取信息失败"
  2742. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2743. return
  2744. }
  2745. industrialIdArr := make([]int, 0)
  2746. for k, v := range listHz {
  2747. listHz[k].Source = 1
  2748. if fllowMap[v.IndustrialManagementId] > 0 {
  2749. listHz[k].IsFollw = true
  2750. }
  2751. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2752. }
  2753. for k, v := range listYx {
  2754. listYx[k].Source = 2
  2755. if fllowMap[v.IndustrialManagementId] > 0 {
  2756. listYx[k].IsFollw = true
  2757. }
  2758. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  2759. }
  2760. if len(industrialIdArr) > 0 {
  2761. //合并产业关联的标的
  2762. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  2763. if err != nil {
  2764. br.Msg = "获取信息失败"
  2765. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2766. return
  2767. }
  2768. mapIndustrial := make(map[string]int)
  2769. for _, v := range listSubjcet {
  2770. for k2, v2 := range listYx {
  2771. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 {
  2772. listYx[k2].IndustrialSubjectList = append(listYx[k2].IndustrialSubjectList, v)
  2773. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  2774. }
  2775. }
  2776. for k2, v2 := range listHz {
  2777. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  2778. listHz[k2].IndustrialSubjectList = append(listHz[k2].IndustrialSubjectList, v)
  2779. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  2780. }
  2781. }
  2782. }
  2783. }
  2784. if keyWord != "" {
  2785. keyWordItem := new(models.CygxUserSearchKeyWord)
  2786. keyWordItem.UserId = user.UserId
  2787. keyWordItem.KeyWord = keyWord
  2788. keyWordItem.PageType = "ReortSearch"
  2789. keyWordItem.CreateTime = time.Now()
  2790. go models.AddUserSearchKeyWord(keyWordItem)
  2791. }
  2792. resp := new(models.SearchResourceResp)
  2793. if len(listYx) == 0 {
  2794. listYx = make([]*models.IndustrialManagementHotResp, 0)
  2795. }
  2796. if len(listHz) == 0 {
  2797. listHz = make([]*models.IndustrialManagementHotResp, 0)
  2798. }
  2799. resp.ListYx = listYx
  2800. resp.ListHz = listHz
  2801. br.Ret = 200
  2802. br.Success = true
  2803. br.Msg = "获取成功"
  2804. br.Data = resp
  2805. }
  2806. // @Title 报告搜索、资源包搜索接口
  2807. // @Description 报告搜索、资源包搜索接口接口
  2808. // @Param KeyWord query string true "搜索关键词"
  2809. // @Param PageSize query int true "每页数据条数"
  2810. // @Success 200 {object} models.SearchReportAndResourceResp
  2811. // @router /searchReportAndResource [get]
  2812. func (this *ReportController) SearchReportAndResource() {
  2813. br := new(models.BaseResponse).Init()
  2814. defer func() {
  2815. this.Data["json"] = br
  2816. this.ServeJSON()
  2817. }()
  2818. user := this.User
  2819. if user == nil {
  2820. br.Msg = "请重新登录"
  2821. br.Ret = 408
  2822. return
  2823. }
  2824. uid := user.UserId
  2825. keyWord := this.GetString("KeyWord")
  2826. pageSize, _ := this.GetInt("PageSize")
  2827. var condition string
  2828. var conditionSpecial string // 研选专栏
  2829. var sqlGroup string
  2830. articleTypeIds, err := services.GetYanXuanArticleTypeIds()
  2831. if err != nil {
  2832. br.Msg = "获取信息失败"
  2833. br.ErrMsg = "GetYanXuanArticleTypeIds,Err:" + err.Error()
  2834. return
  2835. }
  2836. if articleTypeIds == "" {
  2837. br.Msg = "获取信息失败"
  2838. br.ErrMsg = "研选分类ID不能为空"
  2839. return
  2840. }
  2841. //匹配报告标题、
  2842. 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 `
  2843. sqlGroup = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2844. if pageSize > 0 {
  2845. sqlGroup += ` LIMIT 5 `
  2846. } else {
  2847. sqlGroup += ` LIMIT 100 `
  2848. }
  2849. conditionSpecial = ` AND ( a.title LIKE '%` + keyWord + `%' OR a.content LIKE '%` + keyWord + `%' )`
  2850. ListYxReport, err := models.GetArticleAndYxSpecialList(` AND a.article_type_id IN (`+articleTypeIds+`) `+condition, conditionSpecial, user.UserId)
  2851. if err != nil {
  2852. br.Msg = "获取信息失败"
  2853. br.ErrMsg = "获取研选文章列表失败,Err:" + err.Error()
  2854. return
  2855. }
  2856. ListHzReport, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+condition+sqlGroup, user.UserId)
  2857. if err != nil {
  2858. br.Msg = "获取信息失败"
  2859. br.ErrMsg = "获取弘则报告文章列表失败,Err:" + err.Error()
  2860. return
  2861. }
  2862. keyWordArr, err := services.GetIndustryMapNameSliceV3(keyWord)
  2863. if err != nil {
  2864. br.Msg = "获取失败"
  2865. br.ErrMsg = "获取分词失败,GetIndustryMapNameSliceV3 Err: " + err.Error()
  2866. return
  2867. }
  2868. keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  2869. var keyWordIk string
  2870. if len(keyWordArr) > 1 {
  2871. keyWordIk = services.KeyWordArrSqlRegexp(keyWordArr)
  2872. var conditionIk string
  2873. var sqlGroupIk string
  2874. conditionIk = `AND ( a.title REGEXP '` + keyWordIk + `' OR a.annotation REGEXP '` + keyWordIk + `' OR a.abstract REGEXP '` + keyWordIk + `') AND a.publish_status = 1 `
  2875. sqlGroupIk = ` GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2876. if pageSize > 0 {
  2877. sqlGroupIk += ` LIMIT 5 `
  2878. } else {
  2879. sqlGroupIk += ` LIMIT 20 `
  2880. }
  2881. 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 + `%') `
  2882. //研选的联想词列表
  2883. ListYxReportIk, err := models.GetArticleCollectionList(` AND a.article_type_id IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2884. if err != nil && err.Error() != utils.ErrNoRow() {
  2885. br.Msg = "获取信息失败"
  2886. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2887. return
  2888. }
  2889. if len(ListYxReportIk) > 0 {
  2890. for _, v := range ListYxReportIk {
  2891. ListYxReport = append(ListYxReport, v)
  2892. }
  2893. }
  2894. //弘则的联想词列表
  2895. ListHzReportIk, err := models.GetReoprtSearchList(` AND a.article_type_id NOT IN (`+articleTypeIds+`) `+conditionIk+sqlGroupIk, user.UserId)
  2896. if err != nil && err.Error() != utils.ErrNoRow() {
  2897. br.Msg = "获取信息失败"
  2898. br.ErrMsg = "获取研选IK文章列表失败,Err:" + err.Error()
  2899. return
  2900. }
  2901. if len(ListHzReportIk) > 0 {
  2902. for _, v := range ListHzReportIk {
  2903. ListHzReport = append(ListHzReport, v)
  2904. }
  2905. }
  2906. }
  2907. for k, v := range ListHzReport {
  2908. ListHzReport[k].Source = 1
  2909. if v.MyCollectNum > 0 {
  2910. ListHzReport[k].IsCollect = true
  2911. }
  2912. }
  2913. for k, v := range ListYxReport {
  2914. ListYxReport[k].Source = 2
  2915. if v.MyCollectNum > 0 {
  2916. ListYxReport[k].IsCollect = true
  2917. }
  2918. }
  2919. var articleIds string
  2920. for _, v := range ListHzReport {
  2921. articleIds += strconv.Itoa(v.ArticleId) + ","
  2922. }
  2923. for i, v := range ListYxReport {
  2924. articleIds += strconv.Itoa(v.ArticleId) + ","
  2925. if v.ArticleTypeId == -1 {
  2926. ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_SPECIAL
  2927. } else if v.ArticleTypeId > 0 {
  2928. ListYxReport[i].ArticleTypeName = utils.CYGX_YANXUAN_ARTICLE
  2929. }
  2930. if v.SpecialType == 1 {
  2931. ListYxReport[i].Title = "【笔记】" + ListYxReport[i].Title
  2932. } else if ListYxReport[i].SpecialType == 2 {
  2933. ListYxReport[i].Title = "【观点】" + ListYxReport[i].Title
  2934. }
  2935. if v.CompanyTags != "" {
  2936. v.SpecialTags += v.CompanyTags
  2937. }
  2938. if v.IndustryTags != "" {
  2939. if v.SpecialTags != "" {
  2940. v.SpecialTags += ","
  2941. }
  2942. v.SpecialTags += v.IndustryTags
  2943. }
  2944. v.SpecialTags = v.SpecialTags
  2945. }
  2946. articleIds = strings.TrimRight(articleIds, ",")
  2947. silcearticleIds := strings.Split(articleIds, ",")
  2948. var parsindustrial []interface{}
  2949. parsindustrial = make([]interface{}, 0)
  2950. articleIdList := make([]string, 0)
  2951. for _, v := range silcearticleIds {
  2952. articleIdList = append(articleIdList, v)
  2953. }
  2954. conditionindustrial := ` AND mg.article_id IN ( ` + utils.GetOrmInReplace(len(silcearticleIds)) + ` ) `
  2955. parsindustrial = append(parsindustrial, articleIdList)
  2956. industrialList, err := models.GetIndustrialListByarticleId(parsindustrial, conditionindustrial)
  2957. if err != nil {
  2958. return
  2959. }
  2960. industrialMap := make(map[int][]*models.IndustrialManagementResp)
  2961. if len(industrialList) > 0 {
  2962. for _, v := range industrialList {
  2963. item := new(models.IndustrialManagementResp)
  2964. //item.ArticleId = v.ArticleId
  2965. item.IndustrialManagementId = v.IndustrialManagementId
  2966. item.IndustryName = v.IndustryName
  2967. item.ChartPermissionId = v.ChartPermissionId
  2968. industrialMap[v.ArticleId] = append(industrialMap[v.ArticleId], item)
  2969. }
  2970. }
  2971. for k, v := range ListHzReport {
  2972. if len(industrialMap[v.ArticleId]) > 0 {
  2973. ListHzReport[k].List = industrialMap[v.ArticleId]
  2974. } else {
  2975. ListHzReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2976. }
  2977. }
  2978. for k, v := range ListYxReport {
  2979. if len(industrialMap[v.ArticleId]) > 0 {
  2980. ListYxReport[k].List = industrialMap[v.ArticleId]
  2981. } else {
  2982. ListYxReport[k].List = make([]*models.IndustrialManagementResp, 0)
  2983. }
  2984. }
  2985. //获取文章关联的产业
  2986. if len(ListYxReport) == 0 {
  2987. ListYxReport = make([]*models.ArticleCollectionResp, 0)
  2988. }
  2989. if len(ListHzReport) == 0 {
  2990. ListHzReport = make([]*models.ArticleCollectionResp, 0)
  2991. }
  2992. fllowList, err := models.GetUserFllowIndustrialList(uid)
  2993. if err != nil {
  2994. br.Msg = "获取失败"
  2995. br.ErrMsg = "获取失败,GetUserFllowIndustrialList Err:" + err.Error()
  2996. return
  2997. }
  2998. fllowMap := make(map[int]int)
  2999. if len(fllowList) > 0 {
  3000. for _, v := range fllowList {
  3001. fllowMap[v.IndustrialManagementId] = v.IndustrialManagementId
  3002. }
  3003. }
  3004. 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 + `%' ) `
  3005. listHzResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3006. if err != nil {
  3007. br.Msg = "获取信息失败"
  3008. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3009. return
  3010. }
  3011. 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 + `%' ) `
  3012. hotMapindustrial, e := services.IndustrialManagementHotMapGropuPermission()
  3013. if e != nil {
  3014. br.Msg = "获取信息失败"
  3015. br.ErrMsg = "获取hot标签失败,IndustrialManagementHotMapGropuPermission ,Err:" + err.Error()
  3016. return
  3017. }
  3018. listYxResource, err := models.GetSearchResourceList(user.UserId, condition, 0, pageSize)
  3019. if err != nil {
  3020. br.Msg = "获取信息失败"
  3021. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  3022. return
  3023. }
  3024. //合并产业关联的标的
  3025. listSubjcet, err := models.GetThemeHeatSubjectList("")
  3026. if err != nil {
  3027. br.Msg = "获取信息失败"
  3028. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3029. return
  3030. }
  3031. industrialIdArr := make([]int, 0)
  3032. nowTime := time.Now().Local()
  3033. threeMonBefore := nowTime.AddDate(0, -3, 0)
  3034. mapHot := make(map[int]bool)
  3035. //if themeType == 2 {
  3036. mapHot, err = services.GetYanXuanIndustrialManagementIdHotMap(articleTypeIds)
  3037. if err != nil {
  3038. br.Msg = "获取信息失败"
  3039. br.ErrMsg = "GetYanXuanIndustrialManagementIdNewMap,Err:" + err.Error()
  3040. return
  3041. }
  3042. //conditionOrder := ` ORDER BY sum_num DESC `
  3043. //listHot, err := models.GetThemeHeatList(user.UserId, condition, conditionOrder, 0, 3)
  3044. //if err != nil {
  3045. // br.Msg = "获取信息失败"
  3046. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3047. // return
  3048. //}
  3049. for k, _ := range mapHot {
  3050. industrialIdArr = append(industrialIdArr, k)
  3051. }
  3052. orderSrt := "man.recommended_index DESC,update_time DESC"
  3053. for k, v := range listHzResource {
  3054. // 关联报告发布时间均在3个月内则标记New
  3055. if v.MinReportTime != "" {
  3056. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3057. if e != nil {
  3058. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3059. return
  3060. }
  3061. if t.After(threeMonBefore) {
  3062. listHzResource[k].IsNew = true
  3063. }
  3064. }
  3065. //弘则资源包不展示hot标签
  3066. //if mapHot[v.IndustryName] > 0 {
  3067. // listHzResource[k].IsHot = true
  3068. //}
  3069. listHzResource[k].Source = 1
  3070. if fllowMap[v.IndustrialManagementId] > 0 {
  3071. listHzResource[k].IsFollw = true
  3072. }
  3073. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3074. industrialIdSlice := make([]int, 0)
  3075. articleIdArr := make([]int, 0)
  3076. industrialIdSlice = append(industrialIdSlice, v.IndustrialManagementId)
  3077. listUpdateTime, err := models.GetNewArticleDetailByIndustrialIds(industrialIdSlice)
  3078. if err != nil && err.Error() != utils.ErrNoRow() {
  3079. return
  3080. }
  3081. for _, v := range listUpdateTime {
  3082. articleIdArr = append(articleIdArr, v.ArticleId)
  3083. }
  3084. if err != nil {
  3085. return
  3086. }
  3087. mapHistroyArticleId := make(map[int]int)
  3088. if user.UserId > 0 {
  3089. listArticleHistory, e := models.GetUserToArticleHistory(user.UserId, articleIdArr)
  3090. if e != nil && e.Error() != utils.ErrNoRow() {
  3091. err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3092. return
  3093. }
  3094. for _, v := range listArticleHistory {
  3095. mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3096. }
  3097. }
  3098. condition2 := ` AND man.industry_name LIKE '%` + keyWord + `%' `
  3099. list, err := models.GetIndustrialManagementAll(uid, condition2, orderSrt, 0, 20)
  3100. if err != nil {
  3101. br.Msg = "获取信息失败"
  3102. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  3103. return
  3104. }
  3105. mapUPdateTime := make(map[int]string)
  3106. //获取这些产业下最新更新的文章
  3107. //时间线的更新时间
  3108. // maptimelineUPdateTime := make(map[int]string)
  3109. listtimelinePublishdate, err := models.GetTimeLineReportIndustrialPublishdateList(industrialIdArr)
  3110. if err != nil && err.Error() != utils.ErrNoRow() {
  3111. br.Msg = "获取信息失败"
  3112. br.ErrMsg = "GetTimeLineReportIndustrialPublishdateList,Err:" + err.Error()
  3113. return
  3114. }
  3115. for _, v := range listtimelinePublishdate {
  3116. if mapUPdateTime[v.IndustrialManagementId] != "" {
  3117. if utils.StrTimeToTime(v.PublishDate).After(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3118. mapUPdateTime[v.IndustrialManagementId] = v.PublishDate
  3119. }
  3120. }
  3121. }
  3122. //mapHistroyArticleId := make(map[int]int)
  3123. //if userId > 0 {
  3124. // listArticleHistory, e := models.GetUserToArticleHistory(userId, articleIdArr)
  3125. // if e != nil && e.Error() != utils.ErrNoRow() {
  3126. // err = errors.New("获取产业关联的视频失败,GetindustryVideo " + e.Error())
  3127. // return
  3128. // }
  3129. // for _, v := range listArticleHistory {
  3130. // mapHistroyArticleId[v.ArticleId] = v.ArticleId
  3131. // }
  3132. //}
  3133. var industrialIds string
  3134. for _, id := range industrialIdArr {
  3135. industrialIds += strconv.Itoa(id) + ","
  3136. }
  3137. industrialIds = strings.TrimRight(industrialIds, ",")
  3138. articleList, err := models.GetReportIndustrialReadNumList(user.UserId, industrialIds, user.CreatedTime)
  3139. if err != nil && err.Error() != utils.ErrNoRow() {
  3140. br.Msg = "获取信息失败"
  3141. br.ErrMsg = "GetReportIndustrialReadNumList,Err:" + err.Error()
  3142. return
  3143. }
  3144. mapHistroyindustrialId := make(map[int]int)
  3145. for _, v := range articleList {
  3146. mapHistroyindustrialId[v.IndustrialManagementId] = v.Readnum
  3147. }
  3148. //nowTime := time.Now().Local()
  3149. //threeMonBefore := nowTime.AddDate(0, -3, 0)
  3150. //查询用户今天是否看过时间线
  3151. //haveMorningMeeting := false
  3152. //var morningMeetingTime string
  3153. recrodList, err := models.GetTimeLineRecordAllCount(user.UserId, time.Now().Format(utils.FormatDate))
  3154. if err != nil {
  3155. br.Msg = "获取信息失败"
  3156. br.ErrMsg = "GetTimeLineRecordAllCount,Err:" + err.Error()
  3157. return
  3158. }
  3159. var industrialManagementIdstr string
  3160. industrialIdMap := make(map[string]time.Time)
  3161. for _, v := range recrodList {
  3162. industrialManagementIdstr = strings.TrimLeft(v.Parameter, "PageSize=10&CurrentIndex=1&CategoryId=99999&IndustrialManagementId=")
  3163. if createTime, ok := industrialIdMap[industrialManagementIdstr]; ok {
  3164. if createTime.Before(v.CreateTime) {
  3165. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3166. }
  3167. } else {
  3168. industrialIdMap[industrialManagementIdstr] = v.CreateTime
  3169. }
  3170. }
  3171. mmList, err := models.GetCygxMorningMeetingReviewsListByIndustrialIds(industrialIds)
  3172. if err != nil {
  3173. return
  3174. }
  3175. morningMeetingTimeMap := make(map[int]time.Time)
  3176. for _, v := range mmList {
  3177. morningMeetingTimeMap[v.IndustryId] = v.CreateTime
  3178. }
  3179. timeLineRedMap := make(map[int]bool, 0)
  3180. for _, industrialId := range industrialIdArr {
  3181. if createTime, ok := industrialIdMap[strconv.Itoa(industrialId)]; ok {
  3182. if createTime.Before(morningMeetingTimeMap[industrialId]) {
  3183. timeLineRedMap[industrialId] = true
  3184. }
  3185. }
  3186. }
  3187. for k, v := range list {
  3188. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3189. if user.UserId > 0 {
  3190. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3191. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3192. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3193. list[k].IsRed = true
  3194. }
  3195. }
  3196. } else {
  3197. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3198. list[k].IsRed = true
  3199. }
  3200. list[k].IsFollow = 0
  3201. }
  3202. list[k].UpdateTime = utils.TimeRemoveHms(mapUPdateTime[v.IndustrialManagementId])
  3203. if user.UserId > 0 {
  3204. //如果文章没有阅读,而且,文章的发布时间晚于项目的上线时间,而且文章的发布时间晚于用户的注册时间,就进行标红处理
  3205. if mapHistroyindustrialId[v.IndustrialManagementId] == 0 || timeLineRedMap[v.IndustrialManagementId] {
  3206. if user.CreatedTime.Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3207. list[k].IsRed = true
  3208. }
  3209. }
  3210. } else {
  3211. if utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(mapUPdateTime[v.IndustrialManagementId])) {
  3212. list[k].IsRed = true
  3213. }
  3214. list[k].IsFollow = 0
  3215. }
  3216. }
  3217. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3218. }
  3219. for k, v := range listYxResource {
  3220. // 关联报告发布时间均在3个月内则标记New
  3221. if v.MinReportTime != "" {
  3222. t, e := time.Parse(utils.FormatDateTime, v.MinReportTime)
  3223. if e != nil {
  3224. err = errors.New("报告最早发布时间有误,GetindustryVideo " + e.Error())
  3225. return
  3226. }
  3227. if t.After(threeMonBefore) {
  3228. listYxResource[k].IsNew = true
  3229. }
  3230. }
  3231. listYxResource[k].IsHot = mapHot[v.IndustrialManagementId]
  3232. listYxResource[k].Source = 2
  3233. if fllowMap[v.IndustrialManagementId] > 0 {
  3234. listYxResource[k].IsFollw = true
  3235. }
  3236. v.IsHot = hotMapindustrial[v.IndustrialManagementId]
  3237. industrialIdArr = append(industrialIdArr, v.IndustrialManagementId)
  3238. }
  3239. if len(industrialIdArr) > 0 {
  3240. //查询产业视频
  3241. industrialVideoMap := make(map[int]*models.MicroVideoSimpleInfo)
  3242. // 获取默认图配置
  3243. _, videoMap, _, _, e := services.GetMicroRoadShowDefaultImgConfig()
  3244. if e != nil {
  3245. br.Msg = "获取视频默认配置图失败"
  3246. br.ErrMsg = "获取视频默认配置图失败, Err: " + e.Error()
  3247. return
  3248. }
  3249. videoList, err := models.GetMicroRoadshowVideoByIndustryIds(industrialIdArr)
  3250. if err != nil {
  3251. br.Msg = "产业视频列表失败"
  3252. br.ErrMsg = "产业视频列表失败, Err: " + err.Error()
  3253. return
  3254. }
  3255. for _, v := range videoList {
  3256. tmp := &models.MicroVideoSimpleInfo{
  3257. Id: v.VideoId,
  3258. Title: "5min逻辑【" + v.IndustryName + "】解析",
  3259. ResourceUrl: v.VideoUrl,
  3260. BackgroundImg: v.ImgUrl,
  3261. PlaySeconds: v.VideoDuration,
  3262. DetailImgUrl: v.DetailImgUrl,
  3263. ChartPermissionName: v.ChartPermissionName,
  3264. ChartPermissionId: v.ChartPermissionId,
  3265. }
  3266. if tmp.BackgroundImg == "" {
  3267. tmp.BackgroundImg = videoMap[v.ChartPermissionId]
  3268. }
  3269. industrialVideoMap[v.IndustryId] = tmp
  3270. }
  3271. //查询权限
  3272. // 用户权限
  3273. authInfo, permissionArr, e := services.GetUserRaiPermissionInfo(user.UserId, user.CompanyId)
  3274. if e != nil {
  3275. br.Msg = "获取失败"
  3276. br.ErrMsg = "获取用户权限失败, Err: " + e.Error()
  3277. return
  3278. }
  3279. for k, v := range listHzResource {
  3280. //展示产业视频
  3281. if video, ok := industrialVideoMap[v.IndustrialManagementId]; ok {
  3282. au := new(models.UserPermissionAuthInfo)
  3283. au.SellerName = authInfo.SellerName
  3284. au.SellerMobile = authInfo.SellerMobile
  3285. au.HasPermission = authInfo.HasPermission
  3286. au.OperationMode = authInfo.OperationMode
  3287. if au.HasPermission == 1 {
  3288. // 非宏观权限进一步判断是否有权限
  3289. if video.ChartPermissionId != utils.HONG_GUAN_ID && !utils.InArrayByStr(permissionArr, video.ChartPermissionName) {
  3290. au.HasPermission = 2
  3291. }
  3292. }
  3293. // 无权限的弹框提示
  3294. if au.HasPermission != 1 {
  3295. if au.OperationMode == services.UserPermissionOperationModeCall {
  3296. au.PopupMsg = services.UserPermissionPopupMsgCallMicroVideo
  3297. } else {
  3298. au.PopupMsg = services.UserPermissionPopupMsgApplyMicroVideo
  3299. }
  3300. video.ResourceUrl = ""
  3301. }
  3302. listHzResource[k].AuthInfo = au
  3303. listHzResource[k].IndustryVideo = video
  3304. }
  3305. }
  3306. //合并产业关联的标的
  3307. listSubjcet, err = models.GetIndustrialSubjectAllByIndustrialId(industrialIdArr)
  3308. if err != nil {
  3309. br.Msg = "获取信息失败"
  3310. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  3311. return
  3312. }
  3313. //严选的产业只关联研选下面的标的
  3314. var yxcondition string
  3315. var yxPer []interface{}
  3316. yxcondition = ` AND ag.article_id >= ?`
  3317. yxPer = append(yxPer, utils.SummaryArticleId)
  3318. listYxAticleSubject, err := models.GetSubjectArticleGroupManagementList(yxcondition, yxPer)
  3319. if err != nil && err.Error() != utils.ErrNoRow() {
  3320. br.Msg = "获取信息失败"
  3321. br.ErrMsg = "获取研选报告关联的标的信息失败,GetSubjectArticleGroupManagementListErr:" + err.Error()
  3322. return
  3323. }
  3324. mapYxSubject := make(map[int]int)
  3325. for _, v := range listYxAticleSubject {
  3326. mapYxSubject[v.IndustrialSubjectId] = v.IndustrialSubjectId
  3327. }
  3328. mapIndustrial := make(map[string]int)
  3329. for _, v := range listSubjcet {
  3330. for k2, v2 := range listYxResource {
  3331. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] == 0 && mapYxSubject[v.IndustrialSubjectId] > 0 {
  3332. listYxResource[k2].IndustrialSubjectList = append(listYxResource[k2].IndustrialSubjectList, v)
  3333. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Yx", v.SubjectName)] = v2.IndustrialManagementId
  3334. }
  3335. }
  3336. for k2, v2 := range listHzResource {
  3337. if v2.IndustrialManagementId == v.IndustrialManagementId && mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] == 0 {
  3338. listHzResource[k2].IndustrialSubjectList = append(listHzResource[k2].IndustrialSubjectList, v)
  3339. mapIndustrial[fmt.Sprint(v2.IndustrialManagementId, "Hz", v.SubjectName)] = v2.IndustrialManagementId
  3340. }
  3341. }
  3342. }
  3343. }
  3344. resp := new(models.SearchReportAndResourceResp)
  3345. if len(listYxResource) == 0 {
  3346. listYxResource = make([]*models.IndustrialManagementHotResp, 0)
  3347. }
  3348. if len(listHzResource) == 0 {
  3349. listHzResource = make([]*models.IndustrialManagementHotResp, 0)
  3350. }
  3351. if keyWord != "" {
  3352. keyWordItem := new(models.CygxUserSearchKeyWord)
  3353. keyWordItem.UserId = user.UserId
  3354. keyWordItem.KeyWord = keyWord
  3355. keyWordItem.PageType = "ReortSearch"
  3356. keyWordItem.CreateTime = time.Now()
  3357. go models.AddUserSearchKeyWord(keyWordItem)
  3358. //go services.AddUserSearchLog(user, keyWord, 5)
  3359. }
  3360. resp.ListHzResource = listHzResource
  3361. resp.ListYxResource = listYxResource
  3362. resp.ListYxReport = ListYxReport
  3363. resp.ListHzReport = ListHzReport
  3364. br.Ret = 200
  3365. br.Success = true
  3366. br.Msg = "获取成功"
  3367. br.Data = resp
  3368. }
  3369. // @Title 产业报告公司列表
  3370. // @Description 获取产业报告公司列表接口
  3371. // @Param ChartPermissionId query int true "行业id"
  3372. // @Success 200 {object} models.IndustrialManagementList
  3373. // @router /home/stockName [get]
  3374. func (this *ReportController) StockNameList() {
  3375. br := new(models.BaseResponse).Init()
  3376. defer func() {
  3377. this.Data["json"] = br
  3378. this.ServeJSON()
  3379. }()
  3380. user := this.User
  3381. if user == nil {
  3382. br.Msg = "请重新登录"
  3383. br.Ret = 408
  3384. return
  3385. }
  3386. //uid := user.UserId
  3387. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  3388. list, err := models.GetSummaryArticle(chartPermissionId)
  3389. if err != nil {
  3390. br.Msg = "获取综述报告公司名称失败"
  3391. br.ErrMsg = "获取综述报告公司名称失败,Err:" + err.Error()
  3392. return
  3393. }
  3394. var respList []*models.SummaryArticleStock
  3395. for _, item := range list {
  3396. sliceSubjects := strings.Split(item.Stock, "/")
  3397. if len(sliceSubjects) > 0 {
  3398. for i, vSubject := range sliceSubjects {
  3399. sliceKuohao := strings.Split(vSubject, "(") //过滤括号
  3400. sliceXiahuaxian := strings.Split(sliceKuohao[0], "-") //过滤下划线
  3401. subject := sliceXiahuaxian[0]
  3402. if i > 0 {
  3403. newItem := models.SummaryArticleStock{
  3404. Id: item.Id,
  3405. ArticleId: item.ArticleId,
  3406. Stock: subject,
  3407. }
  3408. respList = append(respList, &newItem)
  3409. } else {
  3410. item.Stock = subject
  3411. respList = append(respList, item)
  3412. }
  3413. }
  3414. }
  3415. //index := strings.Index(item.Stock, "(")
  3416. //item.Stock = item.Stock[:index]
  3417. //if strings.Contains(item.Stock, "-B"){
  3418. // item.Stock = strings.Replace(item.Stock, "-B", "", -1)
  3419. //}
  3420. //if strings.Contains(item.Stock, "-W"){
  3421. // item.Stock = strings.Replace(item.Stock, "-W", "", -1)
  3422. //}
  3423. }
  3424. resp := new(models.SummaryArticleStockResp)
  3425. resp.List = respList
  3426. br.Ret = 200
  3427. br.Success = true
  3428. br.Msg = "获取成功"
  3429. br.Data = resp
  3430. }
  3431. // @Title 文章留言接口
  3432. // @Description 文章留言接口
  3433. // @Param request body models.AddCygxActivityHelpAsk true "type json string"
  3434. // @Success 200 {object} models.TacticsListResp
  3435. // @router /commentAdd [post]
  3436. func (this *ReportController) CommentAdd() {
  3437. br := new(models.BaseResponse).Init()
  3438. defer func() {
  3439. this.Data["json"] = br
  3440. this.ServeJSON()
  3441. }()
  3442. user := this.User
  3443. if user == nil {
  3444. br.Msg = "请重新登录"
  3445. br.Ret = 408
  3446. return
  3447. }
  3448. var req models.AddCygxArticleCommentReq
  3449. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3450. if err != nil {
  3451. br.Msg = "参数解析异常!"
  3452. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3453. return
  3454. }
  3455. if req.ArticleId <= 0 {
  3456. br.Msg = "文章不存在"
  3457. br.ErrMsg = "文章不存在,文章ID错误"
  3458. return
  3459. }
  3460. if req.Content == "" {
  3461. br.Msg = "建议内容不可为空"
  3462. return
  3463. }
  3464. content := req.Content
  3465. itemToken, err := services.WxGetToken()
  3466. if err != nil {
  3467. br.Msg = "GetWxAccessToken Err:" + err.Error()
  3468. return
  3469. }
  3470. if itemToken.AccessToken == "" {
  3471. br.Msg = "accessToken is empty"
  3472. return
  3473. }
  3474. commerr, err := weapp.MSGSecCheck(itemToken.AccessToken, content)
  3475. if err != nil {
  3476. br.Msg = "内容校验失败!"
  3477. br.ErrMsg = "内容校验失败,Err:" + err.Error()
  3478. return
  3479. }
  3480. if commerr.ErrCode != 0 {
  3481. br.Msg = "内容违规,请重新提交!"
  3482. br.ErrMsg = "内容违规,Err:" + commerr.ErrMSG
  3483. return
  3484. }
  3485. articleId := req.ArticleId
  3486. articleInfo, errInfo := models.GetArticleDetailById(articleId)
  3487. if articleInfo == nil {
  3488. br.Msg = "操作失败"
  3489. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3490. return
  3491. }
  3492. if errInfo != nil {
  3493. br.Msg = "操作失败"
  3494. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3495. return
  3496. }
  3497. companyDetail, err := models.GetCompanyDetailById(user.CompanyId)
  3498. if err != nil {
  3499. br.Msg = "提交失败!"
  3500. br.ErrMsg = "获取客户详情失败,Err:" + err.Error()
  3501. return
  3502. }
  3503. if companyDetail == nil {
  3504. br.Msg = "提交失败!"
  3505. br.ErrMsg = "客户不存在,uid:" + strconv.Itoa(user.UserId)
  3506. return
  3507. }
  3508. item := models.CygxArticleComment{
  3509. UserId: user.UserId,
  3510. ArticleId: req.ArticleId,
  3511. CreateTime: time.Now(),
  3512. Mobile: user.Mobile,
  3513. Email: user.Email,
  3514. CompanyId: user.CompanyId,
  3515. CompanyName: companyDetail.CompanyName,
  3516. Content: content,
  3517. Title: articleInfo.Title,
  3518. }
  3519. msgId, err := models.AddArticleComment(&item)
  3520. if err != nil {
  3521. br.Msg = "提交失败"
  3522. br.ErrMsg = "提交留言失败,Err:" + err.Error()
  3523. return
  3524. }
  3525. services.SendCommentWxTemplateMsg(req, user, articleInfo, int(msgId))
  3526. br.Ret = 200
  3527. br.Success = true
  3528. br.Msg = "提交成功"
  3529. }
  3530. // @Title 记录用户浏览音频回放接口
  3531. // @Description 记录用户浏览音频回放接口
  3532. // @Param request body models.ArticleIdReq true "type json string"
  3533. // @Success Ret=200 操作成功
  3534. // @router /voiceHistory/add [post]
  3535. func (this *ReportController) ResearchSummaryVoiceHistoryAdd() {
  3536. br := new(models.BaseResponse).Init()
  3537. defer func() {
  3538. this.Data["json"] = br
  3539. this.ServeJSON()
  3540. }()
  3541. user := this.User
  3542. if user == nil {
  3543. br.Msg = "请登录"
  3544. br.ErrMsg = "请登录,用户信息为空"
  3545. br.Ret = 408
  3546. return
  3547. }
  3548. uid := user.UserId
  3549. var req models.ArticleIdReq
  3550. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  3551. if err != nil {
  3552. br.Msg = "参数解析异常!"
  3553. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  3554. return
  3555. }
  3556. articleId := req.ArticleId
  3557. playSeconds := req.PlaySeconds
  3558. pageRouter := req.PageRouter
  3559. if pageRouter == "本周研究汇总" {
  3560. articleInfo, errInfo := models.GetCygxResearchSummaryInfoById(articleId)
  3561. if articleInfo == nil {
  3562. br.Msg = "操作失败"
  3563. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3564. return
  3565. }
  3566. if errInfo != nil {
  3567. br.Msg = "操作失败"
  3568. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3569. return
  3570. }
  3571. var sellerName string
  3572. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3573. if err != nil {
  3574. br.Msg = "报名失败!"
  3575. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3576. return
  3577. }
  3578. item := models.CygxResearchSummaryVoiceHistory{
  3579. ArticleId: articleId,
  3580. UserId: uid,
  3581. CreateTime: time.Now(),
  3582. Mobile: user.Mobile,
  3583. Email: user.Email,
  3584. CompanyId: user.CompanyId,
  3585. CompanyName: user.CompanyName,
  3586. RealName: user.RealName,
  3587. SellerName: sellerName,
  3588. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3589. ModifyTime: time.Now(),
  3590. }
  3591. if playSeconds != 0 {
  3592. lastItem, err := models.GetLastCygxResearchSummaryVoiceHistory(articleId, user.UserId)
  3593. if err != nil {
  3594. br.Msg = "操作失败"
  3595. br.ErrMsg = "操作失败,GetLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3596. return
  3597. }
  3598. err = models.UpdateLastCygxResearchSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3599. if err != nil {
  3600. br.Msg = "更新失败"
  3601. br.ErrMsg = "更新失败,UpdateLastCygxResearchSummaryVoiceHistory Err:" + err.Error()
  3602. return
  3603. }
  3604. } else {
  3605. err = models.AddCygxResearchSummaryVoiceHistory(&item)
  3606. if err != nil {
  3607. br.Msg = "操作失败"
  3608. br.ErrMsg = "操作失败,Err:" + err.Error()
  3609. return
  3610. }
  3611. err = models.UpdateResearchSummaryVoiceCounts(articleId)
  3612. if err != nil {
  3613. br.Msg = "更新失败"
  3614. br.ErrMsg = "更新失败,Err:" + err.Error()
  3615. return
  3616. }
  3617. }
  3618. } else if pageRouter == "上周纪要汇总" {
  3619. articleInfo, errInfo := models.GetCygxMinutesSummaryInfoById(articleId)
  3620. if articleInfo == nil {
  3621. br.Msg = "操作失败"
  3622. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3623. return
  3624. }
  3625. if errInfo != nil {
  3626. br.Msg = "操作失败"
  3627. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3628. return
  3629. }
  3630. var sellerName string
  3631. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3632. if err != nil {
  3633. br.Msg = "报名失败!"
  3634. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3635. return
  3636. }
  3637. item := models.CygxMinutesSummaryVoiceHistory{
  3638. ArticleId: articleId,
  3639. UserId: uid,
  3640. CreateTime: time.Now(),
  3641. Mobile: user.Mobile,
  3642. Email: user.Email,
  3643. CompanyId: user.CompanyId,
  3644. CompanyName: user.CompanyName,
  3645. RealName: user.RealName,
  3646. SellerName: sellerName,
  3647. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3648. ModifyTime: time.Now(),
  3649. }
  3650. if playSeconds != 0 {
  3651. lastItem, err := models.GetLastCygxMinutesSummaryVoiceHistory(articleId, user.UserId)
  3652. if err != nil {
  3653. br.Msg = "操作失败"
  3654. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3655. return
  3656. }
  3657. err = models.UpdateLastCygxMinutesSummaryVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3658. if err != nil {
  3659. br.Msg = "更新失败"
  3660. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3661. return
  3662. }
  3663. } else {
  3664. err = models.AddCygxMinutesSummaryVoiceHistory(&item)
  3665. if err != nil {
  3666. br.Msg = "操作失败"
  3667. br.ErrMsg = "操作失败,Err:" + err.Error()
  3668. return
  3669. }
  3670. err = models.UpdateMinutesSummaryVoiceCounts(articleId)
  3671. if err != nil {
  3672. br.Msg = "更新失败"
  3673. br.ErrMsg = "更新失败,Err:" + err.Error()
  3674. return
  3675. }
  3676. }
  3677. } else if pageRouter == "报告精选" {
  3678. articleInfo, errInfo := models.GetCygxReportSelectionInfoById(articleId)
  3679. if articleInfo == nil {
  3680. br.Msg = "操作失败"
  3681. br.ErrMsg = "文章ID错误,不存在articleId:" + strconv.Itoa(articleId)
  3682. return
  3683. }
  3684. if errInfo != nil {
  3685. br.Msg = "操作失败"
  3686. br.ErrMsg = "操作失败,Err:" + errInfo.Error()
  3687. return
  3688. }
  3689. var sellerName string
  3690. sellerName, err = models.GetCompanySellerName(user.CompanyId)
  3691. if err != nil {
  3692. br.Msg = "报名失败!"
  3693. br.ErrMsg = "获取对应销售失败,Err:" + err.Error()
  3694. return
  3695. }
  3696. item := models.CygxReportSelectionVoiceHistory{
  3697. ArticleId: articleId,
  3698. UserId: uid,
  3699. CreateTime: time.Now(),
  3700. Mobile: user.Mobile,
  3701. Email: user.Email,
  3702. CompanyId: user.CompanyId,
  3703. CompanyName: user.CompanyName,
  3704. RealName: user.RealName,
  3705. SellerName: sellerName,
  3706. PlaySeconds: strconv.Itoa(req.PlaySeconds),
  3707. ModifyTime: time.Now(),
  3708. }
  3709. if playSeconds != 0 {
  3710. lastItem, err := models.GetLastCygxReportSelectionVoiceHistory(articleId, user.UserId)
  3711. if err != nil {
  3712. br.Msg = "操作失败"
  3713. br.ErrMsg = "操作失败,GetLastCygxSummaryVoiceHistory Err:" + err.Error()
  3714. return
  3715. }
  3716. err = models.UpdateLastCygxReportSelectionVoiceHistory(strconv.Itoa(req.PlaySeconds), lastItem.Id)
  3717. if err != nil {
  3718. br.Msg = "更新失败"
  3719. br.ErrMsg = "更新失败,UpdateLastCygxSummaryVoiceHistory Err:" + err.Error()
  3720. return
  3721. }
  3722. } else {
  3723. err = models.AddCygxReportSelectionVoiceHistory(&item)
  3724. if err != nil {
  3725. br.Msg = "操作失败"
  3726. br.ErrMsg = "操作失败,Err:" + err.Error()
  3727. return
  3728. }
  3729. err = models.UpdateReportSelectionVoiceCounts(articleId)
  3730. if err != nil {
  3731. br.Msg = "更新失败"
  3732. br.ErrMsg = "更新失败,Err:" + err.Error()
  3733. return
  3734. }
  3735. }
  3736. }
  3737. br.Ret = 200
  3738. br.Success = true
  3739. br.Msg = "操作成功"
  3740. return
  3741. }