report.go 122 KB

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