meta_info.go 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package user
  2. import "eta_mini_ht_api/models/user"
  3. type MetaInfoDTO struct {
  4. Uid string
  5. Meta string
  6. From string
  7. To string
  8. SourceType string
  9. MetaType string
  10. }
  11. func CreateMetaInfo(dto MetaInfoDTO) (err error) {
  12. return user.CreateMetaInfo(convertToMetaInfo(dto))
  13. }
  14. func convertToMetaInfo(dto MetaInfoDTO) user.MetaInfo {
  15. return user.MetaInfo{
  16. Uid: dto.Uid,
  17. Meta: dto.Meta,
  18. From: dto.From,
  19. To: dto.To,
  20. SourceType: user.SourceType(dto.SourceType),
  21. MetaType: user.MetaType(dto.MetaType),
  22. }
  23. }
  24. func convertToMetaDTO(dto user.MetaInfo) MetaInfoDTO {
  25. return MetaInfoDTO{
  26. Uid: dto.Uid,
  27. Meta: dto.Meta,
  28. From: dto.From,
  29. To: dto.To,
  30. SourceType: string(dto.SourceType),
  31. MetaType: string(dto.MetaType),
  32. }
  33. }
  34. func GetInitMetaInfos() (list []MetaInfoDTO) {
  35. metas := user.GetInitMetaInfos()
  36. for _, meta := range metas {
  37. list = append(list, convertToUserDTO())
  38. }
  39. }