task_logistics_list.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package pack
  2. import (
  3. "youngee_b_api/model/http_model"
  4. "github.com/tidwall/gjson"
  5. "github.com/issue9/conv"
  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)[0:19]
  17. signedTime := conv.MustString(TaskLogisticsInfo.SignedTime)[0:19]
  18. return &http_model.TaskLogisticsPreview{
  19. TaskID: 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. SignedTime: signedTime,
  29. ExplorestoreStarttime: TaskLogisticsInfo.ExplorestoreStarttime,
  30. ExplorestoreEndtime: TaskLogisticsInfo.ExplorestoreEndtime,
  31. ExplorestorePeriod: conv.MustString(TaskLogisticsInfo.ExplorestorePeriod),
  32. CouponCode: conv.MustString(TaskLogisticsInfo.CouponCode),
  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. SignedTime: conv.MustString(TaskLogistics.Logistics.SignedTime),
  56. ExplorestoreStarttime: TaskLogistics.Logistics.ExplorestoreStarttime,
  57. ExplorestoreEndtime: TaskLogistics.Logistics.ExplorestoreEndtime,
  58. ExplorestorePeriod: TaskLogistics.Logistics.ExplorestorePeriod,
  59. CouponCode: TaskLogistics.Logistics.CouponCodeInformation,
  60. }
  61. }