예제 #1
0
func (o _ArticleObjs) toArticle(columns []gmq.Column, rb []sql.RawBytes) Article {
	obj := Article{}
	if len(columns) == len(rb) {
		for i := range columns {
			switch columns[i].Name {
			case "id":
				obj.Id = gmq.AsInt64(rb[i])
			case "user_id":
				obj.UserId = gmq.AsInt64(rb[i])
			case "title":
				obj.Title = gmq.AsString(rb[i])
			case "state":
				obj.State = gmq.AsInt(rb[i])
			case "content":
				obj.Content = gmq.AsString(rb[i])
			case "donation":
				obj.Donation = gmq.AsFloat64(rb[i])
			case "create_time":
				obj.CreateTime = gmq.AsTime(rb[i])
			case "update_time":
				obj.UpdateTime = gmq.AsTime(rb[i])
			}
		}
	}
	return obj
}
예제 #2
0
func (o _CommentObjs) toComment(columns []gmq.Column, rb []sql.RawBytes) Comment {
	obj := Comment{}
	if len(columns) == len(rb) {
		for i := range columns {
			switch columns[i].Name {
			case "user_id":
				obj.UserId = gmq.AsInt64(rb[i])
			case "article_id":
				obj.ArticleId = gmq.AsInt64(rb[i])
			case "content":
				obj.Content = gmq.AsString(rb[i])
			case "create_time":
				obj.CreateTime = gmq.AsTime(rb[i])
			case "update_time":
				obj.UpdateTime = gmq.AsTime(rb[i])
			}
		}
	}
	return obj
}
예제 #3
0
func (o _ColumnsObjs) toColumns(columns []gmq.Column, rb []sql.RawBytes) Columns {
	obj := Columns{}
	if len(columns) == len(rb) {
		for i := range columns {
			switch columns[i].Name {
			case "TABLE_CATALOG":
				obj.TableCatalog = gmq.AsString(rb[i])
			case "TABLE_SCHEMA":
				obj.TableSchema = gmq.AsString(rb[i])
			case "TABLE_NAME":
				obj.TableName = gmq.AsString(rb[i])
			case "COLUMN_NAME":
				obj.ColumnName = gmq.AsString(rb[i])
			case "ORDINAL_POSITION":
				obj.OrdinalPosition = gmq.AsInt64(rb[i])
			case "COLUMN_DEFAULT":
				obj.ColumnDefault = gmq.AsString(rb[i])
			case "IS_NULLABLE":
				obj.IsNullable = gmq.AsString(rb[i])
			case "DATA_TYPE":
				obj.DataType = gmq.AsString(rb[i])
			case "CHARACTER_MAXIMUM_LENGTH":
				obj.CharacterMaximumLength = gmq.AsInt64(rb[i])
			case "CHARACTER_OCTET_LENGTH":
				obj.CharacterOctetLength = gmq.AsInt64(rb[i])
			case "NUMERIC_PRECISION":
				obj.NumericPrecision = gmq.AsInt64(rb[i])
			case "NUMERIC_SCALE":
				obj.NumericScale = gmq.AsInt64(rb[i])
			case "DATETIME_PRECISION":
				obj.DatetimePrecision = gmq.AsInt64(rb[i])
			case "CHARACTER_SET_NAME":
				obj.CharacterSetName = gmq.AsString(rb[i])
			case "COLLATION_NAME":
				obj.CollationName = gmq.AsString(rb[i])
			case "COLUMN_TYPE":
				obj.ColumnType = gmq.AsString(rb[i])
			case "COLUMN_KEY":
				obj.ColumnKey = gmq.AsString(rb[i])
			case "EXTRA":
				obj.Extra = gmq.AsString(rb[i])
			case "PRIVILEGES":
				obj.Privileges = gmq.AsString(rb[i])
			case "COLUMN_COMMENT":
				obj.ColumnComment = gmq.AsString(rb[i])
			}
		}
	}
	return obj
}
예제 #4
0
func (o _UserObjs) toUser(columns []gmq.Column, rb []sql.RawBytes) User {
	obj := User{}
	if len(columns) == len(rb) {
		for i := range columns {
			switch columns[i].Name {
			case "id":
				obj.Id = gmq.AsInt64(rb[i])
			case "name":
				obj.Name = gmq.AsString(rb[i])
			case "password":
				obj.Password = gmq.AsString(rb[i])
			case "is_married":
				obj.IsMarried = gmq.AsBool(rb[i])
			case "age":
				obj.Age = gmq.AsInt(rb[i])
			}
		}
	}
	return obj
}