table.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. #*****************************************************************************
  3. # @file table.go
  4. # @author MakerYang(https://www.makeryang.com)
  5. # @statement 免费课程配套开源项目,任何形式收费均为盗版
  6. #*****************************************************************************
  7. */
  8. package GamePlayerData
  9. import (
  10. "Game/framework/database"
  11. "Game/framework/utils"
  12. )
  13. var TableName = "game_player_data"
  14. type Data struct {
  15. PlayerId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:player_id"`
  16. PlayerAccountId int `gorm:"column:player_account_id"`
  17. PlayerServerId int `gorm:"column:player_server_id"`
  18. PlayerNickname string `gorm:"column:player_nickname"`
  19. PlayerCareer string `gorm:"column:player_career"`
  20. PlayerGender string `gorm:"column:player_gender"`
  21. PlayerAngle int `gorm:"column:player_angle"`
  22. PlayerMap string `gorm:"column:player_map"`
  23. PlayerMapX int `gorm:"column:player_map_x"`
  24. PlayerMapY int `gorm:"column:player_map_y"`
  25. PlayerAssetLife int `gorm:"column:player_asset_life"`
  26. PlayerAssetMagic int `gorm:"column:player_asset_magic"`
  27. PlayerAssetExperience int `gorm:"column:player_asset_experience"`
  28. PlayerBodyClothe string `gorm:"column:player_body_clothe"`
  29. PlayerBodyWeapon string `gorm:"column:player_body_weapon"`
  30. PlayerBodyWing string `gorm:"column:player_body_wing"`
  31. PlayerGroupId int `gorm:"column:player_group_id"`
  32. PlayerStatus int `gorm:"column:player_status"`
  33. Database.DefaultField
  34. }
  35. type Return struct {
  36. Token string `json:"token"`
  37. PlayerNickname string `json:"player_nickname"`
  38. PlayerCareer string `json:"player_career"`
  39. PlayerGender string `json:"player_gender"`
  40. PlayerAngle int `json:"player_angle"`
  41. PlayerMap string `json:"player_map"`
  42. PlayerMapX int `json:"player_map_x"`
  43. PlayerMapY int `json:"player_map_y"`
  44. PlayerAssetLife int `json:"player_asset_life"`
  45. PlayerAssetMagic int `json:"player_asset_magic"`
  46. PlayerAssetExperience int `json:"player_asset_experience"`
  47. PlayerBodyClothe string `json:"player_body_clothe"`
  48. PlayerBodyWeapon string `json:"player_body_weapon"`
  49. PlayerBodyWing string `json:"player_body_wing"`
  50. PlayerGroupId int `json:"player_group_id"`
  51. }
  52. func ReturnData(dataStruct *Data) Return {
  53. data := Return{}
  54. if dataStruct.PlayerId > 0 {
  55. data.Token = Utils.EncodeId(32, dataStruct.PlayerId, dataStruct.PlayerAccountId, dataStruct.PlayerServerId)
  56. data.PlayerNickname = dataStruct.PlayerNickname
  57. data.PlayerCareer = dataStruct.PlayerCareer
  58. data.PlayerGender = dataStruct.PlayerGender
  59. data.PlayerAngle = dataStruct.PlayerAngle
  60. data.PlayerMap = dataStruct.PlayerMap
  61. data.PlayerMapX = dataStruct.PlayerMapX
  62. data.PlayerMapY = dataStruct.PlayerMapY
  63. data.PlayerAssetLife = dataStruct.PlayerAssetLife
  64. data.PlayerAssetMagic = dataStruct.PlayerAssetMagic
  65. data.PlayerAssetExperience = dataStruct.PlayerAssetExperience
  66. data.PlayerBodyClothe = dataStruct.PlayerBodyClothe
  67. data.PlayerBodyWeapon = dataStruct.PlayerBodyWeapon
  68. data.PlayerBodyWing = dataStruct.PlayerBodyWing
  69. data.PlayerGroupId = dataStruct.PlayerGroupId
  70. }
  71. return data
  72. }