add structure

This commit is contained in:
2020-05-29 07:45:27 +06:30
parent 4c851d9971
commit bad27ba5c4
272 changed files with 36065 additions and 174 deletions

79
lib/vo/document_log.dart Normal file
View File

@@ -0,0 +1,79 @@
import 'package:cloud_firestore/cloud_firestore.dart';
import 'buyer.dart';
import 'do.dart';
import 'po.dart';
import 'role.dart';
import 'user.dart';
class DocLog {
String id;
String docID;
String docType;
String ownerID;
String ownerName;
DateTime date;
String actionerID;
String actionerName;
Map<dynamic, dynamic> docData;
String data;
String getDesc(List<Privilege> privileges) {
if (docType == "po") {
return getPO().status;
} else if (docType == "do") {
return getDO().status;
} else if (docType == "buyer") {
return getBuyer().status;
} else if (docType == "user") {
User user=getUser();
return "${user.status}\nprivileges:${user.getLogDesc(privileges)}";
}
return "-";
}
DocLog(
{this.id,
this.docID,
this.docType,
this.date,
this.ownerID,
this.ownerName,
this.actionerID,
this.actionerName,
this.docData});
factory DocLog.fromMap(Map<String, dynamic> map, String id) {
var date = (map['date'] as Timestamp);
return DocLog(
id: id,
docID: map['doc_id'],
docType: map['doc_type'],
ownerID: map['owner_id'],
ownerName: map['owner_name'],
actionerID: map['actioner_id'],
actionerName: map['actioner_name'],
date: date == null ? null : date.toDate(),
docData: map['doc_data'],
);
}
Buyer getBuyer() {
return Buyer.fromMap(docData.cast<String, dynamic>(), docID);
}
POSubmission getPO() {
return POSubmission.fromMap(docData.cast<String, dynamic>(), docID);
}
DOSubmission getDO() {
return DOSubmission.fromMap(docData.cast<String, dynamic>(), docID);
}
User getUser() {
return User.fromMap(docData.cast<String, dynamic>(), docID);
}
}