task_script_list.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 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. }