task_script_list.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 MGormTaskScriptInfoListToHttpTaskScriptPreviewList(gormTaskScriptInfos []*http_model.TaskScriptInfo) []*http_model.TaskScriptPreview {
  8. var httpProjectPreviews []*http_model.TaskScriptPreview
  9. for _, gormTaskScriptInfo := range gormTaskScriptInfos {
  10. httpTaskScriptPreview := MGormTaskScriptInfoToHttpTaskScriptPreview(gormTaskScriptInfo)
  11. httpProjectPreviews = append(httpProjectPreviews, httpTaskScriptPreview)
  12. }
  13. return httpProjectPreviews
  14. }
  15. func MGormTaskScriptInfoToHttpTaskScriptPreview(TaskScriptInfo *http_model.TaskScriptInfo) *http_model.TaskScriptPreview {
  16. //deliveryTime := conv.MustString(TaskScriptInfo.DeliveryTime)
  17. //deliveryTime = deliveryTime[0:19]
  18. return &http_model.TaskScriptPreview{
  19. TaskID: conv.MustString(TaskScriptInfo.TaskID),
  20. PlatformNickname: conv.MustString(TaskScriptInfo.PlatformNickname),
  21. FansCount: conv.MustString(TaskScriptInfo.FansCount),
  22. RecruitStrategyID: conv.MustString(TaskScriptInfo.RecruitStrategyID),
  23. StrategyID: conv.MustString(TaskScriptInfo.StrategyID),
  24. Title: TaskScriptInfo.Title,
  25. Content: TaskScriptInfo.Content,
  26. ReviseOpinion: TaskScriptInfo.ReviseOpinion,
  27. Submit: conv.MustString(TaskScriptInfo.SubmitAt)[0:19],
  28. AgreeAt: conv.MustString(TaskScriptInfo.AgreeAt)[0:19],
  29. }
  30. }
  31. func TaskScriptToTaskInfo(TaskScripts []*http_model.TaskScript) []*http_model.TaskScriptInfo {
  32. var TaskScriptInfos []*http_model.TaskScriptInfo
  33. for _, TaskScript := range TaskScripts {
  34. TaskScript := GetScriptInfoStruct(TaskScript)
  35. TaskScriptInfos = append(TaskScriptInfos, TaskScript)
  36. }
  37. return TaskScriptInfos
  38. }
  39. func GetScriptInfoStruct(TaskScript *http_model.TaskScript) *http_model.TaskScriptInfo {
  40. TalentPlatformInfoSnap := TaskScript.Talent.TalentPlatformInfoSnap
  41. return &http_model.TaskScriptInfo{
  42. TaskID: TaskScript.Talent.TaskID,
  43. PlatformNickname: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "platform_nickname")),
  44. FansCount: conv.MustString(gjson.Get(TalentPlatformInfoSnap, "fans_count")),
  45. StrategyID: TaskScript.Talent.StrategyID,
  46. ScriptId: TaskScript.Script.ScriptID,
  47. Title: TaskScript.Script.Title,
  48. Content: TaskScript.Script.Content,
  49. ReviseOpinion: TaskScript.Script.ReviseOpinion,
  50. CreateAt: TaskScript.Script.CreateAt,
  51. SubmitAt: TaskScript.Script.SubmitAt,
  52. AgreeAt: TaskScript.Script.AgreeAt,
  53. RejectAt: TaskScript.Script.RejectAt,
  54. IsReview: TaskScript.Script.IsReview,
  55. }
  56. }