app_rev.rs 895 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. use crate::{TrashRevision, TrashTypeRevision, ViewRevision};
  2. use nanoid::nanoid;
  3. use serde::{Deserialize, Serialize};
  4. pub fn gen_app_id() -> String {
  5. nanoid!(10)
  6. }
  7. #[derive(Default, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)]
  8. pub struct AppRevision {
  9. pub id: String,
  10. pub workspace_id: String,
  11. pub name: String,
  12. pub desc: String,
  13. pub belongings: Vec<ViewRevision>,
  14. #[serde(default)]
  15. pub version: i64,
  16. #[serde(default)]
  17. pub modified_time: i64,
  18. #[serde(default)]
  19. pub create_time: i64,
  20. }
  21. impl std::convert::From<AppRevision> for TrashRevision {
  22. fn from(app_rev: AppRevision) -> Self {
  23. TrashRevision {
  24. id: app_rev.id,
  25. name: app_rev.name,
  26. modified_time: app_rev.modified_time,
  27. create_time: app_rev.create_time,
  28. ty: TrashTypeRevision::TrashApp,
  29. }
  30. }
  31. }