report.go 109 KB

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