// Path: src/main/java/org/myazure/weixin/domain/CurrentUser.java
// public class CurrentUser extends org.springframework.security.core.userdetails.User {
// 
//     /**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 	private MaUser user;
// 
//     public CurrentUser(MaUser user) {
//         super(user.getUserName(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRole().toString()));
//         this.user = user;
//     }
// 
//     public MaUser getUser() {
//         return user;
//     }
// 
//     public Long getId() {
//         return user.getId();
//     }
// 
//     public MaRole getRole() {
//         return user.getRole();
//     }
// 
//     @Override
//     public String toString() {
//         return "CurrentUser{" +
//                 "user=" + user +
//                 "} " + super.toString();
//     }
// }


import org.myazure.weixin.domain.CurrentUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;
package org.myazure.weixin.controller;

/**
 * 
 * @author WangZhen
 *
 */
@ControllerAdvice
public class CurrentUserControllerAdvice {

    private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUserControllerAdvice.class);

    @ModelAttribute("currentUser")
// Path: src/main/java/org/myazure/weixin/domain/CurrentUser.java
// public class CurrentUser extends org.springframework.security.core.userdetails.User {
// 
//     /**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 1L;
// 	private MaUser user;
// 
//     public CurrentUser(MaUser user) {
//         super(user.getUserName(), user.getPassword(), AuthorityUtils.createAuthorityList(user.getRole().toString()));
//         this.user = user;
//     }
// 
//     public MaUser getUser() {
//         return user;
//     }
// 
//     public Long getId() {
//         return user.getId();
//     }
// 
//     public MaRole getRole() {
//         return user.getRole();
//     }
// 
//     @Override
//     public String toString() {
//         return "CurrentUser{" +
//                 "user=" + user +
//                 "} " + super.toString();
//     }
// }


// Path: src/main/java/org/myazure/weixin/controller/CurrentUserControllerAdvice.java
import org.myazure.weixin.domain.CurrentUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

package org.myazure.weixin.controller;

/**
 * 
 * @author WangZhen
 *
 */
@ControllerAdvice
public class CurrentUserControllerAdvice {

    private static final Logger LOGGER = LoggerFactory.getLogger(CurrentUserControllerAdvice.class);

    @ModelAttribute("currentUser")
    public CurrentUser getCurrentUser(Authentication authentication) {