yanxuan_special_message.go 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "github.com/rdlucklib/rdluck_tools/paging"
  5. "hongze/hongze_web_mfyx/models"
  6. "hongze/hongze_web_mfyx/services"
  7. "hongze/hongze_web_mfyx/utils"
  8. "time"
  9. )
  10. type YanxuanSpecialMessageController struct {
  11. BaseAuthController
  12. }
  13. // @Title 添加留言
  14. // @Description 添加留言接口
  15. // @Param request body models.AddCygxYanxuanSpecialMessageReq true "type json string"
  16. // @Success Ret=200 {object}
  17. // @router /message/add [post]
  18. func (this *YanxuanSpecialMessageController) MessageAdd() {
  19. br := new(models.BaseResponse).Init()
  20. defer func() {
  21. this.Data["json"] = br
  22. this.ServeJSON()
  23. }()
  24. user := this.User
  25. if user == nil {
  26. br.Msg = "请登录"
  27. br.ErrMsg = "请登录,用户信息为空"
  28. br.Ret = 408
  29. return
  30. }
  31. var req models.AddCygxYanxuanSpecialMessageReq
  32. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  33. if err != nil {
  34. br.Msg = "参数解析异常!"
  35. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  36. return
  37. }
  38. yanxuanSpecialId := req.YanxuanSpecialId
  39. content := req.Content
  40. parentId := req.ParentId
  41. if content == "" {
  42. br.Msg = "请输入留言内容!"
  43. return
  44. }
  45. if yanxuanSpecialId == 0 {
  46. br.Msg = "留言失败!"
  47. br.ErrMsg = "专栏信息不能为空"
  48. return
  49. }
  50. // 研选专栏
  51. yanxuanSpecialBySpeciaDetail, err := models.GetYanxuanSpecialBySpecialId(yanxuanSpecialId)
  52. if err != nil {
  53. br.Msg = "获取信息失败"
  54. br.ErrMsg = "获取信息失败,Err:" + err.Error()
  55. return
  56. }
  57. item := new(models.CygxYanxuanSpecialMessage)
  58. item.UserId = user.UserId
  59. item.Mobile = user.Mobile
  60. item.Email = user.Email
  61. item.CompanyId = user.CompanyId
  62. item.CompanyName = user.CompanyName
  63. item.RealName = user.RealName
  64. item.SellerName, _ = services.GetSellerName(user) // 销售姓名
  65. item.YanxuanSpecialId = yanxuanSpecialId
  66. item.Content = content
  67. item.ParentId = parentId
  68. item.YanxuanSpecialUserId = yanxuanSpecialBySpeciaDetail.UserId
  69. item.SourceTitle = yanxuanSpecialBySpeciaDetail.Title
  70. item.CreateTime = time.Now()
  71. item.ModifyTime = time.Now()
  72. item.RegisterPlatform = utils.REGISTER_PLATFORM
  73. messageId, err := models.AddCygxYanxuanSpecialMessage(item)
  74. if err != nil {
  75. br.Msg = "留言失败!"
  76. br.ErrMsg = "留言失败,Err:" + err.Error()
  77. return
  78. }
  79. var msgText string
  80. if parentId == 0 {
  81. msgText = "留言成功"
  82. go services.SendWxCategoryMsgByYanxuanSpecialMassageByAuthor(content, yanxuanSpecialBySpeciaDetail)
  83. } else {
  84. msgText = "回复成功"
  85. go services.SendWxCategoryMsgByYanxuanSpecialMassage(parentId, int(messageId), content, yanxuanSpecialBySpeciaDetail)
  86. }
  87. br.Ret = 200
  88. br.Success = true
  89. br.Msg = msgText
  90. }
  91. // @Title 留言管理列表
  92. // @Description 留言管理列表接口
  93. // @Param PageSize query int true "每页数据条数"
  94. // @Param CurrentIndex query int true "当前页页码,从1开始"
  95. // @Param MessageType query int false "留言类型1:普通留言、2:公开留言"
  96. // @Success 200 {object} models.SpecialListResp
  97. // @router /message/manage/list [get]
  98. func (this *YanxuanSpecialMessageController) MessageManageList() {
  99. br := new(models.BaseResponse).Init()
  100. defer func() {
  101. this.Data["json"] = br
  102. this.ServeJSON()
  103. }()
  104. user := this.User
  105. if user == nil {
  106. br.Msg = "请登录"
  107. br.ErrMsg = "请登录,用户信息为空"
  108. br.Ret = 408
  109. return
  110. }
  111. pageSize, _ := this.GetInt("PageSize")
  112. currentIndex, _ := this.GetInt("CurrentIndex")
  113. messageType, _ := this.GetInt("MessageType", 1)
  114. var startSize int
  115. if pageSize <= 0 {
  116. pageSize = utils.PageSize20
  117. }
  118. if currentIndex <= 0 {
  119. currentIndex = 1
  120. }
  121. startSize = utils.StartIndex(currentIndex, pageSize)
  122. resp := new(models.YanxuanSpecialMessageManageRespListResp)
  123. var condition string
  124. var pars []interface{}
  125. userId := user.UserId
  126. if messageType == 1 {
  127. condition += ` AND status = 0 `
  128. } else {
  129. condition += ` AND status = 1 `
  130. }
  131. condition += ` AND yanxuan_special_user_id = ? `
  132. pars = append(pars, userId)
  133. conditionChildren := condition // 子集留言筛选条件
  134. condition += ` AND parent_id = 0 `
  135. total, err := models.GetCygxYanxuanSpecialMessagerCount(condition, pars)
  136. if err != nil {
  137. br.Msg = "获取失败"
  138. br.ErrMsg = "获取失败, Err:" + err.Error()
  139. return
  140. }
  141. condition += ` ORDER BY message_id DESC `
  142. list, err := models.GetCygxYanxuanSpecialMessageList(condition, pars, startSize, pageSize)
  143. if err != nil {
  144. br.Msg = "获取失败"
  145. br.ErrMsg = "获取失败, Err:" + err.Error()
  146. return
  147. }
  148. if len(list) > 0 {
  149. var messageIds []int
  150. var userIds []int
  151. for _, v := range list {
  152. messageIds = append(messageIds, v.MessageId)
  153. userIds = append(userIds, v.UserId)
  154. }
  155. //获取子集评论
  156. conditionChildren += ` AND parent_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) ORDER BY message_id ASC `
  157. pars = append(pars, messageIds)
  158. listChild, err := models.GetCygxYanxuanSpecialMessageList(conditionChildren, pars, 0, 999)
  159. if err != nil {
  160. br.Msg = "获取失败"
  161. br.ErrMsg = "获取失败, Err:" + err.Error()
  162. return
  163. }
  164. itemChildMap := make(map[int][]*models.CygxYanxuanSpecialMessageManageChildResp)
  165. for _, v := range listChild {
  166. userIds = append(userIds, v.UserId)
  167. itemChild := new(models.CygxYanxuanSpecialMessageManageChildResp)
  168. itemChild.UserId = v.UserId
  169. itemChild.MessageId = v.MessageId
  170. itemChild.Content = v.Content
  171. itemChild.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  172. itemChildMap[v.ParentId] = append(itemChildMap[v.ParentId], itemChild)
  173. }
  174. //用户头像
  175. listUser, err := models.GetWxUserListByUserIdsArr(userIds)
  176. if err != nil {
  177. br.Msg = "获取失败"
  178. br.ErrMsg = "获取失败, Err:" + err.Error()
  179. return
  180. }
  181. mapUserImg := make(map[int]string)
  182. for _, v := range listUser {
  183. if v.Headimgurl != "" {
  184. mapUserImg[v.UserId] = v.Headimgurl
  185. } else {
  186. mapUserImg[v.UserId] = utils.DefaultHeadimgurl
  187. }
  188. }
  189. for _, v := range userIds {
  190. if mapUserImg[v] == "" {
  191. mapUserImg[v] = utils.DefaultHeadimgurl
  192. }
  193. }
  194. for _, v := range list {
  195. item := new(models.CygxYanxuanSpecialMessageManageResp)
  196. item.MessageId = v.MessageId
  197. item.RealName = v.RealName
  198. item.Headimgurl = mapUserImg[v.UserId]
  199. item.YanxuanSpecialId = v.YanxuanSpecialId
  200. item.Content = v.Content
  201. item.TopTime = v.TopTime
  202. item.SourceTitle = v.SourceTitle
  203. item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  204. if len(itemChildMap[v.MessageId]) > 0 {
  205. for _, vm := range itemChildMap[v.MessageId] {
  206. vm.Headimgurl = mapUserImg[vm.UserId]
  207. }
  208. item.ChildList = itemChildMap[v.MessageId]
  209. } else {
  210. item.ChildList = make([]*models.CygxYanxuanSpecialMessageManageChildResp, 0)
  211. }
  212. item.CheckIds = make([]int, 0)
  213. resp.List = append(resp.List, item)
  214. }
  215. } else {
  216. resp.List = make([]*models.CygxYanxuanSpecialMessageManageResp, 0)
  217. }
  218. page := paging.GetPaging(currentIndex, pageSize, total)
  219. resp.Paging = page
  220. br.Data = resp
  221. br.Ret = 200
  222. br.Success = true
  223. br.Msg = "获取成功"
  224. }
  225. // @Title 删除留言
  226. // @Description 删除留言接口
  227. // @Param request body models.DeleteCygxYanxuanSpecialMessageReq true "type json string"
  228. // @Success Ret=200 {object}
  229. // @router /message/delete [post]
  230. func (this *YanxuanSpecialMessageController) MessageDelete() {
  231. br := new(models.BaseResponse).Init()
  232. defer func() {
  233. this.Data["json"] = br
  234. this.ServeJSON()
  235. }()
  236. user := this.User
  237. if user == nil {
  238. br.Msg = "请登录"
  239. br.ErrMsg = "请登录,用户信息为空"
  240. br.Ret = 408
  241. return
  242. }
  243. var req models.DeleteCygxYanxuanSpecialMessageReq
  244. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  245. if err != nil {
  246. br.Msg = "参数解析异常!"
  247. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  248. return
  249. }
  250. messageId := req.MessageId
  251. err = models.DeleteCygxYanxuanSpecialMessage(messageId)
  252. if err != nil {
  253. br.Msg = "删除失败!"
  254. br.ErrMsg = "删除失败,Err:" + err.Error()
  255. return
  256. }
  257. br.Ret = 200
  258. br.Success = true
  259. br.Msg = "删除成功"
  260. }
  261. // @Title 置顶/取消置顶留言
  262. // @Description 置顶/取消置顶留言接口
  263. // @Param request body models.TopCygxYanxuanSpecialMessageReq true "type json string"
  264. // @Success Ret=200 {object}
  265. // @router /message/top [post]
  266. func (this *YanxuanSpecialMessageController) MessageTop() {
  267. br := new(models.BaseResponse).Init()
  268. defer func() {
  269. this.Data["json"] = br
  270. this.ServeJSON()
  271. }()
  272. user := this.User
  273. if user == nil {
  274. br.Msg = "请登录"
  275. br.ErrMsg = "请登录,用户信息为空"
  276. br.Ret = 408
  277. return
  278. }
  279. var req models.TopCygxYanxuanSpecialMessageReq
  280. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  281. if err != nil {
  282. br.Msg = "参数解析异常!"
  283. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  284. return
  285. }
  286. messageId := req.MessageId
  287. doType := req.DoType
  288. messagerDetail, err := models.GetCygxYanxuanSpecialMessagerDetailById(messageId)
  289. if err != nil {
  290. br.Msg = "操作失败!"
  291. br.ErrMsg = "操作失败,Err:" + err.Error()
  292. }
  293. yanxuanSpecialId := messagerDetail.YanxuanSpecialId
  294. var topTime int
  295. var msgContent string
  296. if doType == 1 {
  297. countTop, err := models.GetCygxYanxuanSpecialMessagerCountTop(yanxuanSpecialId)
  298. if err != nil {
  299. br.Msg = "操作失败!"
  300. br.ErrMsg = "操作失败,Err:" + err.Error()
  301. return
  302. }
  303. if countTop > 0 {
  304. br.Msg = "此文章已有置顶留言"
  305. return
  306. }
  307. topTime = int(time.Now().Unix())
  308. msgContent = "已置顶"
  309. } else {
  310. msgContent = "已取消置顶"
  311. }
  312. err = models.UpdateCygxYanxuanSpecialMessageTopTime(topTime, messageId)
  313. if err != nil {
  314. br.Msg = "操作失败!"
  315. br.ErrMsg = "操作失败,Err:" + err.Error()
  316. return
  317. }
  318. br.Ret = 200
  319. br.Success = true
  320. br.Msg = msgContent
  321. }
  322. // @Title 公开/取消公开留言
  323. // @Description 公开/取消公开留言接口
  324. // @Param request body models.TopCygxYanxuanSpecialMessageReq true "type json string"
  325. // @Success Ret=200 {object}
  326. // @router /message/public [post]
  327. func (this *YanxuanSpecialMessageController) MessagePublic() {
  328. br := new(models.BaseResponse).Init()
  329. defer func() {
  330. this.Data["json"] = br
  331. this.ServeJSON()
  332. }()
  333. user := this.User
  334. if user == nil {
  335. br.Msg = "请登录"
  336. br.ErrMsg = "请登录,用户信息为空"
  337. br.Ret = 408
  338. return
  339. }
  340. var req models.PubliceCygxYanxuanSpecialMessageReq
  341. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  342. if err != nil {
  343. br.Msg = "参数解析异常!"
  344. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  345. return
  346. }
  347. messageIds := req.MessageIds
  348. doType := req.DoType
  349. var status int
  350. var publicTime string
  351. var msgContent string
  352. if doType == 1 {
  353. status = 1
  354. publicTime = time.Now().Format(utils.FormatDateTime)
  355. msgContent = "已公开"
  356. } else {
  357. msgContent = "已取消公开"
  358. }
  359. err = models.UpdateCygxYanxuanSpecialMessageStatus(status, publicTime, messageIds)
  360. if err != nil {
  361. br.Msg = "操作失败!"
  362. br.ErrMsg = "操作失败,Err:" + err.Error()
  363. return
  364. }
  365. br.Ret = 200
  366. br.Success = true
  367. br.Msg = msgContent
  368. }
  369. // @Title 点赞/取消点赞
  370. // @Description 点赞/取消点赞接口
  371. // @Param request body models.TopCygxYanxuanSpecialMessageReq true "type json string"
  372. // @Success Ret=200 {object}
  373. // @router /message/like [post]
  374. func (this *YanxuanSpecialMessageController) MessageLike() {
  375. br := new(models.BaseResponse).Init()
  376. defer func() {
  377. this.Data["json"] = br
  378. this.ServeJSON()
  379. }()
  380. user := this.User
  381. if user == nil {
  382. br.Msg = "请登录"
  383. br.ErrMsg = "请登录,用户信息为空"
  384. br.Ret = 408
  385. return
  386. }
  387. var req models.TopCygxYanxuanSpecialMessageReq
  388. err := json.Unmarshal(this.Ctx.Input.RequestBody, &req)
  389. if err != nil {
  390. br.Msg = "参数解析异常!"
  391. br.ErrMsg = "参数解析失败,Err:" + err.Error()
  392. return
  393. }
  394. messageId := req.MessageId
  395. doType := req.DoType
  396. userId := user.UserId
  397. total, err := models.GetCygxYanxuanSpecialMessageLikeCountByUidMid(userId, messageId)
  398. if err != nil {
  399. br.Msg = "操作失败!"
  400. br.ErrMsg = "操作失败,Err:" + err.Error()
  401. return
  402. }
  403. var msgContent string
  404. if doType == 1 {
  405. if total == 0 {
  406. item := new(models.CygxYanxuanSpecialMessageLike)
  407. item.UserId = userId
  408. item.Mobile = user.Mobile
  409. item.Email = user.Email
  410. item.CompanyId = user.CompanyId
  411. item.CompanyName = user.CompanyName
  412. item.RealName = user.RealName
  413. item.MessageId = messageId
  414. item.CreateTime = time.Now()
  415. item.ModifyTime = time.Now()
  416. item.RegisterPlatform = utils.REGISTER_PLATFORM
  417. err = models.AddCygxYanxuanSpecialMessageLike(item)
  418. if err != nil {
  419. br.Msg = "点赞失败!"
  420. br.ErrMsg = "点赞失败,Err:" + err.Error()
  421. return
  422. }
  423. }
  424. msgContent = "已点赞"
  425. } else {
  426. if total > 0 {
  427. err = models.DeleteCygxYanxuanSpecialMessageLike(userId, messageId)
  428. if err != nil {
  429. br.Msg = "点赞失败!"
  430. br.ErrMsg = "点赞失败,Err:" + err.Error()
  431. return
  432. }
  433. }
  434. msgContent = "已取消点赞"
  435. }
  436. br.Ret = 200
  437. br.Success = true
  438. br.Msg = msgContent
  439. }
  440. // @Title 专栏文章留言列表
  441. // @Description 专栏文章留言列表接口
  442. // @Param PageSize query int true "每页数据条数"
  443. // @Param CurrentIndex query int true "当前页页码,从1开始"
  444. // @Param YanxuanSpecialId query int false "研选专栏文章ID"
  445. // @Success 200 {object} models.SpecialListResp
  446. // @router /message/special/list [get]
  447. func (this *YanxuanSpecialMessageController) MessageSpecialList() {
  448. br := new(models.BaseResponse).Init()
  449. defer func() {
  450. this.Data["json"] = br
  451. this.ServeJSON()
  452. }()
  453. user := this.User
  454. if user == nil {
  455. br.Msg = "请登录"
  456. br.ErrMsg = "请登录,用户信息为空"
  457. br.Ret = 408
  458. return
  459. }
  460. pageSize, _ := this.GetInt("PageSize")
  461. currentIndex, _ := this.GetInt("CurrentIndex")
  462. yanxuanSpecialId, _ := this.GetInt("YanxuanSpecialId")
  463. var startSize int
  464. if pageSize <= 0 {
  465. pageSize = utils.PageSize20
  466. }
  467. if currentIndex <= 0 {
  468. currentIndex = 1
  469. }
  470. startSize = utils.StartIndex(currentIndex, pageSize)
  471. userId := user.UserId
  472. resp := new(models.YanxuanSpecialMessageManageRespListResp)
  473. publiccTotal, err := models.GetCygxYanxuanSpecialMessagerPublicCount(yanxuanSpecialId)
  474. if err != nil {
  475. br.Msg = "获取失败"
  476. br.ErrMsg = "获取失败, Err:" + err.Error()
  477. return
  478. }
  479. resp.PublicMessageTotal = publiccTotal
  480. var condition string
  481. var pars []interface{}
  482. var conditionMyself string
  483. var parsMyself []interface{}
  484. conditionMyself += ` AND status = 0 AND parent_id = 0 AND user_id = ? AND yanxuan_special_id = ? ORDER BY message_id DESC `
  485. parsMyself = append(parsMyself, userId, yanxuanSpecialId)
  486. var listMyself []*models.CygxYanxuanSpecialMessage
  487. if currentIndex == 1 {
  488. //获取自己未公开的留言
  489. listMyself, err = models.GetCygxYanxuanSpecialMessageList(conditionMyself, parsMyself, 0, 999)
  490. if err != nil && err.Error() != utils.ErrNoRow() {
  491. br.Msg = "获取失败"
  492. br.ErrMsg = "获取失败, Err:" + err.Error()
  493. return
  494. }
  495. }
  496. condition += ` AND status = 1 `
  497. condition += ` AND yanxuan_special_id = ? `
  498. pars = append(pars, yanxuanSpecialId)
  499. conditionChildren := condition // 子集留言筛选条件
  500. condition += ` AND parent_id = 0 `
  501. total, err := models.GetCygxYanxuanSpecialMessagerCount(condition, pars)
  502. if err != nil {
  503. br.Msg = "获取失败"
  504. br.ErrMsg = "获取失败, Err:" + err.Error()
  505. return
  506. }
  507. condition += ` ORDER BY top_time DESC , message_id DESC `
  508. list, err := models.GetCygxYanxuanSpecialMessageList(condition, pars, startSize, pageSize)
  509. if err != nil {
  510. br.Msg = "获取失败"
  511. br.ErrMsg = "获取失败, Err:" + err.Error()
  512. return
  513. }
  514. for _, v := range list {
  515. listMyself = append(listMyself, v)
  516. }
  517. if len(listMyself) > 0 {
  518. var messageIds []int
  519. var messageIdsAll []int // 所有的留言消息
  520. var userIds []int
  521. for _, v := range list {
  522. messageIds = append(messageIds, v.MessageId)
  523. }
  524. for _, v := range listMyself {
  525. userIds = append(userIds, v.UserId)
  526. }
  527. itemChildMap := make(map[int][]*models.CygxYanxuanSpecialMessageManageChildResp)
  528. if len(messageIds) > 0 {
  529. //获取子集评论
  530. conditionChildren += ` AND parent_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) ORDER BY message_id ASC `
  531. pars = append(pars, messageIds)
  532. listChild, err := models.GetCygxYanxuanSpecialMessageList(conditionChildren, pars, 0, 999)
  533. if err != nil {
  534. br.Msg = "获取失败"
  535. br.ErrMsg = "获取失败, Err:" + err.Error()
  536. return
  537. }
  538. for _, v := range listChild {
  539. userIds = append(userIds, v.UserId)
  540. messageIdsAll = append(messageIdsAll, v.MessageId)
  541. itemChild := new(models.CygxYanxuanSpecialMessageManageChildResp)
  542. itemChild.UserId = v.UserId
  543. itemChild.MessageId = v.MessageId
  544. itemChild.Content = v.Content
  545. itemChild.LikeCount = v.LikeCount
  546. itemChild.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  547. itemChildMap[v.ParentId] = append(itemChildMap[v.ParentId], itemChild)
  548. }
  549. }
  550. likeMap := services.GetYanxuanSpecialMessageLikeMap(userId)
  551. //用户头像
  552. listUser, err := models.GetWxUserListByUserIdsArr(userIds)
  553. if err != nil {
  554. br.Msg = "获取失败"
  555. br.ErrMsg = "获取失败, Err:" + err.Error()
  556. return
  557. }
  558. mapUserImg := make(map[int]string)
  559. for _, v := range listUser {
  560. if v.Headimgurl != "" {
  561. mapUserImg[v.UserId] = v.Headimgurl
  562. } else {
  563. mapUserImg[v.UserId] = utils.DefaultHeadimgurl
  564. }
  565. }
  566. for _, v := range userIds {
  567. if mapUserImg[v] == "" {
  568. mapUserImg[v] = utils.DefaultHeadimgurl
  569. }
  570. }
  571. for _, v := range listMyself {
  572. item := new(models.CygxYanxuanSpecialMessageManageResp)
  573. item.MessageId = v.MessageId
  574. item.RealName = v.RealName
  575. item.Headimgurl = mapUserImg[v.UserId]
  576. item.YanxuanSpecialId = v.YanxuanSpecialId
  577. item.Content = v.Content
  578. item.TopTime = v.TopTime
  579. item.SourceTitle = v.SourceTitle
  580. item.LikeCount = v.LikeCount
  581. item.IsLikeCount = likeMap[v.MessageId]
  582. item.Status = v.Status
  583. if v.UserId == userId {
  584. item.IsMySelf = true
  585. }
  586. item.CreateTime = v.CreateTime.Format(utils.FormatDateTime)
  587. if len(itemChildMap[v.MessageId]) > 0 {
  588. for _, vm := range itemChildMap[v.MessageId] {
  589. vm.IsLikeCount = likeMap[vm.MessageId]
  590. vm.Headimgurl = mapUserImg[vm.UserId]
  591. }
  592. item.ChildList = itemChildMap[v.MessageId]
  593. } else {
  594. item.ChildList = make([]*models.CygxYanxuanSpecialMessageManageChildResp, 0)
  595. }
  596. item.CheckIds = make([]int, 0)
  597. resp.List = append(resp.List, item)
  598. }
  599. } else {
  600. resp.List = make([]*models.CygxYanxuanSpecialMessageManageResp, 0)
  601. }
  602. page := paging.GetPaging(currentIndex, pageSize, total)
  603. resp.Paging = page
  604. br.Data = resp
  605. br.Ret = 200
  606. br.Success = true
  607. br.Msg = "获取成功"
  608. }