| | |
| | | package com.whyc.util; |
| | | |
| | | import com.whyc.constant.YamlProperties; |
| | | import com.whyc.pojo.db_user.UserInf; |
| | | import com.whyc.service.OperationLogService; |
| | | import org.springframework.boot.system.ApplicationHome; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.File; |
| | | |
| | | /** |
| | | * 通用工具列 |
| | |
| | | service.record(type1, type2, msg, msgDetail); |
| | | } |
| | | |
| | | /**获取当前Session中的属性user*/ |
| | | public static UserInf getUser(HttpServletRequest request) { |
| | | return (UserInf) request.getSession().getAttribute("user"); |
| | | } |
| | | |
| | | public static String classesPath(){ |
| | | ApplicationHome applicationHome = new ApplicationHome(CommonUtil.class); |
| | | File jarFile = applicationHome.getDir(); |
| | | return jarFile.toString(); |
| | | } |
| | | |
| | | public static String getRootFile(){ |
| | | ApplicationHome applicationHome = new ApplicationHome(CommonUtil.class); |
| | | File jarFile = applicationHome.getDir(); |
| | | String baseDirPath; |
| | | if(YamlProperties.runModel == 1) { |
| | | //开发路径 |
| | | baseDirPath = jarFile.getParentFile().toString()+File.separator+"fg_file"+File.separator; |
| | | }else { |
| | | //打包路径 |
| | | baseDirPath = jarFile.toString()+File.separator+"fg_file"+File.separator; |
| | | } |
| | | return baseDirPath; |
| | | } |
| | | |
| | | /** |
| | | * 获取项目所在文件夹路径 |
| | | * @return 获取项目所在文件夹路径 |
| | | */ |
| | | public static String getProjectDir(){ |
| | | ApplicationHome applicationHome = new ApplicationHome(CommonUtil.class); |
| | | File jarFile = applicationHome.getDir(); |
| | | String baseDirPath; |
| | | if (YamlProperties.runModel == 1) { |
| | | //开发路径 |
| | | baseDirPath = jarFile.getParentFile().toString(); |
| | | } else { |
| | | //打包路径 |
| | | baseDirPath = jarFile.toString(); |
| | | } |
| | | return baseDirPath; |
| | | } |
| | | |
| | | |
| | | |