ConfigValueUtil.java 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. package jnpf.config;
  2. import cn.hutool.core.net.url.UrlBuilder;
  3. import jnpf.constant.ConfigConst;
  4. import jnpf.constant.TableFieldsNameConst;
  5. import jnpf.util.StringUtil;
  6. import jnpf.util.XSSEscape;
  7. import lombok.Data;
  8. import org.springframework.beans.factory.annotation.Value;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11. import java.util.stream.Collectors;
  12. /**
  13. *
  14. * @author JNPF开发平台组
  15. * @version V3.1.0
  16. * @copyright 引迈信息技术有限公司
  17. * @date 2021/3/16 8:47
  18. */
  19. @Data
  20. public class ConfigValueUtil {
  21. public static final String PREFIX = "config";
  22. @Value("spring.application.name:JNPF")
  23. private String applicationName;
  24. // /**
  25. // * 环境路径
  26. // */
  27. // @Value("${config.Path:}")
  28. // private String path;
  29. /**
  30. * 数据库备份文件路径
  31. */
  32. private String dataBackupFilePath;
  33. /**
  34. * 临时文件存储路径
  35. */
  36. private String temporaryFilePath;
  37. /**
  38. * 系统文件存储路径
  39. */
  40. private String systemFilePath;
  41. /**
  42. * 文件模板存储路径
  43. */
  44. private String templateFilePath;
  45. /**
  46. * 代码模板存储路径
  47. */
  48. private String templateCodePath;
  49. /**
  50. * vue3代码模板存储路径
  51. */
  52. private String templateCodePathVue3;
  53. /**
  54. * 邮件文件存储路径
  55. */
  56. private String emailFilePath;
  57. /**
  58. * 大屏图片存储目录
  59. */
  60. private String biVisualPath;
  61. /**
  62. * 文档管理存储路径
  63. */
  64. private String documentFilePath;
  65. /**
  66. * 文件在线预览存储pdf
  67. */
  68. private String documentPreviewPath;
  69. /**
  70. * 用户头像存储路径
  71. */
  72. private String userAvatarFilePath;
  73. /**
  74. * IM聊天图片+语音存储路径
  75. */
  76. private String imContentFilePath;
  77. /**
  78. * 允许上传文件类型
  79. */
  80. private String allowUploadFileType;
  81. /**
  82. * 允许图片类型
  83. */
  84. private String allowUploadImageType;
  85. /**
  86. * 允许预览类型
  87. */
  88. private String allowPreviewFileType;
  89. /**
  90. * 预览方式
  91. */
  92. private String previewType;
  93. /**
  94. * 预览方式
  95. */
  96. private String kkFileUrl;
  97. /**
  98. * 多语言json路径
  99. */
  100. private String baseLanguagePath;
  101. /**
  102. * 前端文件目录
  103. */
  104. private String serviceDirectoryPath = ConfigConst.CODE_TEMP_FOLDER;
  105. /**
  106. * 代码生成器命名空间
  107. */
  108. private String codeAreasName;
  109. /**
  110. * 前端附件文件目录
  111. */
  112. private String webAnnexFilePath;
  113. /**
  114. * ApacheShardingSphere 配置开关
  115. */
  116. private boolean shardingSphereEnabled;
  117. /**
  118. * 软件的错误报告
  119. */
  120. private String errorReport;
  121. /**
  122. * 软件的错误报告发给谁
  123. */
  124. private String errorReportTo;
  125. /**
  126. * 系统日志启用:true、false
  127. */
  128. private String recordLog;
  129. /**
  130. * 多租户启用:true、false
  131. */
  132. private boolean multiTenancy;
  133. /**
  134. * 多租户接口
  135. */
  136. private String multiTenancyUrl;
  137. /**
  138. * 多租户字段
  139. */
  140. private String multiTenantColumn = TableFieldsNameConst.F_TENANT_ID;
  141. /**
  142. * 字段多租户忽略表
  143. */
  144. private List<String> multiTenantIgnoreTable = initMultiTenantIgnoreTable();
  145. /**
  146. * 多租户登录短信验证接口
  147. */
  148. private String multiTenancyOfficialLoginCodeUrl = null;
  149. /**
  150. * 多租户重置密码短信验证接口
  151. */
  152. private String multiTenancyOfficialResetCodeUrl = null;
  153. /**
  154. * 开启逻辑删除功能
  155. */
  156. private boolean enableLogicDelete = false;
  157. /**
  158. * 身份功能功能开关
  159. */
  160. private boolean standingSwitch = false;
  161. /**
  162. * 扫码登录过期时间
  163. */
  164. private Long codeCertificateTimeout = 180L;
  165. /**
  166. * 逻辑删除字段
  167. */
  168. private String logicDeleteColumn = TableFieldsNameConst.F_DELETE_MARK;
  169. /**
  170. * 版本
  171. */
  172. private String softVersion;
  173. /**
  174. * 推送是否启动:false、true
  175. */
  176. private String igexinEnabled;
  177. /**
  178. * APPID
  179. */
  180. private String igexinAppid;
  181. /**
  182. * APPKEY
  183. */
  184. private String igexinAppkey;
  185. /**
  186. * MASTERSECRET
  187. */
  188. private String igexinMastersecret;
  189. private String appUpdateContent;
  190. private String appVersion;
  191. /**
  192. * pc端服务器域名
  193. */
  194. private String frontDomain;
  195. /**
  196. * app端服务器域名
  197. */
  198. private String appDomain;
  199. /**
  200. * 服务器域名
  201. */
  202. private String apiDomain;
  203. /**
  204. * 工作流域名
  205. */
  206. private String flowDomain;
  207. /**
  208. * 检查PDF文件安全
  209. */
  210. private boolean checkFilePdf;
  211. /**
  212. * -------------跨域配置-----------
  213. */
  214. // @Value("${config.Origins}")
  215. // private String origins;
  216. // @Value("${config.Methods}")
  217. // private String methods;
  218. /**
  219. * -------------是否开启测试环境,admin账户可以无限登陆,并且无法修改密码-----------
  220. */
  221. private String testVersion;
  222. /**
  223. * -------------uniPush在线-----------
  224. */
  225. private String appPushUrl;
  226. public String getMultiTenancyOfficialLoginCodeUrl() {
  227. if(multiTenancyOfficialLoginCodeUrl == null){
  228. if(StringUtil.isNotEmpty(multiTenancyUrl)){
  229. UrlBuilder urlBuilder1 = UrlBuilder.of(multiTenancyUrl);
  230. multiTenancyOfficialLoginCodeUrl = String.format("%s://%s:%s/api/Saas/Tenant/LoginSmsCodeCheck/", urlBuilder1.getSchemeWithDefault(), urlBuilder1.getHost(), urlBuilder1.getPortWithDefault());
  231. }else{
  232. multiTenancyOfficialLoginCodeUrl = "";
  233. }
  234. }
  235. return multiTenancyOfficialLoginCodeUrl;
  236. }
  237. public String getMultiTenancyOfficialResetCodeUrl() {
  238. if(multiTenancyOfficialResetCodeUrl == null){
  239. if(StringUtil.isNotEmpty(multiTenancyUrl)){
  240. UrlBuilder urlBuilder1 = UrlBuilder.of(multiTenancyUrl);
  241. multiTenancyOfficialResetCodeUrl = String.format("%s://%s:%s/api/Saas/Tenant/ResetPasswordSmsCodeCheck/", urlBuilder1.getSchemeWithDefault(), urlBuilder1.getHost(), urlBuilder1.getPortWithDefault());
  242. }else{
  243. multiTenancyOfficialResetCodeUrl = "";
  244. }
  245. }
  246. return multiTenancyOfficialResetCodeUrl;
  247. }
  248. public String getServiceDirectoryPath(){
  249. String folder = StringUtil.isNotEmpty(serviceDirectoryPath) ? serviceDirectoryPath : ConfigConst.CODE_TEMP_FOLDER;
  250. return getXssPath(folder +"/");
  251. }
  252. public String getDataBackupFilePath() {
  253. String folder = StringUtil.isNotEmpty(dataBackupFilePath) ? dataBackupFilePath : ConfigConst.DATA_BACKUP_FOLDER;
  254. return getXssPath(folder +"/");
  255. }
  256. public String getTemporaryFilePath() {
  257. String folder = StringUtil.isNotEmpty(temporaryFilePath) ? temporaryFilePath : ConfigConst.TEMPORARY_FOLDER;
  258. return getXssPath(folder +"/");
  259. }
  260. public String getSystemFilePath() {
  261. String folder = StringUtil.isNotEmpty(systemFilePath) ? systemFilePath : ConfigConst.SYSTEM_FOLDER;
  262. return getXssPath(folder + "/");
  263. }
  264. public String getTemplateFilePath() {
  265. String folder = StringUtil.isNotEmpty(templateFilePath) ? templateFilePath : ConfigConst.TEMPLATE_FOLDER;
  266. return getXssPath(folder + "/");
  267. }
  268. public String getTemplateCodePath() {
  269. String folder = StringUtil.isNotEmpty(templateCodePath) ? templateCodePath : ConfigConst.TEMPLATE_CODE_FOLDER;
  270. return getXssPath(folder + "/");
  271. }
  272. public String getTemplateCodePathVue3() {
  273. String folder = StringUtil.isNotEmpty(templateCodePathVue3) ? templateCodePathVue3 : ConfigConst.TEMPLATEVUE3_CODE_FOLDER;
  274. return getXssPath(folder + "/");
  275. }
  276. public String getEmailFilePath() {
  277. String folder = StringUtil.isNotEmpty(emailFilePath) ? emailFilePath : ConfigConst.EMAIL_FOLDER;
  278. return getXssPath(folder + "/");
  279. }
  280. public String getDocumentPreviewPath() {
  281. String folder = StringUtil.isNotEmpty(documentPreviewPath) ? documentPreviewPath : ConfigConst.DOCUMENT_PREVIEW_FOLDER;
  282. return getXssPath(folder + "/");
  283. }
  284. public String getUserAvatarFilePath() {
  285. String folder = StringUtil.isNotEmpty(userAvatarFilePath) ? userAvatarFilePath : ConfigConst.USER_AVATAR_FOLDER;
  286. return getXssPath(folder + "/");
  287. }
  288. public String getImContentFilePath() {
  289. String folder = StringUtil.isNotEmpty(imContentFilePath) ? imContentFilePath : ConfigConst.IM_CONTENT_FOLDER;
  290. return getXssPath(folder + "/");
  291. }
  292. public String getDocumentFilePath() {
  293. String folder = StringUtil.isNotEmpty(documentFilePath) ? documentFilePath : ConfigConst.DOCUMENT_FOLDER;
  294. return getXssPath(folder + "/");
  295. }
  296. public String getWebAnnexFilePath() {
  297. String folder = StringUtil.isNotEmpty(webAnnexFilePath) ? webAnnexFilePath : ConfigConst.WEB_ANNEX_FOLDER;
  298. return getXssPath(folder + "/");
  299. }
  300. public String getBiVisualPath() {
  301. String folder = StringUtil.isNotEmpty(biVisualPath) ? biVisualPath : ConfigConst.BI_VISUAL_FOLDER;
  302. return getXssPath(folder + "/");
  303. }
  304. public String getBaseLanguagePath() {
  305. String folder = StringUtil.isNotEmpty(baseLanguagePath) ? baseLanguagePath : ConfigConst.BASE_LANGUAGE;
  306. return getXssPath(folder + "/");
  307. }
  308. private String getXssPath(String path){
  309. String xssPath = XSSEscape.escapePath(path);
  310. return xssPath;
  311. }
  312. public void setMultiTenantIgnoreTable(List<String> multiTenantIgnoreTable) {
  313. initMultiTenantIgnoreTable();
  314. this.multiTenantIgnoreTable.addAll(multiTenantIgnoreTable);
  315. // 全部转小写, 对比时也转小写
  316. this.multiTenantIgnoreTable = this.multiTenantIgnoreTable.stream().map(String::toLowerCase).collect(Collectors.toList());
  317. }
  318. public List<String> getMultiTenantIgnoreTable() {
  319. return new ArrayList<>(this.multiTenantIgnoreTable);
  320. }
  321. private List<String> initMultiTenantIgnoreTable(){
  322. List<String> multiTenantIgnoreTable = this.multiTenantIgnoreTable;
  323. if(multiTenantIgnoreTable == null){
  324. multiTenantIgnoreTable = new ArrayList<>();
  325. }else{
  326. multiTenantIgnoreTable.clear();
  327. }
  328. multiTenantIgnoreTable.add("dual");
  329. return multiTenantIgnoreTable;
  330. }
  331. }