report.go 69 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107
  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. }
  598. // 收藏
  599. collectionId, e := collection.GetUserCollectByItem(int(userinfo.UserID), collection.CollectionTypeReport, reportId, 0)
  600. if e != nil {
  601. err = e
  602. return
  603. }
  604. reportDetail.CollectionId = collectionId
  605. // 绑定的路演视频
  606. roadVideo, e := yb_road_video.GetItemByReportId(reportId)
  607. if e != nil && e != utils.ErrNoRow {
  608. err = e
  609. return
  610. }
  611. if roadVideo != nil && roadVideo.RoadVideoID > 0 {
  612. reportDetail.RoadVideoId = roadVideo.RoadVideoID
  613. }
  614. return
  615. }
  616. // CheckReportPermission 验证用户查看报告的权限
  617. func CheckReportPermission(userInfo user.UserInfo, reportId int, productAuthOk bool) (authOk bool, permissionCheckInfo response.PermissionCheckInfo, err error) {
  618. var permissionIds []int
  619. if productAuthOk {
  620. permissionIds, err = chart_permission_chapter_mapping.GetPermissionIdsByReportId(reportId, "rddp")
  621. if err != nil && err != utils.ErrNoRow {
  622. return
  623. }
  624. }
  625. authOk, permissionCheckInfo, _, err = company.GetCheckPermission(userInfo.CompanyID, int(userInfo.UserID), permissionIds)
  626. return
  627. }
  628. // GetReportList 获取报告列表
  629. func GetReportList(user user.UserInfo, keyWord string, classifyIdFirst, classifyIdSecond, pageIndex, pageSize, classifyMenuId int) (ret *response.ReportList, err error) {
  630. var errMsg string
  631. defer func() {
  632. if err != nil {
  633. global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  634. }
  635. }()
  636. // 判断用户状态是否是正常和永续
  637. var productAuthOk bool
  638. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  639. if err == utils.ErrNoRow {
  640. err = nil
  641. }
  642. if err != nil {
  643. errMsg = err.Error()
  644. err = errors.New("查询用户购买产品出错")
  645. return
  646. }
  647. if companyProduct != nil {
  648. // 无FICC权限的客户不可见
  649. if companyProduct.CompanyProductID > 0 {
  650. // 已购或者试用用户可见
  651. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  652. productAuthOk = true
  653. }
  654. }
  655. }
  656. var condition string
  657. pars := make([]interface{}, 0)
  658. classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  659. if err != nil {
  660. errMsg = err.Error()
  661. err = errors.New("分类查询出错")
  662. return
  663. }
  664. if classifyParent.Id == 0 {
  665. err = errors.New("该分类不存在")
  666. return
  667. }
  668. condition = `classify_id_first = ? and state IN (2, 6)`
  669. pars = append(pars, classifyIdFirst)
  670. // 子目录
  671. menuClassifyIds := make([]int, 0)
  672. menuClassifyLen := 0
  673. if classifyMenuId > 0 {
  674. ids, e := classify_menu.GetClassifyIdsByMenuId(classifyMenuId)
  675. if e != nil {
  676. err = errors.New("获取子目录关联分类信息失败, Err: " + e.Error())
  677. return
  678. }
  679. menuClassifyIds = ids
  680. menuClassifyLen = len(menuClassifyIds)
  681. if menuClassifyLen == 0 {
  682. condition += ` AND 1 = 2`
  683. }
  684. }
  685. permissionMap := make(map[int][]int)
  686. checkPermissionMap := make(map[int]bool)
  687. //permissionImageMap := make(map[string]string)
  688. chartPermissionImageMap := make(map[int]string)
  689. var classifyIdSeconds []int
  690. //var reportImgUrl string
  691. chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  692. if err != nil {
  693. errMsg = err.Error()
  694. err = errors.New("分类查询出错")
  695. return
  696. }
  697. if len(chartPermissionList) > 0 {
  698. for _, v := range chartPermissionList {
  699. chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  700. }
  701. }
  702. if classifyIdSecond > 0 && keyWord == "" {
  703. classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  704. if tErr != nil {
  705. errMsg = tErr.Error()
  706. err = errors.New("分类查询出错")
  707. return
  708. }
  709. if classifyInfo.Id == 0 {
  710. err = errors.New("该二级分类不存在")
  711. return
  712. }
  713. condition += " AND classify_id_second = ?"
  714. pars = append(pars, classifyIdSecond)
  715. //查询二级分类对应的权限
  716. permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyIdSecond)
  717. if tErr != nil {
  718. errMsg = tErr.Error()
  719. err = errors.New("分类权限查询出错")
  720. return
  721. }
  722. permissionMap[classifyInfo.Id] = permissionIds
  723. //if len(permissionIds) > 0 {
  724. // for _, v := range permissionIds {
  725. // reportImgUrl = chartPermissionImageMap[v]
  726. // }
  727. //}
  728. } else {
  729. if classifyParent.HasChild == 0 {
  730. //reportImgUrl = chartPermissionImageMap[1]
  731. classifyIdSeconds = append(classifyIdSeconds, 0)
  732. }
  733. chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  734. if tErr != nil {
  735. errMsg = tErr.Error()
  736. err = errors.New("分类权限查询出错")
  737. return
  738. }
  739. if len(chartPermissions) > 0 {
  740. for _, v := range chartPermissions {
  741. permissionMap[v.ClassifyId] = append(permissionMap[v.ClassifyId], v.ChartPermissionId)
  742. //permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  743. }
  744. }
  745. //获取二级分类的所有头像
  746. classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  747. if tErr != nil {
  748. errMsg = tErr.Error()
  749. err = errors.New("二级分类查询出错")
  750. return
  751. }
  752. // 子目录
  753. if menuClassifyLen > 0 {
  754. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  755. } else {
  756. for _, v := range classifyList {
  757. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  758. }
  759. }
  760. if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  761. ret = new(response.ReportList)
  762. ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  763. return
  764. }
  765. condition += ` AND classify_id_second IN ? `
  766. pars = append(pars, classifyIdSeconds)
  767. }
  768. // 获取有效的权限id列表
  769. var validPermissionIdList []int
  770. if productAuthOk {
  771. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  772. if err != nil && err != utils.ErrNoRow {
  773. errMsg = err.Error()
  774. err = errors.New("查询分类出错")
  775. return
  776. }
  777. }
  778. if len(validPermissionIdList) > 0 {
  779. for cid, perIds := range permissionMap {
  780. checkLoop:
  781. for _, checkId := range perIds {
  782. for _, validPerid := range validPermissionIdList {
  783. if checkId == validPerid {
  784. checkPermissionMap[cid] = true
  785. break checkLoop
  786. }
  787. }
  788. }
  789. }
  790. }
  791. var total int64
  792. var list []*report.Report
  793. if keyWord == "" {
  794. offset := (pageIndex - 1) * pageSize
  795. list, err = report.GetReportList(condition, pars, offset, pageSize)
  796. if err != nil {
  797. errMsg = err.Error()
  798. err = errors.New("报告查询出错")
  799. return
  800. }
  801. total, err = report.GetReportListCount(condition, pars)
  802. if err != nil {
  803. errMsg = err.Error()
  804. err = errors.New("查询报告总数出错")
  805. return
  806. }
  807. } else {
  808. if classifyIdSecond > 0 {
  809. classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  810. }
  811. if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  812. classifyIdSeconds = append(classifyIdSeconds, 0)
  813. }
  814. // 子目录
  815. if menuClassifyLen > 0 {
  816. classifyIdSeconds = append(classifyIdSeconds, menuClassifyIds...)
  817. }
  818. searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  819. if tErr != nil {
  820. errMsg = tErr.Error()
  821. err = errors.New("查询失败")
  822. return
  823. }
  824. total = int64(total1)
  825. if searchResp.Hits != nil && total > 0 {
  826. var reportIds []int
  827. for _, v := range searchResp.Hits.Hits {
  828. temp := new(report.Report)
  829. itemJson, tmpErr := v.Source.MarshalJSON()
  830. if tmpErr != nil {
  831. errMsg = tmpErr.Error()
  832. err = errors.New("解析出错")
  833. return
  834. }
  835. reportItem := new(response.EsReportItem)
  836. tmpErr = json.Unmarshal(itemJson, &reportItem)
  837. if tmpErr != nil {
  838. errMsg = tmpErr.Error()
  839. err = errors.New("解析json出错")
  840. return
  841. }
  842. temp.Id = reportItem.ReportId
  843. reportIds = append(reportIds, reportItem.ReportId)
  844. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  845. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  846. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  847. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  848. if reportItem.ClassifyIdSecond > 0 && reportItem.ClassifyIdSecond != reportItem.ClassifyId {
  849. temp.ClassifyIdThird = reportItem.ClassifyId
  850. temp.ClassifyNameThird = reportItem.ClassifyName
  851. }
  852. if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  853. temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  854. }
  855. temp.Abstract = reportItem.Abstract
  856. stageInt, _ := strconv.Atoi(reportItem.StageStr)
  857. temp.Stage = stageInt
  858. temp.StageStr = reportItem.StageStr
  859. temp.Title = reportItem.Title
  860. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  861. if len(v.Highlight["Title"]) > 0 {
  862. temp.Title = v.Highlight["Title"][0]
  863. }
  864. if len(v.Highlight["Abstract"]) > 0 {
  865. temp.Abstract = v.Highlight["Abstract"][0]
  866. }
  867. if len(v.Highlight["StageStr"]) > 0 {
  868. temp.StageStr = v.Highlight["StageStr"][0]
  869. }
  870. list = append(list, temp)
  871. }
  872. reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  873. if tmpErr != nil {
  874. errMsg = tmpErr.Error()
  875. err = errors.New("查询报告出错")
  876. return
  877. }
  878. reportListMap := make(map[int]*report.Report)
  879. for _, temp := range reportInfoList {
  880. reportListMap[temp.Id] = temp
  881. }
  882. for k, reportDetail := range list {
  883. if v, ok := reportListMap[reportDetail.Id]; ok {
  884. list[k].CreateTime = v.CreateTime
  885. }
  886. }
  887. }
  888. }
  889. var reportList []*response.ReportListItem
  890. if len(list) > 0 {
  891. // 封面图
  892. classifyList, e := classify.GetClassifyList()
  893. if e != nil {
  894. err = errors.New("获取报告分类列表失败" + e.Error())
  895. return
  896. }
  897. listImgMap := make(map[int]string, 0)
  898. classifyNameMap := make(map[int]string, 0)
  899. classifyLen := len(classifyList)
  900. for i := 0; i < classifyLen; i++ {
  901. listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  902. classifyNameMap[classifyList[i].Id] = classifyList[i].ClassifyName
  903. }
  904. var videoReportIds []int
  905. videoMap := make(map[int][]*response.VideoListItem)
  906. weekAuthMap := make(map[int]bool)
  907. // 判断周报权限\查询章节报告的音频列表
  908. videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list, user.UserID)
  909. if err != nil {
  910. return
  911. }
  912. // 如果是晨报,那么就要过滤掉weekAuthMap的授权
  913. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  914. weekAuthMap = map[int]bool{}
  915. } else {
  916. //查询所有权限typeID
  917. //如果存在可以查看的章节ID
  918. for _, reportInfo := range list {
  919. if reportInfo.HasChapter == 1 {
  920. videoReportIds = append(videoReportIds, reportInfo.Id)
  921. }
  922. }
  923. }
  924. // 以下分类图标特殊处理 =_=!
  925. //reportImgMap := map[string]string{
  926. // "晨报": "report_list_chen.png",
  927. // "周报": "report_list_zhou.png",
  928. // "月报": "report_list_yue.png",
  929. // "大事点评": "report_list_dashidianping.png",
  930. // "会议纪要": "report_list_huiyijiyao.png",
  931. // "年报合集": "report_list_nianbaoheji.png",
  932. //}
  933. for _, reportInfo := range list {
  934. reportItem := new(response.ReportListItem)
  935. reportItem.ReportId = reportInfo.Id
  936. reportItem.HasChapter = reportInfo.HasChapter
  937. reportItem.VideoUrl = reportInfo.VideoUrl
  938. reportItem.VideoName = reportInfo.VideoName
  939. reportItem.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  940. // 样式限制行数
  941. reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  942. reportItem.PublishTime = reportInfo.PublishTime
  943. //reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  944. //reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  945. reportItem.ClassifyNameFirst = classifyNameMap[reportInfo.ClassifyIdFirst]
  946. reportItem.ClassifyNameSecond = classifyNameMap[reportInfo.ClassifyIdSecond]
  947. reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  948. reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  949. reportItem.ClassifyIdThird = reportInfo.ClassifyIdThird
  950. reportItem.ClassifyNameThird = reportInfo.ClassifyNameThird
  951. reportItem.Stage = reportInfo.Stage
  952. reportItem.Abstract = reportInfo.Abstract
  953. if reportInfo.Abstract != "" {
  954. 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>"
  955. }
  956. reportItem.Author = reportInfo.Author
  957. stageStr := reportInfo.StageStr
  958. if stageStr == "" {
  959. stageStr = strconv.Itoa(reportInfo.Stage)
  960. }
  961. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  962. if reportItem.ClassifyNameThird != `` {
  963. reportItem.TitleInfo = fmt.Sprintf("%s|%s】", reportItem.TitleInfo, reportItem.ClassifyNameThird)
  964. }
  965. //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  966. if reportItem.ClassifyNameFirst == "晨报" || reportItem.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  967. //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  968. reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  969. }
  970. //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  971. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  972. //}
  973. //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  974. // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  975. //}
  976. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  977. coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  978. if coverImg == "" {
  979. coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  980. }
  981. reportItem.ReportImgUrl = coverImg
  982. reportItem.VideoImg = reportItem.ReportImgUrl
  983. if reportItem.HasChapter == 1 {
  984. if classifyParent.ClassifyName == "晨报" && productAuthOk {
  985. // 查询当前晨报的所有音频
  986. if vList, ok := videoMap[reportInfo.Id]; ok {
  987. for _, vd := range vList {
  988. vd.VideoImg = reportItem.ReportImgUrl
  989. }
  990. reportItem.VideoList = vList
  991. }
  992. reportItem.AuthOk = productAuthOk
  993. } else {
  994. if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  995. reportItem.AuthOk = wAuth
  996. if wAuth {
  997. // 查询当前晨报的所有音频
  998. if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  999. for _, vd := range vList {
  1000. vd.VideoImg = reportItem.ReportImgUrl
  1001. }
  1002. reportItem.VideoList = vList
  1003. }
  1004. }
  1005. }
  1006. }
  1007. } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyIdSecond]; ok && authOk {
  1008. if reportInfo.VideoUrl != "" {
  1009. videoTemp := new(response.VideoListItem)
  1010. videoTemp.VideoUrl = reportInfo.VideoUrl
  1011. videoTemp.VideoName = reportInfo.VideoName
  1012. if reportInfo.VideoName == "" {
  1013. videoTemp.VideoName = reportInfo.Title
  1014. }
  1015. videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  1016. videoTemp.VideoImg = reportItem.ReportImgUrl
  1017. reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  1018. }
  1019. reportItem.AuthOk = authOk
  1020. }
  1021. reportList = append(reportList, reportItem)
  1022. }
  1023. }
  1024. ret = new(response.ReportList)
  1025. ret.List = reportList
  1026. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1027. return
  1028. }
  1029. // GetCollectReportList 首页展示报告汇总列表
  1030. func GetCollectReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1031. var errMsg string
  1032. defer func() {
  1033. if err != nil {
  1034. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1035. }
  1036. }()
  1037. // 查询权限的基本信息
  1038. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1039. if err != nil {
  1040. errMsg = err.Error()
  1041. err = errors.New("查询权限出错")
  1042. return
  1043. }
  1044. if permissionInfo.ChartPermissionID == 0 {
  1045. err = errors.New("权限不存在")
  1046. return
  1047. }
  1048. // 除了晨报和周报以外的其他报告
  1049. classifyIdList, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1050. if err != nil {
  1051. errMsg = err.Error()
  1052. err = errors.New("查询权限对应的分类出错")
  1053. return
  1054. }
  1055. var firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList []int
  1056. {
  1057. classifyList, tmpErr := classify.GetListByClassifyIdList(classifyIdList)
  1058. if tmpErr != nil {
  1059. errMsg = tmpErr.Error()
  1060. err = errors.New("查询分类信息失败")
  1061. return
  1062. }
  1063. for _, v := range classifyList {
  1064. switch v.Level {
  1065. case 1:
  1066. firstClassifyIdList = append(firstClassifyIdList, v.Id)
  1067. case 2:
  1068. secondClassifyIdList = append(secondClassifyIdList, v.Id)
  1069. case 3:
  1070. thirdClassifyIdList = append(thirdClassifyIdList, v.Id)
  1071. }
  1072. }
  1073. }
  1074. var reportList []*response.ReportCollectListItem
  1075. list := response.ReportCollectListResp{}
  1076. var total int64
  1077. {
  1078. offset := (pageIndex - 1) * pageSize
  1079. reportList, err = report.GetReportCollectListByPermissionV1(chartPermissionId, firstClassifyIdList, secondClassifyIdList, thirdClassifyIdList, offset, pageSize)
  1080. if err != nil {
  1081. errMsg = err.Error()
  1082. err = errors.New("查询报告信息出错")
  1083. return
  1084. }
  1085. listMap := make(map[string]*response.ReportCollectList)
  1086. for _, v := range reportList {
  1087. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1088. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1089. temp := new(response.ReportCollectList)
  1090. temp.Date = v.PublishTime.Format("2006-01-02")
  1091. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1092. }
  1093. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1094. }
  1095. for _, v := range listMap {
  1096. list = append(list, v)
  1097. }
  1098. total, err = report.GetReportCollectCountByPermissionV1(chartPermissionId, classifyIdList)
  1099. if err != nil {
  1100. errMsg = err.Error()
  1101. err = errors.New("查询报告总数出错")
  1102. return
  1103. }
  1104. if len(list) > 0 {
  1105. sort.Sort(list)
  1106. }
  1107. }
  1108. ret = new(response.ReportCollectResp)
  1109. ret.List = list
  1110. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1111. return
  1112. }
  1113. func GetCollectReportListBak(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportCollectResp, err error) {
  1114. var errMsg string
  1115. defer func() {
  1116. if err != nil {
  1117. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1118. }
  1119. }()
  1120. // 查询权限的基本信息
  1121. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1122. if err != nil {
  1123. errMsg = err.Error()
  1124. err = errors.New("查询权限出错")
  1125. return
  1126. }
  1127. if permissionInfo.ChartPermissionID == 0 {
  1128. err = errors.New("权限不存在")
  1129. return
  1130. }
  1131. // 除了晨报和周报以外的其他报告
  1132. classifySecondIds, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1133. if err != nil {
  1134. errMsg = err.Error()
  1135. err = errors.New("查询权限对应的分类出错")
  1136. return
  1137. }
  1138. //var classifySecondIds []int
  1139. //if len(classifyNames) > 0 {
  1140. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1141. // if err != nil {
  1142. // errMsg = err.Error()
  1143. // err = errors.New("查询分类出错")
  1144. // return
  1145. // }
  1146. //}
  1147. // 查询晨报和周报相对应的章节ID
  1148. reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1149. if err != nil {
  1150. errMsg = err.Error()
  1151. err = errors.New("查询权限对应的章节出错")
  1152. return
  1153. }
  1154. var reportList []*response.ReportCollectListItem
  1155. list := response.ReportCollectListResp{}
  1156. var total int64
  1157. if len(reportChapterTypeIds) > 0 || len(classifySecondIds) > 0 {
  1158. offset := (pageIndex - 1) * pageSize
  1159. reportList, err = report.GetReportCollectListByPermission(classifySecondIds, reportChapterTypeIds, offset, pageSize)
  1160. if err != nil {
  1161. errMsg = err.Error()
  1162. err = errors.New("查询报告信息出错")
  1163. return
  1164. }
  1165. listMap := make(map[string]*response.ReportCollectList)
  1166. for _, v := range reportList {
  1167. v.ContentSub = GetReportContentSub(v.ContentSub, true)
  1168. if _, ok := listMap[v.PublishTime.Format("2006-01-02")]; !ok {
  1169. temp := new(response.ReportCollectList)
  1170. temp.Date = v.PublishTime.Format("2006-01-02")
  1171. listMap[v.PublishTime.Format("2006-01-02")] = temp
  1172. }
  1173. listMap[v.PublishTime.Format("2006-01-02")].SubList = append(listMap[v.PublishTime.Format("2006-01-02")].SubList, v)
  1174. }
  1175. for _, v := range listMap {
  1176. list = append(list, v)
  1177. }
  1178. total, err = report.GetReportCollectCountByPermission(classifySecondIds, reportChapterTypeIds)
  1179. if err != nil {
  1180. errMsg = err.Error()
  1181. err = errors.New("查询报告总数出错")
  1182. return
  1183. }
  1184. if len(list) > 0 {
  1185. sort.Sort(list)
  1186. }
  1187. }
  1188. ret = new(response.ReportCollectResp)
  1189. ret.List = list
  1190. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1191. return
  1192. }
  1193. func SearchReport(user user.UserInfo, keyWord string, pageIndex, pageSize int) (ret *response.ReportSearchResp, err error) {
  1194. var errMsg string
  1195. defer func() {
  1196. if err != nil {
  1197. global.LOG.Critical(fmt.Sprintf("SearchReport: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1198. }
  1199. }()
  1200. //查询正常状态的分类
  1201. classifys, err := classify.GetSimpleAll()
  1202. if err != nil {
  1203. errMsg = err.Error()
  1204. err = errors.New("分类查询出错")
  1205. return
  1206. }
  1207. classifyIdList := make([]int, 0)
  1208. var classifyIdFirsts []int
  1209. classifyIdSeconds := []int{0}
  1210. for _, v := range classifys {
  1211. if v.ParentId == 0 {
  1212. classifyIdFirsts = append(classifyIdFirsts, v.Id)
  1213. } else {
  1214. classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1215. }
  1216. classifyIdList = append(classifyIdList, v.Id)
  1217. }
  1218. keyWord = addAliasToKeyword(keyWord)
  1219. searchResp, total, err := elasticService.SearchReport(keyWord, classifyIdList, pageIndex, pageSize)
  1220. if err != nil {
  1221. errMsg = err.Error()
  1222. err = errors.New("查询失败")
  1223. return
  1224. }
  1225. var reportList []*response.ReportCollectListItem
  1226. if searchResp.Hits != nil {
  1227. for _, v := range searchResp.Hits.Hits {
  1228. temp := new(response.ReportCollectListItem)
  1229. itemJson, tmpErr := v.Source.MarshalJSON()
  1230. if tmpErr != nil {
  1231. errMsg = tmpErr.Error()
  1232. err = errors.New("解析出错")
  1233. return
  1234. }
  1235. reportItem := new(response.EsReportItem)
  1236. tmpErr = json.Unmarshal(itemJson, &reportItem)
  1237. if tmpErr != nil {
  1238. errMsg = tmpErr.Error()
  1239. err = errors.New("解析json出错")
  1240. return
  1241. }
  1242. temp.ReportId = reportItem.ReportId
  1243. temp.ReportChapterId = reportItem.ReportChapterId
  1244. temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1245. temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1246. temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1247. temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1248. temp.ClassifyId = reportItem.ClassifyId
  1249. temp.ClassifyName = reportItem.ClassifyName
  1250. temp.Title = reportItem.Title
  1251. temp.ContentSub = reportItem.BodyContent
  1252. temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1253. if len(v.Highlight["Title"]) > 0 {
  1254. temp.Title = v.Highlight["Title"][0]
  1255. }
  1256. if len(v.Highlight["BodyContent"]) > 0 {
  1257. temp.ContentSub = v.Highlight["BodyContent"][0]
  1258. }
  1259. //if len(v.Highlight["Categories"]) > 0 {
  1260. // if temp.ClassifyNameSecond != "" {
  1261. // temp.ClassifyNameSecond = "<span style=\"color:#E3B377\">"+temp.ClassifyNameSecond+"</span>"
  1262. // }
  1263. // if temp.ClassifyNameFirst != "" {
  1264. // temp.ClassifyNameFirst = "<span style=\"color:#E3B377\">"+temp.ClassifyNameFirst+"</span>"
  1265. // }
  1266. //}
  1267. temp.ContentSub = GetReportContentSub(temp.ContentSub, false)
  1268. reportList = append(reportList, temp)
  1269. }
  1270. }
  1271. ret = new(response.ReportSearchResp)
  1272. ret.List = reportList
  1273. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1274. return
  1275. }
  1276. // GetTickerData 获取指标数据
  1277. func GetTickerData(user user.UserInfo, reportChapterId int) (ret *response.TickerData, err error) {
  1278. var errMsg string
  1279. defer func() {
  1280. if err != nil {
  1281. global.LOG.Critical(fmt.Sprintf("GetTickerData: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1282. }
  1283. }()
  1284. //查询章节类型
  1285. chapter, err := report_chapter.GetTypeIdById(reportChapterId)
  1286. if err != nil {
  1287. errMsg = err.Error()
  1288. err = errors.New("查询章节失败")
  1289. return
  1290. }
  1291. if chapter.ReportChapterId == 0 {
  1292. err = errors.New("章节不存在或者未发布")
  1293. return
  1294. }
  1295. tickers, err := report_chapter_ticker.GetTickerByChapterId(reportChapterId)
  1296. if err != nil {
  1297. errMsg = err.Error()
  1298. err = errors.New("查询章节指标失败")
  1299. return
  1300. }
  1301. var list []*response.TickerDataItem
  1302. if len(tickers) > 0 {
  1303. var tickerNames []string
  1304. for _, v := range tickers {
  1305. tickerNames = append(tickerNames, v.Ticker)
  1306. }
  1307. var dataList []*response.TickerDataItem
  1308. if chapter.TypeId == 17 {
  1309. dataList, err = daily_base_column.GetDataByBaseColumnTickers17(tickerNames)
  1310. } else {
  1311. dataList, err = daily_base_column.GetDataByBaseColumnTickers(tickerNames)
  1312. }
  1313. if err != nil {
  1314. errMsg = err.Error()
  1315. err = errors.New("查询指标数据失败")
  1316. return
  1317. }
  1318. chapterTypeInfo, tErr := report_chapter_type.GetTickerTitleByTypeId(chapter.TypeId)
  1319. if tErr != nil {
  1320. errMsg = tErr.Error()
  1321. err = errors.New("查询章节类型失败")
  1322. return
  1323. }
  1324. if len(dataList) >= 0 {
  1325. for _, v := range dataList {
  1326. temp := new(response.TickerDataItem)
  1327. temp.BaseColumnName = v.BaseColumnName
  1328. temp.Ticker = v.Ticker
  1329. temp.Date = v.Date
  1330. temp.TickerValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.TickerValue), 2)
  1331. temp.LastValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.LastValue), 2)
  1332. temp.MmValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.MmValue), 2)
  1333. temp.DdValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.DdValue), 2)
  1334. temp.WwValue, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", v.WwValue), 2)
  1335. list = append(list, temp)
  1336. }
  1337. }
  1338. tickerTitle := new(response.TickerTitleData)
  1339. tickerTitle.TickerTitle = chapterTypeInfo.TickerTitle
  1340. tickerTitle.ReportChapterTypeId = int(chapterTypeInfo.ReportChapterTypeId)
  1341. tickerTitle.ReportChapterTypeName = chapterTypeInfo.ReportChapterTypeName
  1342. tickerTitle.DataTableImage = fmt.Sprintf("http://hongze.oss-cn-shanghai.aliyuncs.com/data_table/%s.png", chapterTypeInfo.ReportChapterTypeKey)
  1343. ret = new(response.TickerData)
  1344. ret.List = list
  1345. ret.TickerTitle = tickerTitle
  1346. }
  1347. return
  1348. }
  1349. // GetReportContentSub 特殊处理contentSub
  1350. func GetReportContentSub(content string, scapeFlag bool) (contentSub string) {
  1351. if scapeFlag {
  1352. content = html.UnescapeString(content)
  1353. content = utils.TrimHtml(content) //只展示纯文本
  1354. }
  1355. contentSub = "<div style=\"-webkit-line-clamp: 3;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + content + "</div>"
  1356. return
  1357. }
  1358. // addAliasToKeyword 品种别名
  1359. func addAliasToKeyword(keyword string) string {
  1360. if keyword == "" {
  1361. return ""
  1362. }
  1363. keywordArr := make([]string, 0)
  1364. keywordArr = append(keywordArr, keyword)
  1365. if strings.Contains(keyword, "沥青") || strings.Contains(keyword, "BU") {
  1366. keywordArr = append(keywordArr, "沥青", "BU")
  1367. }
  1368. if strings.Contains(keyword, "MEG") || strings.Contains(keyword, "EG") || strings.Contains(keyword, "乙二醇") {
  1369. keywordArr = append(keywordArr, "MEG", "EG", "乙二醇")
  1370. }
  1371. if strings.Contains(keyword, "聚酯") || strings.Contains(keyword, "长丝") || strings.Contains(keyword, "短纤") || strings.Contains(keyword, "瓶片") {
  1372. keywordArr = append(keywordArr, "聚酯", "长丝", "短纤", "瓶片")
  1373. }
  1374. if strings.Contains(keyword, "纯苯") || strings.Contains(keyword, "苯乙烯") || strings.Contains(keyword, "EB") {
  1375. keywordArr = append(keywordArr, "纯苯", "苯乙烯", "EB")
  1376. }
  1377. if strings.Contains(keyword, "甲醇") || strings.Contains(keyword, "MA") {
  1378. keywordArr = append(keywordArr, "甲醇", "MA")
  1379. }
  1380. if strings.Contains(keyword, "橡胶") || strings.Contains(keyword, "RU") {
  1381. keywordArr = append(keywordArr, "橡胶", "RU")
  1382. }
  1383. if strings.Contains(keyword, "聚乙烯") || strings.Contains(keyword, "PP") || strings.Contains(keyword, "PE") {
  1384. keywordArr = append(keywordArr, "聚乙烯", "PP", "PE")
  1385. }
  1386. if strings.Contains(keyword, "玻璃") || strings.Contains(keyword, "纯碱") || strings.Contains(keyword, "FG") || strings.Contains(keyword, "SA") {
  1387. keywordArr = append(keywordArr, "玻璃", "纯碱", "FG", "SA")
  1388. }
  1389. keyword = strings.Join(keywordArr, ",")
  1390. return keyword
  1391. }
  1392. // GetReportPptImgListByReportIdAndReportChapterId 首页展示报告汇总列表
  1393. func GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId int) (list []string, err error) {
  1394. list = make([]string, 0)
  1395. reportPptImgList, err := report_ppt_img.GetReportPptImgListByReportIdAndReportChapterId(reportId, reportChapterId)
  1396. for _, v := range reportPptImgList {
  1397. list = append(list, v.ImgURL)
  1398. }
  1399. return
  1400. }
  1401. // GetVarietyReportList 大宗商品报告列表
  1402. func GetVarietyReportList(user user.UserInfo, classifyId, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1403. var errMsg string
  1404. defer func() {
  1405. if err != nil {
  1406. global.LOG.Critical(fmt.Sprintf("GetCollectReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1407. }
  1408. }()
  1409. // 判断用户状态是否是正常和永续
  1410. var productAuthOk bool
  1411. companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1412. if err == utils.ErrNoRow {
  1413. err = nil
  1414. }
  1415. if err != nil {
  1416. errMsg = err.Error()
  1417. err = errors.New("查询用户购买产品出错")
  1418. return
  1419. }
  1420. if companyProduct != nil {
  1421. // 无FICC权限的客户不可见
  1422. if companyProduct.CompanyProductID > 0 {
  1423. // 已购或者试用用户可见
  1424. if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1425. productAuthOk = true
  1426. }
  1427. }
  1428. }
  1429. // 查询权限的基本信息
  1430. permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1431. if err != nil {
  1432. errMsg = err.Error()
  1433. err = errors.New("查询权限出错")
  1434. return
  1435. }
  1436. if permissionInfo.ChartPermissionID == 0 {
  1437. err = errors.New("权限不存在")
  1438. return
  1439. }
  1440. //分类ids
  1441. var allClassifySecondIds []int
  1442. var classifySecondIds []int
  1443. allClassifySecondIds, err = chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "rddp")
  1444. if err != nil {
  1445. errMsg = err.Error()
  1446. err = errors.New("查询权限对应的分类出错")
  1447. return
  1448. }
  1449. //if len(classifyNames) > 0 {
  1450. // allClassifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1451. // if err != nil {
  1452. // errMsg = err.Error()
  1453. // err = errors.New("查询分类出错")
  1454. // return
  1455. // }
  1456. //}
  1457. //根据所选一级分类id查询二级分类
  1458. classifyChild, err := classify.GetChildByPid(classifyId)
  1459. if err != nil {
  1460. errMsg = err.Error()
  1461. err = errors.New("查询二级分类出错")
  1462. return
  1463. }
  1464. classifyMap := make(map[int]int, 0)
  1465. for _, c := range classifyChild {
  1466. classifyMap[c.Id] = c.Id
  1467. }
  1468. for _, id := range allClassifySecondIds {
  1469. if _, ok := classifyMap[id]; ok {
  1470. classifySecondIds = append(classifySecondIds, id)
  1471. }
  1472. }
  1473. listImgMap := make(map[int]string, 0)
  1474. for i := 0; i < len(classifyChild); i++ {
  1475. listImgMap[classifyChild[i].Id] = classifyChild[i].YbListImg
  1476. }
  1477. // 获取有效的权限id列表
  1478. var validPermissionIdList []int
  1479. if productAuthOk {
  1480. validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1481. if err != nil && err != utils.ErrNoRow {
  1482. errMsg = err.Error()
  1483. err = errors.New("查询分类出错")
  1484. return
  1485. }
  1486. }
  1487. var authOk bool
  1488. if len(validPermissionIdList) > 0 {
  1489. checkLoop:
  1490. for _, validPerid := range validPermissionIdList {
  1491. if chartPermissionId == validPerid {
  1492. authOk = true
  1493. break checkLoop
  1494. }
  1495. }
  1496. }
  1497. //// 查询晨报和周报相对应的章节ID
  1498. //reportChapterTypeIds, err := report_chapter_type_permission.GetTypeIdsByChartPermissionId(chartPermissionId)
  1499. //if err != nil {
  1500. // errMsg = err.Error()
  1501. // err = errors.New("查询权限对应的章节出错")
  1502. // return
  1503. //}
  1504. var reportList []*report.Report
  1505. var total int64
  1506. if len(classifySecondIds) > 0 {
  1507. if productAuthOk {
  1508. offset := (pageIndex - 1) * pageSize
  1509. reportList, err = report.GetCommoditiesReportCollectListByPermission(classifySecondIds, offset, pageSize)
  1510. if err != nil {
  1511. errMsg = err.Error()
  1512. err = errors.New("查询报告信息出错")
  1513. return
  1514. }
  1515. total, err = report.GetCommoditiesReportCollectCountByPermission(classifySecondIds)
  1516. if err != nil {
  1517. errMsg = err.Error()
  1518. err = errors.New("查询报告总数出错")
  1519. return
  1520. }
  1521. }
  1522. }
  1523. var list []*response.ReportListItem
  1524. for _, r := range reportList {
  1525. // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1526. coverImg := listImgMap[r.ClassifyIdSecond]
  1527. if coverImg == "" {
  1528. coverImg = listImgMap[r.ClassifyIdFirst]
  1529. }
  1530. var VideoList []*response.VideoListItem
  1531. videoItem := response.VideoListItem{
  1532. VideoUrl: r.VideoUrl,
  1533. VideoName: r.VideoName,
  1534. VideoPlaySeconds: r.VideoPlaySeconds,
  1535. VideoImg: coverImg,
  1536. }
  1537. VideoList = append(VideoList, &videoItem)
  1538. stageStr := r.StageStr
  1539. if stageStr == "" {
  1540. stageStr = strconv.Itoa(r.Stage)
  1541. }
  1542. item := response.ReportListItem{
  1543. ReportId: r.Id,
  1544. ClassifyIdFirst: r.ClassifyIdFirst,
  1545. ClassifyNameFirst: r.ClassifyNameFirst,
  1546. ClassifyIdSecond: r.ClassifyIdSecond,
  1547. ClassifyNameSecond: r.ClassifyNameSecond,
  1548. Title: r.Title,
  1549. Abstract: r.Abstract,
  1550. Author: r.Author,
  1551. ReportImgUrl: coverImg,
  1552. PublishTime: r.PublishTime,
  1553. Stage: r.Stage,
  1554. VideoList: VideoList,
  1555. AuthOk: authOk,
  1556. TitleInfo: fmt.Sprintf("【第%s期|FICC|%s】", stageStr, r.ClassifyNameSecond),
  1557. }
  1558. list = append(list, &item)
  1559. }
  1560. ret = new(response.ReportList)
  1561. ret.List = list
  1562. ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  1563. return
  1564. }
  1565. // GetMinClassify
  1566. // @Description: 获取最小分类ID
  1567. // @author: Roc
  1568. // @datetime 2024-06-20 09:23:19
  1569. // @param reportInfo *models.Report
  1570. // @return minClassifyId int
  1571. // @return minClassifyName string
  1572. // @return err error
  1573. func GetMinClassify(reportInfo *report.Report) (minClassifyId int, minClassifyName string, err error) {
  1574. defer func() {
  1575. if err != nil {
  1576. global.FILE_LOG.Error("获取最小分类ID失败,报告ID:%d,Err:%s", reportInfo.Id, err.Error())
  1577. }
  1578. }()
  1579. minClassifyId = reportInfo.ClassifyIdThird
  1580. minClassifyName = reportInfo.ClassifyNameThird
  1581. if minClassifyId <= 0 {
  1582. minClassifyId = reportInfo.ClassifyIdSecond
  1583. minClassifyName = reportInfo.ClassifyNameSecond
  1584. }
  1585. if minClassifyId <= 0 {
  1586. minClassifyId = reportInfo.ClassifyIdFirst
  1587. minClassifyName = reportInfo.ClassifyNameFirst
  1588. }
  1589. if minClassifyId <= 0 {
  1590. err = errors.New("分类异常")
  1591. }
  1592. return
  1593. }
  1594. // GetCommoditiesReportList 获取大宗商品报告列表
  1595. //func GetCommoditiesReportList(user user.UserInfo, chartPermissionId, pageIndex, pageSize int) (ret *response.ReportList, err error) {
  1596. // var errMsg string
  1597. // defer func() {
  1598. // if err != nil {
  1599. // global.LOG.Critical(fmt.Sprintf("GetReportList: userId=%d, err:%s, errMsg:%s", user.UserID, err.Error(), errMsg))
  1600. // }
  1601. // }()
  1602. //
  1603. // // 判断用户状态是否是正常和永续
  1604. // var productAuthOk bool
  1605. // companyProduct, err := company_product.GetByCompany2ProductId(user.CompanyID, 1)
  1606. // if err == utils.ErrNoRow {
  1607. // err = nil
  1608. // }
  1609. // if err != nil {
  1610. // errMsg = err.Error()
  1611. // err = errors.New("查询用户购买产品出错")
  1612. // return
  1613. // }
  1614. // if companyProduct != nil {
  1615. // // 无FICC权限的客户不可见
  1616. // if companyProduct.CompanyProductID > 0 {
  1617. // // 已购或者试用用户可见
  1618. // if strings.Contains("永续,正式", companyProduct.Status) || (companyProduct.Status == "试用" && companyProduct.IsSuspend != 1) {
  1619. // productAuthOk = true
  1620. // }
  1621. // }
  1622. // }
  1623. //
  1624. // // 查询权限的基本信息
  1625. // permissionInfo, err := chart_permission.GetByChartPermissionId(chartPermissionId)
  1626. // if err != nil {
  1627. // errMsg = err.Error()
  1628. // err = errors.New("查询权限出错")
  1629. // return
  1630. // }
  1631. //
  1632. // if permissionInfo.ChartPermissionID == 0 {
  1633. // err = errors.New("权限不存在")
  1634. // return
  1635. // }
  1636. // // 除了晨报和周报以外的其他报告
  1637. // classifyNames, err := chart_permission_search_key_word_mapping.GetClassifyIdsByChartPermissionId(chartPermissionId, "two_week")
  1638. // if err != nil {
  1639. // errMsg = err.Error()
  1640. // err = errors.New("查询权限对应的分类出错")
  1641. // return
  1642. // }
  1643. //
  1644. // var classifySecondIds []int
  1645. // if len(classifyNames) > 0 {
  1646. // classifySecondIds, err = classify.GetSecondIdsByClassifyNames(classifyNames)
  1647. // if err != nil {
  1648. // errMsg = err.Error()
  1649. // err = errors.New("查询分类出错")
  1650. // return
  1651. // }
  1652. // }
  1653. //
  1654. // var condition string
  1655. // pars := make([]interface{}, 0)
  1656. //
  1657. // classifyParent, err := classify.GetByClassifyId(classifyIdFirst)
  1658. // if err != nil {
  1659. // errMsg = err.Error()
  1660. // err = errors.New("分类查询出错")
  1661. // return
  1662. // }
  1663. // if classifyParent.Id == 0 {
  1664. // err = errors.New("该分类不存在")
  1665. // return
  1666. // }
  1667. // condition = `classify_id_first = ? and state IN (2, 6)`
  1668. // pars = append(pars, classifyIdFirst)
  1669. // permissionMap := make(map[string][]int)
  1670. // checkPermissionMap := make(map[string]bool)
  1671. // permissionImageMap := make(map[string]string)
  1672. // chartPermissionImageMap := make(map[int]string)
  1673. // var classifyIdSeconds []int
  1674. // //var reportImgUrl string
  1675. //
  1676. // chartPermissionList, err := chart_permission.GetFiccListExceptTacticByProductId()
  1677. // if err != nil {
  1678. // errMsg = err.Error()
  1679. // err = errors.New("分类查询出错")
  1680. // return
  1681. // }
  1682. //
  1683. // if len(chartPermissionList) > 0 {
  1684. // for _, v := range chartPermissionList {
  1685. // chartPermissionImageMap[int(v.ChartPermissionID)] = v.YbImgUrl
  1686. // }
  1687. // }
  1688. //
  1689. // if classifyIdSecond > 0 && keyWord == "" {
  1690. // classifyInfo, tErr := classify.GetByClassifyId(classifyIdSecond)
  1691. // if tErr != nil {
  1692. // errMsg = tErr.Error()
  1693. // err = errors.New("分类查询出错")
  1694. // return
  1695. // }
  1696. // if classifyInfo.Id == 0 {
  1697. // err = errors.New("该二级分类不存在")
  1698. // return
  1699. // }
  1700. //
  1701. // condition += " AND classify_id_second = ?"
  1702. // pars = append(pars, classifyIdSecond)
  1703. // //查询二级分类对应的权限
  1704. // permissionIds, tErr := chart_permission_search_key_word_mapping.GetChartPermissionIdsByKeyWord(classifyInfo.ClassifyName)
  1705. // if tErr != nil {
  1706. // errMsg = tErr.Error()
  1707. // err = errors.New("分类权限查询出错")
  1708. // return
  1709. // }
  1710. // permissionMap[classifyInfo.ClassifyName] = permissionIds
  1711. // //if len(permissionIds) > 0 {
  1712. // // for _, v := range permissionIds {
  1713. // // reportImgUrl = chartPermissionImageMap[v]
  1714. // // }
  1715. // //}
  1716. //
  1717. // } else {
  1718. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1719. // //reportImgUrl = chartPermissionImageMap[1]
  1720. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1721. // }
  1722. //
  1723. // chartPermissions, tErr := chart_permission_search_key_word_mapping.GetChartPermissionByFrom("rddp")
  1724. // if tErr != nil {
  1725. // errMsg = tErr.Error()
  1726. // err = errors.New("分类权限查询出错")
  1727. // return
  1728. // }
  1729. //
  1730. // if len(chartPermissions) > 0 {
  1731. // for _, v := range chartPermissions {
  1732. // permissionMap[v.KeyWord] = append(permissionMap[v.KeyWord], v.ChartPermissionId)
  1733. // permissionImageMap[v.KeyWord] = chartPermissionImageMap[v.ChartPermissionId]
  1734. // }
  1735. // }
  1736. //
  1737. // //获取二级分类的所有头像
  1738. // classifyList, tErr := classify.GetListByPid(classifyIdFirst)
  1739. // if tErr != nil {
  1740. // errMsg = tErr.Error()
  1741. // err = errors.New("二级分类查询出错")
  1742. // return
  1743. // }
  1744. //
  1745. // for _, v := range classifyList {
  1746. // classifyIdSeconds = append(classifyIdSeconds, v.Id)
  1747. // }
  1748. //
  1749. // if len(classifyIdSeconds) == 0 && classifyParent.ClassifyName != "晨报" && classifyParent.ClassifyName != "周报" {
  1750. // ret = new(response.ReportList)
  1751. // ret.Paging = response.GetPaging(pageIndex, pageSize, 0)
  1752. // return
  1753. // }
  1754. // condition += ` AND classify_id_second IN ? `
  1755. // pars = append(pars, classifyIdSeconds)
  1756. // }
  1757. //
  1758. // // 获取有效的权限id列表
  1759. // var validPermissionIdList []int
  1760. // if productAuthOk {
  1761. // validPermissionIdList, err = company.GetValidPermissionIdListByCompany2ProductId(user.CompanyID, 1)
  1762. // if err != nil && err != utils.ErrNoRow {
  1763. // errMsg = err.Error()
  1764. // err = errors.New("查询分类出错")
  1765. // return
  1766. // }
  1767. // }
  1768. //
  1769. // if len(validPermissionIdList) > 0 {
  1770. // for classifyName, perIds := range permissionMap {
  1771. // checkLoop:
  1772. // for _, checkId := range perIds {
  1773. // for _, validPerid := range validPermissionIdList {
  1774. // if checkId == validPerid {
  1775. // checkPermissionMap[classifyName] = true
  1776. // break checkLoop
  1777. // }
  1778. // }
  1779. // }
  1780. // }
  1781. // }
  1782. //
  1783. // var total int64
  1784. // var list []*report.Report
  1785. // if keyWord == "" {
  1786. // offset := (pageIndex - 1) * pageSize
  1787. // list, err = report.GetReportList(condition, pars, offset, pageSize)
  1788. // if err != nil {
  1789. // errMsg = err.Error()
  1790. // err = errors.New("报告查询出错")
  1791. // return
  1792. // }
  1793. // total, err = report.GetReportListCount(condition, pars)
  1794. // if err != nil {
  1795. // errMsg = err.Error()
  1796. // err = errors.New("查询报告总数出错")
  1797. // return
  1798. // }
  1799. // } else {
  1800. // if classifyIdSecond > 0 {
  1801. // classifyIdSeconds = append(classifyIdSeconds, classifyIdSecond)
  1802. // }
  1803. // if classifyParent.ClassifyName == "晨报" || classifyParent.ClassifyName == "周报" {
  1804. // classifyIdSeconds = append(classifyIdSeconds, 0)
  1805. // }
  1806. // searchResp, total1, tErr := elasticService.ReportListSearch(keyWord, classifyIdFirst, classifyIdSeconds, pageIndex, pageSize)
  1807. // if tErr != nil {
  1808. // errMsg = tErr.Error()
  1809. // err = errors.New("查询失败")
  1810. // return
  1811. // }
  1812. // total = int64(total1)
  1813. // if searchResp.Hits != nil && total > 0 {
  1814. // var reportIds []int
  1815. // for _, v := range searchResp.Hits.Hits {
  1816. // temp := new(report.Report)
  1817. // itemJson, tmpErr := v.Source.MarshalJSON()
  1818. // if tmpErr != nil {
  1819. // errMsg = tmpErr.Error()
  1820. // err = errors.New("解析出错")
  1821. // return
  1822. // }
  1823. // reportItem := new(response.EsReportItem)
  1824. // tmpErr = json.Unmarshal(itemJson, &reportItem)
  1825. // if tmpErr != nil {
  1826. // errMsg = tmpErr.Error()
  1827. // err = errors.New("解析json出错")
  1828. // return
  1829. // }
  1830. // temp.Id = reportItem.ReportId
  1831. // reportIds = append(reportIds, reportItem.ReportId)
  1832. // temp.ClassifyIdFirst = reportItem.ClassifyIdFirst
  1833. // temp.ClassifyNameFirst = reportItem.ClassifyNameFirst
  1834. // temp.ClassifyIdSecond = reportItem.ClassifyIdSecond
  1835. // temp.ClassifyNameSecond = reportItem.ClassifyNameSecond
  1836. // if len(v.Highlight["ClassifyNameSecond"]) > 0 {
  1837. // temp.ClassifyNameSecond = v.Highlight["ClassifyNameSecond"][0]
  1838. // }
  1839. // temp.Abstract = reportItem.Abstract
  1840. // stageInt, _ := strconv.Atoi(reportItem.StageStr)
  1841. // temp.Stage = stageInt
  1842. // temp.StageStr = reportItem.StageStr
  1843. // temp.Title = reportItem.Title
  1844. // temp.PublishTime, err = time.ParseInLocation(utils.FormatDateTime, reportItem.PublishTime, time.Local)
  1845. // if len(v.Highlight["Title"]) > 0 {
  1846. // temp.Title = v.Highlight["Title"][0]
  1847. // }
  1848. // if len(v.Highlight["Abstract"]) > 0 {
  1849. // temp.Abstract = v.Highlight["Abstract"][0]
  1850. // }
  1851. // if len(v.Highlight["StageStr"]) > 0 {
  1852. // temp.StageStr = v.Highlight["StageStr"][0]
  1853. // }
  1854. // list = append(list, temp)
  1855. // }
  1856. // reportInfoList, tmpErr := report.GetByReportIds(reportIds)
  1857. // if tmpErr != nil {
  1858. // errMsg = tmpErr.Error()
  1859. // err = errors.New("查询报告出错")
  1860. // return
  1861. // }
  1862. // reportListMap := make(map[int]*report.Report)
  1863. // for _, temp := range reportInfoList {
  1864. // reportListMap[temp.Id] = temp
  1865. // }
  1866. // for k, reportDetail := range list {
  1867. // if v, ok := reportListMap[reportDetail.Id]; ok {
  1868. // list[k].CreateTime = v.CreateTime
  1869. // }
  1870. // }
  1871. // }
  1872. // }
  1873. //
  1874. // var reportList []*response.ReportListItem
  1875. // if len(list) > 0 {
  1876. // // 封面图
  1877. // classifyList, e := classify.GetClassifyList()
  1878. // if e != nil {
  1879. // err = errors.New("获取报告分类列表失败" + e.Error())
  1880. // return
  1881. // }
  1882. // listImgMap := make(map[int]string, 0)
  1883. // classifyLen := len(classifyList)
  1884. // for i := 0; i < classifyLen; i++ {
  1885. // listImgMap[classifyList[i].Id] = classifyList[i].YbListImg
  1886. // }
  1887. //
  1888. // var videoReportIds []int
  1889. // videoMap := make(map[int][]*response.VideoListItem)
  1890. // weekAuthMap := make(map[int]bool)
  1891. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1892. // //获取晨报的音频列表
  1893. // videoMap, _, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1894. // if err != nil {
  1895. // return
  1896. // }
  1897. // } else if classifyParent.ClassifyName == "周报" {
  1898. // //查询所有权限typeID
  1899. // //如果存在可以查看的章节ID
  1900. // for _, reportInfo := range list {
  1901. // videoReportIds = append(videoReportIds, reportInfo.Id)
  1902. // }
  1903. // // 判断周报权限\查询周报的音频列表
  1904. // videoMap, weekAuthMap, errMsg, err = GetReportChapterVideoList(validPermissionIdList, classifyParent.ClassifyName, list)
  1905. // if err != nil {
  1906. // return
  1907. // }
  1908. // }
  1909. // // 以下分类图标特殊处理 =_=!
  1910. // //reportImgMap := map[string]string{
  1911. // // "晨报": "report_list_chen.png",
  1912. // // "周报": "report_list_zhou.png",
  1913. // // "月报": "report_list_yue.png",
  1914. // // "大事点评": "report_list_dashidianping.png",
  1915. // // "会议纪要": "report_list_huiyijiyao.png",
  1916. // // "年报合集": "report_list_nianbaoheji.png",
  1917. // //}
  1918. // for _, reportInfo := range list {
  1919. // reportItem := new(response.ReportListItem)
  1920. // reportItem.ReportId = reportInfo.Id
  1921. // // 样式限制行数
  1922. // reportItem.Title = "<div style=\"-webkit-line-clamp: 2;-webkit-box-orient: vertical;display: -webkit-box;overflow: hidden;text-overflow: ellipsis;\">" + reportInfo.Title + "</div>"
  1923. // reportItem.PublishTime = reportInfo.PublishTime
  1924. // reportItem.ClassifyNameFirst = reportInfo.ClassifyNameFirst
  1925. // reportItem.ClassifyNameSecond = reportInfo.ClassifyNameSecond
  1926. // reportItem.ClassifyIdFirst = reportInfo.ClassifyIdFirst
  1927. // reportItem.ClassifyIdSecond = reportInfo.ClassifyIdSecond
  1928. // reportItem.Stage = reportInfo.Stage
  1929. // reportItem.Abstract = reportInfo.Abstract
  1930. // if reportInfo.Abstract != "" {
  1931. // reportItem.Abstract = "<div style=\"overflow: hidden;white-space: nowrap;text-overflow: ellipsis;\">" + reportInfo.Abstract + "</div>"
  1932. // }
  1933. // reportItem.Author = reportInfo.Author
  1934. // stageStr := reportInfo.StageStr
  1935. // if stageStr == "" {
  1936. // stageStr = strconv.Itoa(reportInfo.Stage)
  1937. // }
  1938. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameSecond)
  1939. // //trimClassifyNameSecond := utils.TrimHtml(reportInfo.ClassifyNameSecond)
  1940. // if reportInfo.ClassifyNameFirst == "晨报" || reportInfo.ClassifyNameFirst == "周报" || classifyIdSecond > 0 {
  1941. // //reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + reportImgUrl
  1942. // reportItem.TitleInfo = fmt.Sprintf("【第%s期|FICC|%s】", stageStr, reportItem.ClassifyNameFirst)
  1943. // }
  1944. // //else if url, ok := permissionImageMap[trimClassifyNameSecond]; ok {
  1945. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + url
  1946. // //}
  1947. // //if img, ok := reportImgMap[reportInfo.ClassifyNameFirst]; ok {
  1948. // // reportItem.ReportImgUrl = utils.ALIYUN_YBIMG_HOST + img
  1949. // //}
  1950. // // 封面图-默认取二级分类的图片,二级分类图片没有(如晨周报)则取一级
  1951. // coverImg := listImgMap[reportInfo.ClassifyIdSecond]
  1952. // if coverImg == "" {
  1953. // coverImg = listImgMap[reportInfo.ClassifyIdFirst]
  1954. // }
  1955. // reportItem.ReportImgUrl = coverImg
  1956. //
  1957. // if classifyParent.ClassifyName == "晨报" && productAuthOk {
  1958. // // 查询当前晨报的所有音频
  1959. // if vList, ok := videoMap[reportInfo.Id]; ok {
  1960. // for _, vd := range vList {
  1961. // vd.VideoImg = reportItem.ReportImgUrl
  1962. // }
  1963. // reportItem.VideoList = vList
  1964. // }
  1965. // reportItem.AuthOk = productAuthOk
  1966. // } else if classifyParent.ClassifyName == "周报" {
  1967. // if wAuth, ok := weekAuthMap[reportInfo.Id]; ok {
  1968. // reportItem.AuthOk = wAuth
  1969. // if wAuth {
  1970. // // 查询当前晨报的所有音频
  1971. // if vList, ok2 := videoMap[reportInfo.Id]; ok2 {
  1972. // for _, vd := range vList {
  1973. // vd.VideoImg = reportItem.ReportImgUrl
  1974. // }
  1975. // reportItem.VideoList = vList
  1976. // }
  1977. // }
  1978. // }
  1979. // } else if authOk, ok := checkPermissionMap[reportInfo.ClassifyNameSecond]; ok && authOk {
  1980. // if reportInfo.VideoUrl != "" {
  1981. // videoTemp := new(response.VideoListItem)
  1982. // videoTemp.VideoUrl = reportInfo.VideoUrl
  1983. // videoTemp.VideoName = reportInfo.VideoName
  1984. // if reportInfo.VideoName == "" {
  1985. // videoTemp.VideoName = reportInfo.Title
  1986. // }
  1987. // videoTemp.VideoPlaySeconds = reportInfo.VideoPlaySeconds
  1988. // videoTemp.VideoImg = reportItem.ReportImgUrl
  1989. // reportItem.VideoList = append(reportItem.VideoList, videoTemp)
  1990. // }
  1991. // reportItem.AuthOk = authOk
  1992. // }
  1993. //
  1994. // reportList = append(reportList, reportItem)
  1995. // }
  1996. //
  1997. // }
  1998. // ret = new(response.ReportList)
  1999. // ret.List = reportList
  2000. // ret.Paging = response.GetPaging(pageIndex, pageSize, int(total))
  2001. // return
  2002. //}