2018-12-31 12:24:21 +00:00
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
|
|
|
|
part of 'main.dart';
|
|
|
|
|
2019-04-30 15:21:05 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// MigrationGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
class EmployeeMigration extends Migration {
|
|
|
|
@override
|
|
|
|
up(Schema schema) {
|
|
|
|
schema.create('employees', (table) {
|
|
|
|
table.serial('id')..primaryKey();
|
2019-07-04 21:08:20 +00:00
|
|
|
table.timeStamp('created_at');
|
|
|
|
table.timeStamp('updated_at');
|
|
|
|
table.varChar('unique_id');
|
2019-04-30 15:21:05 +00:00
|
|
|
table.varChar('first_name');
|
|
|
|
table.varChar('last_name');
|
|
|
|
table.declare('salary', ColumnType('decimal'));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
down(Schema schema) {
|
|
|
|
schema.drop('employees');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// OrmGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
|
|
|
|
EmployeeQuery({Set<String> trampoline}) {
|
|
|
|
trampoline ??= Set();
|
|
|
|
trampoline.add(tableName);
|
|
|
|
_where = EmployeeQueryWhere(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
final EmployeeQueryValues values = EmployeeQueryValues();
|
|
|
|
|
|
|
|
EmployeeQueryWhere _where;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get casts {
|
|
|
|
return {'salary': 'text'};
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
get tableName {
|
|
|
|
return 'employees';
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
get fields {
|
|
|
|
return const [
|
|
|
|
'id',
|
2019-07-04 21:08:20 +00:00
|
|
|
'created_at',
|
|
|
|
'updated_at',
|
2019-04-30 15:21:05 +00:00
|
|
|
'unique_id',
|
|
|
|
'first_name',
|
|
|
|
'last_name',
|
2019-07-04 21:08:20 +00:00
|
|
|
'salary'
|
2019-04-30 15:21:05 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
EmployeeQueryWhere get where {
|
|
|
|
return _where;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
EmployeeQueryWhere newWhereClause() {
|
|
|
|
return EmployeeQueryWhere(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
static Employee parseRow(List row) {
|
|
|
|
if (row.every((x) => x == null)) return null;
|
|
|
|
var model = Employee(
|
2019-07-04 21:08:20 +00:00
|
|
|
id: (row[0] as String),
|
|
|
|
createdAt: (row[1] as DateTime),
|
|
|
|
updatedAt: (row[2] as DateTime),
|
|
|
|
uniqueId: (row[3] as String),
|
|
|
|
firstName: (row[4] as String),
|
|
|
|
lastName: (row[5] as String),
|
|
|
|
salary: double.tryParse(row[6].toString()));
|
2019-04-30 15:21:05 +00:00
|
|
|
return model;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
deserialize(List row) {
|
|
|
|
return parseRow(row);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EmployeeQueryWhere extends QueryWhere {
|
|
|
|
EmployeeQueryWhere(EmployeeQuery query)
|
2019-07-04 21:08:20 +00:00
|
|
|
: id = StringSqlExpressionBuilder(query, 'id'),
|
|
|
|
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
|
|
|
|
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at'),
|
2019-04-30 15:21:05 +00:00
|
|
|
uniqueId = StringSqlExpressionBuilder(query, 'unique_id'),
|
|
|
|
firstName = StringSqlExpressionBuilder(query, 'first_name'),
|
|
|
|
lastName = StringSqlExpressionBuilder(query, 'last_name'),
|
2019-07-04 21:08:20 +00:00
|
|
|
salary = NumericSqlExpressionBuilder<double>(query, 'salary');
|
2019-04-30 15:21:05 +00:00
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
final StringSqlExpressionBuilder id;
|
|
|
|
|
|
|
|
final DateTimeSqlExpressionBuilder createdAt;
|
|
|
|
|
|
|
|
final DateTimeSqlExpressionBuilder updatedAt;
|
2019-04-30 15:21:05 +00:00
|
|
|
|
|
|
|
final StringSqlExpressionBuilder uniqueId;
|
|
|
|
|
|
|
|
final StringSqlExpressionBuilder firstName;
|
|
|
|
|
|
|
|
final StringSqlExpressionBuilder lastName;
|
|
|
|
|
|
|
|
final NumericSqlExpressionBuilder<double> salary;
|
|
|
|
|
|
|
|
@override
|
|
|
|
get expressionBuilders {
|
2019-07-04 21:08:20 +00:00
|
|
|
return [id, createdAt, updatedAt, uniqueId, firstName, lastName, salary];
|
2019-04-30 15:21:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EmployeeQueryValues extends MapQueryValues {
|
|
|
|
@override
|
|
|
|
get casts {
|
|
|
|
return {'salary': 'decimal'};
|
|
|
|
}
|
|
|
|
|
|
|
|
String get id {
|
|
|
|
return (values['id'] as String);
|
|
|
|
}
|
|
|
|
|
|
|
|
set id(String value) => values['id'] = value;
|
2019-07-04 21:08:20 +00:00
|
|
|
DateTime get createdAt {
|
|
|
|
return (values['created_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
set createdAt(DateTime value) => values['created_at'] = value;
|
|
|
|
DateTime get updatedAt {
|
|
|
|
return (values['updated_at'] as DateTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
set updatedAt(DateTime value) => values['updated_at'] = value;
|
2019-04-30 15:21:05 +00:00
|
|
|
String get uniqueId {
|
|
|
|
return (values['unique_id'] as String);
|
|
|
|
}
|
|
|
|
|
|
|
|
set uniqueId(String value) => values['unique_id'] = value;
|
|
|
|
String get firstName {
|
|
|
|
return (values['first_name'] as String);
|
|
|
|
}
|
|
|
|
|
|
|
|
set firstName(String value) => values['first_name'] = value;
|
|
|
|
String get lastName {
|
|
|
|
return (values['last_name'] as String);
|
|
|
|
}
|
|
|
|
|
|
|
|
set lastName(String value) => values['last_name'] = value;
|
|
|
|
double get salary {
|
|
|
|
return double.tryParse((values['salary'] as String));
|
|
|
|
}
|
|
|
|
|
|
|
|
set salary(double value) => values['salary'] = value.toString();
|
|
|
|
void copyFrom(Employee model) {
|
2019-07-04 21:08:20 +00:00
|
|
|
id = model.id;
|
|
|
|
createdAt = model.createdAt;
|
|
|
|
updatedAt = model.updatedAt;
|
2019-04-30 15:21:05 +00:00
|
|
|
uniqueId = model.uniqueId;
|
|
|
|
firstName = model.firstName;
|
|
|
|
lastName = model.lastName;
|
|
|
|
salary = model.salary;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-31 12:24:21 +00:00
|
|
|
// **************************************************************************
|
|
|
|
// JsonModelGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
|
|
|
@generatedSerializable
|
|
|
|
class Employee extends _Employee {
|
|
|
|
Employee(
|
|
|
|
{this.id,
|
2019-07-04 21:08:20 +00:00
|
|
|
this.createdAt,
|
|
|
|
this.updatedAt,
|
2019-04-30 15:21:05 +00:00
|
|
|
this.uniqueId,
|
2018-12-31 12:24:21 +00:00
|
|
|
this.firstName,
|
|
|
|
this.lastName,
|
2019-07-04 21:08:20 +00:00
|
|
|
this.salary});
|
2018-12-31 12:24:21 +00:00
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
/// A unique identifier corresponding to this item.
|
2018-12-31 12:24:21 +00:00
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
String id;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
/// The time at which this item was created.
|
2019-04-30 15:21:05 +00:00
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
DateTime createdAt;
|
2019-04-30 15:21:05 +00:00
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
/// The last time at which this item was updated.
|
2018-12-31 12:24:21 +00:00
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
DateTime updatedAt;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
String uniqueId;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
final String firstName;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
final String lastName;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
|
|
|
@override
|
2019-07-04 21:08:20 +00:00
|
|
|
final double salary;
|
2018-12-31 12:24:21 +00:00
|
|
|
|
|
|
|
Employee copyWith(
|
|
|
|
{String id,
|
2019-07-04 21:08:20 +00:00
|
|
|
DateTime createdAt,
|
|
|
|
DateTime updatedAt,
|
2019-04-30 15:21:05 +00:00
|
|
|
String uniqueId,
|
2018-12-31 12:24:21 +00:00
|
|
|
String firstName,
|
|
|
|
String lastName,
|
2019-07-04 21:08:20 +00:00
|
|
|
double salary}) {
|
|
|
|
return Employee(
|
2018-12-31 12:24:21 +00:00
|
|
|
id: id ?? this.id,
|
2019-07-04 21:08:20 +00:00
|
|
|
createdAt: createdAt ?? this.createdAt,
|
|
|
|
updatedAt: updatedAt ?? this.updatedAt,
|
2019-04-30 15:21:05 +00:00
|
|
|
uniqueId: uniqueId ?? this.uniqueId,
|
2018-12-31 12:24:21 +00:00
|
|
|
firstName: firstName ?? this.firstName,
|
|
|
|
lastName: lastName ?? this.lastName,
|
2019-07-04 21:08:20 +00:00
|
|
|
salary: salary ?? this.salary);
|
2018-12-31 12:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool operator ==(other) {
|
|
|
|
return other is _Employee &&
|
|
|
|
other.id == id &&
|
2019-07-04 21:08:20 +00:00
|
|
|
other.createdAt == createdAt &&
|
|
|
|
other.updatedAt == updatedAt &&
|
2019-04-30 15:21:05 +00:00
|
|
|
other.uniqueId == uniqueId &&
|
2018-12-31 12:24:21 +00:00
|
|
|
other.firstName == firstName &&
|
|
|
|
other.lastName == lastName &&
|
2019-07-04 21:08:20 +00:00
|
|
|
other.salary == salary;
|
2018-12-31 12:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
int get hashCode {
|
2019-04-30 15:21:05 +00:00
|
|
|
return hashObjects(
|
2019-07-04 21:08:20 +00:00
|
|
|
[id, createdAt, updatedAt, uniqueId, firstName, lastName, salary]);
|
2019-04-30 15:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
2019-07-04 21:08:20 +00:00
|
|
|
return "Employee(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, uniqueId=$uniqueId, firstName=$firstName, lastName=$lastName, salary=$salary)";
|
2018-12-31 12:24:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() {
|
|
|
|
return EmployeeSerializer.toMap(this);
|
|
|
|
}
|
|
|
|
}
|
2019-04-30 15:21:05 +00:00
|
|
|
|
|
|
|
// **************************************************************************
|
|
|
|
// SerializerGenerator
|
|
|
|
// **************************************************************************
|
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
const EmployeeSerializer employeeSerializer = EmployeeSerializer();
|
2019-04-30 15:21:05 +00:00
|
|
|
|
|
|
|
class EmployeeEncoder extends Converter<Employee, Map> {
|
|
|
|
const EmployeeEncoder();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Map convert(Employee model) => EmployeeSerializer.toMap(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
class EmployeeDecoder extends Converter<Map, Employee> {
|
|
|
|
const EmployeeDecoder();
|
|
|
|
|
|
|
|
@override
|
|
|
|
Employee convert(Map map) => EmployeeSerializer.fromMap(map);
|
|
|
|
}
|
|
|
|
|
|
|
|
class EmployeeSerializer extends Codec<Employee, Map> {
|
|
|
|
const EmployeeSerializer();
|
|
|
|
|
|
|
|
@override
|
|
|
|
get encoder => const EmployeeEncoder();
|
|
|
|
@override
|
|
|
|
get decoder => const EmployeeDecoder();
|
|
|
|
static Employee fromMap(Map map) {
|
2019-07-04 21:08:20 +00:00
|
|
|
return Employee(
|
2019-04-30 15:21:05 +00:00
|
|
|
id: map['id'] as String,
|
|
|
|
createdAt: map['created_at'] != null
|
|
|
|
? (map['created_at'] is DateTime
|
|
|
|
? (map['created_at'] as DateTime)
|
|
|
|
: DateTime.parse(map['created_at'].toString()))
|
|
|
|
: null,
|
|
|
|
updatedAt: map['updated_at'] != null
|
|
|
|
? (map['updated_at'] is DateTime
|
|
|
|
? (map['updated_at'] as DateTime)
|
|
|
|
: DateTime.parse(map['updated_at'].toString()))
|
2019-07-04 21:08:20 +00:00
|
|
|
: null,
|
|
|
|
uniqueId: map['unique_id'] as String,
|
|
|
|
firstName: map['first_name'] as String,
|
|
|
|
lastName: map['last_name'] as String,
|
|
|
|
salary: map['salary'] as double);
|
2019-04-30 15:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Map<String, dynamic> toMap(_Employee model) {
|
|
|
|
if (model == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
'id': model.id,
|
2019-07-04 21:08:20 +00:00
|
|
|
'created_at': model.createdAt?.toIso8601String(),
|
|
|
|
'updated_at': model.updatedAt?.toIso8601String(),
|
2019-04-30 15:21:05 +00:00
|
|
|
'unique_id': model.uniqueId,
|
|
|
|
'first_name': model.firstName,
|
|
|
|
'last_name': model.lastName,
|
2019-07-04 21:08:20 +00:00
|
|
|
'salary': model.salary
|
2019-04-30 15:21:05 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class EmployeeFields {
|
|
|
|
static const List<String> allFields = <String>[
|
|
|
|
id,
|
2019-07-04 21:08:20 +00:00
|
|
|
createdAt,
|
|
|
|
updatedAt,
|
2019-04-30 15:21:05 +00:00
|
|
|
uniqueId,
|
|
|
|
firstName,
|
|
|
|
lastName,
|
2019-07-04 21:08:20 +00:00
|
|
|
salary
|
2019-04-30 15:21:05 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
static const String id = 'id';
|
|
|
|
|
2019-07-04 21:08:20 +00:00
|
|
|
static const String createdAt = 'created_at';
|
|
|
|
|
|
|
|
static const String updatedAt = 'updated_at';
|
|
|
|
|
2019-04-30 15:21:05 +00:00
|
|
|
static const String uniqueId = 'unique_id';
|
|
|
|
|
|
|
|
static const String firstName = 'first_name';
|
|
|
|
|
|
|
|
static const String lastName = 'last_name';
|
|
|
|
|
|
|
|
static const String salary = 'salary';
|
|
|
|
}
|