Subversion Repositories SmartDukaan

Rev

Rev 3128 | Rev 3701 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3128 Rev 3499
Line 5... Line 5...
5
import in.shop2020.thrift.clients.UserClient;
5
import in.shop2020.thrift.clients.UserClient;
6
 
6
 
7
import java.util.List;
7
import java.util.List;
8
 
8
 
9
import org.apache.log4j.Logger;
9
import org.apache.log4j.Logger;
-
 
10
import org.apache.shiro.SecurityUtils;
10
 
11
 
11
/**
12
/**
12
 * @author vikas
13
 * @author vikas
13
 *
14
 *
14
 */
15
 */
15
@SuppressWarnings("serial")
16
@SuppressWarnings("serial")
16
public class UserInfoController extends BaseController {
17
public class UserInfoController extends BaseController {
17
    private static Logger log = Logger.getLogger(Class.class);
18
    private static Logger log = Logger.getLogger(Class.class);
-
 
19
    private String id;
18
    private long userId;
20
    private long userId;
19
    private User user;
21
    private User user;
20
    private List<Address> userAddresses;
22
    private List<Address> userAddresses;
21
    private Address primaryAdddress;
23
    private Address primaryAdddress;
22
    
-
 
23
    public UserInfoController(){
24
    private String trustLevelDelta;
24
        super();
-
 
25
    }
-
 
26
 
25
 
27
    public String index() throws Exception {
26
    public String index() throws Exception {
28
    	UserClient userServiceClient = new UserClient();
27
    	UserClient userServiceClient = new UserClient();
29
        in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
28
        in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
30
        user = userClient.getUserById(userId);
29
        user = userClient.getUserById(userId);
31
        userAddresses = user.getAddresses();
30
        userAddresses = user.getAddresses();
32
        primaryAdddress = userClient.getAddressById(user.getDefaultAddressId());
31
        primaryAdddress = userClient.getAddressById(user.getDefaultAddressId());
-
 
32
        return INDEX;
-
 
33
    }
-
 
34
 
-
 
35
    public String update() throws Exception {
-
 
36
        userId = Long.parseLong(id);
-
 
37
        userContextServiceClient = new UserClient().getClient();
-
 
38
        userContextServiceClient.increaseTrustLevel(userId, Double.parseDouble(trustLevelDelta));
33
        return "index";
39
        return index();
34
    }
40
    }
35
 
41
 
36
    public void setUserId(String userId) {
42
    public void setUserId(String userId) {
37
        try {
43
        try {
38
            this.userId = Long.parseLong(userId);
44
            this.userId = Long.parseLong(userId);
Line 40... Line 46...
40
        catch (NumberFormatException e) {
46
        catch (NumberFormatException e) {
41
            log.error(e);
47
            log.error(e);
42
        }
48
        }
43
    }
49
    }
44
 
50
 
-
 
51
    public boolean isTrustLevelEditable() {
-
 
52
        return SecurityUtils.getSubject().hasRole("TeamLead");
-
 
53
    }
-
 
54
 
45
    public Long getUserId() {
55
    public Long getUserId() {
46
        return userId;
56
        return userId;
47
    }
57
    }
48
    
58
    
49
    public User getUser() {
59
    public User getUser() {
Line 55... Line 65...
55
    }
65
    }
56
 
66
 
57
    public Address getPrimaryAdddress() {
67
    public Address getPrimaryAdddress() {
58
        return primaryAdddress;
68
        return primaryAdddress;
59
    }
69
    }
-
 
70
 
-
 
71
    public String getTrustLevelDelta() {
-
 
72
        return trustLevelDelta;
-
 
73
    }
-
 
74
 
-
 
75
    public void setTrustLevelDelta(String trustLevelDelta) {
-
 
76
        this.trustLevelDelta = trustLevelDelta;
-
 
77
    }
-
 
78
 
-
 
79
    public String getId() {
-
 
80
        return id;
-
 
81
    }
-
 
82
 
-
 
83
    public void setId(String id) {
-
 
84
        this.id = id;
-
 
85
    }
60
}
86
}
61
87