report.go 106 KB

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