高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
public with sharing class PBIAuthorizationController {
    public string userid {get; set;}
    public string UserName {get; set;}
    public string PBIId {get; set;}
    public boolean ISUser {get; set;}
    public PBIAuthorizationController() {
        userid = ApexPages.currentPage().getParameters().get('userid');
    }
    public void init() {
        try {
            list<User> tempUser = new list<User>();
            if (!string.isblank(userid)) {
                tempUser = [select id,Name from User where id = :userid];
            }
            if (string.isblank(userid) || tempUser.size() == 0) {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error ,
                                     '没有找到对应的用户'));
                return;
            } else {
                ISUser = true;
                UserName = tempUser[0].Name;
                List<PBIAuthorization__c> tempPBIA =
                    [select id from PBIAuthorization__c where User__c = : userid];
                if (tempPBIA.size() > 0) {
                    PBIId = tempPBIA[0].id;
                }
            }
            if(test.isrunningTest()){
                 throw new ControllerUtil.myException('111');
            }
        } catch (exception e) {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error ,
                                 '' + e));
            return;
        }
    }
}