report.go 102 KB

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