operate.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. package pack
  2. import (
  3. "github.com/caixw/lib.go/conv"
  4. "youngee_m_api/consts"
  5. "youngee_m_api/model/common_model"
  6. "youngee_m_api/model/gorm_model"
  7. "youngee_m_api/model/http_model"
  8. "youngee_m_api/util"
  9. )
  10. func HttpPricingRequestToConditions(req *http_model.SearchPricingRequest) *common_model.PricingConditions {
  11. pricingUpdated := conv.MustString(req.UpdateAt, "")
  12. return &common_model.PricingConditions{
  13. ProjectType: conv.MustInt64(req.ProjectType, 0),
  14. FeeForm: conv.MustInt64(req.FeeForm, 0),
  15. Platform: conv.MustInt64(req.Platform, 0),
  16. UpdateAt: pricingUpdated,
  17. }
  18. }
  19. func HttpYoungeeRequestToConditions(req *http_model.SearchYoungeeRequest) *common_model.YoungeeConditions {
  20. return &common_model.YoungeeConditions{
  21. ProjectType: conv.MustInt64(req.ProjectType, 0),
  22. TaskType: conv.MustInt64(req.TaskType, 0),
  23. Platform: conv.MustInt64(req.Platform, 0),
  24. ContentType: conv.MustInt64(req.ContentType, 0),
  25. }
  26. }
  27. func GormSearchPricingDataToHttpData(gormPricings []*gorm_model.InfoPricingStrategy) []*http_model.SearchPricingPreview {
  28. var httpPricingPreviews []*http_model.SearchPricingPreview
  29. for _, gormPricing := range gormPricings {
  30. httpPricingPreview := MGromSearchPricingDataToHttpData(gormPricing)
  31. httpPricingPreviews = append(httpPricingPreviews, httpPricingPreview)
  32. }
  33. return httpPricingPreviews
  34. }
  35. func GormSearchYoungeeDataToHttpData(gormYoungees []*gorm_model.InfoYoungeeStrategy) []*http_model.SearchYoungeePreview {
  36. var httpYoungeePreviews []*http_model.SearchYoungeePreview
  37. for _, gormYoungee := range gormYoungees {
  38. httpYoungeePreview := MGromSearchYoungeeDataToHttpData(gormYoungee)
  39. httpYoungeePreviews = append(httpYoungeePreviews, httpYoungeePreview)
  40. }
  41. return httpYoungeePreviews
  42. }
  43. func MGromSearchYoungeeDataToHttpData(gormYoungee *gorm_model.InfoYoungeeStrategy) *http_model.SearchYoungeePreview {
  44. updatedTime := conv.MustString(gormYoungee.CreateAt, "")
  45. updatedTime = updatedTime[0:19]
  46. //if gormYoungee.FansLow == 0 && gormYoungee.FansUp == 0 {
  47. // fans = "不限"
  48. //} else if gormYoungee.FansLow == 0 && gormYoungee.FansUp != 0 {
  49. // fans = util.GetNumString(gormYoungee.FansUp) + "以下"
  50. //} else if gormYoungee.FansLow != 0 && gormYoungee.FansUp != 0 {
  51. // fans = util.GetNumString(gormYoungee.FansLow) + "-" + util.GetNumString(gormYoungee.FansUp)
  52. //} else if gormYoungee.FansLow != 0 && gormYoungee.FansUp == 0 {
  53. // fans = util.GetNumString(gormYoungee.FansLow) + "以上"
  54. //}
  55. return &http_model.SearchYoungeePreview{
  56. ID: conv.MustString(gormYoungee.ID, ""),
  57. StrategyId: gormYoungee.StrategyId,
  58. ProjectType: consts.GetProjectType(gormYoungee.ProjectType),
  59. Platform: consts.GetProjectPlatform(gormYoungee.Platform),
  60. TaskType: consts.GetTaskType(gormYoungee.TaskType),
  61. ContentType: consts.GetContentType(gormYoungee.ContentType),
  62. Reason: consts.GetReason(gormYoungee.Reason),
  63. Points: conv.MustString(gormYoungee.Points, ""),
  64. Cash: conv.MustString(gormYoungee.Cash/1, "") + "%",
  65. Createat: updatedTime,
  66. }
  67. }
  68. func MGromSearchPricingDataToHttpData(gormPricing *gorm_model.InfoPricingStrategy) *http_model.SearchPricingPreview {
  69. updatedTime := conv.MustString(gormPricing.UpdateAt, "")
  70. updatedTime = updatedTime[0:19]
  71. fans := ""
  72. //if gormPricing.FansLow == 0 && gormPricing.FansUp == 0 {
  73. // fans = "不限"
  74. //} else if gormPricing.FansLow == 0 && gormPricing.FansUp != 0 {
  75. // fans = util.GetNumString(gormPricing.FansUp) + "以下"
  76. //} else if gormPricing.FansLow != 0 && gormPricing.FansUp != 0 {
  77. // fans = util.GetNumString(gormPricing.FansLow) + "-" + util.GetNumString(gormPricing.FansUp)
  78. //} else if gormPricing.FansLow != 0 && gormPricing.FansUp == 0 {
  79. // fans = util.GetNumString(gormPricing.FansLow) + "以上"
  80. //}
  81. fans = util.GetNumString(gormPricing.FansLow) + "-" + util.GetNumString(gormPricing.FansUp)
  82. serviceCharge := ""
  83. if gormPricing.ServiceCharge == 0 {
  84. serviceCharge = "不限"
  85. } else {
  86. serviceCharge = conv.MustString(gormPricing.ServiceCharge, "")
  87. }
  88. return &http_model.SearchPricingPreview{
  89. ID: conv.MustString(gormPricing.ID, ""),
  90. StrategyId: gormPricing.StrategyId,
  91. ProjectType: consts.GetProjectType(gormPricing.ProjectType),
  92. Platform: consts.GetProjectPlatform(gormPricing.Platform),
  93. ManuscriptForm: consts.GetFeeForm(gormPricing.FeeForm),
  94. Fans: fans,
  95. ServiceCharge: serviceCharge,
  96. ServiceRate: conv.MustString(gormPricing.ServiceRate/10, "") + "%",
  97. UpdateTime: updatedTime,
  98. }
  99. }
  100. func HttpBreachHandledRequestToConditions(request *http_model.BreachHandledRequest) *common_model.BreachHandledConditions {
  101. return &common_model.BreachHandledConditions{
  102. HandleResult: conv.MustInt32(request.HandleResult, 0),
  103. TerminateReason: conv.MustInt32(request.TerminateReason, 0),
  104. }
  105. }