copy.go 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package api
  2. import (
  3. "go-common/app/service/main/member/model"
  4. block "go-common/app/service/main/member/model/block"
  5. )
  6. // FromBaseInfo convert from model.BaseInfo to v1.BaseInfoReply
  7. func FromBaseInfo(model *model.BaseInfo) *BaseInfoReply {
  8. baseInfoReply := &BaseInfoReply{
  9. Mid: model.Mid,
  10. Name: model.Name,
  11. Sex: model.Sex,
  12. Face: model.Face,
  13. Sign: model.Sign,
  14. Rank: model.Rank,
  15. Birthday: model.Birthday,
  16. }
  17. return baseInfoReply
  18. }
  19. // FromLevelInfo convert from model.LevelInfo to v1.LevelInfoReply
  20. func FromLevelInfo(model *model.LevelInfo) *LevelInfoReply {
  21. levelInfoReply := &LevelInfoReply{
  22. Cur: model.Cur,
  23. Min: model.Min,
  24. NowExp: model.NowExp,
  25. NextExp: model.NextExp,
  26. }
  27. return levelInfoReply
  28. }
  29. // FromOfficialInfo convert from model.OfficialInfo to v1.OfficialInfoReply
  30. func FromOfficialInfo(model *model.OfficialInfo) *OfficialInfoReply {
  31. officialInfoReply := &OfficialInfoReply{
  32. Role: model.Role,
  33. Title: model.Title,
  34. Desc: model.Desc,
  35. }
  36. return officialInfoReply
  37. }
  38. // FromMember convert from model.Member to v1.MemberInfoReply
  39. func FromMember(res *model.Member) *MemberInfoReply {
  40. var baseInfo *BaseInfoReply
  41. var levelInfo *LevelInfoReply
  42. var officialInfo *OfficialInfoReply
  43. if res.BaseInfo != nil {
  44. baseInfo = FromBaseInfo(res.BaseInfo)
  45. }
  46. if res.LevelInfo != nil {
  47. levelInfo = FromLevelInfo(res.LevelInfo)
  48. }
  49. if res.OfficialInfo != nil {
  50. officialInfo = FromOfficialInfo(res.OfficialInfo)
  51. }
  52. memberInfoReply := &MemberInfoReply{
  53. BaseInfo: baseInfo,
  54. LevelInfo: levelInfo,
  55. OfficialInfo: officialInfo,
  56. }
  57. return memberInfoReply
  58. }
  59. // FromOfficialDoc convert from model.OfficalDoc to v1.OfficialDocInfoReply
  60. func FromOfficialDoc(model *model.OfficialDoc) *OfficialDocInfoReply {
  61. officalDocInfoReply := &OfficialDocInfoReply{
  62. Mid: model.Mid,
  63. Name: model.Name,
  64. State: int32(model.State),
  65. Role: int8(model.Role),
  66. Title: model.Title,
  67. Desc: model.Desc,
  68. RejectReason: model.RejectReason,
  69. Realname: int8(model.Realname),
  70. Operator: model.Operator,
  71. Telephone: model.Telephone,
  72. Email: model.Email,
  73. Address: model.Address,
  74. Company: model.Company,
  75. CreditCode: model.CreditCode,
  76. Organization: model.Organization,
  77. OrganizationType: model.OrganizationType,
  78. BusinessLicense: model.BusinessLicense,
  79. BusinessScale: model.BusinessScale,
  80. BusinessLevel: model.BusinessLevel,
  81. BusinessAuth: model.BusinessAuth,
  82. Supplement: model.Supplement,
  83. Professional: model.Professional,
  84. Identification: model.Identification,
  85. }
  86. return officalDocInfoReply
  87. }
  88. // FromBlockInfo convert from model.BlockInfo to v1.OfficialDocInfoReply
  89. func FromBlockInfo(model *block.BlockInfo) *BlockInfoReply {
  90. blockInfoReply := &BlockInfoReply{
  91. MID: model.MID,
  92. BlockStatus: int32(model.BlockStatus),
  93. StartTime: model.StartTime,
  94. EndTime: model.EndTime,
  95. }
  96. return blockInfoReply
  97. }
  98. // FromBlockUserDetail convert from model.BlockUserDetail v1.OfficialDocInfoReply
  99. func FromBlockUserDetail(model *block.BlockUserDetail) *BlockDetailReply {
  100. blockDetailReply := &BlockDetailReply{
  101. MID: model.MID,
  102. BlockCount: model.BlockCount,
  103. }
  104. return blockDetailReply
  105. }
  106. // ToArgOfficialDoc convert from v1.officalDocReq to model.AragsOfficalDoc
  107. func ToArgOfficialDoc(req *OfficialDocReq) *model.ArgOfficialDoc {
  108. argOfficialDoc := &model.ArgOfficialDoc{
  109. Mid: req.Mid,
  110. Name: req.Name,
  111. Role: req.Role,
  112. Title: req.Title,
  113. Desc: req.Desc,
  114. Realname: int8(req.Realname),
  115. Operator: req.Operator,
  116. Telephone: req.Telephone,
  117. Email: req.Email,
  118. Address: req.Address,
  119. Company: req.Company,
  120. CreditCode: req.CreditCode,
  121. Organization: req.Organization,
  122. OrganizationType: req.OrganizationType,
  123. BusinessLicense: req.BusinessLicense,
  124. BusinessScale: req.BusinessScale,
  125. BusinessLevel: req.BusinessLevel,
  126. BusinessAuth: req.BusinessAuth,
  127. Supplement: req.Supplement,
  128. Professional: req.Professional,
  129. Identification: req.Identification,
  130. SubmitSource: req.SubmitSource,
  131. }
  132. return argOfficialDoc
  133. }
  134. // ToArgUpdateMoral convert from v1.UpdateMoralReq to model.ArgUpdateMoral
  135. func ToArgUpdateMoral(req *UpdateMoralReq) *model.ArgUpdateMoral {
  136. updateMoral := &model.ArgUpdateMoral{
  137. Mid: req.Mid,
  138. Delta: req.Delta,
  139. Origin: req.Origin,
  140. Reason: req.Reason,
  141. ReasonType: req.ReasonType,
  142. Operator: req.Operator,
  143. Remark: req.Remark,
  144. Status: req.Status,
  145. IsNotify: req.IsNotify,
  146. IP: req.Ip,
  147. }
  148. return updateMoral
  149. }
  150. // ToArgUpdateMorals convert from v1.UpdateMoralsReq to model.ArgUpdateMorals
  151. func ToArgUpdateMorals(req *UpdateMoralsReq) *model.ArgUpdateMorals {
  152. updateMorals := &model.ArgUpdateMorals{
  153. Mids: req.Mids,
  154. Delta: req.Delta,
  155. Origin: req.Origin,
  156. Reason: req.Reason,
  157. ReasonType: req.ReasonType,
  158. Operator: req.Operator,
  159. Remark: req.Remark,
  160. Status: req.Status,
  161. IsNotify: req.IsNotify,
  162. IP: req.Ip,
  163. }
  164. return updateMorals
  165. }