unknown
2023-05-04 f1a2ba61dd68baa281a418b38a2ed2efbcf4709e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public with sharing class LexVisitReportCancelController {
 
    @AuraEnabled
    public static String init(String recordId){
        try {
            Visit_Report__c vistReport = [SELECT Id, Status__c, OwnerId from Visit_Report__c WHERE Id = :recordId];
            UserResult currentUser = userInfoOwner();
            if(currentUser.Id == vistReport.OwnerId && vistReport.Status__c=='草案中'){
                Visit_Report__c updateData = new Visit_Report__c();
                updateData.Id = vistReport.Id;
                UPDATE updateData;
                return '取消成功';
            }else{
                return '只草案中状态及同行报告书的所有人可以取消';
            }
        }   
        catch (Exception e) {
           return e.getMessage(); 
        }
        
    }
 
    //获取当前登录人的Id
    public static UserResult userInfoOwner() {
        UserResult result = new UserResult();
        ID myUserID = UserInfo.getUserId();
        
        try { 
            User tempUser =
                [select id from user where id = : myUserID ];
            result.id = tempUser.id;
        } catch (exception e) {
            
            result.result = e.getMessage();
        }
        return result;
    }
 
    public class UserResult {
        @AuraEnabled
        public string result;
        public UserResult( ) {
            result = 'Success';
        }
        @AuraEnabled
        public string id;
        //20210105 CHAN-BWX3YU you end
    }
}