task_terminated_list.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 MGormTaskTerminatedInfoListToHttpTaskTerminatedPreviewList(gormTaskTerminatedInfos []*http_model.TaskTerminatedInfo) []*http_model.TaskTerminatedPreview {
  8. var httpProjectPreviews []*http_model.TaskTerminatedPreview
  9. for _, gormTaskTerminatedInfo := range gormTaskTerminatedInfos {
  10. httpTaskTerminatedPreview := MGormTaskTerminatedInfoToHttpTaskTerminatedPreview(gormTaskTerminatedInfo)
  11. httpProjectPreviews = append(httpProjectPreviews, httpTaskTerminatedPreview)
  12. }
  13. return httpProjectPreviews
  14. }
  15. func MGormTaskTerminatedInfoToHttpTaskTerminatedPreview(TaskTerminatedInfo *http_model.TaskTerminatedInfo) *http_model.TaskTerminatedPreview {
  16. return &http_model.TaskTerminatedPreview{
  17. TaskID: conv.MustString(TaskTerminatedInfo.TaskID, ""),
  18. ProjectID: conv.MustString(TaskTerminatedInfo.ProjectID, ""),
  19. PlatformNickname: conv.MustString(TaskTerminatedInfo.PlatformNickname, ""),
  20. FansCount: conv.MustString(TaskTerminatedInfo.FansCount, ""),
  21. RecruitStrategyID: conv.MustString(TaskTerminatedInfo.RecruitStrategyID, ""),
  22. StrategyID: conv.MustString(TaskTerminatedInfo.StrategyID, ""),
  23. AllPayment: TaskTerminatedInfo.AllPayment,
  24. RealPayment: TaskTerminatedInfo.RealPayment,
  25. BreakType: conv.MustString(TaskTerminatedInfo.BreakType, ""),
  26. }
  27. }
  28. func TaskTerminatedToTaskInfo(TaskTerminateds []*http_model.TaskTerminated) []*http_model.TaskTerminatedInfo {
  29. var TaskTerminatedInfos []*http_model.TaskTerminatedInfo
  30. for _, TaskTerminated := range TaskTerminateds {
  31. TaskTerminated := GetTerminatedInfoStruct(TaskTerminated)
  32. TaskTerminatedInfos = append(TaskTerminatedInfos, TaskTerminated)
  33. }
  34. return TaskTerminatedInfos
  35. }
  36. func GetTerminatedInfoStruct(TaskTerminated *http_model.TaskTerminated) *http_model.TaskTerminatedInfo {
  37. TalentPlatformInfoSnap := TaskTerminated.Talent.TalentPlatformInfoSnap
  38. return &http_model.TaskTerminatedInfo{
  39. TaskID: TaskTerminated.Talent.TaskId,
  40. ProjectID: TaskTerminated.Talent.ProjectId,
  41. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname"), ""),
  42. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count"), ""),
  43. StrategyID: TaskTerminated.Talent.StrategyId,
  44. AllPayment: TaskTerminated.Talent.AllPayment,
  45. RealPayment: TaskTerminated.Talent.RealPayment,
  46. BreakType: TaskTerminated.Default.BreakType,
  47. }
  48. }