report.go 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "github.com/rdlucklib/rdluck_tools/paging"
  6. "hongze/hongze_cygx/models"
  7. "hongze/hongze_cygx/services"
  8. "hongze/hongze_cygx/utils"
  9. "html"
  10. "strconv"
  11. "strings"
  12. "time"
  13. )
  14. //报告
  15. type ReportController struct {
  16. BaseAuthController
  17. }
  18. type ReportCommonController struct {
  19. BaseCommonController
  20. }
  21. // @Title 行业报告分类列表接口
  22. // @Description 获取行业报告分类列表接口
  23. // @Param ChartPermissionId query int true "分类ID"
  24. // @Success 200 {object} models.IndustrialManagementList
  25. // @router /home/tradeList [get]
  26. func (this *ReportController) TradeList() {
  27. br := new(models.BaseResponse).Init()
  28. defer func() {
  29. this.Data["json"] = br
  30. this.ServeJSON()
  31. }()
  32. user := this.User
  33. if user == nil {
  34. br.Msg = "请重新登录"
  35. br.Ret = 408
  36. return
  37. }
  38. uid := user.UserId
  39. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  40. if ChartPermissionId < 1 {
  41. br.Msg = "请输入分类ID"
  42. return
  43. }
  44. list, err := models.GetTradeAll(ChartPermissionId)
  45. if err != nil {
  46. br.Msg = "获取信息失败"
  47. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  48. return
  49. }
  50. for k, v := range list {
  51. list[k].UpdateTime = utils.TimeRemoveHms(v.UpdateTime)
  52. count, err := models.CheckThisCategoryNewArticleIsRead(uid, v.CategoryId)
  53. if err != nil {
  54. br.Msg = "获取信息失败"
  55. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  56. return
  57. }
  58. if count == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.UpdateTime)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.UpdateTime)) {
  59. list[k].IsRed = true
  60. }
  61. }
  62. resp := new(models.TradeReportMappingResp)
  63. resp.List = list
  64. br.Ret = 200
  65. br.Success = true
  66. br.Msg = "获取成功"
  67. br.Data = resp
  68. }
  69. // @Title 产业报告分类列表接口
  70. // @Description 获取产业报告分类列表接口
  71. // @Param ChartPermissionId query int true "分类ID"
  72. // @Param IsNewLabel query string true "是否属于新标签,1是,0否"
  73. // @Param IsDeepLabel query string true "是否属于深标签,1是,0否"
  74. // @Param KeyWord query string true "搜索关键词"
  75. // @Param OrderColumn query int true "排序字段 ,NewTime 最近更新 ,Recommend弘则推荐"
  76. // @Param PageSize query int true "每页数据条数"
  77. // @Param CurrentIndex query int true "当前页页码,从1开始"
  78. // @Success 200 {object} models.IndustrialManagementList
  79. // @router /home/industryList [get]
  80. func (this *ReportController) IndustryList() {
  81. br := new(models.BaseResponse).Init()
  82. defer func() {
  83. this.Data["json"] = br
  84. this.ServeJSON()
  85. }()
  86. user := this.User
  87. if user == nil {
  88. br.Msg = "请重新登录"
  89. br.Ret = 408
  90. return
  91. }
  92. uid := user.UserId
  93. fmt.Println(uid)
  94. ChartPermissionId, _ := this.GetInt("ChartPermissionId")
  95. orderColumn := this.GetString("OrderColumn")
  96. orderColumnNew := this.GetString("OrderColumn")
  97. isNewLabel := this.GetString("IsNewLabel")
  98. isDeepLabel := this.GetString("IsDeepLabel")
  99. keyWord := this.GetString("KeyWord")
  100. pageSize, _ := this.GetInt("PageSize")
  101. currentIndex, _ := this.GetInt("CurrentIndex")
  102. var orderSrt string
  103. var condition string
  104. var startSize int
  105. resp := new(models.IndustrialManagementList)
  106. if pageSize <= 0 {
  107. pageSize = utils.PageSize20
  108. }
  109. if currentIndex <= 0 {
  110. currentIndex = 1
  111. }
  112. startSize = paging.StartIndex(currentIndex, pageSize)
  113. if isNewLabel == "1" {
  114. condition += ` AND is_new_label = ` + isNewLabel
  115. }
  116. if isDeepLabel == "1" {
  117. condition += ` AND is_deep_label = ` + isDeepLabel
  118. }
  119. if keyWord != "" {
  120. //keyWordArr, err := services.GetIndustryMapNameSliceV2(keyWord)
  121. //if err != nil {
  122. // br.Msg = "获取信息失败"
  123. // br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  124. // return
  125. //}
  126. //var conditionkeyWord string
  127. //conditionkeyWord += ` subject_names LIKE '%` + keyWord + `%'`
  128. //keyWordArr = services.RemoveDuplicatesAndEmpty(keyWordArr)
  129. //keyWordLen := len(keyWordArr)
  130. //if keyWordLen <= 0 {
  131. // keyWordArr = append(keyWordArr, keyWord)
  132. // keyWordLen = len(keyWordArr)
  133. //}
  134. //for _, v := range keyWordArr {
  135. // conditionkeyWord += ` OR subject_names LIKE '%` + v + `%'`
  136. //}
  137. //industrialManagementIds, err := models.GetIndustrialManagementIdsBykeyWord(conditionkeyWord)
  138. //if err != nil {
  139. // br.Msg = "获取信息失败"
  140. // br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  141. // return
  142. //}
  143. //if industrialManagementIds == "" {
  144. // br.Ret = 200
  145. // br.Success = true
  146. // br.Msg = "获取成功"
  147. // br.Data = resp
  148. // return
  149. //}
  150. //condition += ` AND man.industrial_management_id IN (` + industrialManagementIds + `)`
  151. condition += ` AND subject_names LIKE '%` + keyWord + `%'`
  152. }
  153. var sqlChartPermissionId string
  154. if ChartPermissionId > 0 {
  155. sqlChartPermissionId += ` AND man_g.industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE chart_permission_id = ` + strconv.Itoa(ChartPermissionId) + ` ) `
  156. condition += ` AND man.chart_permission_id IN (` + strconv.Itoa(ChartPermissionId) + `)`
  157. }
  158. var list []*models.IndustrialManagement
  159. total, err := models.GetIndustrialManagementAllCount(condition)
  160. if err != nil {
  161. br.Msg = "获取信息失败"
  162. br.ErrMsg = "获取数量失败,Err:" + err.Error()
  163. return
  164. }
  165. page := paging.GetPaging(currentIndex, pageSize, total)
  166. if orderColumn == "" {
  167. orderColumn = "NewTime"
  168. }
  169. if orderColumn == "NewTime" {
  170. orderSrt = "update_time DESC"
  171. } else {
  172. orderSrt = "man.recommended_index DESC,update_time DESC"
  173. }
  174. if ChartPermissionId == 0 {
  175. ChartPermissionId = 20
  176. }
  177. detailHot3, err := models.GetIndustrialManagementHot3(ChartPermissionId)
  178. if err != nil {
  179. br.Msg = "获取信息失败"
  180. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  181. return
  182. }
  183. list, err = models.GetIndustrialManagementAll(uid, condition, orderSrt, startSize, pageSize)
  184. if err != nil {
  185. br.Msg = "获取信息失败"
  186. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  187. return
  188. }
  189. for k, v := range list {
  190. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  191. if err != nil {
  192. br.Msg = "获取信息失败"
  193. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  194. return
  195. }
  196. list[k].IndustrialSubjectList = industrialSubjectList
  197. list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  198. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  199. if err != nil {
  200. br.Msg = "获取信息失败"
  201. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  202. return
  203. }
  204. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  205. recordCount, err := models.GetUserToArticleCount(uid, newArtinfo.ArticleId)
  206. if err != nil && err.Error() != utils.ErrNoRow() {
  207. br.Msg = "获取信息失败"
  208. br.ErrMsg = "获取信息失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(newArtinfo.ArticleId)
  209. return
  210. }
  211. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(newArtinfo.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(newArtinfo.PublishDate)) {
  212. list[k].IsRed = true
  213. }
  214. if v.ArticleReadNum >= detailHot3.ArticleReadNum {
  215. list[k].IsHot = true
  216. }
  217. }
  218. //记录用户搜索的筛选条件
  219. if orderColumnNew != "" {
  220. item := new(models.CygxReportIndustrialSeaarchHistory)
  221. item.UserId = user.UserId
  222. item.Mobile = user.Mobile
  223. item.CompanyId = user.CompanyId
  224. item.CompanyName = user.CompanyName
  225. item.CreateTime = time.Now()
  226. item.IsDeepLabel = isDeepLabel
  227. item.IsNewLabel = isNewLabel
  228. item.ChartPermissionId = ChartPermissionId
  229. if orderColumnNew == "NewTime" {
  230. item.OrderColumn = "0"
  231. } else {
  232. item.OrderColumn = "1"
  233. }
  234. go models.AddCygxReportIndustrialSeaarchHistory(item)
  235. }
  236. resp.List = list
  237. resp.Paging = page
  238. br.Ret = 200
  239. br.Success = true
  240. br.Msg = "获取成功"
  241. br.Data = resp
  242. }
  243. // @Title 产业下所关联的文章分类列表
  244. // @Description 产业下所关联的文章分类列表接口
  245. // @Param IndustrialManagementId query int true "产业ID"
  246. // @Success 200 {object} models.IndustrialToArticleCategoryListRep
  247. // @router /toArticleCategoryList [get]
  248. func (this *ReportController) ArticleCategoryList() {
  249. br := new(models.BaseResponse).Init()
  250. defer func() {
  251. this.Data["json"] = br
  252. this.ServeJSON()
  253. }()
  254. user := this.User
  255. if user == nil {
  256. br.Msg = "请重新登录"
  257. br.Ret = 408
  258. return
  259. }
  260. uid := user.UserId
  261. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  262. if industrialManagementId < 1 {
  263. br.Msg = "请输入分类ID"
  264. return
  265. }
  266. detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  267. if err != nil {
  268. br.Msg = "获取信息失败"
  269. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  270. return
  271. }
  272. list, err := models.IndustrialToArticleCategory(industrialManagementId, detail.ChartPermissionId)
  273. if err != nil {
  274. br.Msg = "获取信息失败"
  275. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  276. return
  277. }
  278. for k, v := range list {
  279. recordCount, err := models.IndustrialUserRecordArticleCount(uid, industrialManagementId, v.CategoryId)
  280. if err != nil && err.Error() != utils.ErrNoRow() {
  281. br.Msg = "获取信息失败"
  282. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  283. return
  284. }
  285. Newdetail, err := models.GetNewIndustrialUserRecordArticle(industrialManagementId, v.CategoryId)
  286. if err != nil {
  287. br.Msg = "获取信息失败"
  288. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  289. return
  290. }
  291. if recordCount == 0 && user.CreatedTime.Before(utils.StrTimeToTime(Newdetail.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(Newdetail.PublishDate)) {
  292. list[k].IsRed = true
  293. }
  294. }
  295. //detail, err := models.GetIndustrialManagementDetail(industrialManagementId)
  296. //if err != nil {
  297. // br.Msg = "获取信息失败"
  298. // br.ErrMsg = "获取信息失败,Err:" + err.Error()
  299. // return
  300. //}
  301. resp := new(models.IndustrialToArticleCategoryListRep)
  302. resp.List = list
  303. resp.LayoutTime = utils.TimeRemoveHms(detail.LayoutTime)
  304. resp.IndustryName = detail.IndustryName
  305. resp.IndustrialManagementId = industrialManagementId
  306. br.Ret = 200
  307. br.Success = true
  308. br.Msg = "获取成功"
  309. br.Data = resp
  310. }
  311. // @Title 产业文章列表接口
  312. // @Description 获取产业文章列表接口
  313. // @Param PageSize query int true "每页数据条数"
  314. // @Param CurrentIndex query int true "当前页页码,从1开始"
  315. // @Param CategoryId query int true "分类ID"
  316. // @Param IndustrialManagementId query int true "产业ID"
  317. // @Success 200 {object} models.TacticsListResp
  318. // @router /industry/ArticleList [get]
  319. func (this *ReportController) List() {
  320. br := new(models.BaseResponse).Init()
  321. defer func() {
  322. this.Data["json"] = br
  323. this.ServeJSON()
  324. }()
  325. user := this.User
  326. if user == nil {
  327. br.Msg = "请重新登录"
  328. br.Ret = 408
  329. return
  330. }
  331. uid := user.UserId
  332. pageSize, _ := this.GetInt("PageSize")
  333. currentIndex, _ := this.GetInt("CurrentIndex")
  334. categoryId, _ := this.GetInt("CategoryId")
  335. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  336. var startSize int
  337. if pageSize <= 0 {
  338. pageSize = utils.PageSize20
  339. }
  340. if currentIndex <= 0 {
  341. currentIndex = 1
  342. }
  343. startSize = paging.StartIndex(currentIndex, pageSize)
  344. var pars []interface{}
  345. var total int
  346. resp := new(models.TacticsListResp)
  347. page := paging.GetPaging(currentIndex, pageSize, total)
  348. if categoryId < 1 {
  349. br.Msg = "请输入分类ID"
  350. return
  351. }
  352. if industrialManagementId < 1 {
  353. br.Msg = "请输入产业ID"
  354. return
  355. }
  356. //获取该产业下所对应的行业图片
  357. detail, errCategory := models.GetdetailByCategoryIdOne(categoryId)
  358. if errCategory != nil {
  359. br.Msg = "获取信息失败"
  360. br.ErrMsg = "获取信息失败,Err:" + errCategory.Error() + "categoryID 不存在:" + strconv.Itoa(categoryId)
  361. return
  362. }
  363. //对应行业的图片
  364. detailChartPermissionUrl, err := models.GetConfigByCode("category_chart_permissionimg_url")
  365. if err != nil {
  366. br.Msg = "获取数据失败"
  367. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  368. return
  369. }
  370. chartPermissionUrlList := strings.Split(detailChartPermissionUrl.ConfigValue, "{|}")
  371. mapChartPermission := make(map[string]string)
  372. var permissionName string
  373. var imgUrlChartPermission string
  374. for _, v := range chartPermissionUrlList {
  375. vslice := strings.Split(v, "_")
  376. permissionName = vslice[0]
  377. imgUrlChartPermission = vslice[len(vslice)-1]
  378. mapChartPermission[permissionName] = imgUrlChartPermission
  379. }
  380. total, err = models.GetReportIndustrialCount(categoryId, industrialManagementId)
  381. if err != nil {
  382. br.Msg = "获取信息失败"
  383. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  384. return
  385. }
  386. page = paging.GetPaging(currentIndex, pageSize, total)
  387. list, err := models.GetReportIndustrialList(pars, categoryId, industrialManagementId, uid, startSize, pageSize)
  388. if err != nil {
  389. br.Msg = "获取信息失败"
  390. br.ErrMsg = "获取帖子数据失败,Err:" + err.Error()
  391. return
  392. }
  393. //对应分类的所图片
  394. detailCategoryUrl, err := models.GetConfigByCode("category_map_img_url")
  395. if err != nil {
  396. br.Msg = "获取数据失败"
  397. br.ErrMsg = "行业配置信息失败,Err:" + err.Error()
  398. return
  399. }
  400. categoryUrlList := strings.Split(detailCategoryUrl.ConfigValue, "{|}")
  401. mapCategoryUrl := make(map[string]string)
  402. var categoryIdStr string
  403. var imgUrlChart string
  404. for _, v := range categoryUrlList {
  405. vslice := strings.Split(v, "_")
  406. categoryIdStr = vslice[0]
  407. imgUrlChart = vslice[len(vslice)-1]
  408. mapCategoryUrl[categoryIdStr] = imgUrlChart
  409. }
  410. lenList := len(list)
  411. for i := 0; i < lenList; i++ {
  412. item := list[i]
  413. list[i].Body, _ = services.GetReportContentTextSub(item.Body)
  414. //list[i].Abstract = html.UnescapeString(item.Abstract)
  415. list[i].Abstract, _ = services.GetReportContentTextSub(item.Abstract)
  416. }
  417. for k, v := range list {
  418. if v.Readnum == 0 && user.CreatedTime.Before(utils.StrTimeToTime(v.PublishDate)) && utils.StrTimeToTime(utils.OnlineTime).Before(utils.StrTimeToTime(v.PublishDate)) {
  419. list[k].IsRed = true
  420. }
  421. if v.VideoUrl != "" {
  422. list[k].IsHaveVideo = true
  423. }
  424. list[k].ImgUrlPc = mapCategoryUrl[v.CategoryId]
  425. }
  426. resp.CategoryImgUrlPc = mapChartPermission[detail.ChartPermissionName]
  427. resp.List = list
  428. resp.Paging = page
  429. br.Ret = 200
  430. br.Success = true
  431. br.Msg = "获取成功"
  432. br.Data = resp
  433. }
  434. // @Title 置顶/取消置顶
  435. // @Description 置顶
  436. // @Param request body models.CygxIndustryTopRep true "type json string"
  437. // @Success 200
  438. // @router /top [post]
  439. func (this *ReportController) ArticleCollect() {
  440. br := new(models.BaseResponse).Init()
  441. defer func() {
  442. this.Data["json"] = br
  443. this.ServeJSON()
  444. }()
  445. user := this.User
  446. if user == nil {
  447. br.Msg = "请重新登录"
  448. br.Ret = 408
  449. return
  450. }
  451. uid := user.UserId
  452. var req models.CygxIndustryTopRep
  453. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  454. if err != nil {
  455. br.Msg = "参数解析异常!"
  456. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  457. return
  458. }
  459. industrialManagementId := req.IndustrialManagementId
  460. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  461. if err != nil {
  462. br.Msg = "获取数据失败!"
  463. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  464. return
  465. }
  466. if countIndustrial == 0 {
  467. br.Msg = "产业不存在!"
  468. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  469. return
  470. }
  471. count, err := models.GetCygxIndustryTop(uid, industrialManagementId)
  472. if err != nil {
  473. br.Msg = "获取数据失败!"
  474. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  475. return
  476. }
  477. resp := new(models.ArticleCollectResp)
  478. if count <= 0 {
  479. item := new(models.CygxIndustryTop)
  480. item.IndustrialManagementId = req.IndustrialManagementId
  481. item.UserId = uid
  482. item.CreateTime = time.Now()
  483. _, err = models.AddCygxIndustryTop(item)
  484. if err != nil {
  485. br.Msg = "置顶失败"
  486. br.ErrMsg = "置顶失败,Err:" + err.Error()
  487. return
  488. }
  489. br.Msg = "置顶成功"
  490. resp.Status = 1
  491. } else {
  492. err = models.RemoveCygxIndustryTop(uid, industrialManagementId)
  493. if err != nil {
  494. br.Msg = "取消置顶失败"
  495. br.ErrMsg = "取消置顶失败,Err:" + err.Error()
  496. return
  497. }
  498. br.Msg = "已取消置顶"
  499. resp.Status = 2
  500. }
  501. br.Ret = 200
  502. br.Success = true
  503. br.Data = resp
  504. }
  505. // @Title 关注/取消关注产业
  506. // @Description 关注/取消关注 接口
  507. // @Param request body models.CygxIndustryFllowRep true "type json string"
  508. // @Success 200
  509. // @router /fllow [post]
  510. func (this *ReportController) Fllow() {
  511. br := new(models.BaseResponse).Init()
  512. defer func() {
  513. this.Data["json"] = br
  514. this.ServeJSON()
  515. }()
  516. user := this.User
  517. if user == nil {
  518. br.Msg = "请重新登录"
  519. br.Ret = 408
  520. return
  521. }
  522. uid := user.UserId
  523. var req models.CygxIndustryFllowRep
  524. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  525. if err != nil {
  526. br.Msg = "参数解析异常!"
  527. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  528. return
  529. }
  530. industrialManagementId := req.IndustrialManagementId
  531. var condition string
  532. countIndustrial, err := models.GetIndustrialManagementCount(industrialManagementId)
  533. if err != nil {
  534. br.Msg = "获取数据失败!"
  535. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  536. return
  537. }
  538. if countIndustrial == 0 {
  539. br.Msg = "产业不存在!"
  540. br.ErrMsg = "产业ID不存在:" + strconv.Itoa(industrialManagementId)
  541. return
  542. }
  543. count, err := models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  544. if err != nil {
  545. br.Msg = "获取数据失败!"
  546. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  547. return
  548. }
  549. resp := new(models.CygxIndustryFllowResp)
  550. countUser, err := models.GetCountCygxIndustryFllowByUid(uid)
  551. if countUser == 0 {
  552. resp.GoFollow = true
  553. }
  554. if count == 0 {
  555. item := new(models.CygxIndustryFllow)
  556. item.IndustrialManagementId = industrialManagementId
  557. item.UserId = uid
  558. item.Email = user.Email
  559. item.Mobile = user.Mobile
  560. item.CompanyId = user.CompanyId
  561. item.CompanyName = user.CompanyName
  562. item.Type = 1
  563. item.CreateTime = time.Now()
  564. item.ModifyTime = time.Now()
  565. _, err = models.AddCygxIndustryFllow(item)
  566. if err != nil {
  567. br.Msg = "操作失败"
  568. br.ErrMsg = "操作失败,Err:" + err.Error()
  569. return
  570. }
  571. resp.Status = 1
  572. } else {
  573. var doType int
  574. condition = ` AND type = 1`
  575. count, err = models.GetCountCygxIndustryFllow(uid, industrialManagementId, condition)
  576. if err != nil {
  577. br.Msg = "操作失败!"
  578. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  579. return
  580. }
  581. if count == 1 {
  582. resp.Status = 2
  583. doType = 2
  584. } else {
  585. resp.Status = 1
  586. doType = 1
  587. }
  588. err = models.RemoveCygxIndustryFllow(uid, industrialManagementId, doType)
  589. if err != nil {
  590. br.Msg = "操作失败"
  591. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  592. return
  593. }
  594. }
  595. br.Msg = "操作成功"
  596. br.Ret = 200
  597. br.Success = true
  598. br.Data = resp
  599. }
  600. // @Title 产业报告分类关联作者列表接口
  601. // @Description 获取产业报告分类关联作者列表接口
  602. // @Param ChartPermissionId query int true "分类ID"
  603. // @Param PageSize query int true "每页数据条数"
  604. // @Param CurrentIndex query int true "当前页页码,从1开始"
  605. // @Success 200 {object} models.CygxArticleDepartmentList
  606. // @router /industryListByDepartment [get]
  607. func (this *ReportController) IndustryListByDepartment() {
  608. br := new(models.BaseResponse).Init()
  609. defer func() {
  610. this.Data["json"] = br
  611. this.ServeJSON()
  612. }()
  613. user := this.User
  614. if user == nil {
  615. br.Msg = "请重新登录"
  616. br.Ret = 408
  617. return
  618. }
  619. uid := user.UserId
  620. pageSize, _ := this.GetInt("PageSize")
  621. currentIndex, _ := this.GetInt("CurrentIndex")
  622. //chartPermissionId, _ := this.GetInt("ChartPermissionId")
  623. var startSize int
  624. var condition string
  625. //condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  626. condition = ` AND a.publish_status=1 `
  627. if pageSize <= 0 {
  628. pageSize = utils.PageSize20
  629. }
  630. if currentIndex <= 0 {
  631. currentIndex = 1
  632. }
  633. startSize = paging.StartIndex(currentIndex, pageSize)
  634. total, err := models.GetArticleDepartmentCount(condition)
  635. page := paging.GetPaging(currentIndex, pageSize, total)
  636. resp := new(models.CygxArticleDepartmentList)
  637. userType, _, err := services.GetUserType(user.CompanyId)
  638. if err != nil {
  639. br.Msg = "获取信息失败"
  640. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  641. return
  642. }
  643. if userType == 1 {
  644. resp.Paging = page
  645. br.Ret = 200
  646. br.Success = true
  647. br.Msg = "获取成功"
  648. br.Data = resp
  649. return
  650. }
  651. resp.HaveResearch = true
  652. //获取作者信息,并排序
  653. list, err := models.GetCygxArticleDepartmentList(startSize, pageSize, condition, uid)
  654. if err != nil {
  655. br.Msg = "获取信息失败"
  656. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  657. return
  658. }
  659. for k, v := range list {
  660. artList, err := models.GetArticleByDepartmentId(v.DepartmentId)
  661. if err != nil {
  662. br.Msg = "获取信息失败"
  663. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  664. return
  665. }
  666. for k2, v2 := range artList {
  667. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  668. if err != nil {
  669. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  670. br.ErrMsg = "获取失败,Err:" + err.Error()
  671. return
  672. }
  673. var subjectNamesNew string
  674. if len(subjectNames) > 0 {
  675. slice := strings.Split(subjectNames, "/")
  676. for k3, v3 := range slice {
  677. if k3 < 4 {
  678. subjectNamesNew += v3 + "/"
  679. }
  680. }
  681. }
  682. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  683. if err != nil && err.Error() != utils.ErrNoRow() {
  684. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  685. br.ErrMsg = "获取失败,Err:" + err.Error()
  686. return
  687. }
  688. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  689. artList[k2].SubjectName = subjectNamesNew
  690. artList[k2].DepartmentId = v.DepartmentId
  691. if subjectNamesNew == "" {
  692. artList[k2].IndustryName = industryName
  693. } else {
  694. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  695. }
  696. if artList[k2].IsReport == "1" {
  697. artList[k2].IndustryName = "【观点】" + artList[k2].IndustryName
  698. } else {
  699. artList[k2].IndustryName = "【纪要】" + artList[k2].IndustryName
  700. }
  701. }
  702. list[k].List = artList
  703. if v.FollowNum > 0 {
  704. list[k].IsMyFollow = true
  705. }
  706. }
  707. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  708. if err != nil {
  709. br.Msg = "获取信息失败"
  710. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  711. return
  712. }
  713. if len(listnNew) > 0 {
  714. for _, v := range listnNew {
  715. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  716. Management := new(models.IndustrialManagementIdInt)
  717. if firstStr == 0 {
  718. Management.IndustryName = v.IndustryName
  719. } else {
  720. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  721. if err != nil {
  722. br.Msg = "获取信息失败"
  723. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  724. return
  725. }
  726. var subjectNamesNew string
  727. for _, v1 := range listSub {
  728. subjectNamesNew += v1.SubjectName + "/"
  729. }
  730. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  731. Management.IndustryName = subjectNamesNew
  732. }
  733. Management.IndustrialManagementId = v.IndustrialManagementId
  734. Management.ArticleId = v.ArticleId
  735. resp.ListnNew = append(resp.ListnNew, Management)
  736. }
  737. }
  738. resp.List = list
  739. resp.Paging = page
  740. br.Ret = 200
  741. br.Success = true
  742. br.Msg = "获取成功"
  743. br.Data = resp
  744. }
  745. // @Title 关注作者/取消关注作者
  746. // @Description 关注作者/取消关注作者 接口
  747. // @Param request body models.CygxArticleDepartmentId true "type json string"
  748. // @Success 200
  749. // @router /fllowDepartment [post]
  750. func (this *ReportController) FllowDepartment() {
  751. br := new(models.BaseResponse).Init()
  752. defer func() {
  753. this.Data["json"] = br
  754. this.ServeJSON()
  755. }()
  756. user := this.User
  757. if user == nil {
  758. br.Msg = "请重新登录"
  759. br.Ret = 408
  760. return
  761. }
  762. uid := user.UserId
  763. var req models.CygxArticleDepartmentId
  764. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  765. if err != nil {
  766. br.Msg = "参数解析异常!"
  767. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  768. return
  769. }
  770. departmentId := req.DepartmentId
  771. var condition string
  772. countDepartment, err := models.GetDepartmentCount(departmentId)
  773. if err != nil {
  774. br.Msg = "获取数据失败!"
  775. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  776. return
  777. }
  778. if countDepartment == 0 {
  779. br.Msg = "作者不存在!"
  780. br.ErrMsg = "作者ID不存在:" + strconv.Itoa(departmentId)
  781. return
  782. }
  783. countUser, err := models.GetArticleDepartmentFollowByUid(uid)
  784. count, err := models.GetArticleDepartmentFollow(uid, departmentId, condition)
  785. if err != nil {
  786. br.Msg = "获取数据失败!"
  787. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  788. return
  789. }
  790. resp := new(models.CygxArticleDepartmentFollowResp)
  791. if countUser == 0 {
  792. resp.GoFollow = true
  793. }
  794. if count == 0 {
  795. item := new(models.CygxArticleDepartmentFollow)
  796. item.DepartmentId = departmentId
  797. item.UserId = uid
  798. item.Email = user.Email
  799. item.Mobile = user.Mobile
  800. item.CompanyId = user.CompanyId
  801. item.CompanyName = user.CompanyName
  802. item.Type = 1
  803. item.CreateTime = time.Now()
  804. item.ModifyTime = time.Now()
  805. _, err = models.AddArticleDepartmentFollow(item)
  806. if err != nil {
  807. br.Msg = "操作失败"
  808. br.ErrMsg = "操作失败,Err:" + err.Error()
  809. return
  810. }
  811. resp.Status = 1
  812. } else {
  813. var doType int
  814. condition = ` AND type = 1`
  815. count, err = models.GetArticleDepartmentFollow(uid, departmentId, condition)
  816. if err != nil {
  817. br.Msg = "操作失败!"
  818. br.ErrMsg = "获取数据失败,Err:" + err.Error()
  819. return
  820. }
  821. if count == 1 {
  822. resp.Status = 2
  823. doType = 2
  824. } else {
  825. resp.Status = 1
  826. doType = 1
  827. }
  828. err = models.RemoveArticleDepartmentFollow(uid, departmentId, doType)
  829. if err != nil {
  830. br.Msg = "操作失败"
  831. br.ErrMsg = "取消关注失败,Err:" + err.Error()
  832. return
  833. }
  834. }
  835. br.Msg = "操作成功"
  836. br.Ret = 200
  837. br.Success = true
  838. br.Data = resp
  839. }
  840. // @Title 研选文章列表接口
  841. // @Description 获取研选文章列表接口
  842. // @Param PageSize query int true "每页数据条数"
  843. // @Param CurrentIndex query int true "当前页页码,从1开始"
  844. // @Param ArticleId query int true "文章id"
  845. // @Param DepartmentId query int true "作者ID"
  846. // @Param IndustrialManagementId query int true "产业ID"
  847. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  848. // @router /industry/reportList [get]
  849. func (this *ReportController) ReportList() {
  850. br := new(models.BaseResponse).Init()
  851. defer func() {
  852. this.Data["json"] = br
  853. this.ServeJSON()
  854. }()
  855. user := this.User
  856. if user == nil {
  857. br.Msg = "请重新登录"
  858. br.Ret = 408
  859. return
  860. }
  861. uid := user.UserId
  862. pageSize, _ := this.GetInt("PageSize")
  863. currentIndex, _ := this.GetInt("CurrentIndex")
  864. departmentId, _ := this.GetInt("DepartmentId")
  865. industrialManagementId, _ := this.GetInt("IndustrialManagementId")
  866. articleId, _ := this.GetInt("ArticleId")
  867. var condition string
  868. var startSize int
  869. if pageSize <= 0 {
  870. pageSize = utils.PageSize20
  871. }
  872. if currentIndex <= 0 {
  873. currentIndex = 1
  874. }
  875. startSize = paging.StartIndex(currentIndex, pageSize)
  876. var pars []interface{}
  877. var total int
  878. resp := new(models.ReportArticleWhichIndustrialRepList)
  879. page := paging.GetPaging(currentIndex, pageSize, total)
  880. userType, _, err := services.GetUserType(user.CompanyId)
  881. if err != nil {
  882. br.Msg = "获取信息失败"
  883. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  884. return
  885. }
  886. if userType == 1 {
  887. resp.Paging = page
  888. br.Ret = 200
  889. br.Success = true
  890. br.Msg = "获取成功"
  891. br.Data = resp
  892. return
  893. }
  894. resp.HaveResearch = true
  895. if departmentId > 0 {
  896. condition += ` AND art.department_id = ` + strconv.Itoa(departmentId)
  897. detail, err := models.GetArticleDepartmentDateilById(departmentId)
  898. if err != nil {
  899. br.Msg = "获取信息失败"
  900. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  901. return
  902. }
  903. resp.NickName = detail.NickName
  904. }
  905. if industrialManagementId > 0 {
  906. condition += ` AND m.industrial_management_id = ` + strconv.Itoa(industrialManagementId)
  907. }
  908. if articleId > 0 {
  909. detail, err := models.GetArticleDetailById(articleId)
  910. if err != nil {
  911. br.Msg = "获取信息失败"
  912. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  913. return
  914. }
  915. condition += ` AND art.subject_ids = '` + detail.SubjectIds + `'`
  916. }
  917. total, err = models.GetWhichDepartmentCount(condition)
  918. if err != nil {
  919. br.Msg = "获取信息失败"
  920. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  921. return
  922. }
  923. page = paging.GetPaging(currentIndex, pageSize, total)
  924. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  925. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  926. if err != nil {
  927. br.Msg = "获取失败"
  928. br.ErrMsg = "获取失败,Err:" + err.Error()
  929. return
  930. }
  931. for k, v := range list {
  932. if v.Readnum == 0 {
  933. list[k].IsRed = true
  934. }
  935. list[k].IsResearch = true
  936. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  937. if err != nil {
  938. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  939. br.ErrMsg = "获取失败,Err:" + err.Error()
  940. return
  941. }
  942. var subjectNamesNew string
  943. if len(subjectNames) > 0 {
  944. slice := strings.Split(subjectNames, "/")
  945. for k3, v3 := range slice {
  946. if k3 < 4 {
  947. subjectNamesNew += v3 + "/"
  948. }
  949. }
  950. }
  951. industryName, err := models.GetIndustrialNames(v.ArticleId)
  952. if err != nil && err.Error() != utils.ErrNoRow() {
  953. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  954. br.ErrMsg = "获取失败,Err:" + err.Error()
  955. return
  956. }
  957. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  958. list[k].SubjectName = subjectNamesNew
  959. if subjectNamesNew != "" {
  960. list[k].IndustryName = industryName + "-" + subjectNamesNew
  961. } else {
  962. list[k].IndustryName = industryName
  963. }
  964. resp.IndustryName = industryName
  965. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  966. }
  967. resp.List = list
  968. resp.Paging = page
  969. br.Ret = 200
  970. br.Success = true
  971. br.Msg = "获取成功"
  972. br.Data = resp
  973. }
  974. // @Title 研选最新主题关键词文章列表接口
  975. // @Description 获取研选最新主题关键词文章列表接口
  976. // @Param PageSize query int true "每页数据条数"
  977. // @Param CurrentIndex query int true "当前页页码,从1开始"
  978. // @Param ArticleId query int true "文章id"
  979. // @Success 200 {object} models.ReportArticleWhichIndustrialRepList
  980. // @router /industry/reportListNew [get]
  981. func (this *ReportController) ReportListNew() {
  982. br := new(models.BaseResponse).Init()
  983. defer func() {
  984. this.Data["json"] = br
  985. this.ServeJSON()
  986. }()
  987. user := this.User
  988. if user == nil {
  989. br.Msg = "请重新登录"
  990. br.Ret = 408
  991. return
  992. }
  993. uid := user.UserId
  994. pageSize, _ := this.GetInt("PageSize")
  995. currentIndex, _ := this.GetInt("CurrentIndex")
  996. articleId, _ := this.GetInt("ArticleId")
  997. var condition string
  998. var startSize int
  999. if pageSize <= 0 {
  1000. pageSize = utils.PageSize20
  1001. }
  1002. if currentIndex <= 0 {
  1003. currentIndex = 1
  1004. }
  1005. startSize = paging.StartIndex(currentIndex, pageSize)
  1006. var pars []interface{}
  1007. var total int
  1008. resp := new(models.ReportArticleWhichIndustrialRepList)
  1009. page := paging.GetPaging(currentIndex, pageSize, total)
  1010. userType, _, err := services.GetUserType(user.CompanyId)
  1011. if err != nil {
  1012. br.Msg = "获取信息失败"
  1013. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1014. return
  1015. }
  1016. if userType == 1 {
  1017. resp.Paging = page
  1018. br.Ret = 200
  1019. br.Success = true
  1020. br.Msg = "获取成功"
  1021. br.Data = resp
  1022. return
  1023. }
  1024. resp.HaveResearch = true
  1025. if articleId > 0 {
  1026. detail, err := models.GetArticleDetailById(articleId)
  1027. if err != nil {
  1028. br.Msg = "获取信息失败"
  1029. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1030. return
  1031. }
  1032. firstStr := strings.Index(detail.IndustrialAndSubjectIds, "—")
  1033. if firstStr == 0 {
  1034. condition += ` AND art.industrial_management_id = '` + strconv.Itoa(detail.IndustrialManagementId) + `'`
  1035. } else {
  1036. condition += ` AND art.industrial_and_subject_ids = '` + detail.IndustrialAndSubjectIds + `'`
  1037. }
  1038. }
  1039. total, err = models.GetWhichDepartmentCount(condition)
  1040. if err != nil {
  1041. br.Msg = "获取信息失败"
  1042. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1043. return
  1044. }
  1045. page = paging.GetPaging(currentIndex, pageSize, total)
  1046. condition += ` GROUP BY art.article_id ORDER BY art.publish_date DESC`
  1047. list, err := models.IndustrialToArticleWhichDepartment(condition, pars, uid, startSize, pageSize)
  1048. if err != nil {
  1049. br.Msg = "获取失败"
  1050. br.ErrMsg = "获取失败,Err:" + err.Error()
  1051. return
  1052. }
  1053. for k, v := range list {
  1054. if v.Readnum == 0 {
  1055. list[k].IsRed = true
  1056. }
  1057. list[k].IsResearch = true
  1058. list[k].ImgUrlPc = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202112/20211206/UvMadc63MLZY6rnQZQgGZAFXkqwf.png"
  1059. subjectNames, err := models.GetSubjectNames(v.ArticleId)
  1060. if err != nil {
  1061. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1062. br.ErrMsg = "获取失败,Err:" + err.Error()
  1063. return
  1064. }
  1065. var subjectNamesNew string
  1066. if len(subjectNames) > 0 {
  1067. slice := strings.Split(subjectNames, "/")
  1068. for k3, v3 := range slice {
  1069. if k3 < 4 {
  1070. subjectNamesNew += v3 + "/"
  1071. }
  1072. }
  1073. }
  1074. industryName, err := models.GetIndustrialNames(v.ArticleId)
  1075. if err != nil && err.Error() != utils.ErrNoRow() {
  1076. br.Msg = "获取失败" + strconv.Itoa(v.ArticleId)
  1077. br.ErrMsg = "获取失败,Err:" + err.Error()
  1078. return
  1079. }
  1080. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1081. list[k].SubjectName = subjectNamesNew
  1082. if subjectNamesNew != "" {
  1083. list[k].IndustryName = industryName + "-" + subjectNamesNew
  1084. } else {
  1085. list[k].IndustryName = industryName
  1086. }
  1087. resp.IndustryName = industryName
  1088. }
  1089. resp.List = list
  1090. resp.Paging = page
  1091. br.Ret = 200
  1092. br.Success = true
  1093. br.Msg = "获取成功"
  1094. br.Data = resp
  1095. }
  1096. // @Title 是否展示绝密内参
  1097. // @Description 获取是否展示绝密内参接口
  1098. // @Param request body models.IsShow true "type json string"
  1099. // @Success 200
  1100. // @router /isShow [get]
  1101. func (this *ReportController) IsShow() {
  1102. br := new(models.BaseResponse).Init()
  1103. defer func() {
  1104. this.Data["json"] = br
  1105. this.ServeJSON()
  1106. }()
  1107. user := this.User
  1108. if user == nil {
  1109. br.Msg = "请重新登录"
  1110. br.Ret = 408
  1111. return
  1112. }
  1113. var resp models.IsShow
  1114. resp.IsShowChart = true
  1115. resp.IsShowResearch = true
  1116. mobile := user.Mobile
  1117. if mobile == "" {
  1118. br.Ret = 200
  1119. br.Success = true
  1120. br.Data = resp
  1121. return
  1122. }
  1123. total, _ := models.GetUserIsAdminCount(mobile)
  1124. if total > 0 {
  1125. resp.IsShow = true
  1126. }
  1127. br.Ret = 200
  1128. br.Success = true
  1129. br.Data = resp
  1130. }
  1131. // @Title 报告精选、本周研究汇总、上周纪要汇总列表
  1132. // @Description 获取报告精选、本周研究汇总、上周纪要汇总列表接口
  1133. // @Param PageSize query int true "每页数据条数"
  1134. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1135. // @Param ReportType string query true "报告类型 ,1报告精选、2本周研究汇总、3上周纪要汇总"
  1136. // @Success 200 {object} models.CygxReportSelectionListPublicRep
  1137. // @router /reportList/byType [get]
  1138. func (this *ReportController) ReportListByType() {
  1139. br := new(models.BaseResponse).Init()
  1140. defer func() {
  1141. this.Data["json"] = br
  1142. this.ServeJSON()
  1143. }()
  1144. user := this.User
  1145. if user == nil {
  1146. br.Msg = "请重新登录"
  1147. br.Ret = 408
  1148. return
  1149. }
  1150. uid := user.UserId
  1151. pageSize, _ := this.GetInt("PageSize")
  1152. currentIndex, _ := this.GetInt("CurrentIndex")
  1153. reportType := this.GetString("ReportType")
  1154. var condition string
  1155. var startSize int
  1156. if pageSize <= 0 {
  1157. pageSize = utils.PageSize20
  1158. }
  1159. if currentIndex <= 0 {
  1160. currentIndex = 1
  1161. }
  1162. startSize = paging.StartIndex(currentIndex, pageSize)
  1163. var pars []interface{}
  1164. var total int
  1165. resp := new(models.CygxReportSelectionListPublicRep)
  1166. page := paging.GetPaging(currentIndex, pageSize, total)
  1167. var tbdb string
  1168. var readSql string
  1169. var reportTypeStr string
  1170. if reportType == "1" {
  1171. tbdb = "cygx_report_selection"
  1172. reportTypeStr = "bgjx"
  1173. } else if reportType == "2" {
  1174. tbdb = "cygx_research_summary"
  1175. reportTypeStr = "bzyjhz"
  1176. } else if reportType == "3" {
  1177. tbdb = "cygx_minutes_summary"
  1178. reportTypeStr = "szjyhz"
  1179. } else {
  1180. br.Msg = "请选择报告类型"
  1181. return
  1182. }
  1183. fmt.Println(tbdb)
  1184. condition = ` AND publish_status = 1`
  1185. total, err := models.GetCygxReportSelectionPublic(condition, tbdb, pars)
  1186. if err != nil {
  1187. br.Msg = "获取信息失败"
  1188. br.ErrMsg = "获取帖子总数失败,Err:" + err.Error()
  1189. return
  1190. }
  1191. 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`
  1192. page = paging.GetPaging(currentIndex, pageSize, total)
  1193. list, err := models.GetReportSelectionListPublic(condition, readSql, tbdb, pars, startSize, pageSize)
  1194. if err != nil {
  1195. br.Msg = "获取失败"
  1196. br.ErrMsg = "获取失败,Err:" + err.Error()
  1197. return
  1198. }
  1199. for k, v := range list {
  1200. if reportType == "1" {
  1201. list[k].Abstract = v.UpdateDescription
  1202. }
  1203. list[k].PublishDate = utils.StrTimeToTime(v.PublishDate).Format("2006-01-02")
  1204. if v.ReadNum == 0 {
  1205. list[k].IsRed = true
  1206. }
  1207. }
  1208. resp.List = list
  1209. resp.Paging = page
  1210. br.Ret = 200
  1211. br.Success = true
  1212. br.Msg = "获取成功"
  1213. br.Data = resp
  1214. }
  1215. // @Title 获取报告精选详情
  1216. // @Description 获取报告精选详情接口
  1217. // @Param ArticleId query int true "报告ID"
  1218. // @Success 200 {object} models.ReportSelectionLetailResp
  1219. // @router /reportSelection/detail [get]
  1220. func (this *ReportController) Detail() {
  1221. br := new(models.BaseResponse).Init()
  1222. defer func() {
  1223. this.Data["json"] = br
  1224. this.ServeJSON()
  1225. }()
  1226. user := this.User
  1227. if user == nil {
  1228. br.Msg = "请重新登录"
  1229. br.Ret = 408
  1230. return
  1231. }
  1232. uid := user.UserId
  1233. articleId, _ := this.GetInt("ArticleId")
  1234. if articleId < 0 {
  1235. br.Msg = "参数错误"
  1236. br.ErrMsg = "参数错误"
  1237. return
  1238. }
  1239. resp := new(models.ReportSelectionLetailResp)
  1240. //判断用户权限
  1241. hasPermission, err := services.GetUserhasPermission(user)
  1242. if err != nil {
  1243. br.Msg = "获取信息失败"
  1244. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1245. }
  1246. resp.HasPermission = hasPermission
  1247. if hasPermission != 1 {
  1248. br.Ret = 200
  1249. br.Success = true
  1250. br.Msg = "获取成功"
  1251. br.Data = resp
  1252. return
  1253. }
  1254. detail, err := models.GetCygxReportSelectionInfoById(articleId)
  1255. if err != nil {
  1256. br.Msg = "获取信息失败"
  1257. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1258. return
  1259. }
  1260. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1261. existMap := make(map[int]int)
  1262. var items []*models.ReportSelectionChartPermission
  1263. listLog, err := models.GetReportSelectionlogListAll(articleId)
  1264. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1265. if err != nil {
  1266. br.Msg = "获取失败"
  1267. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1268. return
  1269. }
  1270. //var itemLogs []*models.CygxReportSelectionLogDetail
  1271. for _, v := range listLog {
  1272. item := new(models.ReportSelectionChartPermission)
  1273. if existMap[v.ChartPermissionId] == 0 {
  1274. item.PermissionName = v.PermissionName + "领域深度报告和调研"
  1275. item.IcoLink = v.IcoLink
  1276. listSonLog, err := models.GetReportSelectionlogSonListAll(articleId, v.ChartPermissionId)
  1277. if err != nil && err.Error() != utils.ErrNoRow() {
  1278. br.Msg = "获取信息失败"
  1279. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1280. return
  1281. }
  1282. for k2, v2 := range listSonLog {
  1283. if v2.IndustrialManagementId != "" {
  1284. listIndustrial, err := models.GetIndustrialByIds(v2.IndustrialManagementId)
  1285. if err != nil && err.Error() != utils.ErrNoRow() {
  1286. br.Msg = "获取信息失败"
  1287. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1288. return
  1289. }
  1290. listSonLog[k2].List = listIndustrial
  1291. }
  1292. }
  1293. item.List = listSonLog
  1294. items = append(items, item)
  1295. //itemLogs = make([]*models.CygxReportSelectionLogDetail, 0)
  1296. }
  1297. existMap[v.ChartPermissionId] = v.ChartPermissionId
  1298. }
  1299. historyRecord := new(models.CygxReportHistoryRecord)
  1300. historyRecord.UserId = uid
  1301. historyRecord.ArticleId = articleId
  1302. historyRecord.CreateTime = time.Now()
  1303. historyRecord.Mobile = user.Mobile
  1304. historyRecord.Email = user.Email
  1305. historyRecord.CompanyId = user.CompanyId
  1306. historyRecord.CompanyName = user.CompanyName
  1307. historyRecord.ReportType = "bgjx"
  1308. go models.AddCygxReportHistoryRecord(historyRecord)
  1309. resp.List = items
  1310. resp.Detail = detail
  1311. br.Ret = 200
  1312. br.Success = true
  1313. br.Msg = "获取成功"
  1314. br.Data = resp
  1315. }
  1316. // @Title 获取本周研究汇总详情
  1317. // @Description 获取本周研究汇总详情接口
  1318. // @Param ArticleId query int true "报告ID"
  1319. // @Success 200 {object} models.ResearchSummaryLetailResp
  1320. // @router /researchSummary/detail [get]
  1321. func (this *ReportController) ResearchDetail() {
  1322. br := new(models.BaseResponse).Init()
  1323. defer func() {
  1324. this.Data["json"] = br
  1325. this.ServeJSON()
  1326. }()
  1327. user := this.User
  1328. if user == nil {
  1329. br.Msg = "请重新登录"
  1330. br.Ret = 408
  1331. return
  1332. }
  1333. uid := user.UserId
  1334. articleId, _ := this.GetInt("ArticleId")
  1335. if articleId < 0 {
  1336. br.Msg = "参数错误"
  1337. br.ErrMsg = "参数错误"
  1338. return
  1339. }
  1340. resp := new(models.ResearchSummaryLetailResp)
  1341. //判断用户权限
  1342. hasPermission, err := services.GetUserhasPermission(user)
  1343. if err != nil {
  1344. br.Msg = "获取信息失败"
  1345. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1346. }
  1347. resp.HasPermission = hasPermission
  1348. if hasPermission != 1 {
  1349. br.Ret = 200
  1350. br.Success = true
  1351. br.Msg = "获取成功"
  1352. br.Data = resp
  1353. return
  1354. }
  1355. detail, err := models.GetCygxResearchSummaryInfoById(articleId)
  1356. if err != nil {
  1357. br.Msg = "获取信息失败"
  1358. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1359. return
  1360. }
  1361. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1362. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1363. listFirst, err := models.GetResearchSummarylogListFirst(articleId)
  1364. if err != nil {
  1365. br.Msg = "获取失败"
  1366. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1367. return
  1368. }
  1369. for k, v := range listFirst {
  1370. listSecond, err := models.GetResearchSummarylogSonListSecond(articleId, v.Type)
  1371. if err != nil && err.Error() != utils.ErrNoRow() {
  1372. br.Msg = "获取信息失败"
  1373. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1374. return
  1375. }
  1376. for k2, v2 := range listSecond {
  1377. listThird, err := models.GetResearchSummarylogSonListThird(articleId, v2.ChartPermissionId, v.Type)
  1378. if err != nil && err.Error() != utils.ErrNoRow() {
  1379. br.Msg = "获取信息失败"
  1380. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1381. return
  1382. }
  1383. if v2.ChartPermissionId == utils.YanxSummaryPermissionId {
  1384. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1385. listSecond[k2].PermissionName = "研选纪要"
  1386. } else if v2.ChartPermissionId == utils.YanxViewpointPermissionId {
  1387. listSecond[k2].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1388. listSecond[k2].PermissionName = "研选观点"
  1389. }
  1390. if len(listThird) > 0 {
  1391. for k3, v3 := range listThird {
  1392. if v3.VideoUrl != "" {
  1393. listThird[k3].IsHaveVideo = true
  1394. }
  1395. if v3.ReportLink == "0" {
  1396. listThird[k3].ReportLink = ""
  1397. }
  1398. }
  1399. listSecond[k2].List = listThird
  1400. }
  1401. }
  1402. if len(listSecond) > 0 {
  1403. listFirst[k].List = listSecond
  1404. }
  1405. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1406. if v.Type == "SDBG" {
  1407. listFirst[k].ListName = "深度报告"
  1408. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211027/le8AcRjDz0MhA72bVDiaf3d5ALSe.png"
  1409. } else if v.Type == "BZCHJH" {
  1410. listFirst[k].ListName = "本周晨会精华"
  1411. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/DCfekcxaIKGePBsNVu1ULfmNcJBY.png"
  1412. } else if v.Type == "CYDYJY" {
  1413. listFirst[k].ListName = "产业调研纪要"
  1414. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1415. } else if v.Type == "SSGS" {
  1416. listFirst[k].ListName = "上市公司调研纪要篇"
  1417. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1418. } else if v.Type == "SJDP" {
  1419. listFirst[k].ListName = "事件点评"
  1420. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/2a5cXafO3Iws4QcFp1bd5WPdYikV.png"
  1421. } else if v.Type == "YANX" {
  1422. listFirst[k].ListName = "研选"
  1423. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1424. }
  1425. }
  1426. historyRecord := new(models.CygxReportHistoryRecord)
  1427. historyRecord.UserId = uid
  1428. historyRecord.ArticleId = articleId
  1429. historyRecord.CreateTime = time.Now()
  1430. historyRecord.Mobile = user.Mobile
  1431. historyRecord.Email = user.Email
  1432. historyRecord.CompanyId = user.CompanyId
  1433. historyRecord.CompanyName = user.CompanyName
  1434. historyRecord.ReportType = "bzyjhz"
  1435. go models.AddCygxReportHistoryRecord(historyRecord)
  1436. resp.List = listFirst
  1437. resp.Detail = detail
  1438. br.Ret = 200
  1439. br.Success = true
  1440. br.Msg = "获取成功"
  1441. br.Data = resp
  1442. }
  1443. // @Title 上周纪要汇总内容详情
  1444. // @Description 获取上周纪要汇总内容详情接口
  1445. // @Param ArticleId query int true "报告ID"
  1446. // @Success 200 {object} models.MinutesSummaryLetailResp
  1447. // @router /minutesSummary/detailv4 [get]
  1448. func (this *ReportController) MinutesDetailV4() {
  1449. br := new(models.BaseResponse).Init()
  1450. defer func() {
  1451. this.Data["json"] = br
  1452. this.ServeJSON()
  1453. }()
  1454. user := this.User
  1455. if user == nil {
  1456. br.Msg = "请重新登录"
  1457. br.Ret = 408
  1458. return
  1459. }
  1460. uid := user.UserId
  1461. articleId, _ := this.GetInt("ArticleId")
  1462. if articleId < 0 {
  1463. br.Msg = "参数错误"
  1464. br.ErrMsg = "参数错误"
  1465. return
  1466. }
  1467. resp := new(models.MinutesSummaryLetailRespV4)
  1468. //判断用户权限
  1469. hasPermission, err := services.GetUserhasPermission(user)
  1470. if err != nil {
  1471. br.Msg = "获取信息失败"
  1472. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1473. }
  1474. resp.HasPermission = hasPermission
  1475. if hasPermission != 1 {
  1476. br.Ret = 200
  1477. br.Success = true
  1478. br.Msg = "获取成功"
  1479. br.Data = resp
  1480. return
  1481. }
  1482. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1483. if err != nil {
  1484. br.Msg = "获取信息失败"
  1485. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1486. return
  1487. }
  1488. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format(utils.FormatDate)
  1489. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1490. listFirst, err := models.GetMinutesSummarylogListAllV4(articleId)
  1491. if err != nil {
  1492. br.Msg = "获取失败"
  1493. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1494. return
  1495. }
  1496. for k, v := range listFirst {
  1497. listSecond, err := models.GetMinutesSummarylogSonListSecond(articleId, v.Type)
  1498. if err != nil && err.Error() != utils.ErrNoRow() {
  1499. br.Msg = "获取信息失败"
  1500. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1501. return
  1502. }
  1503. for k2, v2 := range listSecond {
  1504. listThird, err := models.GetMinutesSummarylogListThird(articleId, v2.ChartPermissionId, v.Type)
  1505. if err != nil && err.Error() != utils.ErrNoRow() {
  1506. br.Msg = "获取信息失败"
  1507. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1508. return
  1509. }
  1510. if len(listThird) > 0 {
  1511. for k3, v3 := range listThird {
  1512. if v3.VideoUrl != "" {
  1513. listThird[k3].IsHaveVideo = true
  1514. }
  1515. if v3.ReportLink == "0" {
  1516. listThird[k3].ReportLink = ""
  1517. }
  1518. }
  1519. listSecond[k2].List = listThird
  1520. }
  1521. }
  1522. if len(listSecond) > 0 {
  1523. listFirst[k].List = listSecond
  1524. }
  1525. //`description:"类型'SDBG深度报告片篇,’CYDYJY:产业调研纪要’,’SJDP事件点评,’BZCHJH:本周晨会精华’"`
  1526. if v.Type == "CYDYJY" {
  1527. listFirst[k].ListName = "产业调研纪要"
  1528. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202110/20211020/UPAdozy96z9ypzY04vi0Y3Ogqzji.png"
  1529. } else if v.Type == "SSGS" {
  1530. listFirst[k].ListName = "上市公司调研纪要篇"
  1531. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211101/ujHXB48I8ay9T0XoPRI7lorz7OkL.png"
  1532. } else if v.Type == "YANX" {
  1533. listFirst[k].ListName = "研选纪要"
  1534. listFirst[k].IcoLink = "https://hongze.oss-cn-shanghai.aliyuncs.com/static/images/202111/20211104/QbTGTNhD9MxYp24cJ7V5WpCN0oNl.png"
  1535. }
  1536. }
  1537. historyRecord := new(models.CygxReportHistoryRecord)
  1538. historyRecord.UserId = uid
  1539. historyRecord.ArticleId = articleId
  1540. historyRecord.CreateTime = time.Now()
  1541. historyRecord.Mobile = user.Mobile
  1542. historyRecord.Email = user.Email
  1543. historyRecord.CompanyId = user.CompanyId
  1544. historyRecord.CompanyName = user.CompanyName
  1545. historyRecord.ReportType = "szjyhz"
  1546. go models.AddCygxReportHistoryRecord(historyRecord)
  1547. resp.List = listFirst
  1548. resp.Detail = detail
  1549. br.Ret = 200
  1550. br.Success = true
  1551. br.Msg = "获取成功"
  1552. br.Data = resp
  1553. }
  1554. // @Title 上周纪要汇总内容详情
  1555. // @Description 获取上周纪要汇总内容详情接口
  1556. // @Param ArticleId query int true "报告ID"
  1557. // @Success 200 {object} models.MinutesSummaryLetailResp
  1558. // @router /minutesSummary/detail [get]
  1559. func (this *ReportController) MinutesDetail() {
  1560. br := new(models.BaseResponse).Init()
  1561. defer func() {
  1562. this.Data["json"] = br
  1563. this.ServeJSON()
  1564. }()
  1565. user := this.User
  1566. if user == nil {
  1567. br.Msg = "请重新登录"
  1568. br.Ret = 408
  1569. return
  1570. }
  1571. uid := user.UserId
  1572. articleId, _ := this.GetInt("ArticleId")
  1573. if articleId < 0 {
  1574. br.Msg = "参数错误"
  1575. br.ErrMsg = "参数错误"
  1576. return
  1577. }
  1578. resp := new(models.MinutesSummaryLetailResp)
  1579. //判断用户权限
  1580. hasPermission, err := services.GetUserhasPermission(user)
  1581. if err != nil {
  1582. br.Msg = "获取信息失败"
  1583. br.ErrMsg = "获取用户权限信息失败,Err:" + err.Error()
  1584. }
  1585. resp.HasPermission = hasPermission
  1586. if hasPermission != 1 {
  1587. br.Ret = 200
  1588. br.Success = true
  1589. br.Msg = "获取成功"
  1590. br.Data = resp
  1591. return
  1592. }
  1593. detail, err := models.GetCygxMinutesSummaryInfoById(articleId)
  1594. if err != nil {
  1595. br.Msg = "获取信息失败"
  1596. br.ErrMsg = "报告不存在,Err:" + err.Error() + "articleId:" + strconv.Itoa(articleId)
  1597. return
  1598. }
  1599. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1600. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1601. listLog, err := models.GetMinutesSummarylogListAll(articleId)
  1602. if err != nil {
  1603. br.Msg = "获取失败"
  1604. br.ErrMsg = "获取子类信息失败,Err:" + err.Error()
  1605. return
  1606. }
  1607. for k, v := range listLog {
  1608. listSonLog, err := models.GetMinutesSummarylogSonListAll(articleId, v.ChartPermissionId)
  1609. if err != nil && err.Error() != utils.ErrNoRow() {
  1610. br.Msg = "获取信息失败"
  1611. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1612. return
  1613. }
  1614. if len(listSonLog) > 0 {
  1615. listLog[k].List = listSonLog
  1616. for k2, v2 := range listSonLog {
  1617. if v2.ReportLink == "0" {
  1618. listSonLog[k2].ReportLink = ""
  1619. }
  1620. }
  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 = "szjyhz"
  1632. go models.AddCygxReportHistoryRecord(historyRecord)
  1633. resp.List = listLog
  1634. resp.Detail = detail
  1635. br.Ret = 200
  1636. br.Success = true
  1637. br.Msg = "获取成功"
  1638. br.Data = resp
  1639. }
  1640. // @Title 获取路演精华详情
  1641. // @Description 获取路演精华详情接口
  1642. // @Param ArticleId query int true "报告ID"
  1643. // @Success 200 {object} models.RoadshowDetailResp
  1644. // @router /roadshowEssence/detail [get]
  1645. func (this *ReportController) RoadshowDetail() {
  1646. br := new(models.BaseResponse).Init()
  1647. defer func() {
  1648. this.Data["json"] = br
  1649. this.ServeJSON()
  1650. }()
  1651. user := this.User
  1652. if user == nil {
  1653. br.Msg = "请登录"
  1654. br.ErrMsg = "请登录,用户信息为空"
  1655. br.Ret = 408
  1656. return
  1657. }
  1658. uid := user.UserId
  1659. articleId, err := this.GetInt("ArticleId")
  1660. if articleId <= 0 {
  1661. br.Msg = "文章不存在"
  1662. br.ErrMsg = "文章不存在,文章ID错误"
  1663. return
  1664. }
  1665. detail := new(models.ReportDetailRoadshow)
  1666. hasPermission := 0
  1667. hasFree := 0
  1668. //判断是否已经申请过
  1669. applyCount, err := models.GetApplyRecordCount(uid)
  1670. if err != nil && err.Error() != utils.ErrNoRow() {
  1671. br.Msg = "获取信息失败"
  1672. br.ErrMsg = "判断是否已申请过试用失败,Err:" + err.Error()
  1673. return
  1674. }
  1675. //`description:"1:有该行业权限,正常展示,2:无该行业权限,不存在权益客户下,3:无该品类权限,4:潜在客户,未提交过申请,5:潜在客户,已提交过申请"`
  1676. if user.CompanyId > 1 {
  1677. companyPermission, err := models.GetCompanyPermission(user.CompanyId)
  1678. if err != nil {
  1679. br.Msg = "获取信息失败"
  1680. br.ErrMsg = "判断是否已申请访谈失败,Err:" + strconv.Itoa(uid) + ";articleId" + strconv.Itoa(articleId)
  1681. return
  1682. }
  1683. detail, err = models.GetReportRoadshowDetailById(articleId)
  1684. if err != nil {
  1685. br.Msg = "获取信息失败"
  1686. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  1687. return
  1688. }
  1689. detail.Body = html.UnescapeString(detail.Body)
  1690. detail.Abstract, _ = services.GetReportContentTextSubNew(detail.Abstract)
  1691. detail.PublishDate = utils.StrTimeToTime(detail.PublishDate).Format("2006-01-02")
  1692. detail.VideoPlaySeconds = utils.Mp3Time(detail.VideoPlaySeconds)
  1693. if detail.ReportLink == "0" {
  1694. detail.ReportLink = ""
  1695. }
  1696. if companyPermission == "" {
  1697. if applyCount > 0 {
  1698. hasPermission = 5
  1699. } else {
  1700. hasPermission = 2
  1701. }
  1702. hasFree = 2
  1703. goto Loop
  1704. } else {
  1705. hasFree = 1
  1706. var articlePermissionPermissionName string
  1707. articlePermissionPermissionName = detail.CategoryName
  1708. var hasPersion bool
  1709. slice := strings.Split(articlePermissionPermissionName, ",")
  1710. for _, v := range slice {
  1711. if strings.Contains(companyPermission, v) {
  1712. hasPersion = true
  1713. }
  1714. }
  1715. if hasPersion {
  1716. hasPermission = 1
  1717. historyRecord := new(models.CygxArticleHistoryRecord)
  1718. historyRecord.UserId = uid
  1719. historyRecord.ArticleId = articleId
  1720. historyRecord.CreateTime = time.Now()
  1721. historyRecord.Mobile = user.Mobile
  1722. historyRecord.Email = user.Email
  1723. historyRecord.CompanyId = user.CompanyId
  1724. historyRecord.CompanyName = user.CompanyName
  1725. go models.AddCygxArticleHistoryRecord(historyRecord)
  1726. } else { //无该行业权限
  1727. hasPermission = 3
  1728. }
  1729. if hasPermission == 1 {
  1730. key := "CYGX_ARTICLE_" + strconv.Itoa(articleId) + "_" + strconv.Itoa(uid)
  1731. if !utils.Rc.IsExist(key) {
  1732. //新增浏览记录
  1733. record := new(models.CygxArticleViewRecord)
  1734. record.UserId = uid
  1735. record.ArticleId = articleId
  1736. record.CreateTime = time.Now()
  1737. record.Mobile = user.Mobile
  1738. record.Email = user.Email
  1739. record.CompanyId = user.CompanyId
  1740. record.CompanyName = user.CompanyName
  1741. go models.AddCygxArticleViewRecord(record)
  1742. utils.Rc.Put(key, 1, 5*time.Second)
  1743. models.ModifyReportLastViewTime(uid)
  1744. }
  1745. }
  1746. }
  1747. } else { //潜在客户
  1748. if applyCount > 0 {
  1749. hasPermission = 5
  1750. } else {
  1751. hasPermission = 4
  1752. }
  1753. }
  1754. Loop:
  1755. if hasPermission != 1 {
  1756. detail.Body = ""
  1757. detail.Abstract = ""
  1758. }
  1759. resp := new(models.RoadshowDetailResp)
  1760. resp.HasPermission = hasPermission
  1761. resp.HasFree = hasFree
  1762. resp.Detail = detail
  1763. br.Ret = 200
  1764. br.Success = true
  1765. br.Msg = "获取成功"
  1766. br.Data = resp
  1767. }
  1768. // @Title 产业文章列表接口
  1769. // @Description 获取产业文章列表接口
  1770. // @Param KeyWord query string true "搜索关键词"
  1771. // @Success 200 {object} models.CygxIndustrySearchList
  1772. // @router /industryAndArticle/list [get]
  1773. func (this *ReportController) IndustryAndArticleList() {
  1774. br := new(models.BaseResponse).Init()
  1775. defer func() {
  1776. this.Data["json"] = br
  1777. this.ServeJSON()
  1778. }()
  1779. user := this.User
  1780. if user == nil {
  1781. br.Msg = "请重新登录"
  1782. br.Ret = 408
  1783. return
  1784. }
  1785. uid := user.UserId
  1786. keyWord := this.GetString("KeyWord")
  1787. orderSrt := "update_time DESC"
  1788. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  1789. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  1790. if err != nil {
  1791. br.Msg = "获取信息失败"
  1792. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1793. return
  1794. }
  1795. for k, v := range list {
  1796. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  1797. if err != nil {
  1798. br.Msg = "获取信息失败"
  1799. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1800. return
  1801. }
  1802. list[k].IndustrialSubjectList = industrialSubjectList
  1803. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  1804. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  1805. if err != nil {
  1806. br.Msg = "获取信息失败"
  1807. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1808. return
  1809. }
  1810. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  1811. }
  1812. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  1813. if err != nil {
  1814. br.Msg = "获取失败"
  1815. br.ErrMsg = "获取失败,Err:" + err.Error()
  1816. return
  1817. }
  1818. for k2, v2 := range artList {
  1819. subjectNames, err := models.GetSubjectNames(v2.ArticleId)
  1820. if err != nil {
  1821. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1822. br.ErrMsg = "获取失败,Err:" + err.Error()
  1823. return
  1824. }
  1825. var subjectNamesNew string
  1826. if len(subjectNames) > 0 {
  1827. slice := strings.Split(subjectNames, "/")
  1828. for k3, v3 := range slice {
  1829. if k3 < 4 {
  1830. subjectNamesNew += v3 + "/"
  1831. }
  1832. }
  1833. }
  1834. industryName, err := models.GetIndustrialNames(v2.ArticleId)
  1835. if err != nil && err.Error() != utils.ErrNoRow() {
  1836. br.Msg = "获取失败" + strconv.Itoa(v2.ArticleId)
  1837. br.ErrMsg = "获取失败,Err:" + err.Error()
  1838. return
  1839. }
  1840. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  1841. artList[k2].SubjectName = subjectNamesNew
  1842. if subjectNamesNew == "" {
  1843. artList[k2].IndustryName = industryName
  1844. } else {
  1845. artList[k2].IndustryName = industryName + "-" + subjectNamesNew
  1846. }
  1847. }
  1848. if keyWord != "" {
  1849. keyWordItem := new(models.CygxUserSearchKeyWord)
  1850. keyWordItem.UserId = user.UserId
  1851. keyWordItem.KeyWord = keyWord
  1852. keyWordItem.PageType = "ReortSearch"
  1853. keyWordItem.CreateTime = time.Now()
  1854. go models.AddUserSearchKeyWord(keyWordItem)
  1855. }
  1856. resp := new(models.CygxIndustrySearchList)
  1857. resp.ArtList = artList
  1858. resp.IndList = list
  1859. br.Ret = 200
  1860. br.Success = true
  1861. br.Msg = "获取成功"
  1862. br.Data = resp
  1863. }
  1864. // @Title 产业报告分类关联作者列表接口Pc端
  1865. // @Description 获取产业报告分类关联作者列表接口Pc端
  1866. // @Param ChartPermissionId query int true "分类ID"
  1867. // @Param KeyWord query string true "搜索关键词"
  1868. // @Param PageSize query int true "每页数据条数"
  1869. // @Param CurrentIndex query int true "当前页页码,从1开始"
  1870. // @Success 200 {object} models.CygxArticleDepartmentListPc
  1871. // @router /industryListByDepartmentPc [get]
  1872. func (this *ReportController) IndustryListByDepartmentPc() {
  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.Ret = 408
  1882. return
  1883. }
  1884. uid := user.UserId
  1885. pageSize, _ := this.GetInt("PageSize")
  1886. currentIndex, _ := this.GetInt("CurrentIndex")
  1887. chartPermissionId, _ := this.GetInt("ChartPermissionId")
  1888. keyWord := this.GetString("KeyWord")
  1889. var startSize int
  1890. var condition string
  1891. condition = ` AND a.publish_status=1 AND m.chart_permission_id =` + strconv.Itoa(chartPermissionId)
  1892. if pageSize <= 0 {
  1893. pageSize = utils.PageSize20
  1894. }
  1895. if currentIndex <= 0 {
  1896. currentIndex = 1
  1897. }
  1898. var articleIdGroup string
  1899. if keyWord != "" {
  1900. //获取标的关联的文章ID
  1901. articleIdSub, err := models.GetArticleIdSubjectGroup(keyWord)
  1902. if err != nil {
  1903. br.Msg = "获取信息失败"
  1904. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  1905. return
  1906. }
  1907. //获取产业关联的标的
  1908. articleIdInd, err := models.GetArticleIndustrialIdGroup(keyWord)
  1909. if err != nil {
  1910. br.Msg = "获取信息失败"
  1911. br.ErrMsg = "获取产业信息失败,Err:" + err.Error()
  1912. return
  1913. }
  1914. if articleIdSub != "" && articleIdInd != "" {
  1915. articleIdGroup = articleIdSub + "," + articleIdInd
  1916. } else if articleIdSub != "" && articleIdInd == "" {
  1917. articleIdGroup = articleIdSub
  1918. } else if articleIdSub == "" && articleIdInd != "" {
  1919. articleIdGroup = articleIdInd
  1920. }
  1921. slice := strings.Split(keyWord, "/")
  1922. if len(slice) > 1 {
  1923. var subjectIds string
  1924. for _, v := range slice {
  1925. subjectId, err := models.GetcygxIndustrialSubjectByName(v)
  1926. if err != nil && err.Error() != utils.ErrNoRow() {
  1927. br.Msg = "获取信息失败"
  1928. br.ErrMsg = "获取客户信息失败,Err:" + err.Error()
  1929. return
  1930. }
  1931. if subjectId != "" {
  1932. subjectIds += subjectId + ","
  1933. }
  1934. }
  1935. subjectIds = strings.TrimRight(subjectIds, ",")
  1936. if len(subjectIds) > 0 {
  1937. articleBySub, err := models.GetArticleIdsBySubId(subjectIds)
  1938. if err != nil {
  1939. br.Msg = "获取信息失败"
  1940. br.ErrMsg = "获取文章关联的标的失败,Err:" + err.Error()
  1941. return
  1942. }
  1943. if articleIdGroup != "" {
  1944. if articleBySub != "" {
  1945. articleIdGroup += "," + articleBySub
  1946. }
  1947. } else {
  1948. articleIdGroup = articleBySub
  1949. }
  1950. }
  1951. }
  1952. }
  1953. if articleIdGroup != "" {
  1954. condition += ` AND a.article_id IN (` + articleIdGroup + `)`
  1955. }
  1956. startSize = paging.StartIndex(currentIndex, pageSize)
  1957. total, err := models.GetArticleDepartmentCount(condition)
  1958. page := paging.GetPaging(currentIndex, pageSize, total)
  1959. resp := new(models.CygxArticleDepartmentListPc)
  1960. userType, _, err := services.GetUserType(user.CompanyId)
  1961. if err != nil {
  1962. br.Msg = "获取信息失败"
  1963. br.ErrMsg = "获取用户信息失败,Err:" + err.Error()
  1964. return
  1965. }
  1966. if userType == 1 {
  1967. resp.Paging = page
  1968. br.Ret = 200
  1969. br.Success = true
  1970. br.Msg = "获取成功"
  1971. br.Data = resp
  1972. return
  1973. }
  1974. resp.HaveResearch = true
  1975. //获取作者信息,并排序
  1976. list, err := models.GetCygxArticleDepartmentListPc(startSize, pageSize, condition, uid)
  1977. if err != nil {
  1978. br.Msg = "获取信息失败"
  1979. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  1980. return
  1981. }
  1982. for k, v := range list {
  1983. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIdGroup)
  1984. if err != nil {
  1985. br.Msg = "获取信息失败"
  1986. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  1987. return
  1988. }
  1989. for k2, v2 := range artList {
  1990. if artList[k2].IsReport == "1" {
  1991. artList[k2].Title = v2.Title
  1992. } else {
  1993. artList[k2].Title = v2.Title
  1994. }
  1995. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  1996. }
  1997. list[k].List = artList
  1998. if v.FollowNum > 0 {
  1999. list[k].IsMyFollow = true
  2000. }
  2001. }
  2002. listnNew, err := models.GetIndustrialSubjectByDepartmentNew()
  2003. if err != nil {
  2004. br.Msg = "获取信息失败"
  2005. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2006. return
  2007. }
  2008. if len(listnNew) > 0 {
  2009. for _, v := range listnNew {
  2010. firstStr := strings.Index(v.IndustrialAndSubjectIds, "—")
  2011. Management := new(models.IndustrialManagementIdInt)
  2012. if firstStr == 0 {
  2013. Management.IndustryName = v.IndustryName
  2014. } else {
  2015. listSub, err := models.GetIndustrialManagementSubjectList(v.ArticleId)
  2016. if err != nil {
  2017. br.Msg = "获取信息失败"
  2018. br.ErrMsg = "获取关联标的列表失败,Err:" + err.Error()
  2019. return
  2020. }
  2021. var subjectNamesNew string
  2022. for _, v1 := range listSub {
  2023. subjectNamesNew += v1.SubjectName + "/"
  2024. }
  2025. subjectNamesNew = strings.TrimRight(subjectNamesNew, "/")
  2026. Management.IndustryName = subjectNamesNew
  2027. }
  2028. Management.IndustrialManagementId = v.IndustrialManagementId
  2029. Management.ArticleId = v.ArticleId
  2030. resp.ListnNew = append(resp.ListnNew, Management)
  2031. }
  2032. }
  2033. resp.List = list
  2034. resp.Paging = page
  2035. br.Ret = 200
  2036. br.Success = true
  2037. br.Msg = "获取成功"
  2038. br.Data = resp
  2039. }
  2040. // @Title 产业文章列表接口Pc端
  2041. // @Description 获取产业文章列表接口Pc端
  2042. // @Param KeyWord query string true "搜索关键词"
  2043. // @Success 200 {object} models.CygxIndustrySearchListPc
  2044. // @router /industryAndArticle/listPc [get]
  2045. func (this *ReportController) IndustryAndArticleListPc() {
  2046. br := new(models.BaseResponse).Init()
  2047. defer func() {
  2048. this.Data["json"] = br
  2049. this.ServeJSON()
  2050. }()
  2051. user := this.User
  2052. if user == nil {
  2053. br.Msg = "请重新登录"
  2054. br.Ret = 408
  2055. return
  2056. }
  2057. uid := user.UserId
  2058. keyWord := this.GetString("KeyWord")
  2059. resp := new(models.CygxIndustrySearchListPc)
  2060. orderSrt := "update_time DESC"
  2061. condition := ` AND subject_names LIKE '%` + keyWord + `%'`
  2062. list, err := models.GetIndustrialManagementAll(uid, condition, orderSrt, 0, 100)
  2063. if err != nil {
  2064. br.Msg = "获取信息失败"
  2065. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2066. return
  2067. }
  2068. for k, v := range list {
  2069. industrialSubjectList, err := models.GetIndustrialSubjectAll(v.IndustrialManagementId)
  2070. if err != nil {
  2071. br.Msg = "获取信息失败"
  2072. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2073. return
  2074. }
  2075. list[k].IndustrialSubjectList = industrialSubjectList
  2076. //list[k].LayoutTime = utils.TimeRemoveHms(v.LayoutTime)
  2077. newArtinfo, err := models.GetIndustrialNewArticleDetail(v.IndustrialManagementId)
  2078. if err != nil {
  2079. br.Msg = "获取信息失败"
  2080. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2081. return
  2082. }
  2083. list[k].UpdateTime = utils.TimeRemoveHms(newArtinfo.PublishDate)
  2084. }
  2085. artList, err := models.GetCygxIndustryAndArticleList(keyWord)
  2086. if err != nil {
  2087. br.Msg = "获取失败"
  2088. br.ErrMsg = "获取失败,Err:" + err.Error()
  2089. return
  2090. }
  2091. if len(artList) > 0 {
  2092. var articleIds string
  2093. for _, v := range artList {
  2094. articleIds += strconv.Itoa(v.ArticleId) + ","
  2095. }
  2096. articleIds = strings.TrimRight(articleIds, ",")
  2097. if articleIds != "" {
  2098. condition = ` AND a.article_id IN (` + articleIds + `)`
  2099. DepartmentList, err := models.GetCygxArticleDepartmentListPc(0, 20, condition, uid)
  2100. if err != nil {
  2101. br.Msg = "获取信息失败"
  2102. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2103. return
  2104. }
  2105. for k, v := range DepartmentList {
  2106. artList, err := models.GetArticleByDepartmentIdPc(v.DepartmentId, articleIds)
  2107. if err != nil {
  2108. br.Msg = "获取信息失败"
  2109. br.ErrMsg = "获取文章信息失败,Err:" + err.Error()
  2110. return
  2111. }
  2112. for k2, v2 := range artList {
  2113. if artList[k2].IsReport == "1" {
  2114. artList[k2].Title = v2.Title
  2115. } else {
  2116. artList[k2].Title = v2.Title
  2117. }
  2118. artList[k2].IndustryName = strings.Replace(artList[k2].IndustryName, " ", "", -1)
  2119. }
  2120. DepartmentList[k].List = artList
  2121. if v.FollowNum > 0 {
  2122. DepartmentList[k].IsMyFollow = true
  2123. }
  2124. }
  2125. resp.DepartmentList = DepartmentList
  2126. }
  2127. }
  2128. if keyWord != "" {
  2129. keyWordItem := new(models.CygxUserSearchKeyWord)
  2130. keyWordItem.UserId = user.UserId
  2131. keyWordItem.KeyWord = keyWord
  2132. keyWordItem.PageType = "ReortSearch"
  2133. keyWordItem.CreateTime = time.Now()
  2134. go models.AddUserSearchKeyWord(keyWordItem)
  2135. }
  2136. resp.IndList = list
  2137. br.Ret = 200
  2138. br.Success = true
  2139. br.Msg = "获取成功"
  2140. br.Data = resp
  2141. }
  2142. // @Title 报告搜索
  2143. // @Description 报告搜索接口
  2144. // @Param KeyWord query string true "搜索关键词"
  2145. // @Success 200 {object} models.ReoprtSearchResp
  2146. // @router /searchReport [get]
  2147. func (this *ReportController) SearchReport() {
  2148. br := new(models.BaseResponse).Init()
  2149. defer func() {
  2150. this.Data["json"] = br
  2151. this.ServeJSON()
  2152. }()
  2153. user := this.User
  2154. if user == nil {
  2155. br.Msg = "请重新登录"
  2156. br.Ret = 408
  2157. return
  2158. }
  2159. keyWord := this.GetString("KeyWord")
  2160. var condition string
  2161. //匹配报告标题、对应产业名称、标的名称。
  2162. condition = `AND (
  2163. a.title LIKE '%` + keyWord + `%'
  2164. OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_subject WHERE industrial_subject_id IN ( SELECT industrial_subject_id FROM cygx_industrial_subject WHERE subject_name LIKE '%` + keyWord + `%' ) )
  2165. OR a.article_id IN ( SELECT article_id FROM cygx_industrial_article_group_management WHERE industrial_management_id IN ( SELECT industrial_management_id FROM cygx_industrial_management WHERE industry_name LIKE '%` + keyWord + `%' ) )
  2166. )
  2167. GROUP BY a.article_id ORDER BY a.publish_date DESC `
  2168. listYx, err := models.GetArticleCollectionList(` AND a.article_id >= 1000000 `+condition, user.UserId)
  2169. if err != nil {
  2170. br.Msg = "获取信息失败"
  2171. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2172. return
  2173. }
  2174. for k, v := range listYx {
  2175. if v.MyCollectNum > 0 {
  2176. listYx[k].IsCollect = true
  2177. }
  2178. }
  2179. listHz, err := models.GetReoprtSearchList(` AND a.article_id < 1000000 `+condition, user.UserId)
  2180. if err != nil {
  2181. br.Msg = "获取信息失败"
  2182. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2183. return
  2184. }
  2185. for k, v := range listHz {
  2186. if v.MyCollectNum > 0 {
  2187. listHz[k].IsCollect = true
  2188. }
  2189. }
  2190. if keyWord != "" {
  2191. keyWordItem := new(models.CygxUserSearchKeyWord)
  2192. keyWordItem.UserId = user.UserId
  2193. keyWordItem.KeyWord = keyWord
  2194. keyWordItem.PageType = "ReortSearch"
  2195. keyWordItem.CreateTime = time.Now()
  2196. go models.AddUserSearchKeyWord(keyWordItem)
  2197. }
  2198. resp := new(models.ReoprtSearchResp)
  2199. resp.ListYx = listYx
  2200. resp.ListHz = listHz
  2201. br.Ret = 200
  2202. br.Success = true
  2203. br.Msg = "获取成功"
  2204. br.Data = resp
  2205. }
  2206. // @Title 资源包搜索
  2207. // @Description 资源包搜索接口
  2208. // @Param KeyWord query string true "搜索关键词"
  2209. // @Success 200 {object} models.SearchResourceResp
  2210. // @router /searchResource [get]
  2211. func (this *ReportController) SearchResource() {
  2212. br := new(models.BaseResponse).Init()
  2213. defer func() {
  2214. this.Data["json"] = br
  2215. this.ServeJSON()
  2216. }()
  2217. user := this.User
  2218. if user == nil {
  2219. br.Msg = "请重新登录"
  2220. br.Ret = 408
  2221. return
  2222. }
  2223. keyWord := this.GetString("KeyWord")
  2224. var condition string
  2225. condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id != 31 GROUP BY m.industrial_management_id `
  2226. listHz, err := models.GetSearchResourceList(condition)
  2227. if err != nil {
  2228. br.Msg = "获取信息失败"
  2229. br.ErrMsg = "获取品种信息失败,Err:" + err.Error()
  2230. return
  2231. }
  2232. condition = `AND m.industry_name LIKE '%` + keyWord + `%' AND m.chart_permission_id = 31 GROUP BY m.industrial_management_id `
  2233. listYx, err := models.GetSearchResourceList(condition)
  2234. if err != nil {
  2235. br.Msg = "获取信息失败"
  2236. br.ErrMsg = "获取文章列表失败,Err:" + err.Error()
  2237. return
  2238. }
  2239. //合并产业关联的标的
  2240. listSubjcet, err := models.GetThemeHeatSubjectList("")
  2241. if err != nil {
  2242. br.Msg = "获取信息失败"
  2243. br.ErrMsg = "获取标的信息失败,Err:" + err.Error()
  2244. return
  2245. }
  2246. for k, v := range listHz {
  2247. for _, v2 := range listSubjcet {
  2248. if v2.IndustrialManagementId == v.IndustrialManagementId {
  2249. listHz[k].IndustrialSubjectList = append(listHz[k].IndustrialSubjectList, v2)
  2250. }
  2251. }
  2252. }
  2253. for k, v := range listYx {
  2254. for _, v2 := range listSubjcet {
  2255. if v2.IndustrialManagementId == v.IndustrialManagementId {
  2256. listYx[k].IndustrialSubjectList = append(listYx[k].IndustrialSubjectList, v2)
  2257. }
  2258. }
  2259. }
  2260. if keyWord != "" {
  2261. keyWordItem := new(models.CygxUserSearchKeyWord)
  2262. keyWordItem.UserId = user.UserId
  2263. keyWordItem.KeyWord = keyWord
  2264. keyWordItem.PageType = "ReortSearch"
  2265. keyWordItem.CreateTime = time.Now()
  2266. go models.AddUserSearchKeyWord(keyWordItem)
  2267. }
  2268. resp := new(models.SearchResourceResp)
  2269. resp.ListYx = listYx
  2270. resp.ListHz = listHz
  2271. br.Ret = 200
  2272. br.Success = true
  2273. br.Msg = "获取成功"
  2274. br.Data = resp
  2275. }