Subversion Repositories SmartDukaan

Rev

Rev 3499 | Rev 4086 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2674 vikas 1
package in.shop2020.serving.controllers;
2
 
3
import in.shop2020.model.v1.user.Address;
4
import in.shop2020.model.v1.user.User;
3128 rajveer 5
import in.shop2020.thrift.clients.UserClient;
2674 vikas 6
 
7
import java.util.List;
8
 
9
import org.apache.log4j.Logger;
3499 mandeep.dh 10
import org.apache.shiro.SecurityUtils;
2674 vikas 11
 
12
/**
13
 * @author vikas
14
 *
15
 */
16
@SuppressWarnings("serial")
17
public class UserInfoController extends BaseController {
18
    private static Logger log = Logger.getLogger(Class.class);
3499 mandeep.dh 19
    private String id;
2674 vikas 20
    private long userId;
21
    private User user;
22
    private List<Address> userAddresses;
23
    private Address primaryAdddress;
3499 mandeep.dh 24
    private String trustLevelDelta;
2674 vikas 25
 
26
    public String index() throws Exception {
3128 rajveer 27
    	UserClient userServiceClient = new UserClient();
28
        in.shop2020.model.v1.user.UserContextService.Client userClient = userServiceClient.getClient();
2674 vikas 29
        user = userClient.getUserById(userId);
30
        userAddresses = user.getAddresses();
31
        primaryAdddress = userClient.getAddressById(user.getDefaultAddressId());
3499 mandeep.dh 32
        return INDEX;
2674 vikas 33
    }
34
 
3499 mandeep.dh 35
    public String update() throws Exception {
36
        userId = Long.parseLong(id);
37
        userContextServiceClient = new UserClient().getClient();
38
        userContextServiceClient.increaseTrustLevel(userId, Double.parseDouble(trustLevelDelta));
39
        return index();
40
    }
41
 
2674 vikas 42
    public void setUserId(String userId) {
43
        try {
44
            this.userId = Long.parseLong(userId);
45
        }
46
        catch (NumberFormatException e) {
47
            log.error(e);
48
        }
49
    }
50
 
3499 mandeep.dh 51
    public boolean isTrustLevelEditable() {
3701 mandeep.dh 52
        return SecurityUtils.getSubject().hasRole("TeamLead") && SecurityUtils.getSubject().hasRole("Outbound");
3499 mandeep.dh 53
    }
54
 
2674 vikas 55
    public Long getUserId() {
56
        return userId;
57
    }
58
 
59
    public User getUser() {
60
        return user;
61
    }
62
 
63
    public List<Address> getUserAddresses() {
64
        return userAddresses;
65
    }
66
 
67
    public Address getPrimaryAdddress() {
68
        return primaryAdddress;
69
    }
3499 mandeep.dh 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
    }
2674 vikas 86
}