report.go 109 KB

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