示例#1
0
func GetPlayerByUserId(partnerId, serverId int, userId string) (playerObj *player.Player, exists bool, err error) {
	var id string
	var name string
	var lv int
	var exp int
	var vipExp int
	var diamond int
	var gold int

	err = dal.GameDB.QueryRow(getPlayerByUserIdCommand, partnerId, serverId, userId).Scan(&id, &name, &partnerId, &serverId, &userId, &lv, &exp, &vipExp, &diamond, &gold)
	if err != nil {
		if err == sql.ErrNoRows {
			// 重置err,使其为nil;因为这代表的是没有查找到数据,而不是真正的错误
			err = nil
			return
		} else {
			dal.WriteScanError(getPlayerByUserIdCommand, err)
			return
		}
	}

	playerObj = player.New(id, name, partnerId, serverId, userId, lv, exp, vipExp, diamond, gold)
	exists = true

	return
}
示例#2
0
func GetList() (systemConfigMap map[string]*systemConfig.SystemConfigItem, err error) {
	rows, err := dal.GameModelDB.Query(getListCommand)
	if err != nil {
		return
	}

	defer rows.Close()

	systemConfigMap = make(map[string]*systemConfig.SystemConfigItem)
	for rows.Next() {
		var configKey string
		var configValue string
		if err = rows.Scan(&configKey, &configValue); err != nil {
			dal.WriteScanError(getListCommand, err)
			return
		}

		systemConfigMap[configKey] = systemConfig.New(configKey, configValue)
	}

	return
}
示例#3
0
func GetList() (nameAndIdMap map[string]string, err error) {
	rows, err := dal.GameDB.Query(getListCommand)
	if err != nil {
		return
	}

	defer rows.Close()

	nameAndIdMap = make(map[string]string)
	for rows.Next() {
		var name string
		var id string
		if err = rows.Scan(&name, &id); err != nil {
			dal.WriteScanError(getListCommand, err)
			return
		}

		nameAndIdMap[name] = id
	}

	return
}
func GetList(serverGroupId int) (config *serverGroupSetting.ServerGroupSettingConfig, exists bool, err error) {
	var promotionIfOpen int
	var requestLogIfOpen int
	var saasUrl string
	var appErrorLevel int
	var marqueeInterval int

	err = dal.GameModelDB.QueryRow(getListCommand, serverGroupId).Scan(&serverGroupId, &promotionIfOpen, &requestLogIfOpen, &saasUrl, &appErrorLevel, &marqueeInterval)
	if err != nil {
		if err == sql.ErrNoRows {
			// 重置err,使其为nil;因为这代表的是没有查找到数据,而不是真正的错误
			err = nil
			return
		} else {
			dal.WriteScanError(getListCommand, err)
			return
		}
	}

	config = serverGroupSetting.New(serverGroupId, promotionIfOpen, requestLogIfOpen, saasUrl, appErrorLevel, marqueeInterval)
	exists = true

	return
}