report.go 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111
  1. package report
  2. import (
  3. "encoding/json"
  4. "errors"
  5. "fmt"
  6. report_chapter_type_cache "hongze/hongze_yb/cache/report_chapter_type"
  7. "hongze/hongze_yb/global"
  8. "hongze/hongze_yb/models/response"
  9. "hongze/hongze_yb/models/response/purchase"
  10. "hongze/hongze_yb/models/tables/chart_permission_search_key_word_mapping"
  11. "hongze/hongze_yb/models/tables/company_product"
  12. "hongze/hongze_yb/models/tables/daily_base_column"
  13. "hongze/hongze_yb/models/tables/rddp/chart_permission"
  14. "hongze/hongze_yb/models/tables/rddp/chart_permission_chapter_mapping"
  15. "hongze/hongze_yb/models/tables/rddp/classify"
  16. "hongze/hongze_yb/models/tables/rddp/classify_menu"
  17. "hongze/hongze_yb/models/tables/rddp/report"
  18. "hongze/hongze_yb/models/tables/rddp/report_chapter"
  19. "hongze/hongze_yb/models/tables/rddp/report_chapter_ticker"
  20. "hongze/hongze_yb/models/tables/rddp/report_ppt_img"
  21. "hongze/hongze_yb/models/tables/rddp/smart_report_resource"
  22. "hongze/hongze_yb/models/tables/report_chapter_type"
  23. "hongze/hongze_yb/models/tables/report_chapter_type_permission"
  24. "hongze/hongze_yb/models/tables/user_report_chapter_set"
  25. "hongze/hongze_yb/models/tables/yb_road_video"
  26. "hongze/hongze_yb/services"
  27. "hongze/hongze_yb/services/collection"
  28. "hongze/hongze_yb/services/company"
  29. elasticService "hongze/hongze_yb/services/elastic"
  30. "hongze/hongze_yb/services/user"
  31. "hongze/hongze_yb/utils"
  32. "html"
  33. "sort"
  34. "strconv"
  35. "strings"
  36. "time"
  37. )
  38. // GetLatestClassReport 已购列表最新报告
  39. func GetLatestClassReport(permissionIds []int, userId uint64) (purchaseList []*purchase.PurchaseListItem, err error) {
  40. var errMsg string
  41. defer func() {
  42. if sysErr := recover(); sysErr != nil {
  43. err = errors.New("系统错误")
  44. global.LOG.Critical(fmt.Sprintf("GetLatestClassReport: userId=%d, err:%s,sysErr:%s", userId, err.Error(), sysErr))
  45. }
  46. if err != nil {
  47. global.LOG.Critical(fmt.Sprintf("GetLatestClassReport: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
  48. }
  49. }()
  50. //获取所有分类信息
  51. classifys, err := classify.GetSimpleAll()
  52. if err != nil {
  53. errMsg = err.Error()
  54. err = errors.New("分类查询出错")
  55. return
  56. }
  57. classifyFirstIconMap := make(map[int]string)
  58. //classifySecondNameMap := make(map[int]int)
  59. classifyFirstIdMap := make(map[int]bool)
  60. classifySecondIdMap := make(map[int]bool)
  61. for _, v := range classifys {
  62. if v.ParentId == 0 {
  63. classifyFirstIdMap[v.Id] = true
  64. classifyFirstIconMap[v.Id] = v.YbIconUrl
  65. } else {
  66. classifySecondIdMap[v.Id] = true
  67. //classifySecondNameMap[v.Id] = v.Id
  68. }
  69. }
  70. //获取最新的晨报
  71. dayReport, err := report.GetLatestDay()
  72. if err != nil {
  73. errMsg = err.Error()
  74. err = errors.New("晨报查询出错")
  75. return
  76. }
  77. //获取最新的有权限的周报
  78. //typeIds, err := report_chapter_type.GetEffectTypeID()
  79. typeIds, err := report_chapter_type_cache.GetEffectTypeID()
  80. if err != nil {
  81. errMsg = err.Error()
  82. err = errors.New("晨报查询出错")
  83. return
  84. }
  85. weekReport, err := GetLatestWeek(permissionIds, typeIds)
  86. if err != nil {
  87. errMsg = err.Error()
  88. err = errors.New("周报查询出错")
  89. return
  90. }
  91. // 有权限的二级分类
  92. var reports []*report.Report
  93. var classifyIdSeconds []int
  94. classifyIdSecondMap := make(map[int]bool)
  95. // 获取晨报和周报以外的其他报告
  96. // 获取有权限的二级分类
  97. chartPermissions, err := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  98. if err != nil {
  99. errMsg = err.Error()
  100. err = errors.New("分类权限查询出错")
  101. return
  102. }
  103. if len(chartPermissions) > 0 {
  104. for _, v := range chartPermissions {
  105. for _, myPerId := range permissionIds {
  106. if v.ChartPermissionId == myPerId {
  107. if classifySecondIdMap[v.ClassifyId] {
  108. if _, ok := classifyIdSecondMap[v.ClassifyId]; !ok {
  109. classifyIdSeconds = append(classifyIdSeconds, v.ClassifyId)
  110. classifyIdSecondMap[v.ClassifyId] = true
  111. }
  112. }
  113. break
  114. }
  115. }
  116. }
  117. }
  118. reports, err = report.GetLatestClassReportsByClassifyIdSeconds(classifyIdSeconds)
  119. if err != nil {
  120. errMsg = err.Error()
  121. err = errors.New("二级分类最新报告查询出错")
  122. return
  123. }
  124. if dayReport.Id > 0 {
  125. reports = append(reports, dayReport)
  126. }
  127. if weekReport != nil && weekReport.Id > 0 {
  128. reports = append(reports, weekReport)
  129. }
  130. //获取未读数
  131. unReadItem, tErr := GetUnRead(classifyIdSeconds, userId)
  132. if tErr != nil {
  133. err = tErr
  134. return
  135. }
  136. if len(reports) > 0 {
  137. otherLatestItem := new(purchase.PurchaseListItem)
  138. // 处理其他报告()
  139. for _, v := range reports {
  140. temp := new(purchase.PurchaseListItem)
  141. temp.ReportId = v.Id
  142. temp.ClassifyIdFirst = v.ClassifyIdFirst
  143. temp.ClassifyNameFirst = v.ClassifyNameFirst
  144. temp.Stage = v.Stage
  145. temp.Title = v.Title
  146. temp.ClassifyIdSecond = v.ClassifyIdSecond
  147. temp.ClassifyNameSecond = v.ClassifyNameSecond
  148. temp.Time = v.PublishTime
  149. if temp.ClassifyNameFirst == "大事点评" || temp.ClassifyNameFirst == "会议纪要" || temp.ClassifyNameFirst == "年报合集" {
  150. if otherLatestItem.Time.Format(utils.FormatDateTime) > v.PublishTime.Format(utils.FormatDateTime) {
  151. continue
  152. }
  153. temp.Unread = unReadItem["大事点评"] + unReadItem["会议纪要"] + unReadItem["年报合集"]
  154. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  155. temp.ImgUrl = "https://hzstatic.hzinsights.com/static/yb_wx/purchase_icon_other.png"
  156. otherLatestItem = temp
  157. }
  158. }
  159. for _, v := range reports {
  160. if v.ClassifyNameFirst != "晨报" && v.ClassifyNameFirst != "周报" {
  161. // 报告的分类不存在
  162. if !classifyFirstIdMap[v.ClassifyIdFirst] || !classifyIdSecondMap[v.ClassifyIdSecond] {
  163. continue
  164. }
  165. }
  166. temp := new(purchase.PurchaseListItem)
  167. temp.ReportId = v.Id
  168. temp.ClassifyIdFirst = v.ClassifyIdFirst
  169. temp.ClassifyNameFirst = v.ClassifyNameFirst
  170. temp.Stage = v.Stage
  171. temp.Title = v.Title
  172. temp.ClassifyIdSecond = v.ClassifyIdSecond
  173. temp.ClassifyNameSecond = v.ClassifyNameSecond
  174. temp.Time = v.PublishTime
  175. temp.Unread = unReadItem[temp.ClassifyNameFirst]
  176. if imgUrl, ok := classifyFirstIconMap[temp.ClassifyIdFirst]; ok {
  177. temp.ImgUrl = imgUrl
  178. }
  179. if temp.ClassifyNameFirst == "晨报" || temp.ClassifyNameFirst == "周报" { //晨报或者周报,查询最新的章节信息
  180. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.Title)
  181. } else if temp.ClassifyNameFirst == "大事点评" || temp.ClassifyNameFirst == "会议纪要" || temp.ClassifyNameFirst == "年报合集" {
  182. continue
  183. } else {
  184. if temp.ClassifyNameFirst != temp.ClassifyNameSecond { //包含二级分类
  185. temp.Content = fmt.Sprintf("【第%d期|FICC| %s】%s", temp.Stage, temp.ClassifyNameSecond, temp.ClassifyNameFirst)
  186. } else { //无二级分类
  187. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  188. }
  189. }
  190. purchaseList = append(purchaseList, temp)
  191. }
  192. if otherLatestItem.ReportId > 0 {
  193. purchaseList = append(purchaseList, otherLatestItem)
  194. }
  195. }
  196. return
  197. }
  198. // GetPurchaseDetail 已购详情页面
  199. func GetPurchaseDetail(permissionIds []int, userId uint64, classifyIdFirst int, pageIndex, pageSize int) (ret *purchase.DetailResp, err error) {
  200. var errMsg string
  201. defer func() {
  202. if err != nil {
  203. global.LOG.Critical(fmt.Sprintf("GetPurchaseDetail: userId=%d, err:%s, errMsg:%s", userId, err.Error(), errMsg))
  204. }
  205. }()
  206. var reports []*report.Report
  207. var weekReportIds []int
  208. classifyInfo, err := classify.GetByClassifyId(classifyIdFirst)
  209. if err != nil {
  210. errMsg = err.Error()
  211. err = errors.New("分类查询出错")
  212. return
  213. }
  214. if classifyInfo.Id == 0 {
  215. err = errors.New("分类不存在")
  216. return
  217. }
  218. classifyNameFirst := classifyInfo.ClassifyName
  219. offset := (pageIndex - 1) * pageSize
  220. var total int64
  221. var classifyIdSeconds []int
  222. if classifyNameFirst == "晨报" {
  223. //分类获取
  224. reports, err = report.GetListByClassifyIdFirst(classifyIdFirst, offset, pageSize)
  225. if err != nil {
  226. errMsg = err.Error()
  227. err = errors.New("晨报查询出错")
  228. return
  229. }
  230. total, err = report.GetListCountByClassifyIdFirst(classifyIdFirst)
  231. if err != nil {
  232. errMsg = err.Error()
  233. err = errors.New("查询报告总数出错")
  234. return
  235. }
  236. } else {
  237. if classifyNameFirst == "周报" {
  238. newTypeIds, tErr := GetWeekTypeIdsByPermissionIds(permissionIds, []int{})
  239. if tErr != nil {
  240. return
  241. }
  242. weekReportIds, err = report_chapter.GetReportIdsByTypeIdsAndClass(newTypeIds, classifyNameFirst)
  243. //分类获取
  244. reports, err = report.GetListByIDsAndClassifyIdFirst(weekReportIds, classifyIdFirst, offset, pageSize)
  245. if err != nil {
  246. return
  247. }
  248. total, err = report.GetListCountByIDsAndClassifyIdFirst(weekReportIds, classifyIdFirst)
  249. if err != nil {
  250. errMsg = err.Error()
  251. err = errors.New("查询报告总数出错")
  252. return
  253. }
  254. } else {
  255. //获取有权限的二级分类
  256. var classifyNameSeconds []string
  257. chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  258. if tErr != nil {
  259. errMsg = tErr.Error()
  260. err = errors.New("分类权限查询出错")
  261. return
  262. }
  263. if len(chartPermissions) > 0 {
  264. for _, v := range chartPermissions {
  265. for _, myPerId := range permissionIds {
  266. if v.ChartPermissionId == myPerId {
  267. if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集" {
  268. if v.KeyWord == "大事点评" || v.KeyWord == "会议纪要" || v.KeyWord == "年报合集" { //筛选出用户有权限的二级分类ID
  269. classifyNameSeconds = append(classifyNameSeconds, v.KeyWord)
  270. }
  271. } else {
  272. classifyNameSeconds = append(classifyNameSeconds, v.KeyWord)
  273. }
  274. break
  275. }
  276. }
  277. }
  278. }
  279. //获取所有二级分类的id
  280. if classifyNameFirst == "大事点评" || classifyNameFirst == "会议纪要" || classifyNameFirst == "年报合集" {
  281. classifyIdSeconds, tErr = classify.GetOtherSecondIds([]string{"大事点评", "会议纪要", "年报合集"})
  282. } else {
  283. classifyIdSeconds, tErr = classify.GetIdsByClassifyNameAndParentId(classifyNameSeconds, classifyIdFirst)
  284. }
  285. if tErr != nil {
  286. errMsg = tErr.Error()
  287. err = errors.New("二级分类查询出错")
  288. return
  289. }
  290. if len(classifyIdSeconds) > 0 {
  291. //分类获取
  292. reports, err = report.GetListByClassifyIdSeconds(classifyIdSeconds, offset, pageSize)
  293. if err != nil {
  294. return
  295. }
  296. total, err = report.GetListCountByClassifyIdSeconds(classifyIdSeconds)
  297. if err != nil {
  298. errMsg = err.Error()
  299. err = errors.New("查询报告总数出错")
  300. return
  301. }
  302. }
  303. }
  304. }
  305. var list []*purchase.Detail
  306. ret = new(purchase.DetailResp)
  307. if len(reports) > 0 {
  308. var viewReportIds []int
  309. for _, v := range reports {
  310. viewReportIds = append(viewReportIds, v.Id)
  311. temp := new(purchase.Detail)
  312. temp.ReportId = v.Id
  313. temp.ClassifyIdFirst = v.ClassifyIdFirst
  314. temp.ClassifyNameFirst = v.ClassifyNameFirst
  315. temp.Title = v.Title
  316. temp.ClassifyIdSecond = v.ClassifyIdSecond
  317. temp.ClassifyNameSecond = v.ClassifyNameSecond
  318. temp.Stage = v.Stage
  319. temp.ImgUrl = classifyInfo.YbBgUrl
  320. if temp.ClassifyNameFirst == "晨报" || temp.ClassifyNameFirst == "周报" { //晨报或者周报,查询最新的章节信息
  321. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.Title)
  322. temp.TopName = temp.Title
  323. } else {
  324. if temp.ClassifyNameFirst != temp.ClassifyNameSecond { //包含二级分类
  325. temp.Content = fmt.Sprintf("【第%d期|FICC| %s】%s", temp.Stage, temp.ClassifyNameSecond, temp.ClassifyNameFirst)
  326. temp.TopName = temp.ClassifyNameSecond
  327. } else {
  328. temp.Content = fmt.Sprintf("【第%d期|FICC】%s", temp.Stage, temp.ClassifyNameFirst)
  329. temp.TopName = temp.ClassifyNameFirst
  330. }
  331. }
  332. temp.Time = v.PublishTime
  333. list = append(list, temp)
  334. }
  335. }
  336. ret.List = list
  337. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  338. // 执行一个协程任务,新增用户浏览记录
  339. //_, tErr := BatchInsertReportView(weekReportIds, userId, classifyNameFirst, classifyIdSeconds)
  340. go BatchInsertReportView(userId, weekReportIds, classifyNameFirst, classifyIdSeconds)
  341. /*if tErr != nil {
  342. err = tErr
  343. return
  344. }*/
  345. return
  346. }
  347. // 获取报告详情
  348. func GetReportDetail(userinfo user.UserInfo, reportId int) (reportDetail response.ReportDetail, err error) {
  349. var errMsg string
  350. defer func() {
  351. if err != nil {
  352. global.LOG.Critical(fmt.Sprintf("GetReportDetail: userId=%d, err:%s, errMsg:%s", userinfo.UserID, err.Error(), errMsg))
  353. }
  354. }()
  355. // 判断用户状态是否是正常和永续
  356. var productAuthOk bool
  357. companyProduct, err := company_product.GetByCompany2ProductId(userinfo.CompanyID, 1)
  358. if err == utils.ErrNoRow {
  359. err = nil
  360. }
  361. if err != nil {
  362. errMsg = err.Error()
  363. err = errors.New("查询用户购买产品出错")
  364. return
  365. }
  366. if companyProduct != nil {
  367. // 无FICC权限的客户不可见
  368. if companyProduct.CompanyProductID > 0 {
  369. // 已购或者试用用户可见
  370. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  371. productAuthOk = true
  372. }
  373. }
  374. }
  375. reportInfo, err := report.GetByReportId(reportId)
  376. if err != nil {
  377. errMsg = err.Error()
  378. err = errors.New("报告查询出错")
  379. return
  380. }
  381. if reportInfo.Id == 0 {
  382. err = errors.New("报告不存在")
  383. return
  384. }
  385. if reportInfo.State != 2 && reportInfo.State != 6 {
  386. err = errors.New("报告未发布")
  387. return
  388. }
  389. // 获取最小分类
  390. minClassifyId, _, err := GetMinClassify(reportInfo)
  391. // 判断报告是否属于专栏报告
  392. firstClassify, e := classify.GetByClassifyId(reportInfo.ClassifyIdFirst)
  393. if e != nil {
  394. err = errors.New("报告一级分类有误")
  395. return
  396. }
  397. // 最小分类
  398. var minClassify *classify.Classify
  399. if reportInfo.ClassifyIdFirst == minClassifyId {
  400. minClassify = firstClassify
  401. } else {
  402. minClassify, e = classify.GetByClassifyId(minClassifyId)
  403. if e != nil {
  404. err = errors.New("报告最小层级分类有误")
  405. return
  406. }
  407. }
  408. //判断权限
  409. var authOk bool
  410. var permissionCheckInfo response.PermissionCheckInfo
  411. //var vaildWeekTypeIds []int
  412. var reportChapterIdList []int
  413. if reportInfo.HasChapter == 1 {
  414. if reportInfo.ClassifyNameFirst == "晨报" {
  415. authOk, permissionCheckInfo, err = CheckDayReportPermission(userinfo, productAuthOk)
  416. } else {
  417. authOk, permissionCheckInfo, _, reportChapterIdList, err = CheckWeekReportPermission(userinfo, reportId, productAuthOk)
  418. }
  419. } else {
  420. authOk, permissionCheckInfo, err = CheckReportPermission(userinfo, reportId, productAuthOk)
  421. }
  422. if err != nil {
  423. return
  424. }
  425. reportItem := new(response.ReportItem)
  426. reportItem.ReportId = reportInfo.Id
  427. reportItem.Title = reportInfo.Title
  428. reportItem.PublishTime = reportInfo.PublishTime
  429. reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  430. reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  431. reportItem.Stage = reportInfo.Stage
  432. reportItem.Abstract = reportInfo.Abstract
  433. reportItem.ContentSub = html.UnescapeString(reportInfo.ContentSub)
  434. reportItem.Frequency = reportInfo.Frequency
  435. reportItem.VideoName = reportInfo.VideoName
  436. reportItem.HasChapter = reportInfo.HasChapter
  437. reportItem.ReportLayout = reportInfo.ReportLayout
  438. reportItem.HeadImg = reportInfo.HeadImg
  439. reportItem.EndImg = reportInfo.EndImg
  440. reportItem.CanvasColor = reportInfo.CanvasColor
  441. // 版头版尾样式
  442. {
  443. if reportInfo.HeadResourceId > 0 {
  444. headResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.HeadResourceId)
  445. if tmpErr != nil {
  446. err = tmpErr
  447. return
  448. }
  449. reportItem.HeadImg = headResource.ImgURL
  450. reportItem.HeadStyle = headResource.Style
  451. }
  452. if reportInfo.EndResourceId > 0 {
  453. endResource, tmpErr := smart_report_resource.GetResourceItemById(reportInfo.EndResourceId)
  454. if tmpErr != nil {
  455. err = tmpErr
  456. return
  457. }
  458. reportItem.EndImg = endResource.ImgURL
  459. reportItem.EndStyle = endResource.Style
  460. }
  461. }
  462. if reportInfo.VideoName == "" && reportInfo.VideoUrl != "" {
  463. reportItem.VideoName = reportInfo.Title
  464. }
  465. reportItem.VideoSize = reportInfo.VideoSize
  466. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  467. reportItem.Author = reportInfo.Author
  468. // 分享背景图取二级分类配图, 二级没有配图时使用一级配图, 一级也没有使用默认图
  469. reportItem.ShareBgImg = utils.DEFAULT_REPORT_SHARE_BG_IMG
  470. secondClassify, e := classify.GetByClassifyId(reportInfo.ClassifyIdSecond)
  471. if e != nil {
  472. err = errors.New("报告二级分类有误")
  473. return
  474. }
  475. if secondClassify.YbShareBgImg != "" {
  476. reportItem.ShareBgImg = secondClassify.YbShareBgImg
  477. } else {
  478. if firstClassify.YbShareBgImg != "" {
  479. reportItem.ShareBgImg = firstClassify.YbShareBgImg
  480. }
  481. }
  482. var reportTypeList []*response.ReportChapterListItem
  483. if reportInfo.HasChapter == 1 {
  484. //(晨报和周报的banner图)
  485. if reportInfo.ClassifyNameFirst == "晨报" {
  486. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  487. } else {
  488. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_week.jpg"
  489. }
  490. // 如果还没有配置banner图,则取晨报的
  491. if reportItem.BannerUrl == `` {
  492. reportItem.BannerUrl = utils.ALIYUN_YBIMG_HOST + "report_banner_day.jpg"
  493. }
  494. if authOk {
  495. reportTypeList, err = GetChapterListByReportChapterIdList(reportInfo.ClassifyNameFirst, reportInfo.Id, reportChapterIdList)
  496. if err != nil {
  497. return
  498. }
  499. }
  500. } else {
  501. // 音频播放条图片用分类图片
  502. reportItem.VideoImg = utils.HZ_DEFAULT_AVATAR
  503. permissionIds, tmpErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(reportInfo.ClassifyIdSecond)
  504. if tmpErr != nil {
  505. errMsg = tmpErr.Error()
  506. err = errors.New("查询报告权限失败")
  507. return
  508. }
  509. if len(permissionIds) > 0 {
  510. chartPermission, tmpErr := chart_permission.GetListByIds(permissionIds)
  511. if tmpErr != nil {
  512. errMsg = tmpErr.Error()
  513. err = errors.New("查询品种信息失败")
  514. return
  515. }
  516. lenChart := len(chartPermission)
  517. for i := 0; i < lenChart; i++ {
  518. if chartPermission[i].YbImgUrl != "" {
  519. reportItem.VideoImg = utils.ALIYUN_YBIMG_HOST + chartPermission[i].YbImgUrl
  520. break
  521. }
  522. }
  523. }
  524. }
  525. //如果有权限则展示content
  526. var likeNum int64
  527. var likeEnabled int8
  528. if authOk {
  529. go AddViewRecord(userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0)
  530. reportItem.Content = html.UnescapeString(reportInfo.Content)
  531. reportItem.VideoUrl = reportInfo.VideoUrl
  532. //查询点赞数
  533. likeNum, likeEnabled, _ = services.GetReportLikeByReportIdOldReportId(userinfo.UserID, reportInfo.Id, 0, 0, 0)
  534. }
  535. //处理章节品种,音频开关
  536. {
  537. chapterSetList, err := user_report_chapter_set.GetUserReportChapterSet(userinfo.UserID)
  538. if err != nil {
  539. return reportDetail, err
  540. }
  541. setList := make([]*user_report_chapter_set.UserReportChapterSet, 0)
  542. reportTypeLen := len(reportTypeList)
  543. if len(chapterSetList) == 0 {
  544. for _, v := range reportTypeList {
  545. setItem := new(user_report_chapter_set.UserReportChapterSet)
  546. setItem.UserId = userinfo.UserID
  547. setItem.TypeId = v.TypeId
  548. setItem.TypeName = v.TypeName
  549. setItem.CreateTime = time.Now()
  550. setItem.ModifyTime = time.Now()
  551. setItem.IsClose = 0
  552. setList = append(setList, setItem)
  553. }
  554. } else {
  555. chapterSetMap := make(map[int]int)
  556. for _, v := range chapterSetList {
  557. chapterSetMap[v.TypeId] = v.IsClose
  558. }
  559. for i := 0; i < reportTypeLen; i++ {
  560. typeItem := reportTypeList[i]
  561. if findIsClose, ok := chapterSetMap[typeItem.TypeId]; ok {
  562. reportTypeList[i].IsClose = findIsClose
  563. } else {
  564. setItem := new(user_report_chapter_set.UserReportChapterSet)
  565. setItem.UserId = userinfo.UserID
  566. setItem.TypeId = typeItem.TypeId
  567. setItem.TypeName = typeItem.TypeName
  568. setItem.CreateTime = time.Now()
  569. setItem.ModifyTime = time.Now()
  570. setItem.IsClose = 0
  571. setList = append(setList, setItem)
  572. }
  573. }
  574. }
  575. if len(setList) > 0 {
  576. err = user_report_chapter_set.AddUserReportChapterSet(setList)
  577. if err != nil {
  578. return reportDetail, err
  579. }
  580. }
  581. }
  582. //新增用户访问日志
  583. go AddUserAccessRecord(userinfo, reportInfo.Id, reportInfo.ClassifyNameFirst, 0, authOk)
  584. reportDetail.ReportInfo = reportItem
  585. reportDetail.ReportChapterList = reportTypeList
  586. reportDetail.PermissionCheck = &permissionCheckInfo
  587. reportDetail.AuthOk = authOk
  588. reportDetail.LikeNum = likeNum
  589. reportDetail.LikeEnabled = likeEnabled
  590. reportDetail.ReportShowType = int(firstClassify.ShowType)
  591. reportDetail.ReportDetailShowType = int(minClassify.ReportDetailShowType)
  592. // 如果分类配置是列表展示,那么就移除content内容
  593. if minClassify.ReportDetailShowType == 2 {
  594. for _, v := range reportTypeList {
  595. v.Content = ``
  596. }
  597. } else {
  598. for _, v := range reportTypeList {
  599. v.Content = html.UnescapeString(v.Content)
  600. }
  601. }
  602. // 收藏
  603. collectionId, e := collection.GetUserCollectByItem(int(userinfo.UserID), collection.CollectionTypeReport, reportId, 0)
  604. if e != nil {
  605. err = e
  606. return
  607. }
  608. reportDetail.CollectionId = collectionId
  609. // 绑定的路演视频
  610. roadVideo, e := yb_road_video.GetItemByReportId(reportId)
  611. if e != nil && e != utils.ErrNoRow {
  612. err = e
  613. return
  614. }
  615. if roadVideo != nil && roadVideo.RoadVideoID > 0 {
  616. reportDetail.RoadVideoId = roadVideo.RoadVideoID
  617. }
  618. return
  619. }
  620. // CheckReportPermission 验证用户查看报告的权限
  621. func CheckReportPermission(userInfo user.UserInfo, reportId int, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, err error) {
  622. var permissionIds []int
  623. if productAuthOk {
  624. permissionIds, err = chart_permission_chapter_mapping.GetPermissionIdsByReportId(reportId, "rddp")
  625. if err != nil && err != utils.ErrNoRow {
  626. return
  627. }
  628. }
  629. authOk, permissionCheckInfo, _, err = company.GetCheckPermission(userInfo.CompanyID, int(userInfo.UserID), permissionIds)
  630. return
  631. }
  632. // GetReportList 获取报告列表
  633. func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classifyIdSecond, pageIndex, pageSize, classifyMenuId int) (ret *response.ReportList, err error) {
  634. var errMsg string
  635. defer func() {
  636. if err != nil {
  637. global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  638. }
  639. }()
  640. // 判断用户状态是否是正常和永续
  641. var productAuthOk bool
  642. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  643. if err == utils.ErrNoRow {
  644. err = nil
  645. }
  646. if err != nil {
  647. errMsg = err.Error()
  648. err = errors.New("查询用户购买产品出错")
  649. return
  650. }
  651. if companyProduct != nil {
  652. // 无FICC权限的客户不可见
  653. if companyProduct.CompanyProductID > 0 {
  654. // 已购或者试用用户可见
  655. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  656. productAuthOk = true
  657. }
  658. }
  659. }
  660. var condition string
  661. pars := make([]interface{}, 0)
  662. classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  663. if err != nil {
  664. errMsg = err.Error()
  665. err = errors.New("分类查询出错")
  666. return
  667. }
  668. if classifyParent.Id == 0 {
  669. err = errors.New("该分类不存在")
  670. return
  671. }
  672. condition = `classify_id_first = ? and state IN (2, 6)`
  673. pars = append(pars, classifyIdFirst)
  674. // 子目录
  675. menuClassifyIds := make([]int, 0)
  676. menuClassifyLen := 0
  677. if classifyMenuId > 0 {
  678. ids, e := classify_menu.GetClassifyIdsByMenuId(classifyMenuId)
  679. if e != nil {
  680. err = errors.New("获取子目录关联分类信息失败, Err: " + e.Error())
  681. return
  682. }
  683. menuClassifyIds = ids
  684. menuClassifyLen = len(menuClassifyIds)
  685. if menuClassifyLen == 0 {
  686. condition += ` AND 1 = 2`
  687. }
  688. }
  689. permissionMap := make(map[int][]int)
  690. checkPermissionMap := make(map[int]bool)
  691. //permissionImageMap := make(map[string]string)
  692. chartPermissionImageMap := make(map[int]string)
  693. var classifyIdSeconds []int
  694. //var reportImgUrl string
  695. chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  696. if err != nil {
  697. errMsg = err.Error()
  698. err = errors.New("分类查询出错")
  699. return
  700. }
  701. if len(chartPermissionList) > 0 {
  702. for _, v := range chartPermissionList {
  703. chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  704. }
  705. }
  706. if classifyIdSecond > 0 && keyWord == "" {
  707. classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  708. if tErr != nil {
  709. errMsg = tErr.Error()
  710. err = errors.New("分类查询出错")
  711. return
  712. }
  713. if classifyInfo.Id == 0 {
  714. err = errors.New("该二级分类不存在")
  715. return
  716. }
  717. condition += " AND classify_id_second = ?"
  718. pars = append(pars, classifyIdSecond)
  719. //查询二级分类对应的权限
  720. permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyIdSecond)
  721. if tErr != nil {
  722. errMsg = tErr.Error()
  723. err = errors.New("分类权限查询出错")
  724. return
  725. }
  726. permissionMap[classifyInfo.Id] = permissionIds
  727. //if len(permissionIds) > 0 {
  728. // for _, v := range permissionIds {
  729. // reportImgUrl = chartPermissionImageMap[v]
  730. // }
  731. //}
  732. } else {
  733. if classifyParent.HasChild == 0 {
  734. //reportImgUrl = chartPermissionImageMap[1]
  735. classifyIdSeconds = append(classifyIdSeconds, 0)
  736. }
  737. chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  738. if tErr != nil {
  739. errMsg = tErr.Error()
  740. err = errors.New("分类权限查询出错")
  741. return
  742. }
  743. if len(chartPermissions) > 0 {
  744. for _, v := range chartPermissions {
  745. permissionMap[v.ClassifyId] = append(permissionMap[v.ClassifyId], v.ChartPermissionId)
  746. //permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  747. }
  748. }
  749. //获取二级分类的所有头像
  750. classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  751. if tErr != nil {
  752. errMsg = tErr.Error()
  753. err = errors.New("二级分类查询出错")
  754. return
  755. }
  756. // 子目录
  757. if menuClassifyLen > 0 {
  758. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  759. } else {
  760. for _, v := range classifyList {
  761. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  762. }
  763. }
  764. if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  765. ret = new(response.ReportList)
  766. ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  767. return
  768. }
  769. condition += ` AND classify_id_second IN ? `
  770. pars = append(pars, classifyIdSeconds)
  771. }
  772. // 获取有效的权限id列表
  773. var validPermissionIdList []int
  774. if productAuthOk {
  775. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  776. if err != nil && err != utils.ErrNoRow {
  777. errMsg = err.Error()
  778. err = errors.New("查询分类出错")
  779. return
  780. }
  781. }
  782. if len(validPermissionIdList) > 0 {
  783. for cid, perIds := range permissionMap {
  784. checkLoop:
  785. for _, checkId := range perIds {
  786. for _, validPerid := range validPermissionIdList {
  787. if checkId == validPerid {
  788. checkPermissionMap[cid] = true
  789. break checkLoop
  790. }
  791. }
  792. }
  793. }
  794. }
  795. var total int64
  796. var list []*report.Report
  797. if keyWord == "" {
  798. offset := (pageIndex - 1) * pageSize
  799. list, err = report.GetReportList(condition, pars, offset, pageSize)
  800. if err != nil {
  801. errMsg = err.Error()
  802. err = errors.New("报告查询出错")
  803. return
  804. }
  805. total, err = report.GetReportListCount(condition, pars)
  806. if err != nil {
  807. errMsg = err.Error()
  808. err = errors.New("查询报告总数出错")
  809. return
  810. }
  811. } else {
  812. if classifyIdSecond > 0 {
  813. classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  814. }
  815. if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  816. classifyIdSeconds = append(classifyIdSeconds, 0)
  817. }
  818. // 子目录
  819. if menuClassifyLen > 0 {
  820. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  821. }
  822. searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  823. if tErr != nil {
  824. errMsg = tErr.Error()
  825. err = errors.New("查询失败")
  826. return
  827. }
  828. total = int64(total1)
  829. if searchResp.Hits != nil && total > 0 {
  830. var reportIds []int
  831. for _, v := range searchResp.Hits.Hits {
  832. temp := new(report.Report)
  833. itemJson, tmpErr := v.Source.MarshalJSON()
  834. if tmpErr != nil {
  835. errMsg = tmpErr.Error()
  836. err = errors.New("解析出错")
  837. return
  838. }
  839. reportItem := new(response.EsReportItem)
  840. tmpErr = json.Unmarshal(itemJson, &reportItem)
  841. if tmpErr != nil {
  842. errMsg = tmpErr.Error()
  843. err = errors.New("解析json出错")
  844. return
  845. }
  846. temp.Id = reportItem.ReportId
  847. reportIds = append(reportIds, reportItem.ReportId)
  848. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  849. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  850. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  851. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  852. if reportItem.ClassifyIdSecond > 0 && reportItem.ClassifyIdSecond != reportItem.ClassifyId {
  853. temp.ClassifyIdThird = reportItem.ClassifyId
  854. temp.ClassifyNameThird = reportItem.ClassifyName
  855. }
  856. if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  857. temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  858. }
  859. temp.Abstract = reportItem.Abstract
  860. stageInt, _ := strconv.Atoi(reportItem.StageStr)
  861. temp.Stage = stageInt
  862. temp.StageStr = reportItem.StageStr
  863. temp.Title = reportItem.Title
  864. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  865. if len(v.Highlight["Title"]) > 0 {
  866. temp.Title = v.Highlight["Title"][0]
  867. }
  868. if len(v.Highlight["Abstract"]) > 0 {
  869. temp.Abstract = v.Highlight["Abstract"][0]
  870. }
  871. if len(v.Highlight["StageStr"]) > 0 {
  872. temp.StageStr = v.Highlight["StageStr"][0]
  873. }
  874. list = append(list, temp)
  875. }
  876. reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  877. if tmpErr != nil {
  878. errMsg = tmpErr.Error()
  879. err = errors.New("查询报告出错")
  880. return
  881. }
  882. reportListMap := make(map[int]*report.Report)
  883. for _, temp := range reportInfoList {
  884. reportListMap[temp.Id] = temp
  885. }
  886. for k, reportDetail := range list {
  887. if v, ok := reportListMap[reportDetail.Id]; ok {
  888. list[k].CreateTime = v.CreateTime
  889. }
  890. }
  891. }
  892. }
  893. var reportList []*response.ReportListItem
  894. if len(list) > 0 {
  895. // 封面图
  896. classifyList, e := classify.GetClassifyList()
  897. if e != nil {
  898. err = errors.New("获取报告分类列表失败" + e.Error())
  899. return
  900. }
  901. listImgMap := make(map[int]string, 0)
  902. classifyNameMap := make(map[int]string, 0)
  903. classifyLen := len(classifyList)
  904. for i := 0; i < classifyLen; i++ {
  905. listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  906. classifyNameMap[classifyList[i].Id] = classifyList[i].ClassifyName
  907. }
  908. var videoReportIds []int
  909. videoMap := make(map[int][]*response.VideoListItem)
  910. weekAuthMap := make(map[int]bool)
  911. // 判断周报权限\查询章节报告的音频列表
  912. videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list, user.UserID)
  913. if err != nil {
  914. return
  915. }
  916. // 如果是晨报,那么就要过滤掉weekAuthMap的授权
  917. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  918. weekAuthMap = map[int]bool{}
  919. } else {
  920. //查询所有权限typeID
  921. //如果存在可以查看的章节ID
  922. for _, reportInfo := range list {
  923. if reportInfo.HasChapter == 1 {
  924. videoReportIds = append(videoReportIds, reportInfo.Id)
  925. }
  926. }
  927. }
  928. // 以下分类图标特殊处理 =_=!
  929. //reportImgMap := map[string]string{
  930. // "晨报": "report_list_chen.png",
  931. // "周报": "report_list_zhou.png",
  932. // "月报": "report_list_yue.png",
  933. // "大事点评": "report_list_dashidianping.png",
  934. // "会议纪要": "report_list_huiyijiyao.png",
  935. // "年报合集": "report_list_nianbaoheji.png",
  936. //}
  937. for _, reportInfo := range list {
  938. reportItem := new(response.ReportListItem)
  939. reportItem.ReportId = reportInfo.Id
  940. reportItem.HasChapter = reportInfo.HasChapter
  941. reportItem.VideoUrl = reportInfo.VideoUrl
  942. reportItem.VideoName = reportInfo.VideoName
  943. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  944. // 样式限制行数
  945. reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  946. reportItem.PublishTime = reportInfo.PublishTime
  947. //reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  948. //reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  949. reportItem.ClassifyNameFirst = classifyNameMap[reportInfo.ClassifyIdFirst]
  950. reportItem.ClassifyNameSecond = classifyNameMap[reportInfo.ClassifyIdSecond]
  951. reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  952. reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  953. reportItem.ClassifyIdThird = reportInfo.ClassifyIdThird
  954. reportItem.ClassifyNameThird = reportInfo.ClassifyNameThird
  955. reportItem.Stage = reportInfo.Stage
  956. reportItem.Abstract = reportInfo.Abstract
  957. if reportInfo.Abstract != "" {
  958. reportItem.Abstract = "<div style=\"display: -webkit-box;overflow: hidden;text-overflow: ellipsis;word-break: break-all;-webkit-box-orient: vertical;-webkit-line-clamp: 1;\">" + reportInfo.Abstract + "</div>"
  959. }
  960. reportItem.Author = reportInfo.Author
  961. stageStr := reportInfo.StageStr
  962. if stageStr == "" {
  963. stageStr = strconv.Itoa(reportInfo.Stage)
  964. }
  965. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  966. if reportItem.ClassifyNameThird != `` {
  967. reportItem.TitleInfo = fmt.Sprintf("%s|%s】", reportItem.TitleInfo, reportItem.ClassifyNameThird)
  968. }
  969. //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  970. if reportItem.ClassifyNameFirst == "晨报" || reportItem.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  971. //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  972. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  973. }
  974. //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  975. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  976. //}
  977. //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  978. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  979. //}
  980. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  981. coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  982. if coverImg == "" {
  983. coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  984. }
  985. reportItem.ReportImgUrl = coverImg
  986. reportItem.VideoImg = reportItem.ReportImgUrl
  987. if reportItem.HasChapter == 1 {
  988. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  989. // 查询当前晨报的所有音频
  990. if vList, ok := videoMap[reportInfo.Id]; ok {
  991. for _, vd := range vList {
  992. vd.VideoImg = reportItem.ReportImgUrl
  993. }
  994. reportItem.VideoList = vList
  995. }
  996. reportItem.AuthOk = productAuthOk
  997. } else {
  998. if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  999. reportItem.AuthOk = wAuth
  1000. if wAuth {
  1001. // 查询当前晨报的所有音频
  1002. if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  1003. for _, vd := range vList {
  1004. vd.VideoImg = reportItem.ReportImgUrl
  1005. }
  1006. reportItem.VideoList = vList
  1007. }
  1008. }
  1009. }
  1010. }
  1011. } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyIdSecond]; ok && authOk {
  1012. if reportInfo.VideoUrl != "" {
  1013. videoTemp := new(response.VideoListItem)
  1014. videoTemp.VideoUrl = reportInfo.VideoUrl
  1015. videoTemp.VideoName = reportInfo.VideoName
  1016. if reportInfo.VideoName == "" {
  1017. videoTemp.VideoName = reportInfo.Title
  1018. }
  1019. videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  1020. videoTemp.VideoImg = reportItem.ReportImgUrl
  1021. reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  1022. }
  1023. reportItem.AuthOk = authOk
  1024. }
  1025. reportList = append(reportList, reportItem)
  1026. }
  1027. }
  1028. ret = new(response.ReportList)
  1029. ret.List = reportList
  1030. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1031. return
  1032. }
  1033. // GetCollectReportList 首页展示报告汇总列表
  1034. func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1035. var errMsg string
  1036. defer func() {
  1037. if err != nil {
  1038. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1039. }
  1040. }()
  1041. // 查询权限的基本信息
  1042. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1043. if err != nil {
  1044. errMsg = err.Error()
  1045. err = errors.New("查询权限出错")
  1046. return
  1047. }
  1048. if permissionInfo.ChartPermissionID == 0 {
  1049. err = errors.New("权限不存在")
  1050. return
  1051. }
  1052. // 除了晨报和周报以外的其他报告
  1053. classifyIdList, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1054. if err != nil {
  1055. errMsg = err.Error()
  1056. err = errors.New("查询权限对应的分类出错")
  1057. return
  1058. }
  1059. var firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList []int
  1060. {
  1061. classifyList, tmpErr := classify.GetListByClassifyIdList(classifyIdList)
  1062. if tmpErr != nil {
  1063. errMsg = tmpErr.Error()
  1064. err = errors.New("查询分类信息失败")
  1065. return
  1066. }
  1067. for _, v := range classifyList {
  1068. switch v.Level {
  1069. case 1:
  1070. firstClassifyIdList = append(firstClassifyIdList, v.Id)
  1071. case 2:
  1072. secondClassifyIdList = append(secondClassifyIdList, v.Id)
  1073. case 3:
  1074. thirdClassifyIdList = append(thirdClassifyIdList, v.Id)
  1075. }
  1076. }
  1077. }
  1078. var reportList []*response.ReportCollectListItem
  1079. list := response.ReportCollectListResp{}
  1080. var total int64
  1081. {
  1082. offset := (pageIndex - 1) * pageSize
  1083. reportList, err = report.GetReportCollectListByPermissionV1(chartPermissionId, firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList, offset, pageSize)
  1084. if err != nil {
  1085. errMsg = err.Error()
  1086. err = errors.New("查询报告信息出错")
  1087. return
  1088. }
  1089. listMap := make(map[string]*response.ReportCollectList)
  1090. for _, v := range reportList {
  1091. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1092. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1093. temp := new(response.ReportCollectList)
  1094. temp.Date = v.PublishTime.Format("2006-01-02")
  1095. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1096. }
  1097. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1098. }
  1099. for _, v := range listMap {
  1100. list = append(list, v)
  1101. }
  1102. total, err = report.GetReportCollectCountByPermissionV1(chartPermissionId, classifyIdList)
  1103. if err != nil {
  1104. errMsg = err.Error()
  1105. err = errors.New("查询报告总数出错")
  1106. return
  1107. }
  1108. if len(list) > 0 {
  1109. sort.Sort(list)
  1110. }
  1111. }
  1112. ret = new(response.ReportCollectResp)
  1113. ret.List = list
  1114. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1115. return
  1116. }
  1117. func GetCollectReportListBak(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1118. var errMsg string
  1119. defer func() {
  1120. if err != nil {
  1121. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1122. }
  1123. }()
  1124. // 查询权限的基本信息
  1125. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1126. if err != nil {
  1127. errMsg = err.Error()
  1128. err = errors.New("查询权限出错")
  1129. return
  1130. }
  1131. if permissionInfo.ChartPermissionID == 0 {
  1132. err = errors.New("权限不存在")
  1133. return
  1134. }
  1135. // 除了晨报和周报以外的其他报告
  1136. classifySecondIds, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1137. if err != nil {
  1138. errMsg = err.Error()
  1139. err = errors.New("查询权限对应的分类出错")
  1140. return
  1141. }
  1142. //var classifySecondIds []int
  1143. //if len(classifyNames) > 0 {
  1144. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1145. // if err != nil {
  1146. // errMsg = err.Error()
  1147. // err = errors.New("查询分类出错")
  1148. // return
  1149. // }
  1150. //}
  1151. // 查询晨报和周报相对应的章节ID
  1152. reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1153. if err != nil {
  1154. errMsg = err.Error()
  1155. err = errors.New("查询权限对应的章节出错")
  1156. return
  1157. }
  1158. var reportList []*response.ReportCollectListItem
  1159. list := response.ReportCollectListResp{}
  1160. var total int64
  1161. if len(reportChapterTypeIds) > 0 || len(classifySecondIds) > 0 {
  1162. offset := (pageIndex - 1) * pageSize
  1163. reportList, err = report.GetReportCollectListByPermission(classifySecondIds, reportChapterTypeIds, offset, pageSize)
  1164. if err != nil {
  1165. errMsg = err.Error()
  1166. err = errors.New("查询报告信息出错")
  1167. return
  1168. }
  1169. listMap := make(map[string]*response.ReportCollectList)
  1170. for _, v := range reportList {
  1171. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1172. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1173. temp := new(response.ReportCollectList)
  1174. temp.Date = v.PublishTime.Format("2006-01-02")
  1175. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1176. }
  1177. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1178. }
  1179. for _, v := range listMap {
  1180. list = append(list, v)
  1181. }
  1182. total, err = report.GetReportCollectCountByPermission(classifySecondIds, reportChapterTypeIds)
  1183. if err != nil {
  1184. errMsg = err.Error()
  1185. err = errors.New("查询报告总数出错")
  1186. return
  1187. }
  1188. if len(list) > 0 {
  1189. sort.Sort(list)
  1190. }
  1191. }
  1192. ret = new(response.ReportCollectResp)
  1193. ret.List = list
  1194. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1195. return
  1196. }
  1197. func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (ret *response.ReportSearchResp, err error) {
  1198. var errMsg string
  1199. defer func() {
  1200. if err != nil {
  1201. global.LOG.Critical(fmt.Sprintf("SearchReport: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1202. }
  1203. }()
  1204. //查询正常状态的分类
  1205. classifys, err := classify.GetSimpleAll()
  1206. if err != nil {
  1207. errMsg = err.Error()
  1208. err = errors.New("分类查询出错")
  1209. return
  1210. }
  1211. classifyIdList := make([]int, 0)
  1212. var classifyIdFirsts []int
  1213. classifyIdSeconds := []int{0}
  1214. for _, v := range classifys {
  1215. if v.ParentId == 0 {
  1216. classifyIdFirsts = append(classifyIdFirsts, v.Id)
  1217. } else {
  1218. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1219. }
  1220. classifyIdList = append(classifyIdList, v.Id)
  1221. }
  1222. keyWord = addAliasToKeyword(keyWord)
  1223. searchResp, total, err := elasticService.SearchReport(keyWord, classifyIdList, pageIndex, pageSize)
  1224. if err != nil {
  1225. errMsg = err.Error()
  1226. err = errors.New("查询失败")
  1227. return
  1228. }
  1229. var reportList []*response.ReportCollectListItem
  1230. if searchResp.Hits != nil {
  1231. for _, v := range searchResp.Hits.Hits {
  1232. temp := new(response.ReportCollectListItem)
  1233. itemJson, tmpErr := v.Source.MarshalJSON()
  1234. if tmpErr != nil {
  1235. errMsg = tmpErr.Error()
  1236. err = errors.New("解析出错")
  1237. return
  1238. }
  1239. reportItem := new(response.EsReportItem)
  1240. tmpErr = json.Unmarshal(itemJson, &reportItem)
  1241. if tmpErr != nil {
  1242. errMsg = tmpErr.Error()
  1243. err = errors.New("解析json出错")
  1244. return
  1245. }
  1246. temp.ReportId = reportItem.ReportId
  1247. temp.ReportChapterId = reportItem.ReportChapterId
  1248. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1249. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1250. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1251. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1252. temp.ClassifyId = reportItem.ClassifyId
  1253. temp.ClassifyName = reportItem.ClassifyName
  1254. temp.Title = reportItem.Title
  1255. temp.ContentSub = reportItem.BodyContent
  1256. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1257. if len(v.Highlight["Title"]) > 0 {
  1258. temp.Title = v.Highlight["Title"][0]
  1259. }
  1260. if len(v.Highlight["BodyContent"]) > 0 {
  1261. temp.ContentSub = v.Highlight["BodyContent"][0]
  1262. }
  1263. //if len(v.Highlight["Categories"]) > 0 {
  1264. // if temp.ClassifyNameSecond != "" {
  1265. // temp.ClassifyNameSecond = "<span style=\"color:#E3B377\">"+temp.ClassifyNameSecond+"</span>"
  1266. // }
  1267. // if temp.ClassifyNameFirst != "" {
  1268. // temp.ClassifyNameFirst = "<span style=\"color:#E3B377\">"+temp.ClassifyNameFirst+"</span>"
  1269. // }
  1270. //}
  1271. temp.ContentSub = GetReportContentSub(temp.ContentSub, false)
  1272. reportList = append(reportList, temp)
  1273. }
  1274. }
  1275. ret = new(response.ReportSearchResp)
  1276. ret.List = reportList
  1277. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1278. return
  1279. }
  1280. // GetTickerData 获取指标数据
  1281. func GetTickerData(user user.UserInfo, reportChapterId int) (ret *response.TickerData, err error) {
  1282. var errMsg string
  1283. defer func() {
  1284. if err != nil {
  1285. global.LOG.Critical(fmt.Sprintf("GetTickerData: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1286. }
  1287. }()
  1288. //查询章节类型
  1289. chapter, err := report_chapter.GetTypeIdById(reportChapterId)
  1290. if err != nil {
  1291. errMsg = err.Error()
  1292. err = errors.New("查询章节失败")
  1293. return
  1294. }
  1295. if chapter.ReportChapterId == 0 {
  1296. err = errors.New("章节不存在或者未发布")
  1297. return
  1298. }
  1299. tickers, err := report_chapter_ticker.GetTickerByChapterId(reportChapterId)
  1300. if err != nil {
  1301. errMsg = err.Error()
  1302. err = errors.New("查询章节指标失败")
  1303. return
  1304. }
  1305. var list []*response.TickerDataItem
  1306. if len(tickers) > 0 {
  1307. var tickerNames []string
  1308. for _, v := range tickers {
  1309. tickerNames = append(tickerNames, v.Ticker)
  1310. }
  1311. var dataList []*response.TickerDataItem
  1312. if chapter.TypeId == 17 {
  1313. dataList, err = daily_base_column.GetDataByBaseColumnTickers17(tickerNames)
  1314. } else {
  1315. dataList, err = daily_base_column.GetDataByBaseColumnTickers(tickerNames)
  1316. }
  1317. if err != nil {
  1318. errMsg = err.Error()
  1319. err = errors.New("查询指标数据失败")
  1320. return
  1321. }
  1322. chapterTypeInfo, tErr := report_chapter_type.GetTickerTitleByTypeId(chapter.TypeId)
  1323. if tErr != nil {
  1324. errMsg = tErr.Error()
  1325. err = errors.New("查询章节类型失败")
  1326. return
  1327. }
  1328. if len(dataList) >= 0 {
  1329. for _, v := range dataList {
  1330. temp := new(response.TickerDataItem)
  1331. temp.BaseColumnName = v.BaseColumnName
  1332. temp.Ticker = v.Ticker
  1333. temp.Date = v.Date
  1334. temp.TickerValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.TickerValue), 2)
  1335. temp.LastValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.LastValue), 2)
  1336. temp.MmValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.MmValue), 2)
  1337. temp.DdValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.DdValue), 2)
  1338. temp.WwValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.WwValue), 2)
  1339. list = append(list, temp)
  1340. }
  1341. }
  1342. tickerTitle := new(response.TickerTitleData)
  1343. tickerTitle.TickerTitle = chapterTypeInfo.TickerTitle
  1344. tickerTitle.ReportChapterTypeId = int(chapterTypeInfo.ReportChapterTypeId)
  1345. tickerTitle.ReportChapterTypeName = chapterTypeInfo.ReportChapterTypeName
  1346. tickerTitle.DataTableImage = fmt.Sprintf("http://hongze.oss-cn-shanghai.aliyuncs.com/data_table/%s.png", chapterTypeInfo.ReportChapterTypeKey)
  1347. ret = new(response.TickerData)
  1348. ret.List = list
  1349. ret.TickerTitle = tickerTitle
  1350. }
  1351. return
  1352. }
  1353. // GetReportContentSub 特殊处理contentSub
  1354. func GetReportContentSub(content string, scapeFlag bool) (contentSub string) {
  1355. if scapeFlag {
  1356. content = html.UnescapeString(content)
  1357. content = utils.TrimHtml(content) //只展示纯文本
  1358. }
  1359. contentSub = "<div style=\"-webkit-line-clamp: 3;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + content + "</div>"
  1360. return
  1361. }
  1362. // addAliasToKeyword 品种别名
  1363. func addAliasToKeyword(keyword string) string {
  1364. if keyword == "" {
  1365. return ""
  1366. }
  1367. keywordArr := make([]string, 0)
  1368. keywordArr = append(keywordArr, keyword)
  1369. if strings.Contains(keyword, "沥青") || strings.Contains(keyword, "BU") {
  1370. keywordArr = append(keywordArr, "沥青", "BU")
  1371. }
  1372. if strings.Contains(keyword, "MEG") || strings.Contains(keyword, "EG") || strings.Contains(keyword, "乙二醇") {
  1373. keywordArr = append(keywordArr, "MEG", "EG", "乙二醇")
  1374. }
  1375. if strings.Contains(keyword, "聚酯") || strings.Contains(keyword, "长丝") || strings.Contains(keyword, "短纤") || strings.Contains(keyword, "瓶片") {
  1376. keywordArr = append(keywordArr, "聚酯", "长丝", "短纤", "瓶片")
  1377. }
  1378. if strings.Contains(keyword, "纯苯") || strings.Contains(keyword, "苯乙烯") || strings.Contains(keyword, "EB") {
  1379. keywordArr = append(keywordArr, "纯苯", "苯乙烯", "EB")
  1380. }
  1381. if strings.Contains(keyword, "甲醇") || strings.Contains(keyword, "MA") {
  1382. keywordArr = append(keywordArr, "甲醇", "MA")
  1383. }
  1384. if strings.Contains(keyword, "橡胶") || strings.Contains(keyword, "RU") {
  1385. keywordArr = append(keywordArr, "橡胶", "RU")
  1386. }
  1387. if strings.Contains(keyword, "聚乙烯") || strings.Contains(keyword, "PP") || strings.Contains(keyword, "PE") {
  1388. keywordArr = append(keywordArr, "聚乙烯", "PP", "PE")
  1389. }
  1390. if strings.Contains(keyword, "玻璃") || strings.Contains(keyword, "纯碱") || strings.Contains(keyword, "FG") || strings.Contains(keyword, "SA") {
  1391. keywordArr = append(keywordArr, "玻璃", "纯碱", "FG", "SA")
  1392. }
  1393. keyword = strings.Join(keywordArr, ",")
  1394. return keyword
  1395. }
  1396. // GetReportPptImgListByReportIdAndReportChapterId 首页展示报告汇总列表
  1397. func GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId int) (list []string, err error) {
  1398. list = make([]string, 0)
  1399. reportPptImgList, err := report_ppt_img.GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId)
  1400. for _, v := range reportPptImgList {
  1401. list = append(list, v.ImgURL)
  1402. }
  1403. return
  1404. }
  1405. // GetVarietyReportList 大宗商品报告列表
  1406. func GetVarietyReportList(user user.UserInfo, classifyId, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1407. var errMsg string
  1408. defer func() {
  1409. if err != nil {
  1410. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1411. }
  1412. }()
  1413. // 判断用户状态是否是正常和永续
  1414. var productAuthOk bool
  1415. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1416. if err == utils.ErrNoRow {
  1417. err = nil
  1418. }
  1419. if err != nil {
  1420. errMsg = err.Error()
  1421. err = errors.New("查询用户购买产品出错")
  1422. return
  1423. }
  1424. if companyProduct != nil {
  1425. // 无FICC权限的客户不可见
  1426. if companyProduct.CompanyProductID > 0 {
  1427. // 已购或者试用用户可见
  1428. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1429. productAuthOk = true
  1430. }
  1431. }
  1432. }
  1433. // 查询权限的基本信息
  1434. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1435. if err != nil {
  1436. errMsg = err.Error()
  1437. err = errors.New("查询权限出错")
  1438. return
  1439. }
  1440. if permissionInfo.ChartPermissionID == 0 {
  1441. err = errors.New("权限不存在")
  1442. return
  1443. }
  1444. //分类ids
  1445. var allClassifySecondIds []int
  1446. var classifySecondIds []int
  1447. allClassifySecondIds, err = chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1448. if err != nil {
  1449. errMsg = err.Error()
  1450. err = errors.New("查询权限对应的分类出错")
  1451. return
  1452. }
  1453. //if len(classifyNames) > 0 {
  1454. // allClassifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1455. // if err != nil {
  1456. // errMsg = err.Error()
  1457. // err = errors.New("查询分类出错")
  1458. // return
  1459. // }
  1460. //}
  1461. //根据所选一级分类id查询二级分类
  1462. classifyChild, err := classify.GetChildByPid(classifyId)
  1463. if err != nil {
  1464. errMsg = err.Error()
  1465. err = errors.New("查询二级分类出错")
  1466. return
  1467. }
  1468. classifyMap := make(map[int]int, 0)
  1469. for _, c := range classifyChild {
  1470. classifyMap[c.Id] = c.Id
  1471. }
  1472. for _, id := range allClassifySecondIds {
  1473. if _, ok := classifyMap[id]; ok {
  1474. classifySecondIds = append(classifySecondIds, id)
  1475. }
  1476. }
  1477. listImgMap := make(map[int]string, 0)
  1478. for i := 0; i < len(classifyChild); i++ {
  1479. listImgMap[classifyChild[i].Id] = classifyChild[i].YbListImg
  1480. }
  1481. // 获取有效的权限id列表
  1482. var validPermissionIdList []int
  1483. if productAuthOk {
  1484. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1485. if err != nil && err != utils.ErrNoRow {
  1486. errMsg = err.Error()
  1487. err = errors.New("查询分类出错")
  1488. return
  1489. }
  1490. }
  1491. var authOk bool
  1492. if len(validPermissionIdList) > 0 {
  1493. checkLoop:
  1494. for _, validPerid := range validPermissionIdList {
  1495. if chartPermissionId == validPerid {
  1496. authOk = true
  1497. break checkLoop
  1498. }
  1499. }
  1500. }
  1501. //// 查询晨报和周报相对应的章节ID
  1502. //reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1503. //if err != nil {
  1504. // errMsg = err.Error()
  1505. // err = errors.New("查询权限对应的章节出错")
  1506. // return
  1507. //}
  1508. var reportList []*report.Report
  1509. var total int64
  1510. if len(classifySecondIds) > 0 {
  1511. if productAuthOk {
  1512. offset := (pageIndex - 1) * pageSize
  1513. reportList, err = report.GetCommoditiesReportCollectListByPermission(classifySecondIds, offset, pageSize)
  1514. if err != nil {
  1515. errMsg = err.Error()
  1516. err = errors.New("查询报告信息出错")
  1517. return
  1518. }
  1519. total, err = report.GetCommoditiesReportCollectCountByPermission(classifySecondIds)
  1520. if err != nil {
  1521. errMsg = err.Error()
  1522. err = errors.New("查询报告总数出错")
  1523. return
  1524. }
  1525. }
  1526. }
  1527. var list []*response.ReportListItem
  1528. for _, r := range reportList {
  1529. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1530. coverImg := listImgMap[r.ClassifyIdSecond]
  1531. if coverImg == "" {
  1532. coverImg = listImgMap[r.ClassifyIdFirst]
  1533. }
  1534. var VideoList []*response.VideoListItem
  1535. videoItem := response.VideoListItem{
  1536. VideoUrl: r.VideoUrl,
  1537. VideoName: r.VideoName,
  1538. VideoPlaySeconds: r.VideoPlaySeconds,
  1539. VideoImg: coverImg,
  1540. }
  1541. VideoList = append(VideoList, &videoItem)
  1542. stageStr := r.StageStr
  1543. if stageStr == "" {
  1544. stageStr = strconv.Itoa(r.Stage)
  1545. }
  1546. item := response.ReportListItem{
  1547. ReportId: r.Id,
  1548. ClassifyIdFirst: r.ClassifyIdFirst,
  1549. ClassifyNameFirst: r.ClassifyNameFirst,
  1550. ClassifyIdSecond: r.ClassifyIdSecond,
  1551. ClassifyNameSecond: r.ClassifyNameSecond,
  1552. Title: r.Title,
  1553. Abstract: r.Abstract,
  1554. Author: r.Author,
  1555. ReportImgUrl: coverImg,
  1556. PublishTime: r.PublishTime,
  1557. Stage: r.Stage,
  1558. VideoList: VideoList,
  1559. AuthOk: authOk,
  1560. TitleInfo: fmt.Sprintf("【第%s期|FICC|%s】", stageStr, r.ClassifyNameSecond),
  1561. }
  1562. list = append(list, &item)
  1563. }
  1564. ret = new(response.ReportList)
  1565. ret.List = list
  1566. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1567. return
  1568. }
  1569. // GetMinClassify
  1570. // @Description: 获取最小分类ID
  1571. // @author: Roc
  1572. // @datetime 2024-06-20 09:23:19
  1573. // @param reportInfo *models.Report
  1574. // @return minClassifyId int
  1575. // @return minClassifyName string
  1576. // @return err error
  1577. func GetMinClassify(reportInfo *report.Report) (minClassifyId int, minClassifyName string, err error) {
  1578. defer func() {
  1579. if err != nil {
  1580. global.FILE_LOG.Error("获取最小分类ID失败,报告ID:%d,Err:%s", reportInfo.Id, err.Error())
  1581. }
  1582. }()
  1583. minClassifyId = reportInfo.ClassifyIdThird
  1584. minClassifyName = reportInfo.ClassifyNameThird
  1585. if minClassifyId <= 0 {
  1586. minClassifyId = reportInfo.ClassifyIdSecond
  1587. minClassifyName = reportInfo.ClassifyNameSecond
  1588. }
  1589. if minClassifyId <= 0 {
  1590. minClassifyId = reportInfo.ClassifyIdFirst
  1591. minClassifyName = reportInfo.ClassifyNameFirst
  1592. }
  1593. if minClassifyId <= 0 {
  1594. err = errors.New("分类异常")
  1595. }
  1596. return
  1597. }
  1598. // GetCommoditiesReportList 获取大宗商品报告列表
  1599. //func GetCommoditiesReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1600. // var errMsg string
  1601. // defer func() {
  1602. // if err != nil {
  1603. // global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1604. // }
  1605. // }()
  1606. //
  1607. // // 判断用户状态是否是正常和永续
  1608. // var productAuthOk bool
  1609. // companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1610. // if err == utils.ErrNoRow {
  1611. // err = nil
  1612. // }
  1613. // if err != nil {
  1614. // errMsg = err.Error()
  1615. // err = errors.New("查询用户购买产品出错")
  1616. // return
  1617. // }
  1618. // if companyProduct != nil {
  1619. // // 无FICC权限的客户不可见
  1620. // if companyProduct.CompanyProductID > 0 {
  1621. // // 已购或者试用用户可见
  1622. // if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1623. // productAuthOk = true
  1624. // }
  1625. // }
  1626. // }
  1627. //
  1628. // // 查询权限的基本信息
  1629. // permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1630. // if err != nil {
  1631. // errMsg = err.Error()
  1632. // err = errors.New("查询权限出错")
  1633. // return
  1634. // }
  1635. //
  1636. // if permissionInfo.ChartPermissionID == 0 {
  1637. // err = errors.New("权限不存在")
  1638. // return
  1639. // }
  1640. // // 除了晨报和周报以外的其他报告
  1641. // classifyNames, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "two_week")
  1642. // if err != nil {
  1643. // errMsg = err.Error()
  1644. // err = errors.New("查询权限对应的分类出错")
  1645. // return
  1646. // }
  1647. //
  1648. // var classifySecondIds []int
  1649. // if len(classifyNames) > 0 {
  1650. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1651. // if err != nil {
  1652. // errMsg = err.Error()
  1653. // err = errors.New("查询分类出错")
  1654. // return
  1655. // }
  1656. // }
  1657. //
  1658. // var condition string
  1659. // pars := make([]interface{}, 0)
  1660. //
  1661. // classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  1662. // if err != nil {
  1663. // errMsg = err.Error()
  1664. // err = errors.New("分类查询出错")
  1665. // return
  1666. // }
  1667. // if classifyParent.Id == 0 {
  1668. // err = errors.New("该分类不存在")
  1669. // return
  1670. // }
  1671. // condition = `classify_id_first = ? and state IN (2, 6)`
  1672. // pars = append(pars, classifyIdFirst)
  1673. // permissionMap := make(map[string][]int)
  1674. // checkPermissionMap := make(map[string]bool)
  1675. // permissionImageMap := make(map[string]string)
  1676. // chartPermissionImageMap := make(map[int]string)
  1677. // var classifyIdSeconds []int
  1678. // //var reportImgUrl string
  1679. //
  1680. // chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  1681. // if err != nil {
  1682. // errMsg = err.Error()
  1683. // err = errors.New("分类查询出错")
  1684. // return
  1685. // }
  1686. //
  1687. // if len(chartPermissionList) > 0 {
  1688. // for _, v := range chartPermissionList {
  1689. // chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  1690. // }
  1691. // }
  1692. //
  1693. // if classifyIdSecond > 0 && keyWord == "" {
  1694. // classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  1695. // if tErr != nil {
  1696. // errMsg = tErr.Error()
  1697. // err = errors.New("分类查询出错")
  1698. // return
  1699. // }
  1700. // if classifyInfo.Id == 0 {
  1701. // err = errors.New("该二级分类不存在")
  1702. // return
  1703. // }
  1704. //
  1705. // condition += " AND classify_id_second = ?"
  1706. // pars = append(pars, classifyIdSecond)
  1707. // //查询二级分类对应的权限
  1708. // permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyInfo.ClassifyName)
  1709. // if tErr != nil {
  1710. // errMsg = tErr.Error()
  1711. // err = errors.New("分类权限查询出错")
  1712. // return
  1713. // }
  1714. // permissionMap[classifyInfo.ClassifyName] = permissionIds
  1715. // //if len(permissionIds) > 0 {
  1716. // // for _, v := range permissionIds {
  1717. // // reportImgUrl = chartPermissionImageMap[v]
  1718. // // }
  1719. // //}
  1720. //
  1721. // } else {
  1722. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1723. // //reportImgUrl = chartPermissionImageMap[1]
  1724. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1725. // }
  1726. //
  1727. // chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  1728. // if tErr != nil {
  1729. // errMsg = tErr.Error()
  1730. // err = errors.New("分类权限查询出错")
  1731. // return
  1732. // }
  1733. //
  1734. // if len(chartPermissions) > 0 {
  1735. // for _, v := range chartPermissions {
  1736. // permissionMap[v.KeyWord] = append(permissionMap[v.KeyWord], v.ChartPermissionId)
  1737. // permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  1738. // }
  1739. // }
  1740. //
  1741. // //获取二级分类的所有头像
  1742. // classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  1743. // if tErr != nil {
  1744. // errMsg = tErr.Error()
  1745. // err = errors.New("二级分类查询出错")
  1746. // return
  1747. // }
  1748. //
  1749. // for _, v := range classifyList {
  1750. // classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1751. // }
  1752. //
  1753. // if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  1754. // ret = new(response.ReportList)
  1755. // ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  1756. // return
  1757. // }
  1758. // condition += ` AND classify_id_second IN ? `
  1759. // pars = append(pars, classifyIdSeconds)
  1760. // }
  1761. //
  1762. // // 获取有效的权限id列表
  1763. // var validPermissionIdList []int
  1764. // if productAuthOk {
  1765. // validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1766. // if err != nil && err != utils.ErrNoRow {
  1767. // errMsg = err.Error()
  1768. // err = errors.New("查询分类出错")
  1769. // return
  1770. // }
  1771. // }
  1772. //
  1773. // if len(validPermissionIdList) > 0 {
  1774. // for classifyName, perIds := range permissionMap {
  1775. // checkLoop:
  1776. // for _, checkId := range perIds {
  1777. // for _, validPerid := range validPermissionIdList {
  1778. // if checkId == validPerid {
  1779. // checkPermissionMap[classifyName] = true
  1780. // break checkLoop
  1781. // }
  1782. // }
  1783. // }
  1784. // }
  1785. // }
  1786. //
  1787. // var total int64
  1788. // var list []*report.Report
  1789. // if keyWord == "" {
  1790. // offset := (pageIndex - 1) * pageSize
  1791. // list, err = report.GetReportList(condition, pars, offset, pageSize)
  1792. // if err != nil {
  1793. // errMsg = err.Error()
  1794. // err = errors.New("报告查询出错")
  1795. // return
  1796. // }
  1797. // total, err = report.GetReportListCount(condition, pars)
  1798. // if err != nil {
  1799. // errMsg = err.Error()
  1800. // err = errors.New("查询报告总数出错")
  1801. // return
  1802. // }
  1803. // } else {
  1804. // if classifyIdSecond > 0 {
  1805. // classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  1806. // }
  1807. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1808. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1809. // }
  1810. // searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  1811. // if tErr != nil {
  1812. // errMsg = tErr.Error()
  1813. // err = errors.New("查询失败")
  1814. // return
  1815. // }
  1816. // total = int64(total1)
  1817. // if searchResp.Hits != nil && total > 0 {
  1818. // var reportIds []int
  1819. // for _, v := range searchResp.Hits.Hits {
  1820. // temp := new(report.Report)
  1821. // itemJson, tmpErr := v.Source.MarshalJSON()
  1822. // if tmpErr != nil {
  1823. // errMsg = tmpErr.Error()
  1824. // err = errors.New("解析出错")
  1825. // return
  1826. // }
  1827. // reportItem := new(response.EsReportItem)
  1828. // tmpErr = json.Unmarshal(itemJson, &reportItem)
  1829. // if tmpErr != nil {
  1830. // errMsg = tmpErr.Error()
  1831. // err = errors.New("解析json出错")
  1832. // return
  1833. // }
  1834. // temp.Id = reportItem.ReportId
  1835. // reportIds = append(reportIds, reportItem.ReportId)
  1836. // temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1837. // temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1838. // temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1839. // temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1840. // if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  1841. // temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  1842. // }
  1843. // temp.Abstract = reportItem.Abstract
  1844. // stageInt, _ := strconv.Atoi(reportItem.StageStr)
  1845. // temp.Stage = stageInt
  1846. // temp.StageStr = reportItem.StageStr
  1847. // temp.Title = reportItem.Title
  1848. // temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1849. // if len(v.Highlight["Title"]) > 0 {
  1850. // temp.Title = v.Highlight["Title"][0]
  1851. // }
  1852. // if len(v.Highlight["Abstract"]) > 0 {
  1853. // temp.Abstract = v.Highlight["Abstract"][0]
  1854. // }
  1855. // if len(v.Highlight["StageStr"]) > 0 {
  1856. // temp.StageStr = v.Highlight["StageStr"][0]
  1857. // }
  1858. // list = append(list, temp)
  1859. // }
  1860. // reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  1861. // if tmpErr != nil {
  1862. // errMsg = tmpErr.Error()
  1863. // err = errors.New("查询报告出错")
  1864. // return
  1865. // }
  1866. // reportListMap := make(map[int]*report.Report)
  1867. // for _, temp := range reportInfoList {
  1868. // reportListMap[temp.Id] = temp
  1869. // }
  1870. // for k, reportDetail := range list {
  1871. // if v, ok := reportListMap[reportDetail.Id]; ok {
  1872. // list[k].CreateTime = v.CreateTime
  1873. // }
  1874. // }
  1875. // }
  1876. // }
  1877. //
  1878. // var reportList []*response.ReportListItem
  1879. // if len(list) > 0 {
  1880. // // 封面图
  1881. // classifyList, e := classify.GetClassifyList()
  1882. // if e != nil {
  1883. // err = errors.New("获取报告分类列表失败" + e.Error())
  1884. // return
  1885. // }
  1886. // listImgMap := make(map[int]string, 0)
  1887. // classifyLen := len(classifyList)
  1888. // for i := 0; i < classifyLen; i++ {
  1889. // listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  1890. // }
  1891. //
  1892. // var videoReportIds []int
  1893. // videoMap := make(map[int][]*response.VideoListItem)
  1894. // weekAuthMap := make(map[int]bool)
  1895. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1896. // //获取晨报的音频列表
  1897. // videoMap, _, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1898. // if err != nil {
  1899. // return
  1900. // }
  1901. // } else if classifyParent.ClassifyName == "周报" {
  1902. // //查询所有权限typeID
  1903. // //如果存在可以查看的章节ID
  1904. // for _, reportInfo := range list {
  1905. // videoReportIds = append(videoReportIds, reportInfo.Id)
  1906. // }
  1907. // // 判断周报权限\查询周报的音频列表
  1908. // videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1909. // if err != nil {
  1910. // return
  1911. // }
  1912. // }
  1913. // // 以下分类图标特殊处理 =_=!
  1914. // //reportImgMap := map[string]string{
  1915. // // "晨报": "report_list_chen.png",
  1916. // // "周报": "report_list_zhou.png",
  1917. // // "月报": "report_list_yue.png",
  1918. // // "大事点评": "report_list_dashidianping.png",
  1919. // // "会议纪要": "report_list_huiyijiyao.png",
  1920. // // "年报合集": "report_list_nianbaoheji.png",
  1921. // //}
  1922. // for _, reportInfo := range list {
  1923. // reportItem := new(response.ReportListItem)
  1924. // reportItem.ReportId = reportInfo.Id
  1925. // // 样式限制行数
  1926. // reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  1927. // reportItem.PublishTime = reportInfo.PublishTime
  1928. // reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  1929. // reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  1930. // reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  1931. // reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  1932. // reportItem.Stage = reportInfo.Stage
  1933. // reportItem.Abstract = reportInfo.Abstract
  1934. // if reportInfo.Abstract != "" {
  1935. // reportItem.Abstract = "<div style=\"overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\">" + reportInfo.Abstract + "</div>"
  1936. // }
  1937. // reportItem.Author = reportInfo.Author
  1938. // stageStr := reportInfo.StageStr
  1939. // if stageStr == "" {
  1940. // stageStr = strconv.Itoa(reportInfo.Stage)
  1941. // }
  1942. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  1943. // //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  1944. // if reportInfo.ClassifyNameFirst == "晨报" || reportInfo.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  1945. // //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  1946. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  1947. // }
  1948. // //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  1949. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  1950. // //}
  1951. // //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  1952. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  1953. // //}
  1954. // // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1955. // coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  1956. // if coverImg == "" {
  1957. // coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  1958. // }
  1959. // reportItem.ReportImgUrl = coverImg
  1960. //
  1961. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1962. // // 查询当前晨报的所有音频
  1963. // if vList, ok := videoMap[reportInfo.Id]; ok {
  1964. // for _, vd := range vList {
  1965. // vd.VideoImg = reportItem.ReportImgUrl
  1966. // }
  1967. // reportItem.VideoList = vList
  1968. // }
  1969. // reportItem.AuthOk = productAuthOk
  1970. // } else if classifyParent.ClassifyName == "周报" {
  1971. // if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  1972. // reportItem.AuthOk = wAuth
  1973. // if wAuth {
  1974. // // 查询当前晨报的所有音频
  1975. // if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  1976. // for _, vd := range vList {
  1977. // vd.VideoImg = reportItem.ReportImgUrl
  1978. // }
  1979. // reportItem.VideoList = vList
  1980. // }
  1981. // }
  1982. // }
  1983. // } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyNameSecond]; ok && authOk {
  1984. // if reportInfo.VideoUrl != "" {
  1985. // videoTemp := new(response.VideoListItem)
  1986. // videoTemp.VideoUrl = reportInfo.VideoUrl
  1987. // videoTemp.VideoName = reportInfo.VideoName
  1988. // if reportInfo.VideoName == "" {
  1989. // videoTemp.VideoName = reportInfo.Title
  1990. // }
  1991. // videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  1992. // videoTemp.VideoImg = reportItem.ReportImgUrl
  1993. // reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  1994. // }
  1995. // reportItem.AuthOk = authOk
  1996. // }
  1997. //
  1998. // reportList = append(reportList, reportItem)
  1999. // }
  2000. //
  2001. // }
  2002. // ret = new(response.ReportList)
  2003. // ret.List = reportList
  2004. // ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  2005. // return
  2006. //}