第三课时操作引导文档。
用户界面的知识点、用户界面的规划
game_account_data
数据表字段映射程序
package GameAccountData
import (
"Game/framework/database"
"Game/framework/utils"
)
var TableName = "game_account_data"
type Data struct {
AccountId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:account_id"`
AccountAccount string `gorm:"column:account_account"`
AccountPassword string `gorm:"column:account_password"`
AccountName string `gorm:"column:account_name"`
AccountNumber string `gorm:"column:account_number"`
AccountQuestionA string `gorm:"column:account_question_a"`
AccountQuestionB string `gorm:"column:account_question_b"`
AccountAnswerA string `gorm:"column:account_answer_a"`
AccountAnswerB string `gorm:"column:account_answer_b"`
AccountStatus int `gorm:"column:account_status"`
Database.DefaultField
}
type Return struct {
Token string `json:"token"`
}
func ReturnData(dataStruct *Data) Return {
data := Return{}
if dataStruct.AccountId > 0 {
data.Token = Utils.EncodeId(32, dataStruct.AccountId)
}
return data
}
game_level_data
数据表字段映射程序
package GameLevelData
import (
"Game/framework/database"
)
var TableName = "game_level_data"
type Data struct {
LevelId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:level_id"`
LevelServerId int `gorm:"column:level_server_id"`
LevelCareer string `gorm:"column:level_career"`
LevelName string `gorm:"column:level_name"`
LevelMin int `gorm:"column:level_min"`
LevelMax int `gorm:"column:level_max"`
LevelLifeValue int `gorm:"column:level_life_value"`
LevelMagicValue int `gorm:"column:level_magic_value"`
LevelStatus int `gorm:"column:level_status"`
Database.DefaultField
}
type Return struct {
LevelCareer string `json:"level_career"`
LevelName string `json:"level_name"`
LevelMin int `json:"level_min"`
LevelMax int `json:"level_max"`
LevelLifeValue int `json:"level_life_value"`
LevelMagicValue int `json:"level_magic_value"`
}
func ReturnData(dataStruct *Data) Return {
data := Return{}
if dataStruct.LevelId > 0 {
data.LevelCareer = dataStruct.LevelCareer
data.LevelName = dataStruct.LevelName
data.LevelMin = dataStruct.LevelMin
data.LevelMax = dataStruct.LevelMax
data.LevelLifeValue = dataStruct.LevelLifeValue
data.LevelMagicValue = dataStruct.LevelMagicValue
}
return data
}
game_map_data
数据表字段映射程序
package GameMapData
import (
"Game/framework/database"
)
var TableName = "game_map_data"
type Data struct {
MapId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:map_id"`
MapServerId int `gorm:"column:map_server_id"`
MapNumber string `gorm:"column:map_number"`
MapName string `gorm:"column:map_name"`
MapDefaultX int `gorm:"column:map_default_x"`
MapDefaultY int `gorm:"column:map_default_y"`
MapStatus int `gorm:"column:map_status"`
Database.DefaultField
}
type Return struct {
MapNumber string `json:"map_number"`
MapName string `json:"map_name"`
MapDefaultX int `json:"map_default_x"`
MapDefaultY int `json:"map_default_y"`
}
func ReturnData(dataStruct *Data) Return {
data := Return{}
if dataStruct.MapId > 0 {
data.MapNumber = dataStruct.MapNumber
data.MapName = dataStruct.MapName
data.MapDefaultX = dataStruct.MapDefaultX
data.MapDefaultY = dataStruct.MapDefaultY
}
return data
}
game_player_data
数据表字段映射程序
package GamePlayerData
import (
"Game/framework/database"
"Game/framework/utils"
)
var TableName = "game_player_data"
type Data struct {
PlayerId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:player_id"`
PlayerAccountId int `gorm:"column:player_account_id"`
PlayerServerId int `gorm:"column:player_server_id"`
PlayerNickname string `gorm:"column:player_nickname"`
PlayerCareer string `gorm:"column:player_career"`
PlayerGender string `gorm:"column:player_gender"`
PlayerAngle int `gorm:"column:player_angle"`
PlayerMap string `gorm:"column:player_map"`
PlayerMapX int `gorm:"column:player_map_x"`
PlayerMapY int `gorm:"column:player_map_y"`
PlayerAssetLife int `gorm:"column:player_asset_life"`
PlayerAssetMagic int `gorm:"column:player_asset_magic"`
PlayerAssetExperience int `gorm:"column:player_asset_experience"`
PlayerBodyClothe string `gorm:"column:player_body_clothe"`
PlayerBodyWeapon string `gorm:"column:player_body_weapon"`
PlayerBodyWing string `gorm:"column:player_body_wing"`
PlayerGroupId int `gorm:"column:player_group_id"`
PlayerStatus int `gorm:"column:player_status"`
Database.DefaultField
}
type Return struct {
Token string `json:"token"`
PlayerNickname string `json:"player_nickname"`
PlayerCareer string `json:"player_career"`
PlayerGender string `json:"player_gender"`
PlayerAngle int `json:"player_angle"`
PlayerMap string `json:"player_map"`
PlayerMapX int `json:"player_map_x"`
PlayerMapY int `json:"player_map_y"`
PlayerAssetLife int `json:"player_asset_life"`
PlayerAssetMagic int `json:"player_asset_magic"`
PlayerAssetExperience int `json:"player_asset_experience"`
PlayerBodyClothe string `json:"player_body_clothe"`
PlayerBodyWeapon string `json:"player_body_weapon"`
PlayerBodyWing string `json:"player_body_wing"`
PlayerGroupId int `json:"player_group_id"`
}
func ReturnData(dataStruct *Data) Return {
data := Return{}
if dataStruct.PlayerId > 0 {
data.Token = Utils.EncodeId(32, dataStruct.PlayerId, dataStruct.PlayerAccountId, dataStruct.PlayerServerId)
data.PlayerNickname = dataStruct.PlayerNickname
data.PlayerCareer = dataStruct.PlayerCareer
data.PlayerGender = dataStruct.PlayerGender
data.PlayerAngle = dataStruct.PlayerAngle
data.PlayerMap = dataStruct.PlayerMap
data.PlayerMapX = dataStruct.PlayerMapX
data.PlayerMapY = dataStruct.PlayerMapY
data.PlayerAssetLife = dataStruct.PlayerAssetLife
data.PlayerAssetMagic = dataStruct.PlayerAssetMagic
data.PlayerAssetExperience = dataStruct.PlayerAssetExperience
data.PlayerBodyClothe = dataStruct.PlayerBodyClothe
data.PlayerBodyWeapon = dataStruct.PlayerBodyWeapon
data.PlayerBodyWing = dataStruct.PlayerBodyWing
data.PlayerGroupId = dataStruct.PlayerGroupId
}
return data
}
game_server_data
数据表字段映射程序
package GameServerData
import (
"Game/framework/database"
"Game/framework/utils"
)
var TableName = "game_server_data"
type Data struct {
ServerId int `gorm:"primary_key;AUTO_INCREMENT;unique_index;not null;column:server_id"`
ServerName string `gorm:"column:server_name"`
ServerStatus int `gorm:"column:server_status"`
Database.DefaultField
}
type Return struct {
Token string `json:"token"`
ServerName string `json:"server_name"`
}
func ReturnData(dataStruct *Data) Return {
data := Return{}
if dataStruct.ServerId > 0 {
data.Token = Utils.EncodeId(32, dataStruct.ServerId)
data.ServerName = dataStruct.ServerName
}
return data
}
game_level_data
数据表测试数据
INSERT INTO `game_level_data` VALUES (1, 1, 'warrior', 1, 1, 100, 10, 10, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (2, 1, 'warrior', 2, 100, 500, 20, 20, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (3, 1, 'warrior', 3, 500, 1000, 30, 30, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (4, 1, 'warrior', 4, 1000, 1500, 40, 40, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (5, 1, 'warrior', 5, 1500, 2000, 50, 50, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (6, 1, 'warrior', 6, 2000, 2500, 60, 60, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (7, 1, 'warrior', 7, 2500, 3000, 70, 70, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (8, 1, 'warrior', 8, 3000, 3500, 80, 80, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (9, 1, 'warrior', 9, 3500, 4000, 90, 90, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (10, 1, 'warrior', 10, 4000, 4500, 100, 100, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (11, 1, 'warrior', 11, 4500, 5000, 110, 110, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (12, 1, 'warrior', 12, 5000, 5500, 120, 120, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (13, 1, 'warrior', 13, 5500, 6000, 130, 130, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (14, 1, 'warrior', 14, 6000, 6500, 140, 140, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (15, 1, 'warrior', 15, 6500, 7000, 150, 150, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (16, 1, 'warrior', 16, 7000, 7500, 160, 160, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (17, 1, 'warrior', 17, 7500, 8000, 170, 170, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (18, 1, 'warrior', 18, 8000, 8500, 180, 180, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (19, 1, 'warrior', 19, 8500, 9000, 190, 190, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (20, 1, 'warrior', 20, 9000, 9500, 200, 200, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (21, 1, 'warrior', 21, 9500, 10500, 250, 220, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (22, 1, 'warrior', 22, 10500, 11000, 300, 240, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (23, 1, 'warrior', 23, 11000, 15000, 350, 260, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (24, 1, 'warrior', 24, 15000, 20000, 400, 280, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (25, 1, 'warrior', 25, 20000, 25000, 450, 300, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (26, 1, 'warrior', 26, 25000, 30000, 500, 320, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (27, 1, 'warrior', 27, 30000, 35000, 550, 340, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (28, 1, 'warrior', 28, 35000, 40000, 600, 380, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (29, 1, 'warrior', 29, 40000, 45000, 650, 400, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (30, 1, 'warrior', 30, 45000, 50000, 700, 420, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (31, 1, 'warrior', 31, 50000, 60000, 750, 440, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (32, 1, 'warrior', 32, 70000, 80000, 800, 460, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (33, 1, 'warrior', 33, 80000, 90000, 850, 480, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (34, 1, 'warrior', 34, 90000, 100000, 900, 500, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (35, 1, 'warrior', 35, 100000, 200000, 950, 520, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (36, 1, 'warrior', 36, 200000, 300000, 1000, 540, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (37, 1, 'warrior', 37, 300000, 400000, 1050, 560, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (38, 1, 'warrior', 38, 400000, 500000, 1100, 580, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (39, 1, 'warrior', 39, 500000, 600000, 1150, 600, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (40, 1, 'warrior', 40, 600000, 700000, 1200, 620, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (41, 1, 'warrior', 41, 700000, 800000, 1250, 640, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (42, 1, 'warrior', 42, 800000, 900000, 1300, 660, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (43, 1, 'warrior', 43, 900000, 1000000, 1350, 680, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (44, 1, 'warrior', 44, 1000000, 110000, 1400, 700, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (45, 1, 'warrior', 45, 1100000, 1200000, 1450, 720, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (46, 1, 'warrior', 46, 1200000, 1300000, 1500, 740, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (47, 1, 'warrior', 47, 1300000, 1400000, 1550, 760, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (48, 1, 'warrior', 48, 1400000, 1500000, 1600, 780, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (49, 1, 'warrior', 49, 1500000, 1600000, 1650, 800, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (50, 1, 'warrior', 50, 1600000, 1700000, 1700, 820, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (61, 1, 'warrior', 51, 1700000, 1800000, 1750, 840, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (62, 1, 'warrior', 52, 1800000, 1900000, 1800, 860, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (63, 1, 'warrior', 53, 1900000, 2000000, 1850, 880, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (64, 1, 'warrior', 54, 2000000, 3000000, 1900, 900, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (65, 1, 'warrior', 55, 3000000, 4000000, 1950, 920, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (66, 1, 'warrior', 56, 4000000, 5000000, 2000, 940, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (67, 1, 'warrior', 57, 5000000, 6000000, 2050, 960, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (68, 1, 'warrior', 58, 6000000, 7000000, 2100, 980, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (69, 1, 'warrior', 59, 7000000, 8000000, 2150, 1000, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (70, 1, 'warrior', 60, 8000000, 100000000, 2200, 1020, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (71, 1, 'mage', 1, 1, 100, 10, 10, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (72, 1, 'mage', 2, 100, 500, 20, 20, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (73, 1, 'mage', 3, 500, 1000, 30, 30, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (74, 1, 'mage', 4, 1000, 1500, 40, 40, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (75, 1, 'mage', 5, 1500, 2000, 50, 50, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (76, 1, 'mage', 6, 2000, 2500, 60, 60, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (77, 1, 'mage', 7, 2500, 3000, 70, 70, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (78, 1, 'mage', 8, 3000, 3500, 80, 80, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (79, 1, 'mage', 9, 3500, 4000, 90, 90, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (80, 1, 'mage', 10, 4000, 4500, 100, 100, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (81, 1, 'mage', 11, 4500, 5000, 110, 110, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (82, 1, 'mage', 12, 5000, 5500, 120, 120, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (83, 1, 'mage', 13, 5500, 6000, 130, 130, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (84, 1, 'mage', 14, 6000, 6500, 140, 140, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (85, 1, 'mage', 15, 6500, 7000, 150, 150, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (86, 1, 'mage', 16, 7000, 7500, 160, 160, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (87, 1, 'mage', 17, 7500, 8000, 170, 170, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (88, 1, 'mage', 18, 8000, 8500, 180, 180, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (89, 1, 'mage', 19, 8500, 9000, 190, 190, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (90, 1, 'mage', 20, 9000, 9500, 200, 200, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (91, 1, 'mage', 21, 9500, 10500, 250, 220, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (92, 1, 'mage', 22, 10500, 11000, 300, 240, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (93, 1, 'mage', 23, 11000, 15000, 350, 260, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (94, 1, 'mage', 24, 15000, 20000, 400, 280, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (95, 1, 'mage', 25, 20000, 25000, 450, 300, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (96, 1, 'mage', 26, 25000, 30000, 500, 320, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (97, 1, 'mage', 27, 30000, 35000, 550, 340, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (98, 1, 'mage', 28, 35000, 40000, 600, 380, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (99, 1, 'mage', 29, 40000, 45000, 650, 400, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (100, 1, 'mage', 30, 45000, 50000, 700, 420, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (101, 1, 'mage', 31, 50000, 60000, 750, 440, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (102, 1, 'mage', 32, 70000, 80000, 800, 460, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (103, 1, 'mage', 33, 80000, 90000, 850, 480, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (104, 1, 'mage', 34, 90000, 100000, 900, 500, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (105, 1, 'mage', 35, 100000, 200000, 950, 520, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (106, 1, 'mage', 36, 200000, 300000, 1000, 540, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (107, 1, 'mage', 37, 300000, 400000, 1050, 560, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (108, 1, 'mage', 38, 400000, 500000, 1100, 580, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (109, 1, 'mage', 39, 500000, 600000, 1150, 600, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (110, 1, 'mage', 40, 600000, 700000, 1200, 620, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (111, 1, 'mage', 41, 700000, 800000, 1250, 640, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (112, 1, 'mage', 42, 800000, 900000, 1300, 660, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (113, 1, 'mage', 43, 900000, 1000000, 1350, 680, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (114, 1, 'mage', 44, 1000000, 110000, 1400, 700, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (115, 1, 'mage', 45, 1100000, 1200000, 1450, 720, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (116, 1, 'mage', 46, 1200000, 1300000, 1500, 740, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (117, 1, 'mage', 47, 1300000, 1400000, 1550, 760, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (118, 1, 'mage', 48, 1400000, 1500000, 1600, 780, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (119, 1, 'mage', 49, 1500000, 1600000, 1650, 800, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (120, 1, 'mage', 50, 1600000, 1700000, 1700, 820, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (121, 1, 'mage', 51, 1700000, 1800000, 1750, 840, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (122, 1, 'mage', 52, 1800000, 1900000, 1800, 860, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (123, 1, 'mage', 53, 1900000, 2000000, 1850, 880, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (124, 1, 'mage', 54, 2000000, 3000000, 1900, 900, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (125, 1, 'mage', 55, 3000000, 4000000, 1950, 920, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (126, 1, 'mage', 56, 4000000, 5000000, 2000, 940, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (127, 1, 'mage', 57, 5000000, 6000000, 2050, 960, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (128, 1, 'mage', 58, 6000000, 7000000, 2100, 980, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (129, 1, 'mage', 59, 7000000, 8000000, 2150, 1000, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (130, 1, 'mage', 60, 8000000, 100000000, 2200, 1020, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (131, 1, 'taoist', 1, 1, 100, 10, 10, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (132, 1, 'taoist', 2, 100, 500, 20, 20, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (133, 1, 'taoist', 3, 500, 1000, 30, 30, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (134, 1, 'taoist', 4, 1000, 1500, 40, 40, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (135, 1, 'taoist', 5, 1500, 2000, 50, 50, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (136, 1, 'taoist', 6, 2000, 2500, 60, 60, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (137, 1, 'taoist', 7, 2500, 3000, 70, 70, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (138, 1, 'taoist', 8, 3000, 3500, 80, 80, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (139, 1, 'taoist', 9, 3500, 4000, 90, 90, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (140, 1, 'taoist', 10, 4000, 4500, 100, 100, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (141, 1, 'taoist', 11, 4500, 5000, 110, 110, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (142, 1, 'taoist', 12, 5000, 5500, 120, 120, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (143, 1, 'taoist', 13, 5500, 6000, 130, 130, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (144, 1, 'taoist', 14, 6000, 6500, 140, 140, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (145, 1, 'taoist', 15, 6500, 7000, 150, 150, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (146, 1, 'taoist', 16, 7000, 7500, 160, 160, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (147, 1, 'taoist', 17, 7500, 8000, 170, 170, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (148, 1, 'taoist', 18, 8000, 8500, 180, 180, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (149, 1, 'taoist', 19, 8500, 9000, 190, 190, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (150, 1, 'taoist', 20, 9000, 9500, 200, 200, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (151, 1, 'taoist', 21, 9500, 10500, 250, 220, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (152, 1, 'taoist', 22, 10500, 11000, 300, 240, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (153, 1, 'taoist', 23, 11000, 15000, 350, 260, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (154, 1, 'taoist', 24, 15000, 20000, 400, 280, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (155, 1, 'taoist', 25, 20000, 25000, 450, 300, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (156, 1, 'taoist', 26, 25000, 30000, 500, 320, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (157, 1, 'taoist', 27, 30000, 35000, 550, 340, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (158, 1, 'taoist', 28, 35000, 40000, 600, 380, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (159, 1, 'taoist', 29, 40000, 45000, 650, 400, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (160, 1, 'taoist', 30, 45000, 50000, 700, 420, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (161, 1, 'taoist', 31, 50000, 60000, 750, 440, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (162, 1, 'taoist', 32, 70000, 80000, 800, 460, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (163, 1, 'taoist', 33, 80000, 90000, 850, 480, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (164, 1, 'taoist', 34, 90000, 100000, 900, 500, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (165, 1, 'taoist', 35, 100000, 200000, 950, 520, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (166, 1, 'taoist', 36, 200000, 300000, 1000, 540, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (167, 1, 'taoist', 37, 300000, 400000, 1050, 560, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (168, 1, 'taoist', 38, 400000, 500000, 1100, 580, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (169, 1, 'taoist', 39, 500000, 600000, 1150, 600, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (170, 1, 'taoist', 40, 600000, 700000, 1200, 620, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (171, 1, 'taoist', 41, 700000, 800000, 1250, 640, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (172, 1, 'taoist', 42, 800000, 900000, 1300, 660, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (173, 1, 'taoist', 43, 900000, 1000000, 1350, 680, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (174, 1, 'taoist', 44, 1000000, 110000, 1400, 700, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (175, 1, 'taoist', 45, 1100000, 1200000, 1450, 720, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (176, 1, 'taoist', 46, 1200000, 1300000, 1500, 740, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (177, 1, 'taoist', 47, 1300000, 1400000, 1550, 760, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (178, 1, 'taoist', 48, 1400000, 1500000, 1600, 780, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (179, 1, 'taoist', 49, 1500000, 1600000, 1650, 800, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (180, 1, 'taoist', 50, 1600000, 1700000, 1700, 820, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (181, 1, 'taoist', 51, 1700000, 1800000, 1750, 840, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (182, 1, 'taoist', 52, 1800000, 1900000, 1800, 860, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (183, 1, 'taoist', 53, 1900000, 2000000, 1850, 880, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (184, 1, 'taoist', 54, 2000000, 3000000, 1900, 900, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (185, 1, 'taoist', 55, 3000000, 4000000, 1950, 920, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (186, 1, 'taoist', 56, 4000000, 5000000, 2000, 940, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (187, 1, 'taoist', 57, 5000000, 6000000, 2050, 960, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (188, 1, 'taoist', 58, 6000000, 7000000, 2100, 980, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (189, 1, 'taoist', 59, 7000000, 8000000, 2150, 1000, 2, 0, 0, 0);
INSERT INTO `game_level_data` VALUES (190, 1, 'taoist', 60, 8000000, 100000000, 2200, 1020, 2, 0, 0, 0);
game_server_data
数据表测试数据
INSERT INTO `game_server_data` VALUES (1, '游戏一区', 2, 0, 0, 0);
INSERT INTO `game_server_data` VALUES (2, '游戏二区', 2, 0, 0, 0);
INSERT INTO `game_server_data` VALUES (3, '游戏三区', 2, 0, 0, 0);
用户注册接口程序源码
package AccountInterface
import (
"Game/framework/database"
"Game/framework/database/game_account_data"
"Game/framework/utils"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"io/ioutil"
)
type requestRegister struct {
Account string `json:"account"`
Password string `json:"password"`
Name string `json:"name"`
Number string `json:"number"`
QuestionA string `json:"question_a"`
AnswerA string `json:"answer_a"`
QuestionB string `json:"question_b"`
AnswerB string `json:"answer_b"`
}
type responseRegister struct {
Token string `json:"token"`
}
func Register(c *gin.Context) {
returnData := responseRegister{}
jsonData := requestRegister{}
requestJson, _ := ioutil.ReadAll(c.Request.Body)
err := json.Unmarshal(requestJson, &jsonData)
if err != nil {
Utils.Error(c, returnData)
return
}
accountDatabase := Database.New(GameAccountData.TableName)
accountData := GameAccountData.Data{}
where := fmt.Sprintf("account_account = %q", jsonData.Account)
err = accountDatabase.GetData(&accountData, where, "")
if err == nil && accountData.AccountId > 0 {
Utils.Warning(c, 10001, "邮箱已经被注册", returnData)
return
}
setData := &GameAccountData.Data{}
setData.AccountAccount = jsonData.Account
setData.AccountPassword = Utils.MD5Hash(jsonData.Password)
setData.AccountName = jsonData.Name
setData.AccountNumber = jsonData.Number
setData.AccountQuestionA = jsonData.QuestionA
setData.AccountAnswerA = jsonData.AnswerA
setData.AccountQuestionB = jsonData.QuestionB
setData.AccountAnswerB = jsonData.AnswerB
setData.AccountStatus = 2
err = accountDatabase.CreateData(setData)
if err != nil {
Utils.Error(c, accountData)
return
}
if setData.AccountId == 0 {
Utils.Error(c, accountData)
return
}
returnData.Token = Utils.EncodeId(128, setData.AccountId)
Utils.Success(c, returnData)
return
}
用户注册接口路由
// 账户相关接口
account := router.Group("account")
{
account.POST("/register", AccountInterface.Register)
}