Parcourir la source

feat: save with ACL

未来全栈 il y a 4 mois
Parent
commit
875fb91be8
2 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 9 1
      wisdom-app/src/app/tab1/tab1.page.ts
  2. 1 1
      wisdom-app/src/lib/ncloud.ts

+ 9 - 1
wisdom-app/src/app/tab1/tab1.page.ts

@@ -161,6 +161,13 @@ export class Tab1Page {
     let consult = new CloudObject("Consultation")
     let now = new Date();
     let dateStr = `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()}`
+    // 对象权限的精确指定
+    let ACL:any = {
+      "*":{read:false,write:false}
+    }
+    if(currentUser?.id){
+      ACL[currentUser?.id] = {read:true,write:true}
+    }
     consult.set({
       title:`${doctor.get('depart')?.name || ""}门诊记录${dateStr}-${doctor?.get("name")}`,
       doctor:doctor.toPointer(),
@@ -169,7 +176,8 @@ export class Tab1Page {
         className:"Department",
         objectId:doctor.get("depart")?.objectId
       },
-      user:currentUser.toPointer()
+      user:currentUser.toPointer(),
+      ACL:ACL
     })
 
     let options:ChatPanelOptions = {

+ 1 - 1
wisdom-app/src/lib/ncloud.ts

@@ -16,7 +16,7 @@ export class CloudObject {
 
     set(json: Record<string, any>) {
         Object.keys(json).forEach(key => {
-            if (["objectId", "id", "createdAt", "updatedAt", "ACL"].indexOf(key) > -1) {
+            if (["objectId", "id", "createdAt", "updatedAt"].indexOf(key) > -1) {
                 return;
             }
             this.data[key] = json[key];