| | |
| | | import com.whyc.constant.YamlProperties; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.service.UserLogService; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | |
| | | import static org.apache.shiro.web.filter.mgt.DefaultFilter.user; |
| | | |
| | | /** |
| | | * 通用工具列 |
| | |
| | | return (User) request.getSession().getAttribute("user"); |
| | | } |
| | | |
| | | /** |
| | | * Shiro框架下的用户获取 |
| | | * @return |
| | | */ |
| | | public static User getUser() { |
| | | User user; |
| | | Subject currentUser = SecurityUtils.getSubject(); |
| | | if(currentUser!=null && currentUser.isAuthenticated()){ |
| | | user = (User) currentUser.getPrincipal(); |
| | | }else{ |
| | | user = new User(); |
| | | user.setName("unlogged_user"); |
| | | user.setId(0); |
| | | user.setRole(1); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | public static String classesPath(){ |
| | | ApplicationHome applicationHome = new ApplicationHome(CommonUtil.class); |
| | | File jarFile = applicationHome.getDir(); |