task_logistics_list.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package pack
  2. import (
  3. "github.com/caixw/lib.go/conv"
  4. "github.com/tidwall/gjson"
  5. "youngee_m_api/model/http_model"
  6. )
  7. func MGormTaskLogisticsInfoListToHttpTaskLogisticsPreviewList(gormTaskLogisticsInfos []*http_model.TaskLogisticsInfo) []*http_model.TaskLogisticsPreview {
  8. var httpProjectPreviews []*http_model.TaskLogisticsPreview
  9. for _, gormTaskLogisticsInfo := range gormTaskLogisticsInfos {
  10. httpTaskLogisticsPreview := MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(gormTaskLogisticsInfo)
  11. httpProjectPreviews = append(httpProjectPreviews, httpTaskLogisticsPreview)
  12. }
  13. return httpProjectPreviews
  14. }
  15. func MGormTaskLogisticsInfoToHttpTaskLogisticsPreview(TaskLogisticsInfo *http_model.TaskLogisticsInfo) *http_model.TaskLogisticsPreview {
  16. deliveryTime := conv.MustString(TaskLogisticsInfo.DeliveryTime, "")
  17. deliveryTime = deliveryTime[0:19]
  18. return &http_model.TaskLogisticsPreview{
  19. TaskID: conv.MustString(TaskLogisticsInfo.TaskID, ""),
  20. PlatformNickname: conv.MustString(TaskLogisticsInfo.PlatformNickname, ""),
  21. FansCount: conv.MustString(TaskLogisticsInfo.FansCount, ""),
  22. RecruitStrategyID: conv.MustString(TaskLogisticsInfo.RecruitStrategyID, ""),
  23. StrategyID: conv.MustString(TaskLogisticsInfo.StrategyID, ""),
  24. DetailAddr: conv.MustString(TaskLogisticsInfo.DetailAddr, ""),
  25. CompanyName: conv.MustString(TaskLogisticsInfo.CompanyName, ""),
  26. LogisticsNumber: conv.MustString(TaskLogisticsInfo.LogisticsNumber, ""),
  27. DeliveryTime: deliveryTime,
  28. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  29. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  30. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod, ""),
  31. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode, ""),
  32. SignedTime: conv.MustString(TaskLogisticsInfo.SignedTime, "")[:19],
  33. }
  34. }
  35. func TaskLogisticsToTaskInfo(TaskLogisticss []*http_model.TaskLogistics) []*http_model.TaskLogisticsInfo {
  36. var TaskLogisticsInfos []*http_model.TaskLogisticsInfo
  37. for _, TaskLogistics := range TaskLogisticss {
  38. TaskLogistics := GetTalentInfoStruct(TaskLogistics)
  39. TaskLogisticsInfos = append(TaskLogisticsInfos, TaskLogistics)
  40. }
  41. return TaskLogisticsInfos
  42. }
  43. func GetTalentInfoStruct(TaskLogistics *http_model.TaskLogistics) *http_model.TaskLogisticsInfo {
  44. TalentPlatformInfoSnap := TaskLogistics.Talent.TalentPlatformInfoSnap
  45. TalentPostAddrSnap := TaskLogistics.Talent.TalentPostAddrSnap
  46. return &http_model.TaskLogisticsInfo{
  47. TaskID: TaskLogistics.Talent.TaskId,
  48. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
  49. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""),
  50. StrategyID: TaskLogistics.Talent.StrategyId,
  51. DetailAddr: conv.MustString(gjson.Get(TalentPostAddrSnap, "detail_addr"), ""),
  52. CompanyName: TaskLogistics.Logistics.CompanyName,
  53. LogisticsNumber: TaskLogistics.Logistics.LogisticsNumber,
  54. DeliveryTime: conv.MustString(TaskLogistics.Logistics.DeliveryTime, ""),
  55. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  56. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  57. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  58. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  59. SignedTime: conv.MustString(TaskLogistics.Logistics.SignedTime, ""),
  60. }
  61. }