report.go 108 KB

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