You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB

import 'package:floor/floor.dart';
@entity
class Message {
@primaryKey
int id;
int fromId;
int toId;
String content;
String attach;
int msgType;
int time;
int state;
int isDelete;
Message(id, fromId, toId, content, attach, msgType, time, state, isDelete);
factory Message.fromJson(Map<String, dynamic> json) => Message(
json["id"],
json["fromId"],
json["toId"],
json["content"],
json["attach"],
json["msgType"],
json["time"],
json["state"],
json["isDelete"]);
Map<String, dynamic> toJson() => <String, dynamic>{
"id": id,
"fromId": fromId,
"toId": toId,
"content": content,
"attach": attach,
"msgType": msgType,
"time": time,
"state": state,
"isDelete": isDelete == null ? 0 : isDelete
};
}
createMessage(var toId, String content, {String attach, int msgType, userId}) {
return Message.fromJson(<String, dynamic>{
"fromId": userId,
"toId": toId,
"content": content,
"attach": attach,
"msgType": msgType ?? 0,
"time": DateTime.now().millisecondsSinceEpoch,
"state": 0,
"isDelete": 0
});
}