buli
2023-05-22 71b93327e8f3fb3bffffc7c033c1f782e7b6ab32
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
50
51
52
public with sharing class LexVisitReportCancelController {
    public 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 = userInfo_Owner();
            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 userInfo_Owner() {
        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
    }
}